Fix SIOCSIFNETMASK -- it needs to use in_ifscrub() and in_ifinit() to update

the interface route and various internal state.  Also, it should use an ifreq,
not an if_aliasreq.  Addresses PR 9604.  (Nothing in our source tree uses
SIOCSIFNETMASK, though.  Perhaps it should be deprecated.)
This commit is contained in:
mycroft 2004-07-07 01:39:00 +00:00
parent e9bd9c26d8
commit cc559c8583

View File

@ -1,4 +1,4 @@
/* $NetBSD: in.c,v 1.96 2004/06/22 12:50:41 itojun Exp $ */
/* $NetBSD: in.c,v 1.97 2004/07/07 01:39:00 mycroft Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -98,7 +98,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.96 2004/06/22 12:50:41 itojun Exp $");
__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.97 2004/07/07 01:39:00 mycroft Exp $");
#include "opt_inet.h"
#include "opt_inet_conf.h"
@ -476,9 +476,11 @@ in_control(so, cmd, data, ifp, p)
return error;
case SIOCSIFNETMASK:
ia->ia_subnetmask = ia->ia_sockmask.sin_addr.s_addr =
ifra->ifra_addr.sin_addr.s_addr;
break;
in_ifscrub(ifp, ia);
ia->ia_sockmask = *satosin(&ifr->ifr_addr);
ia->ia_subnetmask = ia->ia_sockmask.sin_addr.s_addr;
error = in_ifinit(ifp, ia, NULL, 0);
return (error);
case SIOCAIFADDR:
maskIsNew = 0;
@ -799,10 +801,13 @@ in_ifinit(ifp, ia, sin, scrub)
struct sockaddr_in *sin;
int scrub;
{
u_int32_t i = sin->sin_addr.s_addr;
u_int32_t i;
struct sockaddr_in oldaddr;
int s = splnet(), flags = RTF_UP, error;
if (!sin)
sin = &ia->ia_addr;
/*
* Set up new addresses.
*/
@ -827,6 +832,7 @@ in_ifinit(ifp, ia, sin, scrub)
ia->ia_ifa.ifa_addr = sintosa(&ia->ia_addr);
}
i = ia->ia_addr.sin_addr.s_addr;
if (IN_CLASSA(i))
ia->ia_netmask = IN_CLASSA_NET;
else if (IN_CLASSB(i))