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 v2 3/5] net: dsa: motorcomm: Reject isolated redirect targets
Date: Mon, 30 Nov 2026 12:25:55 +0000	[thread overview]
Message-ID: <179604155555.3146.15300874955804709416@kernel.org> (raw)
In-Reply-To: <20261129115556.1669188-4-mmyangfl@gmail.com>

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

Critical: 0 · High: 1 · Medium: 0 · 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).

- [High] This patch makes the REDIR-vs-TRAP decision once.

--

net: dsa: motorcomm: Reject isolated redirect targets

This patch checks the port isolation mask while parsing a flower redirect
action. If the redirect target is isolated, skip_sw rules are rejected.
Other rules are marked sw_assisting, and yt921x_acl_commit() then installs
them as TRAP instead of REDIR.

> diff --git a/drivers/net/dsa/motorcomm/tc.c b/drivers/net/dsa/motorcomm/tc.c
> index e3f057ed580f5..20edfd53b230d 100644
> --- a/drivers/net/dsa/motorcomm/tc.c
> +++ b/drivers/net/dsa/motorcomm/tc.c

[ ... ]

> @@ -1072,6 +1075,20 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext,
>  				goto fallback;
>  			}
>  
> +			/* Port isolation takes after REDIR judgment, but
> +			 * software delivers such frames.
> +			 */
> +			if (pp->isolation_mask & BIT(to_dp->index)) {
> +				if (cls->common.skip_sw) {
> +					if (to_dp->index == port)
> +						reason = "Redirect to self, which is not hairpinning";
> +					else
> +						reason = "Redirect target isolated, or not in the same bridge";
> +					goto fallback;
> +				}
> +				ruleext->r.sw_assisting = true;
> +			}
> +

[Severity: High]
Can sw_assisting go stale after the rule is installed? The isolation mask
is read only once, when yt921x_acl_rule_ext_parse_flow_action() parses the
rule, and the result is cached in aclrule->sw_assisting.

At this commit, yt921x_acl_commit() is called only from yt921x_acl_add()
and yt921x_acl_del(). Nothing rechecks the REDIR vs TRAP choice after
that.

Several paths in chip.c rewrite PORTn_ISOLATION and isolation_mask but
leave installed ACL rules alone:

drivers/net/dsa/motorcomm/chip.c:yt921x_userport_standalone() {
    ...
	ctrl = ~dsa_cpu_ports(ds);
	res = yt921x_reg_write(priv, YT921X_PORTn_ISOLATION(port), ctrl);
	if (res)
		return res;
	pp->isolation_mask = ctrl;
    ...
}

drivers/net/dsa/motorcomm/chip.c:yt921x_isolate() {
    ...
		priv->ports[i].isolation_mask |= mask;
    ...
}

drivers/net/dsa/motorcomm/chip.c:yt921x_bridge() {
    ...
		res = yt921x_reg_write(priv, YT921X_PORTn_ISOLATION(port),
				       ctrl);
		if (res)
			return res;
		pp->isolation_mask = ctrl;
    ...
}

For example, say swp1 and swp2 are both in br0, and this rule is added:

  tc filter add dev swp1 ingress flower [skip_sw] \
      action mirred egress redirect dev swp2

BIT(2) is clear in the mask for swp1, so the rule is installed as REDIR.
Then either swp1 or swp2 leaves br0, or BR_ISOLATED or BR_HAIRPIN_MODE
changes.

Isolation now blocks port 2, but the ACL entry still redirects to it.
Would those frames be dropped in hardware without software ever seeing
them? That is the case the commit message describes. For a skip_sw rule,
tc would also still report the rule as offloaded.

The reverse case looks wrong as well. A rule installed while the ports
were isolated stays trapped to the CPU after they become bridged.

Later commits in this series fix part of this:

"Reject bridge flags that break redirect rules" rejects flag changes that
would break skip_sw rules.

"Recompute redirect rules on bridge changes" adds yt921x_acl_recompute()
for non-skip_sw rules. Its own comment says skip_sw rules are not fixed up
on bridge leave, because port_bridge_leave() cannot fail. So a skip_sw
redirect installed while bridged would still drop traffic silently once
either port leaves the bridge.

yt921x_acl_recompute() also seems to derive the source port without
FIELD_GET():

	src = ffs(aclrule->entries[0].key[1] &
		  YT921X_ACL_KEYb_SPORTS_M) - 1;
	...
	if (src != port && !(dsts & BIT(port)))
		continue;

	aclrule->sw_assisting =
		!!(dsts & priv->ports[src].isolation_mask);

YT921X_ACL_KEYb_SPORTS_M is GENMASK(20, 10), so src would be the real
port plus 10. Two things follow from that:

- The src != port check would skip rules whose source is the changing
  port. For example, after swp1 leaves the bridge, its redirect to swp2
  is never recomputed.

- For rules that match through dsts, src can be as large as 20, but
  priv->ports[] has only YT921X_PORT_NUM (11) entries. Does that read
  priv->ports[] out of bounds?

If so, this problem would still be reachable at the end of the series,
for both skip_sw and non-skip_sw rules. Could isolation changes re-commit
the affected ACL actions?

> @@ -1301,8 +1318,20 @@ yt921x_acl_commit(struct yt921x_priv *priv, unsigned int entid, u8 entsmask)
>  	aclrule = aclblk->rules[binid];
>  
>  	/* Write actions */
> -	res = yt921x_reg96_write(priv, YT921X_ACLn_ACT(entid),
> -				 aclrule ? aclrule->action : zeros);
> +	if (!aclrule || !aclrule->sw_assisting) {
> +		res = yt921x_reg96_write(priv, YT921X_ACLn_ACT(entid),
> +					 aclrule ? aclrule->action : zeros);
> +	} else {

[ ... ]

> diff --git a/drivers/net/dsa/motorcomm/tc.h b/drivers/net/dsa/motorcomm/tc.h
> index cc53f148d690f..81c29a8eec5ac 100644
> --- a/drivers/net/dsa/motorcomm/tc.h
> +++ b/drivers/net/dsa/motorcomm/tc.h
> @@ -349,7 +349,11 @@ struct yt921x_acl_rule {
>  	enum tc_setup_type type;
>  
>  	u32 action[3];
> -	bool sw_assisted;
> +	bool sw_assisted:1;
> +	/* not a TRAP rule, but installed as trapped as some conditions are not
> +	 * met
> +	 */
> +	bool sw_assisting:1;

[ ... ]

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

  reply	other threads:[~2026-11-30 12:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29 11:55 [PATCH net-next v2 0/5] net: dsa: motorcomm: Reject isolated redirect targets David Yang
2026-11-29 11:55 ` [PATCH net-next v2 1/5] net: dsa: motorcomm: Remove local cpu_ports_mask David Yang
2026-11-29 11:55 ` [PATCH net-next v2 2/5] net: dsa: motorcomm: Cache port isolation masks David Yang
2026-11-30 12:25   ` netdev-bot+sashiko
2026-11-29 11:55 ` [PATCH net-next v2 3/5] net: dsa: motorcomm: Reject isolated redirect targets David Yang
2026-11-30 12:25   ` netdev-bot+sashiko [this message]
2026-11-29 11:55 ` [PATCH net-next v2 4/5] net: dsa: motorcomm: Recompute redirect rules on bridge changes David Yang
2026-11-30 12:25   ` netdev-bot+sashiko
2026-11-29 11:55 ` [PATCH net-next v2 5/5] net: dsa: motorcomm: Reject bridge flags that break redirect rules David Yang
2026-11-30 12:25   ` 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=179604155555.3146.15300874955804709416@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