Re: [PATCH net-next v10 07/12] net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D

From: netdev-bot+sashiko

Date: Mon Nov 16 2026 - 13:56:03 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] On family D, the per-VID IVL_EN bit (CVLAN word 1, bit 3) is
set only inside rtl8365mb_vlan_4k_port_set()…

--

net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D

This adds two-word pack/unpack helpers for the family D CVLAN (4K VLAN)
table entry, rtl8365mb_d_vlan_4k_read() and rtl8365mb_d_vlan_4k_write().
It also changes rtl8365mb_vlan_4k_port_set() so that on family D, IVL_EN
is set only while some user port has VLAN filtering enabled. Family C
keeps IVL always on.

> diff --git a/drivers/net/dsa/realtek/rtl8365mb_vlan.c b/drivers/net/dsa/realtek/rtl8365mb_vlan.c
> index 566c6bc1449af..bf1a6a9916114 100644
> --- a/drivers/net/dsa/realtek/rtl8365mb_vlan.c
> +++ b/drivers/net/dsa/realtek/rtl8365mb_vlan.c

[ ... ]

> @@ -314,7 +391,21 @@ rtl8365mb_vlan_4k_port_set(struct dsa_switch *ds, int port,
> vlan4k.untag |= BIT(port);
> else
> vlan4k.untag &= ~BIT(port);
> - vlan4k.ivl_en = true; /* always use Independent VLAN Learning */
> +
> + /* Family C always uses IVL. On family D, IVL is on while any user
> + * port has VLAN filtering enabled, so that static entries match
> + * learned ones in a VLAN-unaware bridge (SVL).
> + */
> + if (!rtl8365mb_is_d(priv)) {
> + vlan4k.ivl_en = true;
> + } else {
> + struct dsa_port *dp;
> +
> + vlan4k.ivl_en = false;
> + dsa_switch_for_each_user_port(dp, ds)
> + if (dsa_port_is_vlan_filtering(dp))
> + vlan4k.ivl_en = true;
> + }

[Severity: Medium]
Can the per-VID IVL_EN bit go stale here when vlan_filtering changes?

The bit is only computed when a VLAN is added or deleted.
rtl8365mb_port_vlan_filtering() in rtl8365mb_main.c changes ingress
filtering, the transparent masks, the frame filter and the egress mode.
It never rewrites the 4K table entries:

rtl8365mb_port_vlan_filtering() {
...
ret = rtl8365mb_port_set_ingress_filtering(priv, port, vlan_filtering);
...
ret = rtl8365mb_port_set_transparent(priv, port, dp->index,
!vlan_filtering);
...
}

rtl8365mb_setup() sets ds->configure_vlan_while_not_filtering = true, so
VLANs are programmed while the bridge is still VLAN-unaware. Take a
common sequence:

ip link add br0 type bridge
ip link set lanX master br0
ip link set br0 type bridge vlan_filtering 1

VID 1 is written with IVL_EN=0 and keeps it after filtering is turned
on. VIDs added after that get IVL_EN=1, so the table ends up with a mix
of IVL and SVL VLANs inside one VLAN-aware bridge.

The reverse also happens. If filtering is turned off, the VLANs stay in
IVL mode. Later in the series, rtl8365mb_d_l2_uc_to_data() and
rtl8365mb_d_l2_mc_to_data() key vid 0 static entries with SVL (FID 0):

bool ivl = uc->key.ivl && uc->key.vid;
u16 id = ivl ? uc->key.vid : uc->key.fid;

In both cases, would static FDB/MDB entries and learned entries end up
with different keys? The commit message says this logic exists to
prevent that.

The bridge join ordering seems to add a further case. In
dsa_port_bridge_join(), switchdev_bridge_port_offload() replays the
bridge VLANs through br_switchdev_vlan_replay() before
dsa_port_switchdev_sync_attrs() sets dp->vlan_filtering. When the first
port joins a bridge that already filters, are the replayed VLANs written
with IVL_EN=0?

The policy is also switch-wide. With one VLAN-aware bridge and one
VLAN-unaware bridge on the same switch, the unaware bridge's VIDs would
be forced to IVL.

The commit message says:

The stored IVL_EN is refreshed on the next port_vlan_add/del for the
VID, not on a vlan_filtering change.

Nothing in the driver triggers that refresh, so the final hardware state
depends on the order of configuration steps. Should
rtl8365mb_port_vlan_filtering(), or the family D join path, walk the
existing 4K entries and rewrite IVL_EN?

This is still present at the end of the series, where the family D info
is wired up in "net: dsa: realtek: rtl8365mb: add support for
RTL8367S-VB".

>
> ret = fi->vlan_4k_write(priv, &vlan4k);
> if (ret) {

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/d9da17af-f49e-4878-a8dd-59a8919e6930%40yahoo.com