summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2006-01-02 23:41:21 +1100
committerDamien Miller <djm@mindrot.org>2006-01-02 23:41:21 +1100
commita1d9a18e142d05cb8cfe10dc7abf253f1e2c6a5b (patch)
tree024259a94d18aec90c07a7a824eb542c76ebb538 /misc.c
parent5444618987402d50fb9c6c722919fe2d428d05bb (diff)
- reyk@cvs.openbsd.org 2006/01/02 07:53:44
[misc.c] 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@
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/misc.c b/misc.c
index 26d7cad2c..0339cede4 100644
--- a/misc.c
+++ b/misc.c
@@ -24,7 +24,7 @@
24 */ 24 */
25 25
26#include "includes.h" 26#include "includes.h"
27RCSID("$OpenBSD: misc.c,v 1.39 2006/01/01 10:08:48 stevesk Exp $"); 27RCSID("$OpenBSD: misc.c,v 1.40 2006/01/02 07:53:44 reyk Exp $");
28 28
29#ifdef SSH_TUN_OPENBSD 29#ifdef SSH_TUN_OPENBSD
30#include <net/if.h> 30#include <net/if.h>
@@ -581,11 +581,17 @@ tun_open(int tun, int mode)
581 581
582 if (ioctl(sock, SIOCGIFFLAGS, &ifr) == -1) 582 if (ioctl(sock, SIOCGIFFLAGS, &ifr) == -1)
583 goto failed; 583 goto failed;
584 if (mode == SSH_TUNMODE_ETHERNET) { 584
585 /* Set interface mode */
586 ifr.ifr_flags &= ~IFF_UP;
587 if (mode == SSH_TUNMODE_ETHERNET)
585 ifr.ifr_flags |= IFF_LINK0; 588 ifr.ifr_flags |= IFF_LINK0;
586 if (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1) 589 else
587 goto failed; 590 ifr.ifr_flags &= ~IFF_LINK0;
588 } 591 if (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1)
592 goto failed;
593
594 /* Bring interface up */
589 ifr.ifr_flags |= IFF_UP; 595 ifr.ifr_flags |= IFF_UP;
590 if (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1) 596 if (ioctl(sock, SIOCSIFFLAGS, &ifr) == -1)
591 goto failed; 597 goto failed;