summaryrefslogtreecommitdiffstats
path: root/sys/net/if_tap.c
diff options
context:
space:
mode:
authorbms <bms@FreeBSD.org>2007-03-19 18:17:31 +0000
committerbms <bms@FreeBSD.org>2007-03-19 18:17:31 +0000
commit9d0975ba995d6d98160e2786c7bfa7e5f2b8f12b (patch)
tree139a4f6a9c17eeacc1ffa7017f84b11cd6a6941a /sys/net/if_tap.c
parent70b3eda27cf46182d91500a0c4b89a18908e72cb (diff)
downloadFreeBSD-src-9d0975ba995d6d98160e2786c7bfa7e5f2b8f12b.zip
FreeBSD-src-9d0975ba995d6d98160e2786c7bfa7e5f2b8f12b.tar.gz
Add a sysctl net.link.tap.up_on_open which defaults to zero; when it
is non-zero, tap(4) instances will be marked IFF_UP on attach. PR: 110383 Requested by: Frank Behrens MFC after: 2 weeks
Diffstat (limited to 'sys/net/if_tap.c')
-rw-r--r--sys/net/if_tap.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c
index 0dcaba0..e08b3b6 100644
--- a/sys/net/if_tap.c
+++ b/sys/net/if_tap.c
@@ -150,7 +150,8 @@ static struct cdevsw tap_cdevsw = {
*/
static struct mtx tapmtx;
static int tapdebug = 0; /* debug flag */
-static int tapuopen = 0; /* allow user open() */
+static int tapuopen = 0; /* allow user open() */
+static int tapuponopen = 0; /* IFF_UP on open() */
static int tapdclone = 1; /* enable devfs cloning */
static SLIST_HEAD(, tap_softc) taphead; /* first device */
static struct clonedevs *tapclones;
@@ -164,6 +165,8 @@ SYSCTL_NODE(_net_link, OID_AUTO, tap, CTLFLAG_RW, 0,
"Ethernet tunnel software network interface");
SYSCTL_INT(_net_link_tap, OID_AUTO, user_open, CTLFLAG_RW, &tapuopen, 0,
"Allow user to open /dev/tap (based on node permissions)");
+SYSCTL_INT(_net_link_tap, OID_AUTO, up_on_open, CTLFLAG_RW, &tapuponopen, 0,
+ "Bring interface up when /dev/tap is opened");
SYSCTL_INT(_net_link_tap, OID_AUTO, devfs_cloning, CTLFLAG_RW, &tapdclone, 0,
"Enably legacy devfs interface creation");
SYSCTL_INT(_net_link_tap, OID_AUTO, debug, CTLFLAG_RW, &tapdebug, 0, "");
@@ -502,6 +505,8 @@ tapopen(struct cdev *dev, int flag, int mode, struct thread *td)
s = splimp();
ifp->if_drv_flags |= IFF_DRV_RUNNING;
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
+ if (tapuponopen)
+ ifp->if_flags |= IFF_UP;
splx(s);
TAPDEBUG("%s is open. minor = %#x\n", ifp->if_xname, minor(dev));
OpenPOWER on IntegriCloud