Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: dsa: motorcomm: Read the port PVID instead of bridge's
@ 2026-11-19 22:09 David Yang
  2026-11-19 22:12 ` netdev-bot+sinfo
  2026-11-23 22:11 ` netdev-bot+sashiko
  0 siblings, 2 replies; 4+ messages in thread
From: David Yang @ 2026-11-19 22:09 UTC (permalink / raw)
  To: netdev
  Cc: David Yang, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni

The driver passed the bridge master to br_vlan_get_pvid(), returning
the bridge's own PVID (VID 1 by default) instead of the configured
port's: deleting a vid that equalled the bridge's PVID wiped the port's
real hardware PVID, and a vlan_filtering toggle programmed that PVID
into every port.

Query the PVID from dsa_port_to_bridge_port() instead. Clear it when the
port has no PVID left, instead of comparing the deleted vid against the
bridge master's PVID, as the bridge unpublishes the PVID before the del
notification.

Fixes: 186623f4aa72 ("net: dsa: yt921x: Add support for Motorcomm YT921x")
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
 drivers/net/dsa/motorcomm/chip.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
index c753c746490a..b12bf32f8896 100644
--- a/drivers/net/dsa/motorcomm/chip.c
+++ b/drivers/net/dsa/motorcomm/chip.c
@@ -948,18 +948,18 @@ static int
 yt921x_vlan_filtering(struct yt921x_priv *priv, int port, bool vlan_filtering)
 {
 	struct dsa_port *dp = dsa_to_port(&priv->ds, port);
-	struct net_device *bdev;
+	struct net_device *brport;
 	u16 pvid;
 	u32 mask;
 	u32 ctrl;
 	int res;
 
-	bdev = dsa_port_bridge_dev_get(dp);
+	brport = dsa_port_to_bridge_port(dp);
 
-	if (!bdev || !vlan_filtering)
+	if (!brport || !vlan_filtering)
 		pvid = YT921X_VID_UNWARE;
 	else
-		br_vlan_get_pvid(bdev, &pvid);
+		br_vlan_get_pvid(brport, &pvid);
 	res = yt921x_port_set_pvid(priv, port, pvid);
 	if (res)
 		return res;
@@ -1098,16 +1098,16 @@ yt921x_dsa_port_vlan_del(struct dsa_switch *ds, int port,
 	mutex_lock(&priv->reg_lock);
 	do {
 		struct dsa_port *dp = dsa_to_port(ds, port);
-		struct net_device *bdev;
+		struct net_device *brport;
 
 		res = yt921x_vlan_del(priv, port, vid);
 		if (res)
 			break;
 
-		bdev = dsa_port_bridge_dev_get(dp);
-		if (bdev) {
-			br_vlan_get_pvid(bdev, &pvid);
-			if (pvid == vid)
+		brport = dsa_port_to_bridge_port(dp);
+		if (brport) {
+			br_vlan_get_pvid(brport, &pvid);
+			if (!pvid)
 				res = yt921x_pvid_clear(priv, port);
 		}
 	} while (0);
@@ -1135,19 +1135,19 @@ yt921x_dsa_port_vlan_add(struct dsa_switch *ds, int port,
 	mutex_lock(&priv->reg_lock);
 	do {
 		struct dsa_port *dp = dsa_to_port(ds, port);
-		struct net_device *bdev;
+		struct net_device *brport;
 
 		res = yt921x_vlan_add(priv, port, vid,
 				      vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED);
 		if (res)
 			break;
 
-		bdev = dsa_port_bridge_dev_get(dp);
-		if (bdev) {
+		brport = dsa_port_to_bridge_port(dp);
+		if (brport) {
 			if (vlan->flags & BRIDGE_VLAN_INFO_PVID) {
 				res = yt921x_pvid_set(priv, port, vid);
 			} else {
-				br_vlan_get_pvid(bdev, &pvid);
+				br_vlan_get_pvid(brport, &pvid);
 				if (pvid == vid)
 					res = yt921x_pvid_clear(priv, port);
 			}
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: dsa: motorcomm: Read the port PVID instead of bridge's
  2026-11-19 22:09 [PATCH net] net: dsa: motorcomm: Read the port PVID instead of bridge's David Yang
@ 2026-11-19 22:12 ` netdev-bot+sinfo
  2026-11-19 22:14   ` David Yang
  2026-11-23 22:11 ` netdev-bot+sashiko
  1 sibling, 1 reply; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-11-19 22:12 UTC (permalink / raw)
  To: David Yang
  Cc: netdev, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

 - Whether the issue was actually triggered, or is only theoretical
   (e.g. found by LLM and not proven at runtime). If it was triggered
   please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: dsa: motorcomm: Read the port PVID instead of bridge's
  2026-11-19 22:12 ` netdev-bot+sinfo
@ 2026-11-19 22:14   ` David Yang
  0 siblings, 0 replies; 4+ messages in thread
From: David Yang @ 2026-11-19 22:14 UTC (permalink / raw)
  To: netdev-bot+sinfo
  Cc: netdev, Andrew Lunn, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni

On Fri, Nov 20, 2026 at 6:12 AM <netdev-bot+sinfo@kernel.org> wrote:
>
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
>  - How the issue was discovered, e.g. hit in production, hit during
>    development, syzbot report, manual code inspection, LLM or static
>    analysis tool scan.
>
>  - Whether the issue was actually triggered, or is only theoretical
>    (e.g. found by LLM and not proven at runtime). If it was triggered
>    please include the symptoms, like the stack trace or kernel messages.
>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account.
>
> *IMPORTANT*: If you do repost (for other reasons) - please include
> the relevant info in the cover letter or commit messages.
> --
> The evaluation is done by an LLM so it may be wrong, if you think
> that is the case please reply and explain.

Assisted by LLM and verified on the hardware.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: dsa: motorcomm: Read the port PVID instead of bridge's
  2026-11-19 22:09 [PATCH net] net: dsa: motorcomm: Read the port PVID instead of bridge's David Yang
  2026-11-19 22:12 ` netdev-bot+sinfo
@ 2026-11-23 22:11 ` netdev-bot+sashiko
  1 sibling, 0 replies; 4+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 22:11 UTC (permalink / raw)
  To: mmyangfl; +Cc: netdev, andrew, olteanv, davem, edumazet, kuba, pabeni

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] yt921x_dsa_port_vlan_del() (drivers/net/dsa/motorcomm/chip.c)
  now only touches the hardware PVID when br_vlan_get_pvid(brport)…

--

net: dsa: motorcomm: Read the port PVID instead of bridge's

The yt921x driver used to query br_vlan_get_pvid() on the bridge master.
This commit makes it query the bridge port returned by
dsa_port_to_bridge_port() instead. In yt921x_dsa_port_vlan_del() it now
clears the hardware PVID only when the bridge port has no PVID left. The
commit message says this works because the bridge unpublishes the PVID
before sending the del notification.

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

[ ... ]

> @@ -1098,16 +1098,16 @@ yt921x_dsa_port_vlan_del(struct dsa_switch *ds, int port,
>  	mutex_lock(&priv->reg_lock);
>  	do {
>  		struct dsa_port *dp = dsa_to_port(ds, port);
> -		struct net_device *bdev;
> +		struct net_device *brport;
>
>  		res = yt921x_vlan_del(priv, port, vid);
>  		if (res)
>  			break;
>
> -		bdev = dsa_port_bridge_dev_get(dp);
> -		if (bdev) {
> -			br_vlan_get_pvid(bdev, &pvid);
> -			if (pvid == vid)
> +		brport = dsa_port_to_bridge_port(dp);
> +		if (brport) {
> +			br_vlan_get_pvid(brport, &pvid);
> +			if (!pvid)
>  				res = yt921x_pvid_clear(priv, port);

[Severity: Medium]
Does the claim that "the bridge unpublishes the PVID before the del
notification" hold for every path that reaches this function?

It holds for nbp_vlan_delete(), which calls __vlan_unpublish() before
__vlan_del(). The rollback path in __vlan_add() in net/bridge/br_vlan.c
looks different.

Take a port that already has PVID Y, and a new VLAN X added with
BRIDGE_VLAN_INFO_PVID. __vlan_vid_add() sends the switchdev add first,
so yt921x_dsa_port_vlan_add()->yt921x_pvid_set() writes X into
YT921X_PORTn_VLAN_CTRL and clears CVLAN_DROP_UNTAGGED.

Several later steps in __vlan_add() can still fail:
br_vlan_add() on the master when BRIDGE_VLAN_INFO_MASTER is set,
br_vlan_get_master(), the per-port stats allocation, br_fdb_add_local(),
or rhashtable_lookup_insert_fast(). Any of these failures leads to:

net/bridge/br_vlan.c:__vlan_add() {
    ...
out_filt:
	if (p) {
		__vlan_vid_del(dev, br, v);
    ...
}

On that path __vlan_flags_commit(v, flags) never ran, so vg->pvid still
holds Y when the del notification reaches the driver.

In that case br_vlan_get_pvid(brport, &pvid) returns Y. Y is non-zero,
so yt921x_pvid_clear() is skipped and nothing else rewrites the PVID.

Would the hardware then keep PVID X, a VLAN the port has just been
removed from, while the bridge reports PVID Y? On a VLAN-filtering port,
untagged ingress would be classified into X and dropped by
VLAN_IGR_FILTER until the PVID is reprogrammed, for example by a
vlan_filtering toggle.

The old pvid == vid comparison had the same gap here. The new !pvid check
depends explicitly on the unpublish ordering, though, and this path
breaks that assumption.

Could the del path re-sync the PVID instead, along these lines?

	pvid ? yt921x_pvid_set(priv, port, pvid) :
	       yt921x_pvid_clear(priv, port)

>  		}
>  	} while (0);

[ ... ]

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-23 22:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 22:09 [PATCH net] net: dsa: motorcomm: Read the port PVID instead of bridge's David Yang
2026-11-19 22:12 ` netdev-bot+sinfo
2026-11-19 22:14   ` David Yang
2026-11-23 22:11 ` netdev-bot+sashiko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox