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 1/2] net: bridge: switchdev: count an offload only after its hwdom is set
Date: Fri, 04 Dec 2026 00:27:41 +0000	[thread overview]
Message-ID: <179634406142.3146.16588048091797797302@kernel.org> (raw)
In-Reply-To: <20261203002451.517879-2-koralilgun@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] On rocker, this patch adds a WARN that userspace can trigger,
  and no patch in the series fixes it.

--

net: bridge: switchdev: count an offload only after its hwdom is set

This patch moves the setting of p->offload_count in nbp_switchdev_add()
so it happens after nbp_switchdev_hwdom_set() succeeds. Before, a port
whose offload failed with -EBUSY kept a count for an offload that never
happened.

> diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
> index 10f3aea6a1f82..8de12d56452dc 100644
> --- a/net/bridge/br_switchdev.c
> +++ b/net/bridge/br_switchdev.c
> @@ -280,12 +280,13 @@ static int nbp_switchdev_add(struct net_bridge_port *p,
>  	}
>  
>  	p->ppid = ppid;
> -	p->offload_count = 1;
>  
>  	err = nbp_switchdev_hwdom_set(p);
>  	if (err)
>  		return err;
>  
> +	p->offload_count = 1;
> +

[Severity: Medium]
Can this make userspace able to trigger the WARN_ON() in
nbp_switchdev_del() on rocker ports? The changelog says so itself:

  "With this patch, that unoffload hits the WARN_ON() in
  nbp_switchdev_del()."

Neither this patch nor the next one in the series seems to address it.

rocker_netdevice_event() only logs the offload failure and returns
NOTIFY_DONE:

drivers/net/ethernet/rocker/rocker_main.c:rocker_netdevice_event() {
    ...
			if (err)
				netdev_warn(dev, "failed to reflect master linked (err %d)\n",
					    err);
    ...
}

So br_add_if() never sees the error and keeps the port in the bridge.

Also, ofdpa_port_bridge_join() sets ofdpa_port->bridge_dev = bridge
before it calls switchdev_bridge_port_offload(). It does not clear it
when the offload fails, so ofdpa_port_is_bridged() is still true when
the port is unlinked later.

When the port leaves the bridge, the call chain is:

del_nbp()
  netdev_upper_dev_unlink()
    rocker_netdevice_event()
      ofdpa_port_master_unlinked()
        ofdpa_port_bridge_leave()
          switchdev_bridge_port_unoffload(dev, NULL, NULL, NULL)
            br_switchdev_blocking_event()
              br_switchdev_port_unoffload()
                nbp_switchdev_del()
                  if (WARN_ON(!p->offload_count))

Before this patch, the failed offload left offload_count at 1, so this
unoffload was balanced. It now runs with offload_count == 0 and fires
the WARN, which panics with panic_on_warn.

The -EBUSY case can be reached on the current tree. A CAP_NET_ADMIN
user fills hwdoms 1..BR_HWDOM_MAX-1 with ports from other switches,
then adds a rocker port from a new switch. While br_add_if() runs, that
port is not yet in br->port_list, so nbp_switchdev_hwdom_set() returns
-EBUSY.

The follow-up patch "net: bridge: switchdev: clear the hwdom of a port
that stops the offload" leaves both rocker and the WARN_ON() in
nbp_switchdev_del() as they are. The WARN is therefore still reachable
at the end of the series.

DSA does not have this problem. dsa_port_bridge_join() calls
dsa_port_bridge_destroy() when the offload fails, and
dsa_port_pre_bridge_leave() returns early when there is no brport_dev.

Should rocker be fixed in the same series? One option is to return
the error with notifier_from_errno() so br_add_if() unwinds. Another
is to record whether the offload succeeded, and skip
switchdev_bridge_port_unoffload() in ofdpa_port_bridge_leave() when it
did not.

>  	if (tx_fwd_offload) {
>  		set_bit(BR_TX_FWD_OFFLOAD_BIT, &p->flags);
>  		static_branch_inc(&br_switchdev_tx_fwd_offload);

-- 
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 [this message]
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

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