From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796279394; b=Rw2aMJFPZzHKbW/ej8lfKuenCn+Tov5kqb7gJtvIvmuxAOu6q347b8w66mrC/GexAFl6 oYwRNncEJzGK/N7Hw74IPo/kFwQTerWz5b7lrw/D0ZscAh1XDUxO7TAX8SzzXVrU0jjg1 OCqRuIPNLBwO78M39N7f+Z+D2ty2Wlyvv+FDrbAE8aGwCDQhJjN7gxwTX7QAgQL/vrqi8 OIn3LYqAnYNVmfyHVfH6H1WVwif7RrgeER5jnR7a7OFnPO2G55gRR98hRCz+3pA5IApk6 QuzBnT9iZw1QEBVsPGi7Y+aSqEsRh07oDYLMk5SStMNzg2udvOC7kKhWCur4wI50A0A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796279394; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=l7xc8HFM5UyD1zMv04jZNN1NwjzxaH0Q5B+CG/stM2Q=; b=4s0V5x1MAHYfEg7puYRYrEXTNuRJsATtKx/SbGYreJvYr+TGcm2lZdNON+O4tAOdg9hF WhanrKtbMDlzCV0H72VE7g624HcECfAMUrb+PdztWUo6Tw2zWA/AaccQJ2jsijSSvGZ/x efFskHTIn9oHYO/ofZC4RVpe1WfOSTA+ZXX9FTfFsK+i6uHG1rkxwVdGTYFplrIHLT97a 04qT9e8iTQUBlMED8EPsiwbgbGVYgtKsHfs7f9V/TeM++9YKyWBAfUbCoR3e1JwZ1tf9K Sndkq7kulG0niFKqFoUpLwop97+KZxIca4JHc4TyDy3JCV0u2MqdS2OpUPfKdE3s+zQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=D1LFSeRC; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C4FD606A681; Thu, 3 Dec 2026 06:29:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=D1LFSeRC Received: by smtp.kernel.org (Postfix) with ESMTPSA id 477D81F0089A; Thu, 3 Dec 2026 06:29:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796279394; bh=l7xc8HFM5UyD1zMv04jZNN1NwjzxaH0Q5B+CG/stM2Q=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=D1LFSeRCqWafKKx55aERn07DT4zZKZ9ufgm3GBkYfgqmcetT0zisNqtLXSdcPccU7 Jtma57wal7DlFsgo6fKvQTXG9PASxTzwPTWm72pncA53r9sxgh0eazdM7a6nbDXy2F YYBKbJmKJMjfBtHWxN4hbEW9+vYhBZ+47p6Of+GmtCKAIuznbeM7o0e2FY97/b13HH chs+IwXeBTrR0i3xT+vH8gJpMO/OUTl9wO8h2Uac3Asx6C4l6wh0TBDhcqAjxj1cxm ihVh/iQob361R6T57+hqXzY+Uv1OEN3UJIUi5EVGlxzVZyt9EcdApCog/Y/vgNUjyn z2gBMbwYt4cqA== Subject: Re: [PATCH net v2 2/3] bonding: update slave array on link change for broadcast mode From: netdev-bot+sashiko@kernel.org To: hangbin.liu@linux.dev Cc: jv@jvosburgh.net, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, tonghao@bamaicloud.com, razor@blackwall.org, shuah@kernel.org, jiangjiehua1@huawei.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Date: Thu, 03 Dec 2026 06:29:52 +0000 Message-ID: <179627939278.3146.9699110701797983880@kernel.org> In-Reply-To: <20261201-bond_broadcast_updelay-v2-2-969e1844f2c4@kylinos.cn> References: <20261201-bond_broadcast_updelay-v2-2-969e1844f2c4@kylinos.cn> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 2 (2) · Low: 0 (2) 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 balance-rr, updelay is ignored for good after the bond has been switched from broadcast mode. - [Medium] bonding: stale usable_slaves in bond_change_active_slave() on LINK_BACK promotion Pre-existing issues: - [Medium] This problem wasn't introduced by this patch, but ALB mode and TLB with tlb_dynamic_lb=1 have the same stale usable_slaves problem… - [Medium] This problem wasn't introduced by this patch, but balance-rr never implements the rule in bonding.rst section 13.1 ('when a bonding… - [Low] This problem wasn't introduced by this patch, but two comments are stale. - [Low] This problem wasn't introduced by this patch, but bond_miimon_inspect() reads usable_slaves->count with a plain load… -- bonding: update slave array on link change for broadcast mode In broadcast mode, this patch rebuilds the usable and all slave arrays on MII and ARP monitor link-state changes, in bond_open(), and on slave NETDEV_UP/CHANGE/DOWN events. The aim is to keep usable_slaves current so that bond_miimon_inspect() decides correctly whether to bypass updelay. It relies on the preceding revert that makes broadcast mode publish usable_slaves again. > diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c > index d6675e87d06b6..a8c79fa9f5bf2 100644 > --- a/drivers/net/bonding/bond_main.c > +++ b/drivers/net/bonding/bond_main.c > @@ -2780,6 +2780,7 @@ static void bond_miimon_link_change(struct bonding *bond, > bond_alb_handle_link_change(bond, slave, link); > break; > case BOND_MODE_XOR: > + case BOND_MODE_BROADCAST: > bond_update_slave_arr(bond, NULL); > break; > } [Severity: Medium] Does this cover every place where a broadcast slave becomes BOND_LINK_UP? bond_change_active_slave() can move a slave that is still in BOND_LINK_BACK straight to BOND_LINK_UP, which skips the rest of its updelay. In that path it resets new_active->delay and calls bond_set_slave_link_state(). After that it only calls bond_3ad_handle_link_change() for 802.3ad and bond_alb_handle_link_change() for TLB/ALB. Nothing rebuilds the arrays for broadcast or xor. Here is one sequence with updelay > 0. Slave A is curr_active_slave and is the only slave that can transmit. Slave B is in BOND_LINK_BACK with delay < updelay. Then A loses carrier: bond_miimon_commit() bond_miimon_link_change(bond, A, BOND_LINK_DOWN) bond_update_slave_arr() <- B is BACK, count == 0 bond_select_active_slave() bond_find_best_slave() <- returns B bond_change_active_slave(bond, B) bond_set_slave_link_state(B, BOND_LINK_UP, ...) Releasing A through __bond_release_one() has the same result. That path rebuilds the array with A skipped, and only then calls bond_select_active_slave(). B is now forwarding, but usable_slaves->count is still 0. B's link is already BOND_LINK_UP, so later bond_miimon_inspect() passes skip it and bond_miimon_commit() never handles it. The array stays empty until some other link event happens. The next slave to recover then sees count == 0 in bond_miimon_inspect(). It sets ignore_updelay and skips updelay while B is still forwarding. That is the case the commit message sets out to fix. Balance-xor already has this hole. There the empty array also makes bond_3ad_xor_xmit() drop packets while B is up. Would it be the right fix to call bond_miimon_link_change(bond, new_active, BOND_LINK_UP) from bond_change_active_slave(), in place of the open-coded 802.3ad and TLB/ALB calls? Or should the callers rebuild the array after bond_select_active_slave()? [Severity: Medium] This is a pre-existing issue, but do ALB mode and TLB with tlb_dynamic_lb=1 have the same stale usable_slaves problem that this patch fixes for broadcast? bond_mode_can_use_xmit_hash() includes TLB and ALB. So enslave, release, bond_open() and NETDEV_UP/CHANGE/DOWN all rebuild the array for those modes. On MII link transitions, though, the TLB/ALB case goes through bond_alb_handle_link_change(). That function rebuilds only for non-dynamic TLB: drivers/net/bonding/bond_alb.c:bond_alb_handle_link_change() { ... if (bond_is_nondyn_tlb(bond)) { if (bond_update_slave_arr(bond, NULL)) ... } This condition is never true for ALB, because bond_option_mode_set() forces tlb_dynamic_lb=1. It is not true for dynamic TLB either. Here is one sequence. Carrier-up raises NETDEV_CHANGE, which is handled promptly because bond slaves are lag ports. The array is rebuilt while slave->link is still DOWN or BACK, so bond_slave_can_tx() leaves the slave out. miimon later commits BOND_LINK_UP, and nothing rebuilds the array. Wouldn't the array then stay empty while a slave is forwarding? The next recovering slave would then bypass updelay in bond_miimon_inspect(). [Severity: Low] This is a pre-existing issue, but bond_miimon_inspect() reads usable_slaves->count with a plain load while holding only RCU: usable_slaves = rcu_dereference(bond->usable_slaves); if (usable_slaves && usable_slaves->count == 0) ignore_updelay = true; bond_skip_slave() can change count in place on the already published array, holding only RTNL. This happens on the ENOMEM path of bond_update_slave_arr() when it is called from __bond_release_one(): WRITE_ONCE(slaves->count, slaves->count - 1); The two sides share no lock and only one access is marked, so KCSAN would report this pair. Other readers already use READ_ONCE(slaves->count), for example bond_xmit_broadcast(), bond_xmit_3ad_xor_slave_get(), bond_xdp_xmit_3ad_xor_slave_get() and __bond_sk_get_lower_dev(). Should bond_miimon_inspect() use READ_ONCE() here too? [ ... ] > @@ -4411,7 +4414,8 @@ static int bond_open(struct net_device *bond_dev) > static_branch_inc(&bond_bcast_neigh_enabled); > } > > - if (bond_mode_can_use_xmit_hash(bond)) > + if (bond_mode_can_use_xmit_hash(bond) || > + BOND_MODE(bond) == BOND_MODE_BROADCAST) > bond_update_slave_arr(bond, NULL); > > return 0; [Severity: Medium] Can a bond that is switched from broadcast to balance-rr end up ignoring updelay for good? With the preceding revert, broadcast mode publishes bond->usable_slaves again. Releasing the last broadcast slave goes through: __bond_release_one() bond_update_slave_arr(bond, slave) bond_set_slave_arr() <- publishes non-NULL usable_slaves, count == 0 The mode option requires BOND_OPTFLAG_NOSLAVES | BOND_OPTFLAG_IFDOWN. But neither bond_option_mode_set() nor bond_close() resets usable_slaves or all_slaves, so the count == 0 array carries over into balance-rr. In balance-rr, nothing rebuilds that array: - enslave, release, bond_open() and bond_slave_netdev_event() are gated on bond_mode_can_use_xmit_hash() || BROADCAST. - bond_miimon_link_change() has no rr case. The check in bond_miimon_inspect() is then true on every pass: if (usable_slaves && usable_slaves->count == 0) ignore_updelay = true; As a result, every recovering rr slave gets delay = 0, even while other slaves are still forwarding. This looks like the case the commit message says it fixes: A stale empty array can make a recovering slave bypass updelay while another slave is still forwarding. The xor to rr path already had this problem. The broadcast to rr variant is new with this series. It is only mentioned in the "For Sashiko" note below the --- line, which won't reach the git log or stable reviewers, even though the patch carries Cc: stable. Should the arrays be reset on mode change or in bond_close()? Or should the commit message at least note this limitation? [Severity: Medium] This is a pre-existing issue, but does balance-rr ever follow the bonding.rst section 13.1 rule that the commit message cites? Note that when a bonding interface has no active links, the driver will immediately reuse the first link that goes up, even if the updelay parameter has been specified bond_miimon_inspect() derives ignore_updelay from bond->usable_slaves for every mode except active-backup. No bond_update_slave_arr() call site covers BOND_MODE_ROUNDROBIN: - enslave, release, open and netdev events are gated on xmit_hash || BROADCAST. - bond_miimon_link_change() covers 8023AD/TLB/ALB/XOR/BROADCAST. - bond_loadbalance_arp_mon() covers XOR/BROADCAST. A bond that has always been in rr mode therefore has usable_slaves == NULL, and ignore_updelay stays false. Doesn't the first recovering link then wait the full updelay, even though no slave can transmit? If the bond was earlier in xor or broadcast mode, the opposite failure described above happens instead. [Severity: Low] This isn't a bug introduced by this patch, but two existing comments no longer match how broadcast mode uses the arrays. The header comment of bond_update_slave_arr() leaves out BOND_MODE_BROADCAST: /* Build the usable slaves array in control path for modes that use xmit-hash * to determine the slave interface - * (a) BOND_MODE_8023AD * (b) BOND_MODE_XOR * (c) (BOND_MODE_TLB || BOND_MODE_ALB) && tlb_dynamic_lb == 0 The comment in bond_enslave() gives all_slaves as the only reason for broadcast: /* broadcast mode uses the all_slaves to loop through slaves. */ The new broadcast call sites, however, exist to keep usable_slaves current for bond_miimon_inspect(). Could these comments be updated as well? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201-bond_broadcast_updelay-v2-0-969e1844f2c4%40kylinos.cn