From owner-svn-src-all@FreeBSD.ORG Mon Nov 24 14:00:28 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 906B7224; Mon, 24 Nov 2014 14:00:28 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7D7DF93E; Mon, 24 Nov 2014 14:00:28 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAOE0S3x063101; Mon, 24 Nov 2014 14:00:28 GMT (envelope-from philip@FreeBSD.org) Received: (from philip@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAOE0Srq063100; Mon, 24 Nov 2014 14:00:28 GMT (envelope-from philip@FreeBSD.org) Message-Id: <201411241400.sAOE0Srq063100@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: philip set sender to philip@FreeBSD.org using -f From: Philip Paeps Date: Mon, 24 Nov 2014 14:00:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r274966 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Nov 2014 14:00:28 -0000 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);