Re: [PATCH net 1/2] net: bridge: vlan: fix vlan range dumps starting with pvid

Ido Schimmel <[email protected]> Wed, 22 Jul 2026 19:51:53 +0300
Newsgroups gmane.linux.network.bridge
Message-ID <20260722165153.GA3080508__36983.1283156358$1784739300$gmane$org@shredder>
On Tue, Jul 21, 2026 at 05:09:21PM +0300, Nikolay Aleksandrov wrote:
> There is a bug in all range dumps that rely on br_vlan_can_enter_range()
> when the PVID is a range starting VLAN, all following VLANs that match
> its flags can enter the range, but when the range is filled in only the
> PVID VLAN is dumped and the rest of the range is discarded because
> br_vlan_fill_vids() checks for the PVID flag. Since the PVID VLAN can
> be only one, we need to break ranges around it, the best way to do that
> consistently for all is to alter br_vlan_can_enter_range() to take into
> account the PVID and return false to break the range when it's matched.
> 
> Before the fix:
> $ ip l add br0 type bridge vlan_filtering 1
> $ ip l add dumdum type dummy
> $ ip l set dumdum master br0
> $ ip l set br0 up
> $ ip l set dumdum up
> $ bridge vlan add dev dumdum vid 1 pvid untagged master
> $ bridge vlan add dev dumdum vid 2 untagged master
> $ bridge vlan show dev dumdum # use legacy dump to show all vlans
> port              vlan-id
> dumdum            1 PVID Egress Untagged
>                   2 Egress Untagged
> 
> $ bridge -d vlan show dev dumdum # use the new dump (RTM_GETVLAN)
> port              vlan-id
> dumdum            1 PVID Egress Untagged
>                     state forwarding mcast_router 1
> 
> VLAN 2 is missing, and if there are more matching VLANs afterwards
> they'd be missing too.
> 
> After the fix:
> [ same setup steps ]
> $ bridge vlan show dev dumdum
> port              vlan-id
> dumdum            1 PVID Egress Untagged
>                   2 Egress Untagged
> $ bridge -d vlan show dev dumdum # use the new dump (RTM_GETVLAN)
> port              vlan-id
> dumdum            1 PVID Egress Untagged
>                     state forwarding mcast_router 1
>                   2 Egress Untagged
>                     state forwarding mcast_router 1
> 
> Fixes: 0ab558795184 ("net: bridge: vlan: add rtm range support")
> Signed-off-by: Nikolay Aleksandrov <[email protected]>

Reviewed-by: Ido Schimmel <[email protected]>