Vladimir Oltean
2021-Apr-26 19:40 UTC
[Bridge] [RFC net-next 5/9] net: dsa: Track port PVIDs
Hi Tobias, On Mon, Apr 26, 2021 at 07:04:07PM +0200, Tobias Waldekranz wrote:> In some scenarios a tagger must know which VLAN to assign to a packet, > even if the packet is set to egress untagged. Since the VLAN > information in the skb will be removed by the bridge in this case, > track each port's PVID such that the VID of an outgoing frame can > always be determined. > > Signed-off-by: Tobias Waldekranz <tobias at waldekranz.com> > ---Let me give you this real-life example: #!/bin/bash ip link add br0 type bridge vlan_filtering 1 for eth in eth0 eth1 swp2 swp3 swp4 swp5; do ip link set $eth up ip link set $eth master br0 done ip link set br0 up bridge vlan add dev eth0 vid 100 pvid untagged bridge vlan del dev swp2 vid 1 bridge vlan del dev swp3 vid 1 bridge vlan add dev swp2 vid 100 bridge vlan add dev swp3 vid 100 untagged reproducible on the NXP LS1021A-TSN board. The bridge receives an untagged packet on eth0 and floods it. It should reach swp2 and swp3, and be tagged on swp2, and untagged on swp3 respectively. With your idea of sending untagged frames towards the port's pvid, wouldn't we be leaking this packet to VLAN 1, therefore towards ports swp4 and swp5, and the real destination ports would not get this packet?
Tobias Waldekranz
2021-Apr-26 20:05 UTC
[Bridge] [RFC net-next 5/9] net: dsa: Track port PVIDs
On Mon, Apr 26, 2021 at 22:40, Vladimir Oltean <olteanv at gmail.com> wrote:> Hi Tobias, > > On Mon, Apr 26, 2021 at 07:04:07PM +0200, Tobias Waldekranz wrote: >> In some scenarios a tagger must know which VLAN to assign to a packet, >> even if the packet is set to egress untagged. Since the VLAN >> information in the skb will be removed by the bridge in this case, >> track each port's PVID such that the VID of an outgoing frame can >> always be determined. >> >> Signed-off-by: Tobias Waldekranz <tobias at waldekranz.com> >> --- > > Let me give you this real-life example: > > #!/bin/bash > > ip link add br0 type bridge vlan_filtering 1 > for eth in eth0 eth1 swp2 swp3 swp4 swp5; do > ip link set $eth up > ip link set $eth master br0 > done > ip link set br0 up > > bridge vlan add dev eth0 vid 100 pvid untagged > bridge vlan del dev swp2 vid 1 > bridge vlan del dev swp3 vid 1 > bridge vlan add dev swp2 vid 100 > bridge vlan add dev swp3 vid 100 untagged > > reproducible on the NXP LS1021A-TSN board. > The bridge receives an untagged packet on eth0 and floods it. > It should reach swp2 and swp3, and be tagged on swp2, and untagged on > swp3 respectively. > > With your idea of sending untagged frames towards the port's pvid, > wouldn't we be leaking this packet to VLAN 1, therefore towards ports > swp4 and swp5, and the real destination ports would not get this packet?I am not sure I follow. The bridge would never send the packet to swp{4,5} because should_deliver() rejects them (as usual). So it could only be sent either to swp2 or swp3. In the case that swp3 is first in the bridge's port list, it would be sent untagged, but the PVID would be 100 and the flooding would thus be limited to swp{2,3}. You did make me realize that there is a fatal flaw in the current design though: Using this approach, it is not possible to have multiple VLANs configured to egress untagged out of one port. Rare, but allowed. So the VLAN information will have to remain in the skb somehow. My initial plan was actually to always send offloaded skbs tagged. I went this route because I thought we already had all the information we needed in the driver. It seems reasonable that skb->vlan_tci could always be set for offloaded frames from a filtering bridge, no?
Vladimir Oltean
2021-Apr-26 20:28 UTC
[Bridge] [RFC net-next 5/9] net: dsa: Track port PVIDs
On Mon, Apr 26, 2021 at 10:05:52PM +0200, Tobias Waldekranz wrote:> On Mon, Apr 26, 2021 at 22:40, Vladimir Oltean <olteanv at gmail.com> wrote: > > Hi Tobias, > > > > On Mon, Apr 26, 2021 at 07:04:07PM +0200, Tobias Waldekranz wrote: > >> In some scenarios a tagger must know which VLAN to assign to a packet, > >> even if the packet is set to egress untagged. Since the VLAN > >> information in the skb will be removed by the bridge in this case, > >> track each port's PVID such that the VID of an outgoing frame can > >> always be determined. > >> > >> Signed-off-by: Tobias Waldekranz <tobias at waldekranz.com> > >> --- > > > > Let me give you this real-life example: > > > > #!/bin/bash > > > > ip link add br0 type bridge vlan_filtering 1 > > for eth in eth0 eth1 swp2 swp3 swp4 swp5; do > > ip link set $eth up > > ip link set $eth master br0 > > done > > ip link set br0 up > > > > bridge vlan add dev eth0 vid 100 pvid untagged > > bridge vlan del dev swp2 vid 1 > > bridge vlan del dev swp3 vid 1 > > bridge vlan add dev swp2 vid 100 > > bridge vlan add dev swp3 vid 100 untagged > > > > reproducible on the NXP LS1021A-TSN board. > > The bridge receives an untagged packet on eth0 and floods it. > > It should reach swp2 and swp3, and be tagged on swp2, and untagged on > > swp3 respectively. > > > > With your idea of sending untagged frames towards the port's pvid, > > wouldn't we be leaking this packet to VLAN 1, therefore towards ports > > swp4 and swp5, and the real destination ports would not get this packet? > > I am not sure I follow. The bridge would never send the packet to > swp{4,5} because should_deliver() rejects them (as usual). So it could > only be sent either to swp2 or swp3. In the case that swp3 is first in > the bridge's port list, it would be sent untagged, but the PVID would be > 100 and the flooding would thus be limited to swp{2,3}.Sorry, _I_ don't understand. When you say that the PVID is 100, whose PVID is it, exactly? Is it the pvid of the source port (aka eth0 in this example)? That's not what I see, I see the pvid of the egress port (the Marvell device)... So to reiterate: when you transmit a packet towards your hardware switch which has br0 inside the sb_dev, how does the switch know in which VLAN to forward that packet? As far as I am aware, when the bridge had received the packet as untagged on eth0, it did not insert VLAN 100 into the skb itself, so the bridge VLAN information is lost when delivering the frame to the egress net device. Am I wrong?