Add a sysctl `net.link.tap.deladdrs_on_close' to configure whether tap
should delete configured addresses and routes when the interface is closed. Default is enabled (preserve current behaviour). MFC after: 1 week
This commit is contained in:
parent
f1730eff39
commit
1f1e4bf8b6
@ -156,6 +156,7 @@ static int tapdebug = 0; /* debug flag */
|
||||
static int tapuopen = 0; /* allow user open() */
|
||||
static int tapuponopen = 0; /* IFF_UP on open() */
|
||||
static int tapdclone = 1; /* enable devfs cloning */
|
||||
static int tapclosedeladdrs = 1; /* del addrs on close */
|
||||
static SLIST_HEAD(, tap_softc) taphead; /* first device */
|
||||
static struct clonedevs *tapclones;
|
||||
|
||||
@ -172,6 +173,9 @@ 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_RWTUN, &tapdclone, 0,
|
||||
"Enably legacy devfs interface creation");
|
||||
SYSCTL_INT(_net_link_tap, OID_AUTO, deladdrs_on_close, CTLFLAG_RW,
|
||||
&tapclosedeladdrs, 0, "Delete addresses and routes when /dev/tap is "
|
||||
"closed");
|
||||
SYSCTL_INT(_net_link_tap, OID_AUTO, debug, CTLFLAG_RW, &tapdebug, 0, "");
|
||||
|
||||
DEV_MODULE(if_tap, tapmodevent, NULL);
|
||||
@ -536,7 +540,8 @@ tapclose(struct cdev *dev, int foo, int bar, struct thread *td)
|
||||
* interface, if we are in VMnet mode. just close the device.
|
||||
*/
|
||||
|
||||
if (((tp->tap_flags & TAP_VMNET) == 0) && (ifp->if_flags & IFF_UP)) {
|
||||
if (tapclosedeladdrs == 1 && ((tp->tap_flags & TAP_VMNET) == 0) &&
|
||||
(ifp->if_flags & IFF_UP)) {
|
||||
mtx_unlock(&tp->tap_mtx);
|
||||
if_down(ifp);
|
||||
mtx_lock(&tp->tap_mtx);
|
||||
|
Loading…
Reference in New Issue
Block a user