diff options
author | des <des@FreeBSD.org> | 2001-10-30 15:57:20 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2001-10-30 15:57:20 +0000 |
commit | 3554d69eb7586d90560931e7765242b2d0cd614f (patch) | |
tree | 8b0ad35d7459a161352a651f5ef3f1b68c18e484 /sys/netinet/in.c | |
parent | 85a9f299f9ff18dd7fee037e0aee7e70d3971e7e (diff) | |
download | FreeBSD-src-3554d69eb7586d90560931e7765242b2d0cd614f.zip FreeBSD-src-3554d69eb7586d90560931e7765242b2d0cd614f.tar.gz |
Make sure the netmask always has an address family. This fixes Linux
ifconfig, which expects the address returned by the SIOCGIFNETMASK ioctl
to have a valid sa_family. Similar changes may be necessary for IPv6.
While we're here, get rid of an unnecessary temp variable.
MFC after: 2 weeks
Diffstat (limited to 'sys/netinet/in.c')
-rw-r--r-- | sys/netinet/in.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 8008d79..12db13e 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -198,7 +198,6 @@ in_control(so, cmd, data, ifp, td) struct in_aliasreq *ifra = (struct in_aliasreq *)data; struct sockaddr_in oldaddr; int error, hostIsNew, maskIsNew, s; - u_long i; switch (cmd) { case SIOCALIFADDR: @@ -286,6 +285,7 @@ in_control(so, cmd, data, ifp, td) ifa->ifa_dstaddr = (struct sockaddr *)&ia->ia_dstaddr; ifa->ifa_netmask = (struct sockaddr *)&ia->ia_sockmask; ia->ia_sockmask.sin_len = 8; + ia->ia_sockmask.sin_family = AF_INET; if (ifp->if_flags & IFF_BROADCAST) { ia->ia_broadaddr.sin_len = sizeof(ia->ia_addr); ia->ia_broadaddr.sin_family = AF_INET; @@ -362,8 +362,8 @@ in_control(so, cmd, data, ifp, td) (struct sockaddr_in *) &ifr->ifr_addr, 1)); case SIOCSIFNETMASK: - i = ifra->ifra_addr.sin_addr.s_addr; - ia->ia_subnetmask = ntohl(ia->ia_sockmask.sin_addr.s_addr = i); + ia->ia_sockmask.sin_addr = ifra->ifra_addr.sin_addr; + ia->ia_subnetmask = ntohl(ia->ia_sockmask.sin_addr.s_addr); break; case SIOCAIFADDR: @@ -381,6 +381,7 @@ in_control(so, cmd, data, ifp, td) if (ifra->ifra_mask.sin_len) { in_ifscrub(ifp, ia); ia->ia_sockmask = ifra->ifra_mask; + ia->ia_sockmask.sin_family = AF_INET; ia->ia_subnetmask = ntohl(ia->ia_sockmask.sin_addr.s_addr); maskIsNew = 1; |