From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796438994; b=E2CYdUjz0j4IlFfmx2wh4zzg78h4dp7CpCN15q9iirC9L7BOCeEvuP2zQ68MQed6Va3h bENy/u37tW4u4+yQWaltHBLR5ZJWIWdkdb1zm8RnpqnyzSNzRaduubH+BgS8S0Lm1rOlA HDAZ/xtSuaS/CLdV0D0K7zDF6jEWGyT7YRdYFGetIL0jJopFcmiFDRhtARGFpBbu2dZS3 B9BuhMH9BQbvS49EW/ecV4CRoXQk57Mcp8EmHdlNYPflOQv9yoFJSDoko7Bnj3+3t8DAd s2SMmZbId9aOxNT9d6mbE4M0wQH8979hQqDeI7uJK6r90Gdr2nixj83Q+L4tFSCIh5w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796438994; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=TUAuO5yOdwGkmEzBd+hW2eRsuSeUnsMuawy2lCtGWHg=; b=3WrEp/T7KMsZIJoDwilzbVHB1/ySmNoj4eMPA/6jC5Qw99sJCUftsm/kzJGq/H1hyaHQ pZQg+c7j8p5yQKe0fXUWuW2pRnwjAslONF0eJha8i9MTxt2QWdrzaBRKj78jyzCbP0xZN 6L4l5LxAOt9Ic81jpCHFd509Nu1aGnHdusIJpMxbNmEvIGvQMpW6XH3eKvvE0QRctybRM /aYHDmZ4UdLRAsSUcmrm7yW7XPuZhLz4uEoub2dIMGNr38weS6QaENgiJiookokcFM/nV DE1AQcKwtMm/d18EVW/QP1Zmf2NI6OB/leFmvssUeJj7nMTYzdQ3e3qpc5juWdAb/Fg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=lngnO+qx; arc=none smtp.remote-ip=74.125.82.43 Received: from mail-dl1-f43.google.com (mail-dl1-f43.google.com [74.125.82.43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 285A3606A322 for ; Sat, 5 Dec 2026 02:49:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 285A3606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=lngnO+qx Received: by mail-dl1-f43.google.com with SMTP id a92af1059eb24-1b546061d58so3647636c88.1 for ; Fri, 04 Dec 2026 18:49:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796438992; x=1797043792; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=TUAuO5yOdwGkmEzBd+hW2eRsuSeUnsMuawy2lCtGWHg=; b=lngnO+qxUoztbQAp7E81zk28fqNQ/vbzfs5kiVC5rIsdXshWgN2oKlxmret0Pvl16U 6KLkFkrqouqzGMi5BUXLRgMHrDO5PcAKemEPmhr1Cr4QsCz0a9Xb4Mo18nC/Z6k2NYpc AuQqielKjIOkv+VYtpWRVmOFuyAEWUz+BQRbi/T+2Jd+9VW1KMXHlPYXNSQ4S4CnTvQa TseVIiUKnask3oC0GL/3b1MNrz4NwyvM1v86c39M6f6ijwQKyML0+2vvVN5zrJMYNy8P 5HJ+8u56hhwTcPBi5RGQwdB0ibiFyLSTbZheUShz5mrFhY9Tcc/dHil7531Hk1BjtgWx Sawg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796438992; x=1797043792; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=TUAuO5yOdwGkmEzBd+hW2eRsuSeUnsMuawy2lCtGWHg=; b=pGjbyK9fV2WyFjwpnD02i7YiHKtc+KB8dt7G8n3LoYJpPtsThmKQDm5gwYYaiQe2Qe tPkj5qs9+doMTon2Shsyb3CCTWkM2JidXaOzwMgSZ4T+qeUfpomWwfzNPHn7s4cy4vF9 DEQhDcpMOKk2o+AgfGipqNQPG1Oqxw8cr+7Sj+qRbdri0iLfcIlBqkCMCdra65ONjYOm Dos+wUWEf/ycIby0JzsRFCvqAO5KGm6J49zsrY2twekXePO0ejvuo+KVa6zRmVPPx+Jx 5OkvrrHSl+OmSzzF7JAsAwauGsbCXKPj+L47OKlASFKA8H25FKgLXr+cvh9zcy9nW5i4 sVhA== X-Forwarded-Encrypted: i=1; AL+hErHmzGP/I/10Xv+juyJTq0yJ62j2WQQRwPue5mNlJQNYEKA6wI8x/jOd7jQ6rZlCoMGVmicqFkg=@vger.kernel.org X-Gm-Message-State: AB4q+uF22tkOtUQa53Qpv+CWY72N83F7/5P3sSLc9I0RrTztIc/TKJ0z zR6JYD2DCe/IGvuXQDSFH0+/7OvpnxtgireCMlZ4ZbzVc2rsBqsBAv8G X-Gm-Gg: AZFdTZfjxRQsLiSJ/uwlkSVcKsam8uFkDcLmRANK5te/AlwwAM9Iaywj+jrTjqiChPs bZQHw+FxnKvPftF7PKNqMGO/IPpAsz+Wq6g8qJZkkOSjSSHgu/B4IJIyFlkrUw5Vsi88burXsVM 82iXsbe/TC+qcbwtFrzi2C9kqWk9s3Mk+8wF0g4JNAiRk0SlvBTlsFsnxEd7YamQNulhTl9oJrw 5pBOYcNCofHJ5NfjZJJMMo4Z/4GF2Okolt2kGjfrhDnMotw/sO844XfQTeElPigxkUeBCeyPGYx 1ux8+KVBzeJ8cEMZFEm0OfdS0T5e9XnJb3EjLOCQ5oEky5X14dWF11CA1MAqTeLHXnoipav56IN 2Sc0I+Q0hE/ZuwZ8JD3uiD8b5olJkrDuf9sNMIjuZSpJR4mkcjs93Xz8S74UCONMuxlEHXRL1wN RAq3LCAVClrqBmwYjX1Og3huM6p6it0f6L1apGxD77RAGeOxLim7l6KiSB16SPCc+/Uh0jIbY1H AXggX/rj+tS2r2qMo/jKr+bQSKvMdjqqs9PbRZMjZbRm1bSOFLl/Z2wiT7GVnGEDVtSgrK8W7qZ trB1HsO40xURVtZ2BszLGJyuR07bg5lrP3Njr0nBtb7jd/15J8T82n+zgx4KyVYe85eslurWk7e QzUAA/xTs+VZUSKpyB91Mo8c= X-Received: by 2002:a05:7301:d811:b0:387:44b1:fdc2 with SMTP id 5a478bee46e88-387521ace8emr3814092eec.42.1796438992107; Fri, 04 Dec 2026 18:49:52 -0800 (PST) Received: from samniyama.tailbcd61.ts.net ([76.20.4.3]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-387521bb368sm17797155eec.10.2026.12.04.18.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 18:49:51 -0800 (PST) From: Koral Ilgun To: Jiri Pirko , Nikolay Aleksandrov , Ido Schimmel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Willem de Bruijn , Simon Horman , Vladimir Oltean , Ioana Ciornei , Andrew Lunn , Daniel Machon , bridge@lists.linux.dev, netdev@vger.kernel.org, Koral Ilgun Subject: [PATCH net v3 1/3] rocker: fail the bridge join when the offload fails Date: Fri, 4 Dec 2026 18:49:40 -0800 Message-ID: <20261205024943.3657727-2-koralilgun@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261205024943.3657727-1-koralilgun@gmail.com> References: <20261205024943.3657727-1-koralilgun@gmail.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Koral Ilgun ofdpa_port_bridge_join() sets bridge_dev, moves the port to the internal VLAN of the bridge, adds the untagged VLAN again and then calls switchdev_bridge_port_offload(). When ofdpa_port_vlan_add() or the offload fails, it returns the error and undoes nothing. rocker_netdevice_event() only logs the error and returns NOTIFY_DONE, so br_add_if() keeps the port in the bridge. At the leave, ofdpa_port_bridge_leave() calls switchdev_bridge_port_unoffload() for an offload that did not happen. When ofdpa_port_vlan_add() failed, the bridge never counted an offload of the port, and nbp_switchdev_del() hits WARN_ON(!p->offload_count). When the offload failed with -EBUSY because all hwdoms are busy, nbp_switchdev_add() keeps offload_count 1 today, so the leave is balanced. The next patch fixes that count, and the leave then hits the same WARN_ON(). Undo the join in ofdpa_port_bridge_join() when the VLAN add or the offload fails: give the port its own internal VLAN and untagged VLAN again, and clear bridge_dev. Return the error of a bridge join from rocker_netdevice_event() with notifier_from_errno(), so that __netdev_upper_dev_link() rolls back the link and br_add_if() fails. That rollback sends no event for the unlink, so rocker must undo its own state before it returns the error. A failure of the first ofdpa_port_vlan_del() in ofdpa_port_bridge_join() now also fails the join; that path has no undo, as before. The undo does not check the errors of its own calls, because it already returns the error of the join. The undo alone does not leave a working port. br_add_if() calls new_nbp() before it links the port, and new_nbp() sets the port state to BLOCKING and then DISABLED with SWITCHDEV_F_DEFER. del_nbp() runs switchdev_deferred_process() before the unlink, but the error path of br_add_if() does not, so both states reach rocker after the undo. ofdpa_port_attr_stp_state_set() applies them to the port that is no longer bridged, and the standalone port loses the ACL flows that pass ARP and link-local frames to the CPU. The deferred ageing time from br_init_port() reaches rocker too, and it sets the ageing time of the port, as each join does. Make ofdpa_port_attr_stp_state_set() ignore an STP state for a port that is not bridged. DSA has the same check: dsa_user_port_attr_set() returns -EOPNOTSUPP when dsa_port_offloads_bridge_port() is false. rocker returns 0, and in both cases the change is skipped without a message. Keep the OVS case as it is. ofdpa_port_ovs_changed() sets bridge_dev before the calls that can fail and does not undo it, so a returned error would leave bridge_dev at a master that the port did not join. rocker logged and dropped a join error already before the commit in the Fixes tag. That commit put in the offload and unoffload calls, and with them the WARN_ON() at the leave. Tested in QEMU (TCG) with a rocker device of one port, sw1p1, cabled through a QEMU hub to a virtio NIC in another network namespace. A local knob made nbp_switchdev_hwdom_set() return -EBUSY as if all hwdoms were busy: ip link add br1 type bridge ip link set sw1p1 master br1 # knob on ip link set sw1p1 nomaster With the next patch but without this one, the join succeeds, rocker logs "failed to reflect master linked (err -16)", and the leave hits the WARN_ON() in nbp_switchdev_del(). With this patch, the join fails with EBUSY, sw1p1 is not a port of br1, and the leave gives no WARN. Then a ping from sw1p1 as a standalone port to the virtio NIC passes 5 of 5, and sw1p1 joins br1 with the knob off, passes a ping through br1 and leaves without a WARN. Each kernel ran the test in three boots. Without the change to ofdpa_port_attr_stp_state_set(), the standalone ping lost 5 of 5 in each boot, and a dump of the QEMU rocker tables showed that the ARP and link-local ACL flows were gone. The failures of the first ofdpa_port_vlan_del() and of ofdpa_port_vlan_add(), and the OVS case, come from a read of the source. No kernel selftest ran. The Sashiko AI review of v2 of this series pointed out that the next patch makes the WARN_ON() reachable on rocker and that no patch of the series fixed it. Claude Code found the WARN_ON() after a failed ofdpa_port_vlan_add() in a read of the source. This patch was prepared with Claude Code (Anthropic). It wrote the code change, this changelog and the reproducer, and ran the tests in the VM, under my direction; a separate model instance reviewed the patch. I reviewed the result and checked the test output. Fixes: 2f5dc00f7a3e ("net: bridge: switchdev: let drivers inform which bridge ports are offloaded") Signed-off-by: Koral Ilgun --- drivers/net/ethernet/rocker/rocker_main.c | 8 +++++++- drivers/net/ethernet/rocker/rocker_ofdpa.c | 24 +++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c index 0fcd65fc0af7..e721b68625c6 100644 --- a/drivers/net/ethernet/rocker/rocker_main.c +++ b/drivers/net/ethernet/rocker/rocker_main.c @@ -3101,9 +3101,15 @@ static int rocker_netdevice_event(struct notifier_block *unused, err = rocker_world_port_master_linked(rocker_port, info->upper_dev, extack); - if (err) + if (err) { netdev_warn(dev, "failed to reflect master linked (err %d)\n", err); + /* Only the bridge join undoes its own state + * on an error. + */ + if (netif_is_bridge_master(info->upper_dev)) + return notifier_from_errno(err); + } } else { err = rocker_world_port_master_unlinked(rocker_port, info->upper_dev); diff --git a/drivers/net/ethernet/rocker/rocker_ofdpa.c b/drivers/net/ethernet/rocker/rocker_ofdpa.c index 1e0558bd78c3..4d59ad76dd17 100644 --- a/drivers/net/ethernet/rocker/rocker_ofdpa.c +++ b/drivers/net/ethernet/rocker/rocker_ofdpa.c @@ -2471,6 +2471,9 @@ static int ofdpa_port_attr_stp_state_set(struct rocker_port *rocker_port, { struct ofdpa_port *ofdpa_port = rocker_port->wpriv; + if (!ofdpa_port_is_bridged(ofdpa_port)) + return 0; + return ofdpa_port_stp_update(ofdpa_port, 0, state); } @@ -2583,10 +2586,25 @@ static int ofdpa_port_bridge_join(struct ofdpa_port *ofdpa_port, err = ofdpa_port_vlan_add(ofdpa_port, OFDPA_UNTAGGED_VID, 0); if (err) - return err; + goto err_vlan_add; + + err = switchdev_bridge_port_offload(dev, dev, NULL, NULL, NULL, + false, extack); + if (err) + goto err_bridge_port_offload; + + return 0; - return switchdev_bridge_port_offload(dev, dev, NULL, NULL, NULL, - false, extack); +err_bridge_port_offload: + ofdpa_port_vlan_del(ofdpa_port, OFDPA_UNTAGGED_VID, 0); +err_vlan_add: + ofdpa_port_internal_vlan_id_put(ofdpa_port, bridge->ifindex); + ofdpa_port->internal_vlan_id = + ofdpa_port_internal_vlan_id_get(ofdpa_port, + ofdpa_port->dev->ifindex); + ofdpa_port->bridge_dev = NULL; + ofdpa_port_vlan_add(ofdpa_port, OFDPA_UNTAGGED_VID, 0); + return err; } static int ofdpa_port_bridge_leave(struct ofdpa_port *ofdpa_port) -- 2.43.0