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
Subject: Re: [PATCH net-next v4 5/6] net: dsa: motorcomm: Reject bridge flags that break redirect rules
Date: Sat, 05 Dec 2026 11:00:45 +0000	[thread overview]
Message-ID: <179646844578.3146.6159172839639383786@kernel.org> (raw)
In-Reply-To: <20261204101300.3680838-6-mmyangfl@gmail.com>

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_pre_bridge_flags()
  (drivers/net/dsa/motorcomm/chip.c) does not veto BR_ISOLATED when the…

--

net: dsa: motorcomm: Reject bridge flags that break redirect rules

This commit adds per-port acl_dst_cnts bookkeeping in yt921x_acl_add() and
yt921x_acl_del() for redirect rules that are not sw_assisted. It then uses
those counters in yt921x_dsa_port_pre_bridge_flags() to reject turning off
hairpin mode, or turning on BR_ISOLATED, when the change would block such a
rule.

> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index a71a8dd5dc63c..323c1705f613c 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c
> @@ -1525,9 +1525,52 @@ yt921x_dsa_port_pre_bridge_flags(struct dsa_switch *ds, int port,

[ ... ]

> +	if ((flags.mask & BR_ISOLATED) && (flags.val & BR_ISOLATED)) {
> +		struct dsa_port *other_dp;
> +
> +		dsa_switch_for_each_user_port(other_dp, ds) {
> +			struct net_device *other_brport;
> +			int i = other_dp->index;
> +
> +			if (i == port || !(ports_mask & BIT(i)))
> +				continue;
> +			if (!pp->acl_dst_cnts[i] &&
> +			    !priv->ports[i].acl_dst_cnts[port])
> +				continue;
> +
> +			other_brport = dsa_port_to_bridge_port(other_dp);
> +			if (!br_port_flag_is_set(other_brport, BR_ISOLATED))
> +				continue;

[Severity: Medium]
Can this check be bypassed when both ends of a skip_sw redirect rule are
members of the same offloaded LAG?

The port being changed gets its new isolation state from flags.val. The
peer's state is read back from the bridge. For LAG members,
dsa_port_to_bridge_port() returns the shared LAG netdev:

include/net/dsa.h:dsa_port_to_bridge_port() {
    ...
	if (dp->lag)
		return dp->lag->dev;
    ...
}

The bridge sends PRE_BRIDGE_FLAGS before it writes the new value into
p->flags. This happens on both the netlink path and the sysfs path:

net/bridge/br_netlink.c:br_setport() {
    ...
	err = br_switchdev_set_port_flag(p, flags, changed_mask, extack);
    ...
	} while (!try_cmpxchg(&p->flags, &old_flags, flags));
    ...
}

net/bridge/br_sysfs_if.c:store_flag() {
    ...
	err = br_switchdev_set_port_flag(p, flags, BIT(bitnr), &extack);
    ...
	assign_bit(bitnr, &p->flags, v);
    ...
}

So when the LAG bridge port itself is being isolated, each member sees its
LAG peer as not yet isolated and hits the continue above.

Here is an example. Ports P and Q are in one offloaded LAG, bond0, and bond0
is a bridge port:

  skip_sw flower redirect rule from P to Q
    -> P's acl_dst_cnts[Q] is incremented

  bridge link set dev bond0 isolated on
    -> pre_bridge_flags(P) and pre_bridge_flags(Q) both return 0
    -> .port_bridge_flags
       -> yt921x_isolation_refresh()
          -> yt921x_isolation_calc_bridge()

When yt921x_isolation_calc_bridge() runs, bond0 now reads as isolated:

	if (br_port_flag_is_set(brport, BR_ISOLATED))
		isolated_mask |= BIT(port);

That gives isolated_mask = BIT(P) | BIT(Q). Q's bit then lands in P's
isolation mask, and the hardware drops the P->Q redirect even though the
rule was accepted as skip_sw.

Isn't this the case the commit message says should be rejected?

The later patch in the series ("net: dsa: motorcomm: Recompute redirect
rules on bridge changes") does not change yt921x_dsa_port_pre_bridge_flags(),
so this still seems to apply at the end of the series.

The new warning that patch adds in yt921x_bridge_flags() would not reach
the user here either, because the deferred switchdev attr path passes a
NULL extack.

> +
> +			NL_SET_ERR_MSG_MOD(extack,
> +					   "Cannot isolate port while there are redirect rules");
> +			return -EINVAL;
> +		}
> +	}
> +
>  	return 0;
>  }

[ ... ]

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

  reply	other threads:[~2026-12-05 11:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 10:12 [PATCH net-next v4 0/6] net: dsa: motorcomm: Reject isolated redirect targets David Yang
2026-12-04 10:12 ` [PATCH net-next v4 1/6] net: dsa: motorcomm: Remove local cpu_ports_mask David Yang
2026-12-04 10:12 ` [PATCH net-next v4 2/6] net: dsa: motorcomm: Do not block hairpins on standalone ports David Yang
2026-12-05 11:00   ` netdev-bot+sashiko
2026-12-04 10:12 ` [PATCH net-next v4 3/6] net: dsa: motorcomm: Derive port isolation masks on the fly David Yang
2026-12-04 10:12 ` [PATCH net-next v4 4/6] net: dsa: motorcomm: Reject isolated redirect targets David Yang
2026-12-04 10:12 ` [PATCH net-next v4 5/6] net: dsa: motorcomm: Reject bridge flags that break redirect rules David Yang
2026-12-05 11:00   ` netdev-bot+sashiko [this message]
2026-12-04 10:12 ` [PATCH net-next v4 6/6] net: dsa: motorcomm: Recompute redirect rules on bridge changes David Yang
2026-12-05 11:00   ` netdev-bot+sashiko

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=179646844578.3146.6159172839639383786@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=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