Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: julius@bairaktaris.de
Cc: andrew@lunn.ch, olteanv@gmail.com, netdev@vger.kernel.org,
	bridge@lists.linux.dev, davem@davemloft.net, edumazet@kernel.org,
	kuba@kernel.org, pabeni@redhat.com, willemb@google.com,
	horms@kernel.org, razor@blackwall.org, idosch@nvidia.com,
	alvin.sipraga@analog.com, f.fainelli@gmail.com,
	tobias@waldekranz.com, linusw@kernel.org,
	paweldembicki@gmail.com
Subject: Re: [PATCH net v3 3/3] net: dsa: forward a marked frame only while its port is in a bridge
Date: Sat, 05 Dec 2026 22:44:31 +0000	[thread overview]
Message-ID: <179651067106.3148.13104164913848720920@kernel.org> (raw)
In-Reply-To: <20261204222045.214014-4-julius@bairaktaris.de>

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] In an mv88e6xxx tree that mixes chips with and without a
  cross-chip Port VLAN Table (PVT), a bridge can still be granted TX…

--

net: dsa: forward a marked frame only while its port is in a bridge

This commit changes the tag_dsa, tag_sja1105 and tag_vsc73xx_8021q
taggers to read dp->bridge only once. A new helper,
dsa_xmit_fwd_offload(), lets them build a forward-in-bridge tag only when
the frame is marked and the port is in a bridge with a non-zero number.
This fixes a NULL dereference in br_vlan_enabled() and FORWARD tags for
bridge 0 when a marked frame reaches a port that has left its bridge or
was redirected by tc.

Link: https://lore.kernel.org/all/20261121185821.1471559-1-julius@bairaktaris.de/ [1]

> diff --git a/net/dsa/tag.h b/net/dsa/tag.h
> index 0e1be1da4537e..fd543eb705c2c 100644
> --- a/net/dsa/tag.h
> +++ b/net/dsa/tag.h
> @@ -241,6 +241,20 @@ static inline void dsa_default_offload_fwd_mark(struct sk_buff *skb)
>  	skb->offload_fwd_mark = !!READ_ONCE(dp->bridge);
>  }
>  
> +/* Whether the switch is to forward @skb on behalf of @bridge, the bridge of
> + * the user port as the tagger read it, once. The bridge marks a frame for TX
> + * forwarding offload only on a port whose bridge has a number. A frame can
> + * also carry a mark set before its port left the bridge, or one set on
> + * reception and kept by a redirect; it is then forwarded in a bridge only if
> + * the port is in one that has a number, and otherwise sent to the port the
> + * stack chose.
> + */
> +static inline bool dsa_xmit_fwd_offload(const struct sk_buff *skb,
> +					const struct dsa_bridge *bridge)
> +{
> +	return skb->offload_fwd_mark && bridge && bridge->num;
> +}

[Severity: Medium]

Does mv88e6xxx actually follow the rule in this comment: "The bridge marks
a frame for TX forwarding offload only on a port whose bridge has a
number"?

On any chip with a PVT, mv88e6xxx_port_bridge_join() grants TX forwarding
offload without checking bridge.num:

drivers/net/dsa/mv88e6xxx/chip.c:mv88e6xxx_port_bridge_join() {
    ...
	if (mv88e6xxx_has_pvt(chip)) {
		err = mv88e6xxx_map_virtual_bridge_to_pvt(ds, bridge.num);
		if (err)
			goto unlock;

		*tx_fwd_offload = true;
	}
    ...
}

A bridge first joined from a chip without a PVT gets number 0.
mv88e6xxx_setup() never sets ds->max_num_bridges for that chip, so
dsa_bridge_num_get() returns 0. Switches that join later reuse that
dsa_bridge through dsa_tree_bridge_find().

A tree with only PVT chips can hit the same case when last_switch is 31.
max_num_bridges is then MV88E6XXX_MAX_PVT_SWITCHES - last_switch - 1, which
is 0.

When a port on a PVT chip joins such a bridge, dsa_port_bridge_join()
passes tx_fwd_offload = true to switchdev_bridge_port_offload(), and the
bridge sets BR_TX_FWD_OFFLOAD_BIT on the port.

On a flood, nbp_switchdev_frame_mark_tx_fwd_to_hwdom() sets the tree's
hwdom bit in fwd_hwdoms. nbp_switchdev_allowed_egress() then skips every
other port in the same DSA tree. The bridge sends one marked copy and
expects the switch to flood it.

With this patch, dsa_xmit_fwd_offload() returns false for bridge->num == 0,
so dsa_xmit_ll() takes the FROM_CPU branch for that one copy:

	cmd = DSA_CMD_FROM_CPU;
	tag_dev = dp->ds->index;
	tag_port = dp->index;

If so, only this one port receives broadcast, multicast and unknown
unicast traffic from the host or from other bridge ports, such as ARP
requests and IPv6 ND. Would the bridge's other ports in the tree stop
getting these floods altogether?

The commit message says such frames "now go to the one port the bridge
chose", but it does not say that the other ports stop getting floods.

The old behaviour was also wrong. A FORWARD tag with tag_dev = last_switch
is treated by mv88e6xxx_port_vlan() as the physical switch last_switch.

Could this be fixed in mv88e6xxx_port_bridge_join() instead? It could skip
setting *tx_fwd_offload, and skip mapping the virtual bridge into the PVT,
when bridge.num is 0. The bridge would then send one unmarked copy per
port, and the FROM_CPU path in dsa_xmit_ll() would be correct.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204222045.214014-1-julius%40bairaktaris.de

      reply	other threads:[~2026-12-05 22:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 22:20 [PATCH net v3 0/3] net: dsa: FDB events and tagging after a port left its bridge Julius Bairaktaris
2026-12-04 22:20 ` [PATCH net v3 1/3] net: dsa: do not run queued FDB events after the port left the bridge Julius Bairaktaris
2026-12-04 22:20 ` [PATCH net v3 2/3] net: dsa: hold the device a queued FDB event is reported to Julius Bairaktaris
2026-12-04 22:20 ` [PATCH net v3 3/3] net: dsa: forward a marked frame only while its port is in a bridge Julius Bairaktaris
2026-12-05 22:44   ` 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=179651067106.3148.13104164913848720920@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alvin.sipraga@analog.com \
    --cc=andrew@lunn.ch \
    --cc=bridge@lists.linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=julius@bairaktaris.de \
    --cc=kuba@kernel.org \
    --cc=linusw@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=paweldembicki@gmail.com \
    --cc=razor@blackwall.org \
    --cc=tobias@waldekranz.com \
    --cc=willemb@google.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