aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPhilip Paeps <philip@FreeBSD.org>2014-11-24 14:00:27 +0000
committerPhilip Paeps <philip@FreeBSD.org>2014-11-24 14:00:27 +0000
commit894d1973f1fd537772cdbcf212f59e59e7404b99 (patch)
treec7e421f229b6d6ee6d99df82973d4e47bcff684c /sys
parentc74915e08d8a183e8a6c1f15b68184c99f86cc09 (diff)
downloadsrc-894d1973f1fd537772cdbcf212f59e59e7404b99.tar.gz
src-894d1973f1fd537772cdbcf212f59e59e7404b99.zip
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
Notes
Notes: svn path=/head/; revision=274966
Diffstat (limited to 'sys')
-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 5de424ca9b45..5f6f0aaaadef 100644
--- a/sys/net/if_tap.c
+++ b/sys/net/if_tap.c
@@ -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);