Page MenuHomeFreeBSD

D55832.id173624.diff
No OneTemporary

D55832.id173624.diff

diff --git a/sys/net/if.c b/sys/net/if.c
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1199,14 +1199,13 @@
sx_sunlock(&allprison_lock);
if (pr == NULL)
return (ENXIO);
- prison_hold_locked(pr);
- mtx_unlock(&pr->pr_mtx);
-
- /* Do not try to move the iface from and to the same prison. */
- if (pr->pr_vnet == ifp->if_vnet) {
- prison_free(pr);
+ /* Do not try to move the iface from and to the same vnet. */
+ if (pr->pr_vnet == TD_TO_VNET(td)) {
+ mtx_unlock(&pr->pr_mtx);
return (EEXIST);
}
+ prison_hold_locked(pr);
+ mtx_unlock(&pr->pr_mtx);
/* Make sure the named iface does not exists in the dst. prison/vnet. */
/* XXX Lock interfaces to avoid races. */
@@ -1250,7 +1249,6 @@
if_vmove_reclaim(struct thread *td, char *ifname, int jid)
{
struct prison *pr;
- struct vnet *vnet_dst;
struct ifnet *ifp;
int found __diagused;
bool shutdown;
@@ -1261,6 +1259,11 @@
sx_sunlock(&allprison_lock);
if (pr == NULL)
return (ENXIO);
+ /* Do not try to move the iface from and to the same vnet. */
+ if (pr->pr_vnet == TD_TO_VNET(td)) {
+ mtx_unlock(&pr->pr_mtx);
+ return (EEXIST);
+ }
prison_hold_locked(pr);
mtx_unlock(&pr->pr_mtx);
@@ -1273,14 +1276,6 @@
return (ENXIO);
}
- /* Do not try to move the iface from and to the same prison. */
- vnet_dst = TD_TO_VNET(td);
- if (vnet_dst == ifp->if_vnet) {
- CURVNET_RESTORE();
- prison_free(pr);
- return (EEXIST);
- }
-
/* Make sure the VNET is stable. */
shutdown = VNET_IS_SHUTTING_DOWN(ifp->if_vnet);
if (shutdown) {
@@ -1293,7 +1288,7 @@
found = if_unlink_ifnet(ifp, true);
MPASS(found);
sx_xlock(&ifnet_detach_sxlock);
- if_vmove(ifp, vnet_dst);
+ if_vmove(ifp, TD_TO_VNET(td));
sx_xunlock(&ifnet_detach_sxlock);
CURVNET_RESTORE();

File Metadata

Mime Type
text/plain
Expires
Thu, Apr 16, 11:36 AM (13 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29631679
Default Alt Text
D55832.id173624.diff (1 KB)

Event Timeline