diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-06-09 17:31:55 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2013-06-09 17:31:55 +0000 |
commit | 0693f53fb0b7bdbeafab3f3b7b962a9d6d3ed6e6 (patch) | |
tree | d3e2fa96f5d25e9687494a38a749c31045dcaeab /sbin/dhclient | |
parent | 3e2683ad937f6dcdf76303725b90a68fa9e0bbc7 (diff) |
Fix/clarify some comments. do memset()'s only when variable is going
to be used.
Diffstat (limited to 'sbin/dhclient')
-rw-r--r-- | sbin/dhclient/dhclient.c | 9 | ||||
-rw-r--r-- | sbin/dhclient/kroute.c | 33 |
2 files changed, 11 insertions, 31 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index 16dd15ac8c7..dc0feac7bff 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.252 2013/06/09 16:21:50 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.253 2013/06/09 17:31:54 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -2285,8 +2285,6 @@ priv_write_file(struct imsg_write_file *imsg) * or * * route -q $rdomain add default $router - * - * depending on the contents of the gateway parameter. */ void add_default_route(int rdomain, struct in_addr addr, struct in_addr gateway) @@ -2299,8 +2297,9 @@ add_default_route(int rdomain, struct in_addr addr, struct in_addr gateway) addrs = RTA_DST | RTA_NETMASK; /* - * Set gateway address if and only if non-zero addr supplied. A - * gateway address of 0 implies '-iface'. + * When 'addr' and 'gateway' are identical the desired behaviour is + * to emulate the '-iface' variant of 'route'. This is done by + * claiming there is no gateway address to use. */ if (bcmp(&gateway, &addr, sizeof(addr)) != 0) addrs |= RTA_GATEWAY; diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c index 2a3321c5aab..2b40fd26993 100644 --- a/sbin/dhclient/kroute.c +++ b/sbin/dhclient/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.52 2013/06/09 16:21:50 krw Exp $ */ +/* $OpenBSD: kroute.c,v 1.53 2013/06/09 17:31:54 krw Exp $ */ /* * Copyright 2012 Kenneth R Westerback <krw@openbsd.org> @@ -170,18 +170,6 @@ priv_flush_routes(struct imsg_flush_routes *imsg) free(buf); } -/* - * [priv_]add_default_route is the equivalent of - * - * route -q $rdomain -n flush -inet -iface $interface - * - * and one of - * - * route -q $rdomain add default -iface $router - * route -q $rdomain add default $router - * - * depending on the contents of the gateway parameter. - */ void add_route(int rdomain, struct in_addr dest, struct in_addr netmask, struct in_addr gateway, int addrs) @@ -229,11 +217,9 @@ priv_add_route(struct imsg_add_route *imsg) iov[iovcnt].iov_base = &rtm; iov[iovcnt++].iov_len = sizeof(rtm); - /* Set destination address. */ - - memset(&dest, 0, sizeof(dest)); - if (imsg->addrs & RTA_DST) { + memset(&dest, 0, sizeof(dest)); + dest.sin_len = sizeof(dest); dest.sin_family = AF_INET; dest.sin_addr.s_addr = imsg->dest.s_addr; @@ -245,13 +231,9 @@ priv_add_route(struct imsg_add_route *imsg) iov[iovcnt++].iov_len = sizeof(dest); } - /* - * Set gateway address if and only if non-zero addr supplied. A - * gateway address of 0 implies '-iface'. - */ - - memset(&gateway, 0, sizeof(gateway)); if (imsg->addrs & RTA_GATEWAY) { + memset(&gateway, 0, sizeof(gateway)); + gateway.sin_len = sizeof(gateway); gateway.sin_family = AF_INET; gateway.sin_addr.s_addr = imsg->gateway.s_addr; @@ -264,10 +246,9 @@ priv_add_route(struct imsg_add_route *imsg) iov[iovcnt++].iov_len = sizeof(gateway); } - /* Add netmask. */ - memset(&mask, 0, sizeof(mask)); - if (imsg->addrs & RTA_NETMASK) { + memset(&mask, 0, sizeof(mask)); + mask.sin_len = sizeof(mask); mask.sin_family = AF_INET; mask.sin_addr.s_addr = imsg->netmask.s_addr; |