Date: Tue, 03 Sep 2019 14:07:44 -0000 From: Kyle Evans <kevans@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r346602 - head/sys/net Message-ID: <201904231728.x3NHSSqw005098@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904231728.x3NHSSqw005098>