Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] net: sparx5/lan969x: ignore attributes of other bridges
@ 2026-12-04 12:36 Daniel Machon
  2026-12-05 13:23 ` netdev-bot+sashiko
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Machon @ 2026-12-04 12:36 UTC (permalink / raw)
  To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Steen Hegelund, UNGLinuxDriver
  Cc: netdev, linux-arm-kernel

sparx5_port_attr_set() is called through switchdev_handle_port_attr_set(),
which passes the attributes of a bridge and its ports down through the
uppers of a port. It applies every attribute it handles, without
checking which bridge or bridge port it comes from.

The port then also takes attributes from a bridge it is not offloaded
in. They reach it through a VLAN upper of the port that is a port of
another bridge, or through a bond with sparx5 members that the switch
does not offload. The port takes that bridge's VLAN mode and ageing
time, and the STP state, flood flags and multicast router state of the
upper. For example, removing the VLAN upper from the other bridge sets
the port to the disabled STP state, so it stops forwarding in the
offloaded bridge.

Apply the port attributes only when they come from the port itself, and
the bridge attributes only when they come from the offloaded bridge.

An ignored attribute returns -EOPNOTSUPP, as from any netdev that does
not offload it, so the other bridge handles the VLAN upper or the bond
like a software port.

This is in preparation for LAG support, which follows in a later
series.

Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
This does not fix a regression, so it is targeted at net-next.
---
 .../ethernet/microchip/sparx5/sparx5_switchdev.c   | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
index 322806fbfe2bb..9e85a746414c4 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
@@ -140,18 +140,39 @@ static int sparx5_port_attr_set(struct net_device *dev, const void *ctx,
 
 	switch (attr->id) {
 	case SWITCHDEV_ATTR_ID_PORT_PRE_BRIDGE_FLAGS:
+		/* Ignore it from a bridge port other than the port itself */
+		if (attr->orig_dev != dev)
+			return -EOPNOTSUPP;
+
 		return sparx5_port_attr_pre_bridge_flags(port,
 							 attr->u.brport_flags);
 	case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
+		/* Ignore it from a bridge port other than the port itself */
+		if (attr->orig_dev != dev)
+			return -EOPNOTSUPP;
+
 		sparx5_port_attr_bridge_flags(port, attr->u.brport_flags);
 		break;
 	case SWITCHDEV_ATTR_ID_PORT_STP_STATE:
+		/* Ignore it from a bridge port other than the port itself */
+		if (attr->orig_dev != dev)
+			return -EOPNOTSUPP;
+
 		sparx5_attr_stp_state_set(port, attr->u.stp_state);
 		break;
 	case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME:
+		/* Ignore it from a bridge the switch does not offload */
+		if (attr->orig_dev != port->sparx5->hw_bridge_dev)
+			return -EOPNOTSUPP;
+
 		sparx5_port_attr_ageing_set(port, attr->u.ageing_time);
 		break;
 	case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING:
+		/* Ignore it from a bridge the port is not offloaded in */
+		if (!test_bit(port->portno, port->sparx5->bridge_mask) ||
+		    attr->orig_dev != port->sparx5->hw_bridge_dev)
+			return -EOPNOTSUPP;
+
 		/* L3 offload requires a VLAN aware bridge. */
 		if (!attr->u.vlan_filtering)
 			sparx5_rr_bridge_legs_flush(port->sparx5,
@@ -173,6 +194,10 @@ static int sparx5_port_attr_set(struct net_device *dev, const void *ctx,
 		sparx5_rr_legs_reconcile_schedule(port->sparx5);
 		return -EOPNOTSUPP;
 	case SWITCHDEV_ATTR_ID_PORT_MROUTER:
+		/* Ignore it from a bridge port other than the port itself */
+		if (attr->orig_dev != dev)
+			return -EOPNOTSUPP;
+
 		sparx5_port_attr_mrouter_set(port,
 					     attr->orig_dev,
 					     attr->u.mrouter);

---
base-commit: ffd713dc373629317dc374f71690dae61060ead0
change-id: 20261203-sparx5-vlan-filtering-other-bridges-6ce769bbbace

Best regards,
-- 
Daniel Machon <daniel.machon@microchip.com>


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

* Re: [PATCH net-next] net: sparx5/lan969x: ignore attributes of other bridges
  2026-12-04 12:36 [PATCH net-next] net: sparx5/lan969x: ignore attributes of other bridges Daniel Machon
@ 2026-12-05 13:23 ` netdev-bot+sashiko
  0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 13:23 UTC (permalink / raw)
  To: daniel.machon
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, Steen.Hegelund,
	UNGLinuxDriver, netdev, linux-arm-kernel

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

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

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] net: sparx5: BRIDGE_AGEING_TIME check drops br_init_port()
  port orig_dev
- [Low] The patch fixes a real, user-visible bug that dates back to
  commit d6fce5141929 ("net: sparx5: add switching support"), but it has…
- [Low] The new SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME filter in
  sparx5_port_attr_set() only checks `attr->orig_dev !=…

--

net: sparx5/lan969x: ignore attributes of other bridges

With this patch, sparx5_port_attr_set() applies port attributes only when
attr->orig_dev is the port itself. It applies bridge attributes only when
they come from the offloaded bridge. Attributes from other bridges, which
arrive through a VLAN upper or a bond that is not offloaded, now return
-EOPNOTSUPP.

> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
> index 322806fbfe2bb..9e85a746414c4 100644
> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
> @@ -140,18 +140,39 @@ static int sparx5_port_attr_set(struct net_device *dev, const void *ctx,

[ ... ]

>  	case SWITCHDEV_ATTR_ID_PORT_STP_STATE:
> +		/* Ignore it from a bridge port other than the port itself */
> +		if (attr->orig_dev != dev)
> +			return -EOPNOTSUPP;
> +
>  		sparx5_attr_stp_state_set(port, attr->u.stp_state);
>  		break;

[Severity: Low]
Should this have a Fixes: tag?

The commit message describes a user-visible bug. Removing a VLAN upper
such as eth0.100 from a foreign bridge runs br_stp_disable_port(). That
sends PORT_STP_STATE=DISABLED with orig_dev set to eth0.100.

__switchdev_handle_port_attr_set() then recurses into the lower eth0, and
sparx5_attr_stp_state_set() clears eth0's bits in bridge_fwd_mask and
bridge_lrn_mask. eth0 then stops forwarding in the offloaded bridge.

The unchecked STP state, bridge flags, ageing time and vlan_filtering
cases look unchanged since commit d6fce5141929 ("net: sparx5: add
switching support"). PORT_PRE_BRIDGE_FLAGS and PORT_MROUTER were added
later and have the same gap.

The note below the --- line says:

  This does not fix a regression, so it is targeted at net-next.

Documentation/process/submitting-patches.rst asks for a Fixes: tag
whenever a patch fixes a bug in a specific commit, not only for
regressions. Without the tag, backport tooling will not pick up the fix.

>  	case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME:
> +		/* Ignore it from a bridge the switch does not offload */
> +		if (attr->orig_dev != port->sparx5->hw_bridge_dev)
> +			return -EOPNOTSUPP;
> +
>  		sparx5_port_attr_ageing_set(port, attr->u.ageing_time);
>  		break;

[Severity: Medium]
Does this also drop the ageing time that the bridge sends when a port
joins or comes up?

br_init_port() calls __set_ageing_time() with the bridge port, not the
bridge:

net/bridge/br_stp_if.c:br_init_port() {
    ...
	err = __set_ageing_time(p->dev, p->br->ageing_time);
    ...
}

__set_ageing_time() stores that device in attr.orig_dev. br_init_port()
runs from new_nbp() in br_add_if() and from br_stp_enable_port(). For a
sparx5 port, the attribute therefore arrives with orig_dev == dev, and
that never equals hw_bridge_dev. The new check returns -EOPNOTSUPP, and
SWITCHDEV_F_SKIP_EOPNOTSUPP hides the failure.

Only br_set_ageing_time() and __br_set_topology_change() send the
attribute with br->dev as orig_dev. sparx5_port_bridge_join() does not
apply br_get_ageing_time() itself, and sparx5_port_bridge_leave() does
not restore the default. After this patch, nothing programs the
hardware ageing when a port joins.

Two examples. First, create a bridge with ageing_time 30s and then add
the sparx5 ports. The ageing_time change happened before any sparx5 port
was a member, so the switch keeps the probe-time value from
sparx5_mact_init(). Second, delete a bridge that used a short ageing
time and create a new one. The hardware keeps the old value. In both
cases the hardware FDB ages differently from the software bridge until
userspace sets ageing_time again.

Would it work to also accept orig_dev == dev here, as long as the port
is set in bridge_mask? That still ignores the br_init_port() event from
a VLAN upper, and the one from a join that sparx5_port_bridge_join()
rejected. Another option is for sparx5_port_bridge_join() to apply
br_get_ageing_time(bridge) on join, the way
dsa_port_switchdev_sync_attrs() does for DSA.

[Severity: Low]
Can hw_bridge_dev point at a bridge that is not offloaded when this check
runs?

sparx5_port_bridge_join() sets hw_bridge_dev on the first join. Its error
path does not reset it:

drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c:sparx5_port_bridge_join() {
    ...
	first = bitmap_empty(sparx5->bridge_mask, SPX5_PORTS);
	if (first)
		/* First bridged port */
		sparx5->hw_bridge_dev = bridge;
    ...
	err = switchdev_bridge_port_offload(ndev, ndev, NULL, NULL, NULL,
					    false, extack);
	if (err)
		goto err_switchdev_offload;
    ...
err_switchdev_offload:
	clear_bit(port->portno, sparx5->bridge_mask);
	return err;
}

Suppose switchdev_bridge_port_offload() fails on that first join, for
example with -EBUSY from nbp_switchdev_hwdom_set(). Then bridge_mask is
empty, but hw_bridge_dev still names that bridge.

Next, a sparx5 VLAN upper or a bond with sparx5 members joins the same
bridge as a software port, and ageing_time is changed:

br_set_ageing_time()
  __set_ageing_time(br->dev, t)
    __switchdev_handle_port_attr_set()
      sparx5_port_attr_set()
        sparx5_port_attr_ageing_set()

orig_dev == hw_bridge_dev, so the new check passes. The global hardware
ageing is then set from a bridge that the switch does not offload.

The VLAN_FILTERING case below avoids this because it also tests
bridge_mask. Would it make sense to add a bridge_mask check here too?
Another option is to reset hw_bridge_dev to NULL in the join error path
when first is true.

>  	case SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING:
> +		/* Ignore it from a bridge the port is not offloaded in */
> +		if (!test_bit(port->portno, port->sparx5->bridge_mask) ||
> +		    attr->orig_dev != port->sparx5->hw_bridge_dev)
> +			return -EOPNOTSUPP;
> +

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204-sparx5-vlan-filtering-other-bridges-v1-1-b72e9562019f%40microchip.com

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

end of thread, other threads:[~2026-12-05 13:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 12:36 [PATCH net-next] net: sparx5/lan969x: ignore attributes of other bridges Daniel Machon
2026-12-05 13:23 ` 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