diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2006-01-02 07:53:45 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2006-01-02 07:53:45 +0000 |
commit | 8d51848d36862681f815cc109c826ef6de4da5c6 (patch) | |
tree | 8dd864673166d945288023af6d020b00e602f8c9 | |
parent | c11a4bd434e5d23cee65a597c8c689b07a2ea65e (diff) |
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; |