Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: koralilgun@gmail.com
Cc: razor@blackwall.org, idosch@nvidia.com, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	willemb@google.com, horms@kernel.org, vladimir.oltean@nxp.com,
	ioana.ciornei@nxp.com, andrew@lunn.ch, jiri@resnulli.us,
	daniel.machon@microchip.com, bridge@lists.linux.dev,
	netdev@vger.kernel.org, koral.ilgun@adtran.com
Subject: Re: [PATCH net v2 2/2] net: bridge: switchdev: clear the hwdom of a port that stops the offload
Date: Fri, 04 Dec 2026 00:27:42 +0000	[thread overview]
Message-ID: <179634406290.3146.7449604759040986420@kernel.org> (raw)
In-Reply-To: <20261203002451.517879-3-koralilgun@gmail.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] In the LAG-leave window and the dsa_port_change_conduit() window,
  this patch makes a bridge port that the switch still forwards for act…

--

net: bridge: switchdev: clear the hwdom of a port that stops the offload

When the last offload of a bridge port stops, nbp_switchdev_del() now
clears the port's hwdom. Before, the hwdom leaked when the port stayed in
the bridge. nbp_switchdev_hwdom_set() now skips ports without a hwdom, and
the forwarding path helpers read the hwdom once with READ_ONCE().

> diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
> index 8de12d56452dc..52b51b8753f43 100644
> --- a/net/bridge/br_switchdev.c
> +++ b/net/bridge/br_switchdev.c

[ ... ]

> @@ -305,8 +330,10 @@ static void nbp_switchdev_del(struct net_bridge_port *p)
>  	if (p->offload_count)
>  		return;
>  
> -	if (p->hwdom)
> +	if (p->hwdom) {
>  		nbp_switchdev_hwdom_put(p);
> +		WRITE_ONCE(p->hwdom, 0);
> +	}
>  
>  	if (test_bit(BR_TX_FWD_OFFLOAD_BIT, &p->flags)) {
>  		clear_bit(BR_TX_FWD_OFFLOAD_BIT, &p->flags);

[Severity: Low]
During a LAG leave, can clearing the hwdom here drop frames toward bridge
ports that are software only?

The last DSA port can leave a LAG that stays a bridge port. In that case
this code runs at NETDEV_PRECHANGEUPPER:

dsa_user_prechangeupper()
  dsa_port_pre_lag_leave()
    dsa_port_pre_bridge_leave()
      switchdev_bridge_port_unoffload()
        nbp_switchdev_del()
          WRITE_ONCE(p->hwdom, 0)

The hardware bridge and the trunk are torn down later, at
NETDEV_CHANGEUPPER, by dsa_port_lag_leave()->dsa_port_bridge_leave().
Until then, tag_dsa still marks every trunk frame:

net/dsa/tag_dsa.c:dsa_rcv_ll() {
    ...
	if (trunk)
		skb->offload_fwd_mark = true;
    ...
}

nbp_switchdev_frame_mark() then leaves src_hwdom at 0 for the LAG port.
Take a software-only egress port such as a veth or tap, which has hwdom 0.
For that port, nbp_switchdev_allowed_egress() checks:

	return !test_bit(hwdom, &cb->fwd_hwdoms) &&
		(!skb->offload_fwd_mark || cb->src_hwdom != hwdom);

Here offload_fwd_mark is set and cb->src_hwdom == hwdom == 0. The port is
refused, but the hardware never delivered the frame to it.

The other switch ports have hwdom X and pass the check, because 0 != X.
They get a software copy of a frame that the hardware already flooded.

In the other direction, a marked frame from another switch port passes the
check for the LAG, which now has hwdom 0. It then goes out through the
trunk a second time.

Documentation/networking/switchdev.rst says the bridge stops a frame from
being forwarded "through any bridge port with the same mark". Here hwdom 0
means that the port has no hardware domain, not that it shares a mark.

dsa_port_change_conduit() opens the same window between
dsa_port_pre_bridge_leave() and dsa_port_bridge_leave().

The commit message describes this window, and it lasts one RTNL operation.
Before this patch, though, the LAG kept its hwdom during the window and
these checks gave the right result.

Could the drops toward software-only ports be avoided by not counting
src_hwdom 0 as a match in nbp_switchdev_allowed_egress()? For example, the
check could require cb->src_hwdom != 0 before it refuses the port.

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

      reply	other threads:[~2026-12-04  0:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  0:24 [PATCH net v2 0/2] net: bridge: switchdev: fix the hwdom state of a port that stops the offload Koral Ilgun
2026-12-03  0:24 ` [PATCH net v2 1/2] net: bridge: switchdev: count an offload only after its hwdom is set Koral Ilgun
2026-12-04  0:27   ` netdev-bot+sashiko
2026-12-03  0:24 ` [PATCH net v2 2/2] net: bridge: switchdev: clear the hwdom of a port that stops the offload Koral Ilgun
2026-12-04  0:27   ` 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=179634406290.3146.7449604759040986420@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=bridge@lists.linux.dev \
    --cc=daniel.machon@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=jiri@resnulli.us \
    --cc=koral.ilgun@adtran.com \
    --cc=koralilgun@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=vladimir.oltean@nxp.com \
    --cc=willemb@google.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