Bug 165174 - [patch] [tap] allow tap(4) to keep its address on close
Summary: [patch] [tap] allow tap(4) to keep its address on close
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 8.2-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-net (Nobody)
URL:
Keywords:
: 199136 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-02-15 12:00 UTC by Eugene Grosbein
Modified: 2018-03-19 04:56 UTC (History)
4 users (show)

See Also:


Attachments
file.diff (2.92 KB, patch)
2012-02-15 12:00 UTC, Eugene Grosbein
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Grosbein 2012-02-15 12:00:20 UTC
	I routinely start, run and close several VirtualBox-controlled
	virtual machines within FreeBSD. These machines use tap(4)-based
	networking. tap interfaces are configured in /etc/rc.conf
	just like all other interfaces:

cloned_interfaces="tap0 tap1 tap2"
ifconfig_tap0="inet 192.168.254.1/29"
ifconfig_tap1="inet 192.168.254.17/28"
ifconfig_tap2="inet 192.168.254.9/29"

	Each machine uses its own tapX. VirtualBox runs as non-root user
	with help of /etc/sysctl.conf:

net.link.tap.user_open=1
net.link.tap.up_on_open=1

	This works for first start of each VM only as tap(4) driver
	removes interface addresses of tapX on close. Very inconvinient.

Fix: The following patch introduces new per-interface sysctls
	that may be used to keep addresses of tap interfaces
	and interfaces itself up on close:

net.link.tap.0.keep_up=1
net.link.tap.1.keep_up=1
net.link.tap.2.keep_up=1

	Default value is 0 and corresponds to current behaviour.

	The patch updates manual page too.
How-To-Repeat: 
	Create tap0 with ifconfig, run an application working with tap0,
	restart the application and its networking fails.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2012-02-17 06:53:28 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-net

Over to maintainer(s).
Comment 2 terehovv 2016-03-02 07:43:46 UTC
I have the same problem. This patch helps to work with bhyve when you need a network connection between the virtual machine and the host.
Comment 3 Eugene Grosbein freebsd_committer freebsd_triage 2017-09-09 19:37:32 UTC
These days tap(4) has IFF_LINK0 flag to keep interface up on close, so one can just use following in /etc/rc.conf:

ifconfig_tap0="inet 192.168.0.1/29 link0"
Comment 4 Eugene Grosbein freebsd_committer freebsd_triage 2018-03-19 04:56:56 UTC
*** Bug 199136 has been marked as a duplicate of this bug. ***