summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2011-02-16 21:29:13 +0000
committerbz <bz@FreeBSD.org>2011-02-16 21:29:13 +0000
commitb9b7d3e93a251adacd363eaf9d23963ec7467075 (patch)
treee312f60d853b2306ae67fe2988280d1dbc41c9cf /sys/net
parentea2186a5ebf08dfc9eddc393caec2d574ac8ce0b (diff)
downloadFreeBSD-src-b9b7d3e93a251adacd363eaf9d23963ec7467075.zip
FreeBSD-src-b9b7d3e93a251adacd363eaf9d23963ec7467075.tar.gz
Mfp4 CH=177274,177280,177284-177285,177297,177324-177325
VNET socket push back: try to minimize the number of places where we have to switch vnets and narrow down the time we stay switched. Add assertions to the socket code to catch possibly unset vnets as seen in r204147. While this reduces the number of vnet recursion in some places like NFS, POSIX local sockets and some netgraph, .. recursions are impossible to fix. The current expectations are documented at the beginning of uipc_socket.c along with the other information there. Sponsored by: The FreeBSD Foundation Sponsored by: CK Software GmbH Reviewed by: jhb Tested by: zec Tested by: Mikolaj Golub (to.my.trociny gmail.com) MFC after: 2 weeks
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index ccd4689..2e21ae9 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -2440,10 +2440,13 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td)
int error;
int oif_flags;
+ CURVNET_SET(so->so_vnet);
switch (cmd) {
case SIOCGIFCONF:
case OSIOCGIFCONF:
- return (ifconf(cmd, data));
+ error = ifconf(cmd, data);
+ CURVNET_RESTORE();
+ return (error);
#ifdef COMPAT_FREEBSD32
case SIOCGIFCONF32:
@@ -2455,7 +2458,9 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td)
ifc.ifc_len = ifc32->ifc_len;
ifc.ifc_buf = PTRIN(ifc32->ifc_buf);
- return (ifconf(SIOCGIFCONF, (void *)&ifc));
+ error = ifconf(SIOCGIFCONF, (void *)&ifc);
+ CURVNET_RESTORE();
+ return (error);
}
#endif
}
@@ -2465,42 +2470,55 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td)
#ifdef VIMAGE
case SIOCSIFRVNET:
error = priv_check(td, PRIV_NET_SETIFVNET);
- if (error)
- return (error);
- return (if_vmove_reclaim(td, ifr->ifr_name, ifr->ifr_jid));
+ if (error == 0)
+ error = if_vmove_reclaim(td, ifr->ifr_name,
+ ifr->ifr_jid);
+ CURVNET_RESTORE();
+ return (error);
#endif
case SIOCIFCREATE:
case SIOCIFCREATE2:
error = priv_check(td, PRIV_NET_IFCREATE);
- if (error)
- return (error);
- return (if_clone_create(ifr->ifr_name, sizeof(ifr->ifr_name),
- cmd == SIOCIFCREATE2 ? ifr->ifr_data : NULL));
+ if (error == 0)
+ error = if_clone_create(ifr->ifr_name,
+ sizeof(ifr->ifr_name),
+ cmd == SIOCIFCREATE2 ? ifr->ifr_data : NULL);
+ CURVNET_RESTORE();
+ return (error);
case SIOCIFDESTROY:
error = priv_check(td, PRIV_NET_IFDESTROY);
- if (error)
- return (error);
- return if_clone_destroy(ifr->ifr_name);
+ if (error == 0)
+ error = if_clone_destroy(ifr->ifr_name);
+ CURVNET_RESTORE();
+ return (error);
case SIOCIFGCLONERS:
- return (if_clone_list((struct if_clonereq *)data));
+ error = if_clone_list((struct if_clonereq *)data);
+ CURVNET_RESTORE();
+ return (error);
case SIOCGIFGMEMB:
- return (if_getgroupmembers((struct ifgroupreq *)data));
+ error = if_getgroupmembers((struct ifgroupreq *)data);
+ CURVNET_RESTORE();
+ return (error);
}
ifp = ifunit_ref(ifr->ifr_name);
- if (ifp == NULL)
+ if (ifp == NULL) {
+ CURVNET_RESTORE();
return (ENXIO);
+ }
error = ifhwioctl(cmd, ifp, data, td);
if (error != ENOIOCTL) {
if_rele(ifp);
+ CURVNET_RESTORE();
return (error);
}
oif_flags = ifp->if_flags;
if (so->so_proto == NULL) {
if_rele(ifp);
+ CURVNET_RESTORE();
return (EOPNOTSUPP);
}
#ifndef COMPAT_43
@@ -2575,6 +2593,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td)
#endif
}
if_rele(ifp);
+ CURVNET_RESTORE();
return (error);
}
OpenPOWER on IntegriCloud