From 103dd7a73b6e05882b247983432da6ef9c85f66e Mon Sep 17 00:00:00 2001 From: "Anurag S. Maskey" Date: Thu, 18 Dec 2008 13:03:43 -0500 Subject: 6730161 dhcpagent may scare itself off when canonizing interfaces --- usr/src/cmd/cmd-inet/sbin/dhcpagent/interface.c | 36 +++++++++++++++++++------ 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'usr/src') 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 #include #include @@ -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; + } + } + } } /* -- cgit v1.2.3