🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8212

[PATCH net v4 1/2] bonding: fix initial last_rx vs ARP-monitor slack window

#8212
From: Ramses de Norre via B4 Relay
Date: Wed, 28 Oct 2026 11:48
92 lines
14436 bytes
From: Ramses de Norre <ramses@well-founded.dev>

bond_enslave() seeds a new slave's last_rx so that the ARP monitor does
not report it UP before a real ARP reply arrives, see commit
f31c7937c254 ("bonding: start slaves with link down for ARP monitor").

The seed is one arp_interval (plus a tick) in the past. That was old
enough when the up test was "jiffies <= last_rx + arp_interval". Commit
da210f559019 ("bonding: add some slack to arp monitoring time limits")
added arp_interval/2 of slack to that test without moving the seed, so
the seed now falls inside the up window. For the first half interval
after enslavement, bond_ab_arp_inspect() proposes a slave that starts
DOWN as UP although it has received nothing. The up test always uses a
single interval, so this does not depend on primary_reselect or
arp_missed_max.

If that slave is the configured primary, force_primary makes it the
active slave. ARP validation fails it shortly after (on SFP+ ports the
PHY is often still negotiating) and the bond falls back to the backup.
With primary_reselect=always the bond recovers once the port really
comes up, but drops traffic until then. With primary_reselect=failure,
force_primary is spent and the bond stays on the backup.

Reproducer:

  ip link add bond0 type bond mode active-backup arp_interval 1000 \
      arp_validate all arp_ip_target 192.0.2.1 \
      primary eth0 primary_reselect failure
  # eth0: SFP+ (slow link-up), eth1: RJ45 (fast link-up)
  ip link set eth0 master bond0
  ip link set eth1 master bond0
  ip link set bond0 up
  # bond0 lands on eth0 via force_primary, ARP-fails it before the
  # SFP+ has carrier, falls to eth1, and stays there.

Move the seed below the initial link state and seed a slave that starts
DOWN two intervals in the past, outside the up window. A slave that
starts UP keeps its current seed: the up test does not apply to it, and
an older seed would only bring its down deadline forward by one
interval. The initial link state is unchanged.

Fixes: da210f559019 ("bonding: add some slack to arp monitoring time limits")
Signed-off-by: Ramses de Norre <ramses@well-founded.dev>
---
 drivers/net/bonding/bond_main.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 7019e5d8fdc8e..bfa4cb97e647c 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2122,13 +2122,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 	if (res && bond_needs_speed_duplex(bond))
 		new_slave->link = BOND_LINK_DOWN;
 
-	new_slave->last_rx = jiffies -
-		(msecs_to_jiffies(bond->params.arp_interval) + 1);
-	for (i = 0; i < BOND_MAX_ARP_TARGETS; i++)
-		new_slave->target_last_arp_rx[i] = new_slave->last_rx;
-
-	new_slave->last_tx = new_slave->last_rx;
-
 	/* check for initial state */
 	new_slave->link = BOND_LINK_NOCHANGE;
 	if (bond->params.miimon) {
@@ -2159,6 +2152,22 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 
 	if (new_slave->link != BOND_LINK_DOWN)
 		new_slave->last_link_up = jiffies;
+
+	/* The ARP monitor's up test includes arp_interval/2 of slack, see
+	 * bond_time_in_interval(). Seed a slave that starts DOWN outside
+	 * that window, so it stays DOWN until a real reply arrives.
+	 */
+	if (new_slave->link == BOND_LINK_DOWN)
+		new_slave->last_rx = jiffies -
+			(2 * msecs_to_jiffies(bond->params.arp_interval) + 1);
+	else
+		new_slave->last_rx = jiffies -
+			(msecs_to_jiffies(bond->params.arp_interval) + 1);
+	for (i = 0; i < BOND_MAX_ARP_TARGETS; i++)
+		new_slave->target_last_arp_rx[i] = new_slave->last_rx;
+
+	new_slave->last_tx = new_slave->last_rx;
+
 	slave_dbg(bond_dev, slave_dev, "Initial state of slave is BOND_LINK_%s\n",
 		  new_slave->link == BOND_LINK_DOWN ? "DOWN" :
 		  (new_slave->link == BOND_LINK_UP ? "UP" : "BACK"));

-- 
2.56.0
Technical Details
Message-ID: <20261028-bonding-last-rx-v4-1-4d8e4cd47467@well-founded.dev>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352831-linux-kernel-netdev=dewy.ru
References: <20261028-bonding-last-rx-v4-0-4d8e4cd47467@well-founded.dev>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-352831-linux-kernel-netdev=dewy.ru
From: devnull+ramses.well-founded.dev@kernel.org (Ramses de Norre via B4 Relay)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net v4 1/2] bonding: fix initial last_rx vs ARP-monitor
 slack window
Date: Wed, 28 Oct 2026 12:48:07 +0100
Organization: Usenet Network
Message-ID: <20261028-bonding-last-rx-v4-1-4d8e4cd47467@well-founded.dev>
References: <20261028-bonding-last-rx-v4-0-4d8e4cd47467@well-founded.dev>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="1762281"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:wsVk3BGqAdiZLarT+aRsrsoCTwg= sha256:PNz7UNRmFmmVUIuRA3v8PnxuH5GvhZzqUQxzMMonXyA=
	sha1:Zka2EOtYICewe4rbCT6HZmr7Zr8= sha256:N7AOWFCy5MQJfTCnJfBpilltjRzycpZn0JBVQp5G/WQ=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 6E4E6125C36; Wed, 28 Oct 2026 14:50:42 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 3VfB-WOW5EhK;
	Wed, 28 Oct 2026 14:50:35 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-352831-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 77DDC125C33; Wed, 28 Oct 2026 14:50:27 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 6ED7A2DDBE; Wed, 28 Oct 2026 11:48:22 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793188098;
	b=yfWm2X8YY64dT0LsAl67uEBdgcu5FGQCE8YnqwAMwjCQirweFzCnLIUSxjFI2GbiLkDp
	 Hd1U5wLGZuVdLxfRlrfUBRZvSDOVqBCS5z035VZkPJ0vLNadwzcwVa7FmC+cnilwRozbQ
	 35W9eYj5ug5SDLXJ2kFppHGwN5xfVCfS61r4d0naEeHPihfaDctzNrGtzzXEcBvqZ3CPx
	 lraUy6z3LfmY2zRM047C3bZf0t9cbtRqjd5qSBtacLb2meQkI0JCuiPkeE2OXWb//vXpM
	 CRWr0hksb94MnMAtMvVZsckLsRrDcFU7iVXLEGmoJy/VesoVjUTsu666AUY23TMg42Q==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793188098;
	h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Date:
	 Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Message-Id:References:In-Reply-To:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=XhC2imG05+2RFrqn7oAIJ8gmety7mulQdSdn3ejKh9I=;
	b=aBUQECWHX9sH9kz9H0hMHIf2rWn45gyktJu7mu8QTW7nJovkRxvYEfUL554EUTsg/uO5
	 QB3VhjFsEXs+CMqCr/A34rxNFGTpFid45wkFvcv8252dhL/bq1UkQbZICagoNScG34g8n
	 BPuCO4ruMBBdTk0lAAIoSb14Owfi5uqnZBrTXf+FYPT16OLv6njb+Yqje/CDzgAYUiP1H
	 t9SwFTKFtG0Gku/YJM34YFP0ieQebsGWo5JzHVEcq7z1kNGLi5/mDaKLifrGSsyOaTeeU
	 RDbZFMMrbSBkLzFTCu1F++TVfW9IaNKnZqJtJMI1+/YRwxHZlWxbB1i5MMcNuqCAwiw==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TKwyW3Y8;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 6508E60A260B;
	Wed, 28 Oct 2026 11:48:18 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TKwyW3Y8
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793188092;
	b=UCh7K/mGbg4OzLeg628Z9Mri4gkVc5HqEbdIcKM3WOoR8ko/9aaWPP03gDgqnDvX44OR
	 5uT8aPJvmudfBteQ4AN10O6wvpOETY2lti6O+EWNB7dnkoxB/YMzueMqtb4wdWlrUZcPW
	 JBC9H6TiohUwUkxiUTMy/GBLUv3tYAeMwPhUu2k2a9lRi4YhIo+l/vTAwBQZ5JsfTgtAt
	 O0aX0aXxu1FGKtu2BBTJZfEpRKHFiWKqwNg3RxNjvdhpgPd9tdeD/dTSi6WKb5HGF0hXq
	 ByOjqA8HgWZmD7zCN76nBnFzEEwjDkcHGjftANnmZOVrQ7AzjM9j2ACrkjB+DRiJ98A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793188092;
	h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version:
	 Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=XhC2imG05+2RFrqn7oAIJ8gmety7mulQdSdn3ejKh9I=;
	b=1GsCA3l2z22JNVTtUjEVwM55+DDcjtaFgR3kt6dBBC0VM/Rh2cYxupb54Tm+TVciPcEW
	 +LrGMKF13Ibk8hy9Smf+Lidwk0xu9n0JLQZMMn2sfc/7e4UA9UAppjC49jtDarsbjgh9K
	 xr1WSw9OHEdwDQ8EqFKIWfEwnm3fPAtQpjDEMk3x6fIrRlIKx4kvnK14VmGFGaJFfQJFL
	 /CyASXS/GSfzLi8W25RSPcZdCuz4ckr06mmNYrdYBwOSC2LIturqPhPoCKL205THMrplf
	 whG89TsjaMrX3XQjPobGgT1BRN6a2USTix0reM08H/X+Z99V3VNU91TGDQagCWT1CZQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TKwyW3Y8;
	arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18
X-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 39B92606A321;
	Wed, 28 Oct 2026 11:48:12 +0000 (UTC)
X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77
X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none;
	t=1793188091;
	b=SRYxB0vOjFmzgz39kk2T5pw99sRt9jg58YR88Tw8BT2+dEebx+YJhuciYvIUcUCkaj86
	 bADHdqOXGYe1eGBMlMnCAq4+ii4a4UNuPIpzafHqg8S5zaVaY4g4rbk4lNygsRk/JHkt8
	 MyU7GCWqMrAcaWDYytYtaxtZ6y8xjU3i5323X+GSBBdlUk2eQXgQK8/AUf3DJQm0afMP3
	 N/cR1jo4V91nWPZYah1EmZJQTiWtEGNZcgcR3g5txlH8ur1Wq3GX9W6uJhwNHU0/7acvo
	 bRc+j4Q4WvbgMuUGX/y5gvNMQD64Wrz683gQLYPN74mTWEbL+jkOsPl4/tudoymd9mw==
X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256;
	c=relaxed/relaxed; t=1793188091;
	h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type:
	 Message-Id:References:In-Reply-To:To:Cc:X-Mailer:
	 X-Developer-Signature:X-Developer-Key:X-Endpoint-Received:
	 X-Original-From:Reply-To:Content-Transfer-Encoding;
	bh=XhC2imG05+2RFrqn7oAIJ8gmety7mulQdSdn3ejKh9I=;
	b=cn11PiEc9KcaCG55RvXnhdJm1g3W8TYELDw+GZciTxV3JiEMlwrAijcv/opymHboK1S7
	 Y370ig/ZUO68gvjgn3d6i5VxP8urQK+mQPGJ+iKZQ8S3Zr6B9ns/qqO+URHp8cqMtp8QP
	 RbT6mdx2J9WXnzhP6XHdNTJ5mG4rpvLCC50TGqlimuK0cwu8tC2TDXG9ZE1CsZhJ3ewL5
	 JzGgoUmY01GELrvXSI7B+Ib6Xb3PjYT6zOXUxKOgfEQajO/BJiOGc4b+7CJAu50Pph0WO
	 /KtqjBVjXD2B66/6NSBObDRoFgeeEeos/ilrYZmBfMcveaGSsagt80+TV1w6/NdDvKw==
X-ARC-Authentication-Results: i=1; smtp.kernel.org; 
	arc=none smtp.remote-ip=100.80.115.77
X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.kernel.org (Postfix) with ESMTPS id E049F1F031E4;
	Wed, 28 Oct 2026 11:48:10 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793188091;
	bh=XhC2imG05+2RFrqn7oAIJ8gmety7mulQdSdn3ejKh9I=;
	h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To;
	b=TKwyW3Y8w8pCwTlBKKR9kWwjSQXsUjFBjeyKGEi7i+flP9peILQE+ugqGDaXzUj0H
	 MShANFhLjeYm8Ymn0vALrA/M3p8dq7UPrhqJdXNUoXr5oHcY6QunFTps7IcVGAiQyu
	 lV4a/4eMrHUfwA0JvRjGEOhdWP2S0Id+Vmsp/Zrz+u+4uWAIHtffS9tc8XIxthA7G7
	 rAxXtKbqCikOAcGD+LSgg9bgcBz82l4QIPTaq75j7pT6NNiOjaAJYZDOOpJ+oM7Fs5
	 QKOKB9gsf15U2AN47VcU4nVXSl8n/zb+so/+SSzgWpzBn76oMyM/Q3G+fsPdeIiiBu
	 cGsERz/oXodbA==
X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1])
	by lkml.kernel.org (Postfix) with ESMTP id 4A0D745437;
	Wed, 28 Oct 2026 11:48:10 +0000 (UTC)
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261028-bonding-last-rx-v4-0-4d8e4cd47467@well-founded.dev>
X-Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, 
 Nikolay Aleksandrov <razor@blackwall.org>, 
 Hangbin Liu <hangbin.liu@linux.dev>, 
 Ramses de Norre <ramses@well-founded.dev>
X-Mailer: b4 0.15.2
X-Developer-Signature: v=1; a=ed25519-sha256; t=1793188089; l=3973;
 i=ramses@well-founded.dev; s=20260817; h=from:subject:message-id;
 bh=0sZ4MeprU+UjQ+ei1h7UCE9FsfSS+q+//+ci1EBUfME=;
 b=8F2HTzxYqJFk3Ptbk2N9b9sC/FBn7L4AXqh8iCDVeoENvkJ+dgtW8pOMShlqvSMzszFjUYJXl
 8do8yaV4Nn5ABEkgAFPwR37QtSApv9pqhSvV4H2mPClexXSuZFyM6pH
X-Developer-Key: i=ramses@well-founded.dev; a=ed25519;
 pk=1vBXHBVeJBMaC+2Zuonl0QQhEgGIQHERyF5RZNnrCmw=
X-Endpoint-Received: by B4 Relay for ramses@well-founded.dev/20260817 with
 auth_id=957
X-Original-From: Ramses de Norre <ramses@well-founded.dev>
X-Reply-To: ramses@well-founded.dev