Lines 153-159
Link Here
|
153 |
*/ |
153 |
*/ |
154 |
static struct mtx tapmtx; |
154 |
static struct mtx tapmtx; |
155 |
static int tapdebug = 0; /* debug flag */ |
155 |
static int tapdebug = 0; /* debug flag */ |
156 |
static int tapuopen = 0; /* allow user open() */ |
|
|
157 |
static int tapuponopen = 0; /* IFF_UP on open() */ |
156 |
static int tapuponopen = 0; /* IFF_UP on open() */ |
158 |
static int tapdclone = 1; /* enable devfs cloning */ |
157 |
static int tapdclone = 1; /* enable devfs cloning */ |
159 |
static SLIST_HEAD(, tap_softc) taphead; /* first device */ |
158 |
static SLIST_HEAD(, tap_softc) taphead; /* first device */ |
Lines 166-177
Link Here
|
166 |
SYSCTL_DECL(_net_link); |
165 |
SYSCTL_DECL(_net_link); |
167 |
static SYSCTL_NODE(_net_link, OID_AUTO, tap, CTLFLAG_RW, 0, |
166 |
static SYSCTL_NODE(_net_link, OID_AUTO, tap, CTLFLAG_RW, 0, |
168 |
"Ethernet tunnel software network interface"); |
167 |
"Ethernet tunnel software network interface"); |
169 |
SYSCTL_INT(_net_link_tap, OID_AUTO, user_open, CTLFLAG_RW, &tapuopen, 0, |
|
|
170 |
"Allow user to open /dev/tap (based on node permissions)"); |
171 |
SYSCTL_INT(_net_link_tap, OID_AUTO, up_on_open, CTLFLAG_RW, &tapuponopen, 0, |
168 |
SYSCTL_INT(_net_link_tap, OID_AUTO, up_on_open, CTLFLAG_RW, &tapuponopen, 0, |
172 |
"Bring interface up when /dev/tap is opened"); |
169 |
"Bring interface up when /dev/tap is opened"); |
173 |
SYSCTL_INT(_net_link_tap, OID_AUTO, devfs_cloning, CTLFLAG_RWTUN, &tapdclone, 0, |
170 |
SYSCTL_INT(_net_link_tap, OID_AUTO, devfs_cloning, CTLFLAG_RWTUN, &tapdclone, 0, |
174 |
"Enably legacy devfs interface creation"); |
171 |
"Enable legacy devfs interface creation"); |
175 |
SYSCTL_INT(_net_link_tap, OID_AUTO, debug, CTLFLAG_RW, &tapdebug, 0, ""); |
172 |
SYSCTL_INT(_net_link_tap, OID_AUTO, debug, CTLFLAG_RW, &tapdebug, 0, ""); |
176 |
|
173 |
|
177 |
DEV_MODULE(if_tap, tapmodevent, NULL); |
174 |
DEV_MODULE(if_tap, tapmodevent, NULL); |
Lines 345-352
Link Here
|
345 |
if (*dev != NULL) |
342 |
if (*dev != NULL) |
346 |
return; |
343 |
return; |
347 |
|
344 |
|
348 |
if (!tapdclone || |
345 |
if (!tapdclone || priv_check_cred(cred, PRIV_NET_IFCREATE, 0) != 0) |
349 |
(!tapuopen && priv_check_cred(cred, PRIV_NET_IFCREATE, 0) != 0)) |
|
|
350 |
return; |
346 |
return; |
351 |
|
347 |
|
352 |
unit = 0; |
348 |
unit = 0; |
Lines 477-490
Link Here
|
477 |
{ |
473 |
{ |
478 |
struct tap_softc *tp = NULL; |
474 |
struct tap_softc *tp = NULL; |
479 |
struct ifnet *ifp = NULL; |
475 |
struct ifnet *ifp = NULL; |
480 |
int error; |
|
|
481 |
|
476 |
|
482 |
if (tapuopen == 0) { |
|
|
483 |
error = priv_check(td, PRIV_NET_TAP); |
484 |
if (error) |
485 |
return (error); |
486 |
} |
487 |
|
488 |
if ((dev2unit(dev) & CLONE_UNITMASK) > TAPMAXUNIT) |
477 |
if ((dev2unit(dev) & CLONE_UNITMASK) > TAPMAXUNIT) |
489 |
return (ENXIO); |
478 |
return (ENXIO); |
490 |
|
479 |
|