diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if_tun.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index f10e7b4fb13..6659acbde69 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.81 2006/11/10 09:34:39 claudio Exp $ */ +/* $OpenBSD: if_tun.c,v 1.82 2007/01/26 10:58:47 claudio Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -274,25 +274,21 @@ tun_switch(struct tun_softc *tp, int flags) /* tp will be removed so store unit number */ unit = tp->tun_unit; - open = tp->tun_flags & TUN_OPEN; + open = tp->tun_flags & (TUN_OPEN|TUN_NBIO|TUN_ASYNC); TUNDEBUG(("%s: switching to layer %d\n", ifp->if_xname, flags & TUN_LAYER2 ? 2 : 3)); - /* - * remove old device - */ + /* remove old device and ... */ tun_clone_destroy(ifp); - - /* - * attach new interface - */ + /* attach new interface */ r = tun_create(&tun_cloner, unit, flags); + if (open && r == 0) { /* already opened before ifconfig tunX link0 */ if ((tp = tun_lookup(unit)) == NULL) /* this should never fail */ return (ENXIO); - tp->tun_flags |= TUN_OPEN; + tp->tun_flags |= open; TUNDEBUG(("%s: already open\n", tp->tun_if.if_xname)); } return (r); @@ -354,7 +350,8 @@ tunclose(dev_t dev, int flag, int mode, struct proc *p) return (ENXIO); ifp = &tp->tun_if; - tp->tun_flags &= ~TUN_OPEN; + tp->tun_flags &= ~(TUN_OPEN|TUN_NBIO|TUN_ASYNC); + ifp->if_flags &= ~IFF_RUNNING; /* * junk all pending output |