summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorAnurag S. Maskey <Anurag.Maskey@Sun.COM>2008-12-18 13:03:43 -0500
committerAnurag S. Maskey <Anurag.Maskey@Sun.COM>2008-12-18 13:03:43 -0500
commit103dd7a73b6e05882b247983432da6ef9c85f66e (patch)
tree9751a7fe4f0eea399b6f39aac15d2ae07ccecf5d /usr/src
parent0de66c941512d3ab0d15397815d8c9c552bcbf8d (diff)
downloadillumos-joyent-103dd7a73b6e05882b247983432da6ef9c85f66e.tar.gz
6730161 dhcpagent may scare itself off when canonizing interfaces
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/cmd-inet/sbin/dhcpagent/interface.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/usr/src/cmd/cmd-inet/sbin/dhcpagent/interface.c b/usr/src/cmd/cmd-inet/sbin/dhcpagent/interface.c
index bca6f1acd9..0cfdad40e3 100644
--- a/usr/src/cmd/cmd-inet/sbin/dhcpagent/interface.c
+++ b/usr/src/cmd/cmd-inet/sbin/dhcpagent/interface.c
@@ -23,8 +23,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
@@ -833,12 +831,6 @@ canonize_lif(dhcp_lif_t *lif, boolean_t dhcponly)
lif->lif_name);
}
- /* Netmask is under in.ndpd control with IPv6 */
- if (!isv6 && ioctl(fd, SIOCSLIFNETMASK, &lifr) == -1) {
- dhcpmsg(MSG_ERR, "canonize_lif: can't clear netmask on %s",
- lif->lif_name);
- }
-
if (lif->lif_flags & IFF_POINTOPOINT) {
if (ioctl(fd, SIOCSLIFDSTADDR, &lifr) == -1) {
dhcpmsg(MSG_ERR,
@@ -852,6 +844,34 @@ canonize_lif(dhcp_lif_t *lif, boolean_t dhcponly)
lif->lif_name);
}
}
+
+ /*
+ * Clear the netmask last as it has to be refetched after clearing.
+ * Netmask is under in.ndpd control with IPv6.
+ */
+ if (!isv6) {
+ /* Clear the netmask */
+ if (ioctl(fd, SIOCSLIFNETMASK, &lifr) == -1) {
+ dhcpmsg(MSG_ERR,
+ "canonize_lif: can't clear netmask on %s",
+ lif->lif_name);
+ } else {
+ /*
+ * When the netmask is cleared, the kernel actually sets
+ * the netmask to 255.0.0.0. So, refetch that netmask.
+ */
+ if (ioctl(fd, SIOCGLIFNETMASK, &lifr) == -1) {
+ dhcpmsg(MSG_ERR,
+ "canonize_lif: can't reload cleared "
+ "netmask on %s", lif->lif_name);
+ } else {
+ /* Refetch succeeded, update LIF */
+ lif->lif_netmask =
+ ((struct sockaddr_in *)&lifr.lifr_addr)->
+ sin_addr.s_addr;
+ }
+ }
+ }
}
/*