summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2012-11-04 03:25:32 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2012-11-04 03:25:32 +0000
commit9c54734c732a0511977412d5b33e708f011aebc5 (patch)
tree9e04716f00451c412473c840b1c23447f48f6623 /sbin
parentb0530a6e909c4987338e152d0486e014df946a88 (diff)
No need to pass interface name around when creating routes.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dhclient/dhclient.c5
-rw-r--r--sbin/dhclient/dhcpd.h6
-rw-r--r--sbin/dhclient/kroute.c16
-rw-r--r--sbin/dhclient/privsep.c24
4 files changed, 10 insertions, 41 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index d9678b79579..07f7b26eb27 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.164 2012/11/03 16:54:34 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.165 2012/11/04 03:25:31 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -675,8 +675,7 @@ bind_lease(void)
gateway.len = sizeof(in_addr_t);
bcopy(options[DHO_ROUTERS].data,
gateway.iabuf, sizeof(in_addr_t));
- add_default_route(ifi->name, ifi->rdomain,
- client->new->address, gateway);
+ add_default_route(ifi->rdomain, client->new->address, gateway);
}
if (options[DHO_DOMAIN_NAME].len)
domainname = strdup(pretty_print_option(
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index 43510092127..4107cb0cce5 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.85 2012/11/03 16:54:34 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.86 2012/11/04 03:25:31 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -345,5 +345,5 @@ void priv_add_new_address(char *, int, struct iaddr, in_addr_t);
void flush_routes_and_arp_cache(char *, int);
void priv_flush_routes_and_arp_cache(char *, int);
-void add_default_route(char *, int, struct iaddr, struct iaddr);
-void priv_add_default_route(char *, int, struct iaddr, struct iaddr);
+void add_default_route(int, struct iaddr, struct iaddr);
+void priv_add_default_route(int, struct iaddr, struct iaddr);
diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c
index 732622449b8..4f5a96978ef 100644
--- a/sbin/dhclient/kroute.c
+++ b/sbin/dhclient/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.5 2012/11/03 01:59:31 krw Exp $ */
+/* $OpenBSD: kroute.c,v 1.6 2012/11/04 03:25:31 krw Exp $ */
/*
* Copyright 2012 Kenneth R Westerback <krw@openbsd.org>
@@ -76,11 +76,6 @@ priv_flush_routes_and_arp_cache(char *ifname, int rdomain)
struct sockaddr_inarp *sin;
struct sockaddr_rtlabel *sa_rl;
int s, seqno = 0, rlen, i;
- unsigned int ifi_index;
-
- ifi_index = if_nametoindex(ifname);
- if (ifi_index == 0)
- error("No interface index found for '%s'", ifname);
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
@@ -199,7 +194,7 @@ priv_flush_routes_and_arp_cache(char *ifname, int rdomain)
* depending on the contents of the gateway parameter.
*/
void
-add_default_route(char *ifname, int rdomain, struct iaddr addr,
+add_default_route(int rdomain, struct iaddr addr,
struct iaddr gateway)
{
size_t len;
@@ -208,7 +203,6 @@ add_default_route(char *ifname, int rdomain, struct iaddr addr,
hdr.code = IMSG_ADD_DEFAULT_ROUTE;
hdr.len = sizeof(hdr) +
- sizeof(len) + strlen(ifname) +
sizeof(len) + sizeof(rdomain) +
sizeof(len) + sizeof(addr) +
sizeof(len) + sizeof(gateway);
@@ -216,10 +210,6 @@ add_default_route(char *ifname, int rdomain, struct iaddr addr,
buf = buf_open(hdr.len);
buf_add(buf, &hdr, sizeof(hdr));
- len = strlen(ifname);
- buf_add(buf, &len, sizeof(len));
- buf_add(buf, ifname, len);
-
len = sizeof(rdomain);
buf_add(buf, &len, sizeof(len));
buf_add(buf, &rdomain, len);
@@ -236,7 +226,7 @@ add_default_route(char *ifname, int rdomain, struct iaddr addr,
}
void
-priv_add_default_route(char *ifname, int rdomain, struct iaddr addr,
+priv_add_default_route(int rdomain, struct iaddr addr,
struct iaddr router)
{
struct rt_msghdr rtm;
diff --git a/sbin/dhclient/privsep.c b/sbin/dhclient/privsep.c
index bd1c9db179e..b2d9e52b713 100644
--- a/sbin/dhclient/privsep.c
+++ b/sbin/dhclient/privsep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.c,v 1.18 2012/11/03 16:54:34 krw Exp $ */
+/* $OpenBSD: privsep.c,v 1.19 2012/11/04 03:25:31 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -269,25 +269,8 @@ dispatch_imsg(int fd)
case IMSG_ADD_DEFAULT_ROUTE:
totlen = sizeof(hdr);
- ifname = NULL;
addr = NULL;
if (hdr.len < totlen + sizeof(len))
- error("IMSG_ADD_DEFAULT_ROUTE missing ifname length");
- buf_read(fd, &len, sizeof(len));
- totlen += sizeof(len);
- if (len == SIZE_T_MAX) {
- error("IMSG_ADD_DEFAULT_ROUTE invalid ifname length");
- } else if (len > 0) {
- if (hdr.len < totlen + len)
- error("IMSG_ADD_DEFAULT_ROUTE short ifname");
- if ((ifname = calloc(1, len + 1)) == NULL)
- error("%m");
- buf_read(fd, ifname, len);
- totlen += len;
- } else
- error("IMSG_ADD_DEFAULT_ROUTE ifname missing");
-
- if (hdr.len < totlen + sizeof(len))
error("IMSG_ADD_DEFAULT_ROUTE missing rdomain length");
buf_read(fd, &len, sizeof(len));
totlen += sizeof(len);
@@ -334,14 +317,12 @@ dispatch_imsg(int fd)
len);
}
- priv_add_default_route(ifname, rdomain, *addr, *gateway);
- free(ifname);
+ priv_add_default_route(rdomain, *addr, *gateway);
free(addr);
free(gateway);
break;
case IMSG_NEW_RESOLV_CONF:
totlen = sizeof(hdr);
- ifname = NULL;
contents = NULL;
if (hdr.len < totlen + sizeof(len))
@@ -360,7 +341,6 @@ dispatch_imsg(int fd)
}
priv_new_resolv_conf(contents);
- free(ifname);
free(contents);
break;
default: