From cc559c858338fcc7dc6d7d8186d4d55e6ab08b72 Mon Sep 17 00:00:00 2001 From: mycroft Date: Wed, 7 Jul 2004 01:39:00 +0000 Subject: [PATCH] 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.) --- sys/netinet/in.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sys/netinet/in.c b/sys/netinet/in.c index d9feca0d91da..dcfa7aaf8da3 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -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 -__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))