1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-18 10:35:55 +00:00

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
This commit is contained in:
Dag-Erling Smørgrav 2001-10-30 15:57:20 +00:00
parent 3fc980b135
commit bc183b3fe8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=85740

View File

@ -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;