diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/cmd-inet/sbin/dhcpagent/interface.c | 36 |
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; + } + } + } } /* |