Re: [PATCH net v2 2/2] net: dsa: realtek: rtl8365mb: keep the neutral PVID in VLAN-unaware bridges
From: Luiz Angelo Daros de Luca
Date: Fri Nov 13 2026 - 11:09:03 EST
> The switch looks up its forwarding database by the VLAN that it
> classifies a frame to, and untagged frames are classified to the port
> PVID. With configure_vlan_while_not_filtering, the bridge PVID is
> programmed into the port also while the bridge is VLAN-unaware, so
> untagged frames of such a bridge are looked up in VLAN 1. DSA however
> installs the FDB and MDB entries of a VLAN-unaware bridge with VID 0,
> so these entries never match a lookup.
>
> This breaks assisted learning on the CPU port: when a station that was
> first learned behind a user port moves behind the CPU port (e.g. a
> wireless client roaming between access points), the static entry that
> DSA installs for it on the CPU port does not override the learned one,
> and unicast to the station is dropped as a hairpin until the learned
> entry ages out. Clients that need a DHCP reply in that window do not
> get one.
>
> Keep the PVID requested by the bridge per port and only program it
> while the port filters VLANs. Otherwise keep the neutral PVID (VLANMC
> index 0, VID 0) that standalone ports already use, so that untagged
> frames are classified to VID 0, the VID that DSA uses for the FDB and
> MDB entries of a VLAN-unaware bridge. The per-bridge EFID keeps these
> lookups local to the bridge.
>
> The PVID and the accepted frame types now both follow from the bridge
> PVID and the filtering state. Replace rtl8365mb_vlan_pvid_port_set() and
> rtl8365mb_vlan_pvid_port_clear() with rtl8365mb_vlan_pvid_port_commit(),
> which programs both, and call it whenever either input changes. The
> filtering state is passed in, as DSA still reports the old one while
> VLAN filtering is being toggled.
>
> This only covers untagged frames. Tagged frames in a VLAN-unaware bridge
> are still classified by their tag, so a tagged station that roams keeps
> hitting the stale learned entry until it ages out, as before. Fixing
> that would need the switch to ignore the C-tag on ingress of these
> ports, which is left for a separate change.
>
> Fixes: 336e3e4a1ab3 ("net: dsa: realtek: rtl8365mb: add FDB support")
> Signed-off-by: Stijn Cleynhens <stijncleynhens@xxxxxxxxx>
Hi Stijn,
I reproduced the issue in my lab. With vlan_filtering enabled, the
CPU-assisted entries have their PVID defined normally, and the client
can successfully roam to and from a switch port and another CPU
interface bridged with the switch (e.g., a WLAN bridged with LAN
ports).
root@archerc5v4:~# tables_dump l2 | grep 64:70:02:cc:27
IDX1300: (UCST) mac:64:70:02:cc:27:69 cvid:001 ivl:1 spa:p0,0(lan4)
fid:0 efid:3 age:6 sa_en:0 auth:0 sablk:0 dablk:0 pri:0 fwd:0 l3:0
static:0
IDX1520: (UCST) mac:64:70:02:cc:27:50 cvid:001 ivl:1 spa:p0,7(CPU)
fid:0 efid:3 age:1 sa_en:0 auth:0 sablk:0 dablk:0 pri:0 fwd:0 l3:0
static:1
and:
root@archerc5v4:~# tables_dump l2 | grep 64:70:02:cc:27
IDX1300: (UCST) mac:64:70:02:cc:27:69 cvid:001 ivl:1 spa:p0,0(lan4)
fid:0 efid:3 age:6 sa_en:0 auth:0 sablk:0 dablk:0 pri:0 fwd:0 l3:0
static:0
IDX1520: (UCST) mac:64:70:02:cc:27:50 cvid:001 ivl:1 spa:p0,1(lan3)
fid:0 efid:3 age:6 sa_en:0 auth:0 sablk:0 dablk:0 pri:0 fwd:0 l3:0
static:0
When you disable filtering, you'll eventually get:
IDX1300: (UCST) mac:64:70:02:cc:27:69 cvid:001 ivl:1 spa:p0,0(lan4)
fid:0 efid:3 age:6 sa_en:0 auth:0 sablk:0 dablk:0 pri:0 fwd:0 l3:0
static:0
IDX1736: (UCST) mac:64:70:02:cc:27:96 cvid:000 ivl:1 spa:p0,7(CPU)
fid:0 efid:3 age:1 sa_en:0 auth:0 sablk:0 dablk:0 pri:0 fwd:0 l3:0
static:1
IDX1768: (UCST) mac:64:70:02:cc:27:96 cvid:001 ivl:1 spa:p0,1(lan3)
fid:0 efid:3 age:3 sa_en:0 auth:0 sablk:0 dablk:0 pri:0 fwd:0 l3:0
static:0
In this case, lan4 will not be able to communicate with
64:70:02:cc:27:96 until the lan3 entry expires. We could find and
delete those conflicting entries once the CPU entry is added. However,
the IDX1736 line is fundamentally wrong: even if it works after lan3
expires, it is only because the switch is flooding unknown unicast
addresses. Learning is disabled on the CPU port, and nothing will
teach the switch where that MAC actually is. I haven't tested it yet,
but I would expect all traffic from lan4 to 64:70:02:cc:27:96 to be
flooded to all bridge ports.
However, the way this patch solves the issue feels a bit off. It
forces all null PVIDs to a (defaut) bridge PVID when VLAN filtering is
disabled. According to IEEE 802.1Q, VLAN ID 0 is reserved and cannot
be used to assign regular data traffic or configure a normal broadcast
domain. The rtl8365mb driver uses VID 0 only to indicate that a port
does not have a PVID. Ultimately, what actually enforces this is
ingress filtering (by rejecting untagged frames). Any real use for VID
0 in both VLAN 4k and VLAN MC violates that assumption, suggesting we
might need to rethink some driver strategies.
AFAIK, when VLAN filtering is disabled in a Linux bridge, the FDB key
changes from [VID, MAC] to simply [MAC]. It explicitly ignores the VID
in the ingress packet, effectively leaving the lookup VID always as 0.
This means a frame with and without a VLAN tag would collide if their
MACs match, regardless of PVID or VLAN membership. This differs from
how this patch handles it, as the patch avoids collisions when the
VLAN tag is present.
It seems the best way to handle this is to use hardware SVL instead of
IVL when VLAN filtering is disabled. What do you guys think?
In the code, I wouldn't change the VLAN 4k VID 0 to enable IVL.
Instead, I would focus on adapting the driver to work in SVL mode when
vlan_filtering is disabled, for example, conditionally setting these:
uc.key.ivl = false;
mc.key.ivl = false;
And setting L2 FID/VID to 0 (isolation is handled by EFID) as well.
Moreover, since the VLAN 4k table is shared among bridges, this might
force us to use vlan_filtering_is_global = true, which carries its own
implications.
I don't know if we would be able to emulate SVL with IVL enabled, as
we cannot control how the hardware will learn dynamic entries with
VLANs configured (a consequence of
configure_vlan_while_not_filtering). Anyway, it might be a common
situation for all DSA drivers that use
configure_vlan_while_not_filtering.
I'll leave these thoughts for discussion.
Luiz