Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Jun 2013 11:48:37 +0200
From:      =?ISO-8859-1?Q?Bernhard_Fr=F6hlich?= <decke@FreeBSD.org>
To:        Landon Fuller <landonf@plausible.coop>
Cc:        "freebsd-emulation@freebsd.org" <freebsd-emulation@freebsd.org>
Subject:   Re: [PATCH] VLAN trunking support in VirtualBox vboxnetflt
Message-ID:  <CAE-m3X3OVb3zkb9FdCvDE7uLq=ix49-wPNs25SNV=UOXkuYr8w@mail.gmail.com>
In-Reply-To: <2E7892C4-F9BD-41A3-9269-D9A24D0DB695@plausible.coop>
References:  <6BCC0BDE-C9FD-47F0-96AE-88F797EFB074@plausible.coop> <2E7892C4-F9BD-41A3-9269-D9A24D0DB695@plausible.coop>

next in thread | previous in thread | raw e-mail | index | archive | help
Thanks a lot for the fix! I've added it to the kmod port in our
testing repository
and it will be included in the next update for vbox 4.1.14.

https://redports.org/changeset/13816

On Sun, May 26, 2013 at 6:17 PM, Landon Fuller <landonf@plausible.coop> wro=
te:
> Hello,
>
> This patch has been in the vbox kmod port for some time now, and I've bee=
n running it without incident; however, I recently ran into a configuration=
 that the patch does not correctly handle:
>         - A single host interface (eg, em0) bridged to a VM
>         - VLANs also configured on the host interface (em0.vlan0, em0.vla=
n1)
>
> The packet flow in this situation should be:
>         - The ng filter is handed a packet from em0
>         - The filter re-adds the VLAN header to the top of the packet and=
 strips the M_VLANTAG flag
>         - After passing to the virtual switch, the packet is re-injected =
into the host via ether_demux().
>         - ether_demux() extracts the embedded VLAN tag and hands the pack=
et off to vlan_input_p().
>
> As it turns out, ether_demux() does not handle frames with embedded VLAN =
tags, and at this point, the packet is dropped, rather than being routed to=
 the host's VLAN handling:
>         http://lists.freebsd.org/pipermail/freebsd-net/2011-October/03020=
1.html
>
> The result is as follows:
>         - Packets received via the host interface are handled correctly.
>         - Packets (including VLAN tagged packets) are passed to sub-VMs c=
orrectly.
>         - Packets that *should* be handled by vlan* sub-interfaces on the=
 host are never received by those interfaces as they're dropped in ether_de=
mux().
>
> This worked in my existing configuration because the host and the VMs act=
ually use two different VLAN trunks (em0 and em1), and so em0 packets being=
 dropped after injection into the virtual switch does not affect the host's=
 handling of packets on em1.
>
> I've attached an updated patch that should resolve this issue; I'm curren=
tly testing it locally on my home deployment and so far it is working fine.=
 The patch simply restores the VLAN flags and stripped ethernet header afte=
r injecting the packet into the virtual ethernet switch. With this change i=
n place, ether_demux() correctly hands the packet off to vlan_input_p().
>
> Cheers,
> Landon
>
>
>
>
> On Apr 13, 2012, at 2:51 PM, Landon J Fuller <landonf@plausible.coop> wro=
te:
>
>> Howdy,
>>
>> I was looking into trunking VLANs into a virtual machine via bridging, a=
nd noted that transmit of 802.1q tagged packets worked from the guest VM, b=
ut upon reception, the VLAN tag seemed to be stripped before the packets hi=
t the guest's interface.
>>
>> Taking a look at the netgraph-based bridging implementation, it looks li=
ke 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 eq=
uivalent 'ether_vtag' field in its INTNETSG struct to handle this.
>>
>> Thus, to preserve the VLAN tag, I modified vboxNetFltFreeBSDMBufToSG() t=
o 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 p=
romisc) flags on the guest interface before virtualbox will pass the VLAN t=
agged packets through. Otherwise, the VBox virtio-net device implementation=
 will filter out the incoming packets before handing them to the VM hardwar=
e.
>>       - VBox's em(4) host implementation does not appear to support 'har=
dware' VLAN tagging, but it does declare it. If using a em(4) virtualized N=
IC, you must set -vlanhwtag on the guest interface.
>>
>> I welcome someone(s) with more experience than I eyeballing the (tiny) a=
ttached patch. I'm also especially concerned as to whether this should be c=
onsidered supported functionality in VBox, or I'm just getting lucky with t=
he virtio-net code path.
>>
>> Thanks,
>> Landon
>>
>> <patch-src-VBox-HostDrivers-VBoxNetFlt-freebsd-VBoxNetFlt-freebsd.c>____=
___________________________________________
>> freebsd-emulation@freebsd.org mailing list
>> http://lists.freebsd.org/mailman/listinfo/freebsd-emulation
>> To unsubscribe, send any mail to "freebsd-emulation-unsubscribe@freebsd.=
org"
>
>
> _______________________________________________
> freebsd-emulation@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-emulation
> To unsubscribe, send any mail to "freebsd-emulation-unsubscribe@freebsd.o=
rg"



--=20
Bernhard Froehlich
http://www.bluelife.at/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAE-m3X3OVb3zkb9FdCvDE7uLq=ix49-wPNs25SNV=UOXkuYr8w>