svn commit: r346602 - head/sys/net
Kyle Evans
kevans at FreeBSD.org
Tue Sep 3 14:07:44 UTC 2019
Author: kevans
Date: Tue Apr 23 17:28:28 2019
New Revision: 346602
URL: https://svnweb.freebsd.org/changeset/base/346602
Log:
tun(4): Defer clearing TUN_OPEN until much later
tun destruction will not continue until TUN_OPEN is cleared. There are brief
moments in tunclose where the mutex is dropped and we've already cleared
TUN_OPEN, so tun_destroy would be able to proceed while we're in the middle
of cleaning up the tun still. tun_destroy should be blocked until these
parts (address/route purges, mostly) are complete.
PR: 233955
MFC after: 2 weeks
Modified:
head/sys/net/if_tun.c
Modified: head/sys/net/if_tun.c
==============================================================================
--- head/sys/net/if_tun.c Tue Apr 23 17:18:20 2019 (r346601)
+++ head/sys/net/if_tun.c Tue Apr 23 17:28:28 2019 (r346602)
@@ -500,8 +500,6 @@ tunclose(struct cdev *dev, int foo, int bar, struct th
ifp = TUN2IFP(tp);
mtx_lock(&tp->tun_mtx);
- tp->tun_flags &= ~TUN_OPEN;
- tp->tun_pid = 0;
/*
* junk all pending output
@@ -540,6 +538,8 @@ tunclose(struct cdev *dev, int foo, int bar, struct th
selwakeuppri(&tp->tun_rsel, PZERO + 1);
KNOTE_LOCKED(&tp->tun_rsel.si_note, 0);
TUNDEBUG (ifp, "closed\n");
+ tp->tun_flags &= ~TUN_OPEN;
+ tp->tun_pid = 0;
cv_broadcast(&tp->tun_cv);
mtx_unlock(&tp->tun_mtx);
More information about the svn-src-head
mailing list