Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178112417
D56374.1795995796.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D56374.1795995796.diff
View Options
diff --git a/sys/net/if.c b/sys/net/if.c
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -447,6 +447,7 @@
struct ifnet *iter;
int found = 0;
+ sx_assert(&ifnet_detach_sxlock, SX_XLOCKED);
IFNET_WLOCK();
CK_STAILQ_FOREACH(iter, &V_ifnet, if_link)
if (iter == ifp) {
@@ -1028,14 +1029,23 @@
{
bool found;
+ /*
+ * The driver private data holds a strong reference to the ifnet, and
+ * it is actually the "owner", hence this routine shall never fail.
+ *
+ * Ideally we can loop retrying when we lose race with other threads
+ * those run if_unlink_ifnet(). For simplicity, use ifnet_detach_sxlock
+ * to serialize all the detach / vmove operations.
+ */
+ sx_xlock(&ifnet_detach_sxlock);
CURVNET_SET_QUIET(ifp->if_vnet);
found = if_unlink_ifnet(ifp, false);
- if (found) {
- sx_xlock(&ifnet_detach_sxlock);
- if_detach_internal(ifp, false);
- sx_xunlock(&ifnet_detach_sxlock);
- }
+ if (! found)
+ panic("%s: interface is not on the active list",
+ ifp->if_xname);
+ if_detach_internal(ifp, false);
CURVNET_RESTORE();
+ sx_xunlock(&ifnet_detach_sxlock);
}
/*
@@ -1290,13 +1300,14 @@
}
/* Get interface back from child jail/vnet. */
+ sx_xlock(&ifnet_detach_sxlock);
found = if_unlink_ifnet(ifp, true);
if (! found) {
+ sx_xunlock(&ifnet_detach_sxlock);
CURVNET_RESTORE();
prison_free(pr);
return (ENODEV);
}
- sx_xlock(&ifnet_detach_sxlock);
if_vmove(ifp, vnet_dst);
sx_xunlock(&ifnet_detach_sxlock);
CURVNET_RESTORE();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 29, 11:43 PM (9 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42098107
Default Alt Text
D56374.1795995796.diff (1 KB)
Attached To
Mode
D56374: ifnet: if_detach(): Fix races with if_vmove()
Attached
Detach File
Event Timeline