Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: mmyangfl@gmail.com
Cc: netdev@vger.kernel.org, andrew@lunn.ch, olteanv@gmail.com,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v2 4/4] net: dsa: motorcomm: Use VID 0 as the unaware PVID
Date: Wed, 18 Nov 2026 16:02:50 +0000	[thread overview]
Message-ID: <179501777066.3136.14665752486224743787@kernel.org> (raw)
In-Reply-To: <20261116160107.1351198-5-mmyangfl@gmail.com>

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

Critical: 0 · High: 0 · Medium: 1 · Low: 2 (1)

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] This patch turns VID 0 into the shared FDB domain of VLAN-
  unaware bridges and removes the YT921X_VLAN_CTRLa_LEARN_DIS that used…
- [Low] After this patch, nothing in the driver ever programs VLAN table
  entry 0.
- [Low] The concern: VID 0 is now the forwarding domain of VLAN-unaware
  bridges, but its VLAN entry is never programmed.

Pre-existing issues:
- [Low] yt921x_bridge_join() first clears YT921X_PORT_LEARN_DIS through
  yt921x_userport_bridge() (line 1301), then writes the isolation…

--

net: dsa: motorcomm: Use VID 0 as the unaware PVID

This patch changes the PVID of ports in VLAN-unaware bridges from 4095 to
0, so the hardware lookups can hit bridge FDB entries that switchdev
reports with VID 0. It also skips VID 0 in the VLAN add/del paths and
programs PVID 0 when a port joins a VLAN-unaware bridge. Finally, it
removes the setup-time write of VLAN table entry 0.

> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index d84d863080ce0..aa4d6a0c930ce 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c

[ ... ]

> @@ -1029,8 +1031,7 @@ yt921x_pvid_clear(struct yt921x_priv *priv, int port)
>  
>  	vlan_filtering = dsa_port_is_vlan_filtering(dp);
>  
> -	res = yt921x_port_set_pvid(priv, port,
> -				   vlan_filtering ? 0 : YT921X_VID_UNWARE);
> +	res = yt921x_port_set_pvid(priv, port, 0);
>  	if (res)
>  		return res;

[Severity: Medium]
Ports in a VLAN-aware bridge that have no bridge PVID get hardware PVID 0.
That happens here, and also in yt921x_vlan_filtering() when
br_vlan_get_pvid() returns 0. On those ports, the only extra protection is
YT921X_PORT_VLAN_CTRL1_CVLAN_DROP_UNTAGGED.

This patch also makes VID 0 the shared FDB domain of the VLAN-unaware
bridges. It removes YT921X_VLAN_CTRLa_LEARN_DIS from VLAN entry 0 in
yt921x_chip_setup_dsa().

Suppose a VLAN-aware bridge and a VLAN-unaware bridge are on the same
switch. A priority-tagged frame arrives on a VLAN-aware port that has no
PVID. The commit message says such frames are classified to the port
PVID, so this one would be classified to VID 0.

If CVLAN_DROP_UNTAGGED does not drop priority-tagged frames, and the reset
member mask of VLAN 0 lets the frame through VLAN_IGR_FILTER, could its
source MAC be learnt into the FDB that the VLAN-unaware bridges use?

The comment in yt921x_chip_setup_dsa() says port isolation is applied
after the FDB lookup. A unicast frame from the VLAN-unaware bridge to that
MAC would hit an entry pointing at a port in the other bridge. It would be
dropped instead of trapped to the CPU until the entry ages out. The
software bridge would have dropped the original priority-tagged frame,
because the port has no PVID.

Before this patch, LEARN_DIS on VLAN 0 prevented this learning. Could
VLAN-filtering ports without a PVID use a VID other than 0, for example an
unused VID with learning disabled, so their traffic stays out of the
unaware domain?

[ ... ]

> @@ -1135,6 +1138,11 @@ yt921x_dsa_port_vlan_add(struct dsa_switch *ds, int port,
>  	 */
>  	if (dsa_is_cpu_port(ds, port))
>  		return 0;
> +	/* VID 0 is the VLAN-unaware bridges' FDB domain; nothing to program,
> +	 * keep the entry at reset defaults
> +	 */
> +	if (!vid)
> +		return 0;

[Severity: Low]
The comment just above says the CPU port is supposed to be a member of
every VLAN. With this early return, VID 0 never reaches yt921x_vlan_add(),
which is the only place that sets the CPU port bits:

yt921x_vlan_add() {
    ...
	masks[0] = YT921X_VLAN_CTRLa_PORTn(port) |
		   YT921X_VLAN_CTRLa_PORTS(priv->cpu_ports_mask);
    ...
}

VID 0 is now the forwarding domain of the VLAN-unaware bridges, yet entry
0 keeps its reset values for member ports, UNTAG_PORTS, FID and STP_ID.

This is probably fine in practice. The old unaware PVID 4095 was never
programmed either. VLAN_IGR_FILTER is only enabled on VLAN-filtering user
ports, and YT921X_VLAN_EGR_FILTER is never written.

Should the CPU port comment mention the VID 0 exception, though?

[ ... ]

> @@ -1297,6 +1306,14 @@ yt921x_bridge_join(struct yt921x_priv *priv, int port, u16 ports_mask)
>  	if (res)
>  		return res;
>  
> +	if (!vlan_filtering) {
> +		/* DSA may shortcut .port_vlan_filtering(), leaving stale PVID
> +		 */
> +		res = yt921x_port_set_pvid(priv, port, 0);
> +		if (res)
> +			return res;
> +	}
> +
>  	return 0;
>  }

[Severity: Low]
This isn't a bug introduced by this patch, but there is a short window
where frames are learnt under the standalone VID 4095.
yt921x_bridge_join() clears YT921X_PORT_LEARN_DIS in
yt921x_userport_bridge(), then writes the isolation registers in
yt921x_bridge(). Only after that is the PVID moved off 4095 here.

For VLAN-aware bridges, the PVID stays at 4095 even longer. It changes
only when dsa_port_switchdev_sync_attrs() calls dsa_port_vlan_filtering(),
which happens after DSA_NOTIFIER_BRIDGE_JOIN has been handled.

Port isolation is applied after the FDB lookup. Could a standalone port
sending to a MAC learnt in this window have its frame dropped instead of
trapped, until the entry ages out?

This patch makes the unaware window much shorter than before. Would
writing the PVID before clearing LEARN_DIS close what remains?

[ ... ]

> @@ -2335,15 +2352,6 @@ static int yt921x_chip_setup_dsa(struct yt921x_priv *priv)
>  	if (res)
>  		return res;
>  
> -	/* Tagged VID 0 should be treated as untagged, which confuses the
> -	 * hardware a lot
> -	 */
> -	ctrls[0] = YT921X_VLAN_CTRLa_LEARN_DIS | YT921X_VLAN_CTRLa_PORTS_M;
> -	ctrls[1] = 0;
> -	res = yt921x_reg64_write(priv, YT921X_VLANn_CTRL(0), ctrls);
> -	if (res)
> -		return res;
> -
>  	return 0;
>  }

[Severity: Low]
After this removal, does anything in the driver still program VLAN table
entry 0?

yt921x_dsa_port_vlan_add() and yt921x_dsa_port_vlan_del() now return early
for vid 0, and yt921x_dsa_vlan_msti_set() rejects vid 0 with -EINVAL.
Learning and membership in the VID 0 domain therefore depend entirely on
the chip's reset value for entry 0.

The commit message says:

    Lift the restriction on VLAN 0.

The new comment in yt921x_dsa_port_vlan_add() says "keep the entry at
reset defaults". Neither one gives the reset values. Neither says that
the all-ports membership (YT921X_VLAN_CTRLa_PORTS_M) is also dropped.
Neither explains why the workaround in the removed comment is no longer
needed.

The commit message mentions a measurement on YT9215S only. Could it
document which reset value of entry 0 is relied on, and whether that value
is the same on the other supported variants?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116160107.1351198-1-mmyangfl%40gmail.com

      reply	other threads:[~2026-11-18 16:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 16:01 [PATCH net v2 0/4] net: dsa: motorcomm: FDB fixup David Yang
2026-11-16 16:01 ` [PATCH net v2 1/4] net: dsa: motorcomm: Do not inherit ports from dynamic FDB entries David Yang
2026-11-16 16:01 ` [PATCH net v2 2/4] net: dsa: motorcomm: Rewrite FDB entry on port migration David Yang
2026-11-18 16:02   ` netdev-bot+sashiko
2026-11-16 16:01 ` [PATCH net v2 3/4] net: dsa: motorcomm: Read the port PVID instead of bridge's David Yang
2026-11-18 16:02   ` netdev-bot+sashiko
2026-11-16 16:01 ` [PATCH net v2 4/4] net: dsa: motorcomm: Use VID 0 as the unaware PVID David Yang
2026-11-18 16:02   ` netdev-bot+sashiko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179501777066.3136.14665752486224743787@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmyangfl@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox