Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Nov 2014 14:00:28 +0000 (UTC)
From:      Philip Paeps <philip@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r274966 - head/sys/net
Message-ID:  <201411241400.sAOE0Srq063100@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: philip
Date: Mon Nov 24 14:00:27 2014
New Revision: 274966
URL: https://svnweb.freebsd.org/changeset/base/274966

Log:
  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

Modified:
  head/sys/net/if_tap.c

Modified: head/sys/net/if_tap.c
==============================================================================
--- head/sys/net/if_tap.c	Mon Nov 24 13:02:39 2014	(r274965)
+++ head/sys/net/if_tap.c	Mon Nov 24 14:00:27 2014	(r274966)
@@ -156,6 +156,7 @@ static int			tapdebug = 0;        /* deb
 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_o
 	"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 
 	 * 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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411241400.sAOE0Srq063100>