aboutsummaryrefslogtreecommitdiff
path: root/sys/net/if.c
diff options
context:
space:
mode:
authorHans Petter Selasky <hselasky@FreeBSD.org>2019-06-28 10:49:04 +0000
committerHans Petter Selasky <hselasky@FreeBSD.org>2019-06-28 10:49:04 +0000
commit0dbdf04125160cb22db7c31c5f14769091701bad (patch)
tree6d9a4f29024ce1eab89306636cc94e3c136ff028 /sys/net/if.c
parent131b2b7658d7e961a245697cb5af55306388fc54 (diff)
downloadsrc-0dbdf04125160cb22db7c31c5f14769091701bad.tar.gz
src-0dbdf04125160cb22db7c31c5f14769091701bad.zip
Need to wait for epoch callbacks to complete before detaching a
network interface. This particularly manifests itself when an INP has multicast options attached during a network interface detach. Then the IPv4 and IPv6 leave group call which results from freeing the multicast address, may access a freed ifnet structure. These are the steps to reproduce: service mdnsd onestart # installed from ports ifconfig epair create ifconfig epair0a 0/24 up ifconfig epair0a destroy Tested by: pho @ MFC after: 1 week Sponsored by: Mellanox Technologies
Notes
Notes: svn path=/head/; revision=349507
Diffstat (limited to 'sys/net/if.c')
-rw-r--r--sys/net/if.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 6ff137cccf7d..d1513d2a32d7 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1127,6 +1127,15 @@ if_detach_internal(struct ifnet *ifp, int vmove, struct if_clone **ifcp)
curvnet->vnet_ifcnt--;
#endif
epoch_wait_preempt(net_epoch_preempt);
+
+ /*
+ * Ensure all pending EPOCH(9) callbacks have been executed. This
+ * fixes issues about late destruction of multicast options
+ * which lead to leave group calls, which in turn access the
+ * belonging ifnet structure:
+ */
+ epoch_drain_callbacks(net_epoch_preempt);
+
/*
* In any case (destroy or vmove) detach us from the groups
* and remove/wait for pending events on the taskq.