aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/net/if.c')
-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 ccd4689e9a45..2e21ae9b185d 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);
}