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] net: dsa: motorcomm: Reject isolated redirect targets
Date: Sat, 28 Nov 2026 14:28:54 +0000	[thread overview]
Message-ID: <179587613426.3135.1461093836269576159@kernel.org> (raw)
In-Reply-To: <20261127142732.1337041-1-mmyangfl@gmail.com>

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

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

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] The new isolation, hairpin and same-bridge check runs only when
  a flower rule is installed, in yt921x_acl_rule_ext_parse_flow_action()…
- [Medium] The new check refuses a redirect from a port to itself when
  that port is both hairpin and isolated, but the driver's own hardware…
- [Low] In yt921x_acl_rule_ext_parse_flow_action()
  (drivers/net/dsa/motorcomm/tc.c:1087-1088), every case where…

--

net: dsa: motorcomm: Reject isolated redirect targets

This patch makes yt921x_acl_rule_ext_parse_flow_action() refuse to
offload a mirred redirect in three cases: the target is not in the same
bridge, the target is the source port without hairpin, or both ports are
isolated. Such rules are rejected under skip_sw. Otherwise they fall back
to a software-assisted TRAP.

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

[ ... ]

> @@ -1072,6 +1075,27 @@ yt921x_acl_rule_ext_parse_flow_action(struct yt921x_acl_rule_ext *ruleext,
>  				goto fallback;
>  			}
>  
> +			/* Port isolation takes after REDIR judgment, but
> +			 * software may deliver such frames.
> +			 *
> +			 * Bridge membership changes may break existing REDIR
> +			 * rules, but we cannot do anything here: driver can
> +			 * neither reject such changes (port_bridge_leave() is
> +			 * void), nor tell tc which one is invalidated.
> +			 */

[Severity: High]
This check only runs when the flower rule is installed. What happens to a
REDIR rule that is already in hardware when the isolation flags change
later?

For example, with swp0 and swp1 in the same bridge and not isolated:

  tc filter add dev swp0 ingress flower ... \
      action mirred egress redirect dev swp1
  bridge link set dev swp0 isolated on
  bridge link set dev swp1 isolated on

The tc rule passes the new check, and a REDIR to port 1 is programmed.
The bridge link changes then go through:

  yt921x_dsa_port_bridge_flags()
    yt921x_bridge_flags()
      pp->isolated = flags.val & BR_ISOLATED;
      yt921x_bridge()
        if (pp->isolated)
            ctrl |= isolated_mask;
        yt921x_reg_write(priv, YT921X_PORTn_ISOLATION(port), ctrl);

None of this touches the ACL table. Wouldn't hardware port isolation then
block the installed REDIR, so matching frames are silently dropped?
Software mirred would have delivered them. That looks like the same case
the commit message describes.

The same seems to happen when BR_HAIRPIN_MODE is cleared on a port that
has a self-redirect rule. It also happens when the target leaves the
bridge, because yt921x_userport_standalone() writes:

  ctrl = ~priv->cpu_ports_mask;
  res = yt921x_reg_write(priv, YT921X_PORTn_ISOLATION(port), ctrl);

The comment only mentions bridge membership changes. Is it right that
nothing can be done about flag changes? BR_ISOLATED and BR_HAIRPIN_MODE
changes go through yt921x_dsa_port_pre_bridge_flags(), which returns int
and gets an extack:

  if (flags.mask & ~(BR_HAIRPIN_MODE | BR_LEARNING | BR_FLOOD |
                     BR_MCAST_FLOOD | BR_ISOLATED))
      return -EINVAL;
  return 0;

Could that hook refuse flag changes that would invalidate live REDIR
rules?

For rules without skip_sw, the driver already records
ruleext->r.sw_assisted. It also has a downgrade-to-TRAP path in
yt921x_acl_add():

  if (use_trap) {
      aclrule->action[2] &= ~YT921X_ACL_ACTc_FWD_REDIR_DPORTS_M &
                            ~YT921X_ACL_ACTc_FWD_M;

Could the affected rules be rewritten to TRAP the same way when bridge
membership or flags change?

As written, the protection only seems to hold if the bridge and isolation
setup is done before the tc rules are added. The commit message doesn't
mention this.

> +			dp = dsa_to_port(&priv->ds, port);
> +			if (!dsa_port_bridge_same(dp, to_dp)) {
> +				reason = "Redirect to another bridge";
> +				goto fallback;
> +			}

[Severity: Low]
This isn't a bug, but dsa_port_bridge_same() also returns false when
either port is standalone:

  /* Standalone ports are not in the same bridge with one another */
  return (!br_a || !br_b) ? false : (br_a == br_b);

With skip_sw, a redirect between two standalone ports, or from a
standalone port to itself, reports "Redirect to another bridge" even
though no bridge is involved.

Rejecting the rule is still correct, since yt921x_userport_standalone()
blocks all non-CPU ports. Could the reason string also cover the
standalone case?

> +
> +			to_pp = &priv->ports[to_dp->index];
> +			if ((to_dp->index == port && !pp->hairpin) ||
> +			    (pp->isolated && to_pp->isolated)) {
> +				reason = "Redirect target is isolated";
> +				goto fallback;
> +			}

[Severity: Medium]
Does this reject a self-redirect on a port that is both hairpin and
isolated, even though the hardware allows it?

When to_dp->index == port, to_pp == pp. The second clause is then true
whenever the port is isolated, even if pp->hairpin is set.

In yt921x_bridge(), the hairpin branch runs after isolated_mask is ORed
in, so the self bit ends up cleared:

  if (pp->isolated)
      ctrl |= isolated_mask;
  /* to itself when non-hairpin */
  if (!pp->hairpin)
      ctrl |= BIT(port);
  else
      ctrl &= ~BIT(port);

With skip_sw, this returns -EOPNOTSUPP for a rule the hardware can run.
Without skip_sw, the rule becomes YT921X_ACL_ACTc_FWD_TRAP, and every
matching frame goes through the CPU. Before this patch the rule was
offloaded.

Should the isolated clause leave out the self case, for example:

  (to_dp->index != port && pp->isolated && to_pp->isolated)

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

      reply	other threads:[~2026-11-28 14:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 14:27 [PATCH net] net: dsa: motorcomm: Reject isolated redirect targets David Yang
2026-11-28 14:28 ` 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=179587613426.3135.1461093836269576159@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