The simple diff below will reduce the noise in an upcoming diff.
As mpi mentioned a while ago, the goal is to merge the two big switches
and to have only one case per ioctl, so we can start pushing the
NET_LOCK() further down in this function.
The point of moving SIOCSIFNETMASK up is that we have two groups of
three ioctls that belong together (SIOC{A,D,S}IFADRR and the other
three, and this way SIOCSIFNETMASK will already be at the right spot
for the next diff.
The next step will involve among other things moving the first block
dealing with SIOC{A,D,S}IFADDR down, and this will be easier to follow
if the SIOCSIFNETMASK is already out of the way.
Index: sys/netinet/in.c
===================================================================
RCS file: /var/cvs/src/sys/netinet/in.c,v
retrieving revision 1.151
diff -u -p -r1.151 in.c
--- sys/netinet/in.c 2 May 2018 12:40:52 -0000 1.151
+++ sys/netinet/in.c 24 May 2018 16:57:05 -0000
@@ -227,6 +227,15 @@ in_ioctl(u_long cmd, caddr_t data, struc
case SIOCGIFDSTADDR:
case SIOCGIFBRDADDR:
return in_ioctl_get(cmd, data, ifp);
+ case SIOCAIFADDR:
+ case SIOCDIFADDR:
+ case SIOCSIFADDR:
+ case SIOCSIFNETMASK:
+ case SIOCSIFDSTADDR:
+ case SIOCSIFBRDADDR:
+ break;
+ default:
+ return (EOPNOTSUPP);
}
NET_LOCK();
@@ -329,6 +338,11 @@ in_ioctl(u_long cmd, caddr_t data, struc
ifa_update_broadaddr(ifp, &ia->ia_ifa, &ifr->ifr_broadaddr);
break;
+ case SIOCSIFNETMASK:
+ ia->ia_netmask = ia->ia_sockmask.sin_addr.s_addr =
+ ifra->ifra_addr.sin_addr.s_addr;
+ break;
+
case SIOCSIFADDR:
in_ifscrub(ifp, ia);
error = in_ifinit(ifp, ia, satosin(&ifr->ifr_addr), newifaddr);
@@ -337,11 +351,6 @@ in_ioctl(u_long cmd, caddr_t data, struc
dohooks(ifp->if_addrhooks, 0);
break;
- case SIOCSIFNETMASK:
- ia->ia_netmask = ia->ia_sockmask.sin_addr.s_addr =
- ifra->ifra_addr.sin_addr.s_addr;
- break;
-
case SIOCAIFADDR: {
int needinit = 0;
@@ -389,10 +398,6 @@ in_ioctl(u_long cmd, caddr_t data, struc
*/
in_purgeaddr(&ia->ia_ifa);
dohooks(ifp->if_addrhooks, 0);
- break;
-
- default:
- error = EOPNOTSUPP;
break;
}