summaryrefslogtreecommitdiffstats
path: root/sys/net/if_tun.c
diff options
context:
space:
mode:
authorqingli <qingli@FreeBSD.org>2008-12-25 22:32:32 +0000
committerqingli <qingli@FreeBSD.org>2008-12-25 22:32:32 +0000
commit2a933d7a9b1578e04e9647ac2714830f18f37390 (patch)
treef3ad766e74e09f0dc5d3d617514b202f493c15b4 /sys/net/if_tun.c
parent6a15aa1665f930c5e5d3d0ac963733bc56de95b3 (diff)
downloadFreeBSD-src-2a933d7a9b1578e04e9647ac2714830f18f37390.zip
FreeBSD-src-2a933d7a9b1578e04e9647ac2714830f18f37390.tar.gz
The "tun?" dev need not be opened at all. One is allowed to perform
the following operations, e.g.: 1) ifconfig tun0 create 2) ifconfig tun0 10.1.1.1 10.1.1.2 3) route add -net 192.103.54.0/24 -iface tun0 4) ifconfig tun0 destroy If cv wait on the TUN_CLOSED flag, then the last operation (4) will block forever. Revert the previous changes and fix the mtx_unlock() leak.
Diffstat (limited to 'sys/net/if_tun.c')
-rw-r--r--sys/net/if_tun.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 2520883..eb65fba3 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -79,7 +79,6 @@ struct tun_softc {
#define TUN_RWAIT 0x0040
#define TUN_ASYNC 0x0080
#define TUN_IFHEAD 0x0100
-#define TUN_CLOSED 0x0200
#define TUN_READY (TUN_OPEN | TUN_INITED)
@@ -257,11 +256,11 @@ tun_destroy(struct tun_softc *tp)
/* Unlocked read. */
mtx_lock(&tp->tun_mtx);
- if ((tp->tun_flags & (TUN_OPEN|TUN_CLOSED)) != TUN_CLOSED)
+ if ((tp->tun_flags & TUN_OPEN) != 0)
cv_wait_unlock(&tp->tun_cv, &tp->tun_mtx);
else
mtx_unlock(&tp->tun_mtx);
-
+
CURVNET_SET(TUN2IFP(tp)->if_vnet);
dev = tp->tun_dev;
bpfdetach(TUN2IFP(tp));
@@ -500,7 +499,6 @@ tunclose(struct cdev *dev, int foo, int bar, struct thread *td)
KNOTE_UNLOCKED(&tp->tun_rsel.si_note, 0);
TUNDEBUG (ifp, "closed\n");
- tp->tun_flags |= TUN_CLOSED;
cv_broadcast(&tp->tun_cv);
mtx_unlock(&tp->tun_mtx);
return (0);
OpenPOWER on IntegriCloud