Have I misunderstood autobridge?

I recently noticed this in rc.conf(5):

autobridge_interfaces

(str) Set to the list of bridge interfaces that will have newly arriving interfaces checked against to be automatically added. If not set to “NO” then for each whitespace separated element in the value, a autobridge_⟨element⟩ variable is assumed to exist which has a whitespace separated list of interface names to match, these names can use wildcards. For example:

autobridge_interfaces="bridge0"
autobridge_bridge0="tap* dc0 vlan[345]"
I thought I would make use of this to automatically add tap(4) interfaces to a bridge when they are created by bhyve, so added the following to my /etc/rc.conf:

Code:
ifconfig_igb0="DHCP"

cloned_interfaces="bridge0"
ifconfig_bridge0="addm igb0"

autobridge_interfaces="bridge0"
autobridge_bridge0="tap*"

When I start my bhyve VM, a tap0 is created, but it is not being added to bridge0 automatically.

Is something not working properly, or are my expectations incorrect?
 
Maybe you need to remove
Code:
ifconfig_bridge0="addm igb0"
and add it to the autobridge
Code:
autobridge_bridge0="tap* igb0"
Maybe it is an issue with the glob pattern too.
 
Having had a read through /etc/rc.d/bridge, it seems that the autobridge directives only do something when the rc scripts run at boot. It doesn't continuously watch for interfaces to add to a bridge.
 
Having had a read through /etc/rc.d/bridge, it seems that the autobridge directives only do something when the rc scripts run at boot. It doesn't continuously watch for interfaces to add to a bridge.
I tried it and it works in live. As you create a tap, it becomes member of bridge0. So, try again.
 
I spoke too soon.

It seems that tap(4) interfaces are only automatically added to the bridge if I explicitly create them with an ifconfig(8) command or in the cloned_interfaces directive in rc.conf(5).

If I let bhyve(8) automatically create a tap(4) interface when I start a VM, it isn't added to the bridge.

I can work around the problem by creating all my tap(4) interfaces in advance of starting up VMs, but it's a bit of a pain. Having them automatically created on demand is more convenient.
 
bhyve is automatically creating tap interface? I can't find where it's documented. Never tried, that said.
 
I tested it and it works. You give just "tap" as interface name for the virtio-net driver and that creates a tapN. But that's not clean. Once you shutdown the VM, that tapN isn't destroyed.

Personally, for each VM I have a script "preRun" and "postRun" which, in this case, create tap, add to the bridge and destroy it at the end. I even rename the tap to the name of the VM like tapWin10, so it's cristal clear the purpose of the tap(s) when VMs are running.
 
  • Thanks
Reactions: jem
Back
Top