diff options
author | 2006-01-02 07:53:44 +0000 | |
---|---|---|
committer | 2006-01-02 07:53:44 +0000 | |
commit | 06daa7e0609d683867ec0128f505a926c3bc08bd (patch) | |
tree | 713d16a963004c258e873a90aca18dba02b2a2a3 | |
parent | remove last traces of __BROKEN_INDIRECT_CONFIG. (diff) | |
download | wireguard-openbsd-06daa7e0609d683867ec0128f505a926c3bc08bd.tar.xz wireguard-openbsd-06daa7e0609d683867ec0128f505a926c3bc08bd.zip |
clarify tun(4) opening - set the mode and bring the interface up. also
(re)sets the tun(4) layer 2 LINK0 flag for existing tunnel interfaces.
suggested and ok by djm@
-rw-r--r-- | usr.bin/ssh/misc.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.bin/ssh/misc.c b/usr.bin/ssh/misc.c index 608e6763a85..8ffb145bae5 100644 --- a/usr.bin/ssh/misc.c +++ b/usr.bin/ssh/misc.c @@ -24,7 +24,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: misc.c,v 1.39 2006/01/01 10:08:48 stevesk Exp $"); +RCSID("$OpenBSD: misc.c,v 1.40 2006/01/02 07:53:44 reyk Exp $"); #include <net/if.h> @@ -570,11 +570,17 @@ tun_open(int tun, int mode) if (ioctl(sock, SIOCGIFFLAGS, &ifr) == -1) goto failed; - if (mode == SSH_TUNMODE_ETHERNET) { + + /* Set interface mode */ + ifr.ifr_flags &= ~IFF_UP; + if (mode == SSH_TUNMODE_ETHERNET) ifr.ifr_flags |= IFF_LINK0; - if (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1) - goto failed; - } + else + ifr.ifr_flags &= ~IFF_LINK0; + if (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1) + goto failed; + + /* Bring interface up */ ifr.ifr_flags |= IFF_UP; if (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1) goto failed; |