[PATCH] VLAN trunking support in VirtualBox vboxnetflt
Landon J Fuller
landonf at plausible.coop
Fri Apr 13 18:52:01 UTC 2012
Howdy,
I was looking into trunking VLANs into a virtual machine via bridging, and noted that transmit of 802.1q tagged packets worked from the guest VM, but upon reception, the VLAN tag seemed to be stripped before the packets hit the guest's interface.
Taking a look at the netgraph-based bridging implementation, it looks like the VLAN tag is not being re-inserted at the head of the ethernet frame prior to handing off the to VirtualBox, and VBox doesn't seem to have an equivalent 'ether_vtag' field in its INTNETSG struct to handle this.
Thus, to preserve the VLAN tag, I modified vboxNetFltFreeBSDMBufToSG() to ether_vlanencap() to insert the VLAN tag before handing off to VBox. With this in place, I was able to successfully trunk VLANs to a virtual machine.
Some caveats:
- If using virtio-kmod's if_vtnet, you must set vlanhwfilter (or promisc) flags on the guest interface before virtualbox will pass the VLAN tagged packets through. Otherwise, the VBox virtio-net device implementation will filter out the incoming packets before handing them to the VM hardware.
- VBox's em(4) host implementation does not appear to support 'hardware' VLAN tagging, but it does declare it. If using a em(4) virtualized NIC, you must set -vlanhwtag on the guest interface.
I welcome someone(s) with more experience than I eyeballing the (tiny) attached patch. I'm also especially concerned as to whether this should be considered supported functionality in VBox, or I'm just getting lucky with the virtio-net code path.
Thanks,
Landon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c
Type: application/octet-stream
Size: 753 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-emulation/attachments/20120413/10ed2e40/patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.obj
More information about the freebsd-emulation
mailing list