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 v3 4/5] net: dsa: motorcomm: Reject bridge flags that break redirect rules
Date: Thu, 03 Dec 2026 11:15:42 +0000	[thread overview]
Message-ID: <179629654283.3146.1293591640887633845@kernel.org> (raw)
In-Reply-To: <20261201081459.2104904-5-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] In yt921x_dsa_port_pre_bridge_flags()
  (drivers/net/dsa/motorcomm/chip.c), the new per-port vetoes run before…

--

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

This commit adds a per-port acl_dst_cnts[] counter. yt921x_acl_add() and
yt921x_acl_del() update it for redirect rules that are not sw_assisted.
yt921x_dsa_port_pre_bridge_flags() then uses the counters to reject turning
off hairpin mode or turning on isolation when such rules would be blocked.

> diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
> index 6c6a87207bd5c..0bc5da2b80d7a 100644
> --- a/drivers/net/dsa/motorcomm/chip.c
> +++ b/drivers/net/dsa/motorcomm/chip.c
> @@ -1448,6 +1448,37 @@ yt921x_dsa_port_pre_bridge_flags(struct dsa_switch *ds, int port,
>  			   BR_MCAST_FLOOD | BR_ISOLATED))
>  		return -EINVAL;
>  
> +	if ((flags.mask & BR_HAIRPIN_MODE) && !(flags.val & BR_HAIRPIN_MODE) &&
> +	    pp->acl_dst_cnts[port]) {
> +		NL_SET_ERR_MSG_MOD(extack,
> +				   "Cannot disable hairpin mode while there are hairpin redirect rules installed");
> +		return -EINVAL;
> +	}
> +
> +	if ((flags.mask & BR_ISOLATED) && (flags.val & BR_ISOLATED)) {

[ ... ]

> +		ports_mask = dsa_bridge_ports(ds, bdev);
> +		for_each_set_bit(i, &ports_mask, YT921X_PORT_NUM) {
> +			if (i == port || !priv->ports[i].isolated)
> +				continue;
> +
> +			if (pp->acl_dst_cnts[i] ||
> +			    priv->ports[i].acl_dst_cnts[port]) {
> +				NL_SET_ERR_MSG_MOD(extack,
> +						   "Cannot isolate port while there are redirect rules installed");
> +				return -EINVAL;
> +			}
> +		}
> +	}
> +
>  	if ((flags.mask & BR_HAIRPIN_MODE) || (flags.mask & BR_ISOLATED)) {
>  		struct dsa_port *dp = dsa_to_port(ds, port);
>  		struct net_device *bdev;

[Severity: Medium]
Can these new per-port checks leave driver state half updated when the
bridge port is an offloaded LAG?

Right after these checks, the prepare phase already changes driver state:

    if (flags.mask & BR_HAIRPIN_MODE)
        pp->hairpin = flags.val & BR_HAIRPIN_MODE;
    if (flags.mask & BR_ISOLATED)
        pp->isolated = flags.val & BR_ISOLATED;
    ...
    yt921x_isolation_calc_bridge(priv, ports_mask);

Take bond0 with lowers swpA and swpB on this switch. The bridge sends one
PRE_BRIDGE_FLAGS notification, and switchdev calls the driver once per
lower:

br_setport()
  br_switchdev_set_port_flag()
    __switchdev_handle_port_attr_set()   /* loops over lowers */
      dsa_user_port_attr_set()
        dsa_port_pre_bridge_flags()
          yt921x_dsa_port_pre_bridge_flags()

__switchdev_handle_port_attr_set() returns on the first hard error. It does
not undo the lowers that already succeeded.

Suppose swpA has no conflicting rules. Its call passes, sets pp->hairpin or
pp->isolated, and rewrites isolation_mask for every bridge member through
yt921x_isolation_calc_bridge().

Then suppose swpB fails one of the new acl_dst_cnts[] checks. br_setport()
returns the error, the bridge keeps its old flags, and the deferred
PORT_BRIDGE_FLAGS is never sent.

Nothing appears to roll back swpA's hairpin/isolated state or the cached
isolation_mask values. The next yt921x_isolation_commit() would write those
stale masks to hardware. That happens on a later successful hairpin or
isolated change, or on a bridge_join. Frames would then be dropped even
though the bridge configuration allows them.

The stale masks are also used by the tc parse path and by
yt921x_acl_recompute_rule(). The isolation check above also reads the stale
priv->ports[i].isolated, so isolation changes on other ports could be
rejected wrongly.

Retrying the same flag change would not fix it. The bridge sees no change in
its flags, so it never calls the driver.

Before this patch, the only failure in this function was the unsupported-flag
mask check. That check gives the same result for every lower, so it failed
on the first lower before any state changed.

The later patch in this series, "net: dsa: motorcomm: Recompute redirect
rules on bridge changes", does not touch pre_bridge_flags. Does this problem
still exist at the end of the series?

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

  reply	other threads:[~2026-12-03 11:15 UTC|newest]

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