🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #8950

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

#8950
From: Ramses de Norre via B4 Relay
Date: Fri, 30 Oct 2026 14:51
95 lines
14565 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 it receives traffic, 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")
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>
Signed-off-by: Ramses de Norre <ramses@well-founded.dev>
---
 drivers/net/bonding/bond_main.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 7019e5d8fdc8e..2f5638f4d3a78 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) {
@@ -2157,8 +2150,23 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 					  BOND_SLAVE_NOTIFY_NOW);
 	}
 
-	if (new_slave->link != BOND_LINK_DOWN)
+	/* 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 it receives traffic.
+	 */
+	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_link_up = jiffies;
+		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: <20261030-bonding-last-rx-v5-1-0b9b653f2f94@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-353821-linux-kernel-netdev=dewy.ru
References: <20261030-bonding-last-rx-v5-0-0b9b653f2f94@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-353821-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 v5 1/2] bonding: fix initial last_rx vs ARP-monitor
 slack window
Date: Fri, 30 Oct 2026 15:51:15 +0100
Organization: Usenet Network
Message-ID: <20261030-bonding-last-rx-v5-1-0b9b653f2f94@well-founded.dev>
References: <20261030-bonding-last-rx-v5-0-0b9b653f2f94@well-founded.dev>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2258901"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:k5A9VplG5y4ZG7bFB1eFnlef8xc= sha256:vXMB7LMjCOApE0RgUWu/2ZphG1JlBIQ4zR04Ct+d+yc=
	sha1:Xw+Xpji6HqW6e8NIZqqbkqTf+UA= sha256:r9U/R0ftGhFRkX4MxgwPwu4BthkXTVz7Kj76M27IZvY=
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 9B816125CA1; Fri, 30 Oct 2026 17:52:41 +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 zS-LMxicqmka;
	Fri, 30 Oct 2026 17:52:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-353821-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id EE04F125CA0; Fri, 30 Oct 2026 17:52:30 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 8A1212B0FE; Fri, 30 Oct 2026 14:51:25 +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=1793371885;
	b=PzmLU9Ir8UmDM6RnB4ICs/cvz+N2W6GHLVwKGxDV5yH587irsEOBUrBKkRBSX2jE51+Z
	 yjnFI6zASDt5Opzz22Wm0FFDYB9xeQOzg9W9Aof5HeWaXJtOp4q5+zzfk6l1QMA5+zboY
	 vaN688U9JPnJb7gfz0nkXLyNmJtfj6g35HGbNGoHq/z1AUwYPCaNuyQJY4TA4dXpg7v9j
	 wXm4gPz7L4ZCYMEOwJtA5xMnl6P5yLGtux+73/WY0N8xFDEkR/TgBEIdtOPO+V9wQ5Bj0
	 HyMrWfL+zEvbPzx+0Pke1c6Juk6gUvxuj8xWPIrDeY3eGehZSoTmhGZHDWCobRki5hw==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793371885;
	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=AOgKJ3hnwzeY3+jNKVK1NEjx8NuNMFS6brj6gyqCvn0=;
	b=HQwVG8kWIfEq7syehfGvdMKH81OcYlqn6puVFWh2pc+cQ4IuVDTzfa+PUWNpsoBNfBmf
	 sh+QUEeSizF+DQhtHgdpx7oiVMdi32l2o77vTrYr3hH78UIU326+TguROF2BudF8MV5p6
	 k2kRLvP+8BJvrzTjGyic36vw5jfWfcIm79Ss0d4MrcJ4NY7y0FnLyZwS5iJFVdOzQfaN6
	 Nv/88XOb70N+dVAB1x+rLRVcfwJ7C2ZYJY4t/kdzVgwgouRPdywGbYc7ala8nZbqwidk0
	 Rhi1f/nh6wKArrCuoz3IZbv1/Y4YQKaU+Bqm6keBbNjeRoLMAh1q7l3fVen3T3tdOFg==
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=PSpJGOUA;
	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 577F0606A323;
	Fri, 30 Oct 2026 14:51:25 +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=PSpJGOUA
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=1793371879;
	b=45M8SgTNpPPN7dkQT4vcDCkDGQp01Dp3qCNNomRSS8ZUQu25uVAdA/hSl6ob8oDFxmBj
	 coz9GJGPEUA/2uUrndIFaVKygEtFkkop3yCzzWcX/ZmnHzo9rm4x5hHUOeLsk6e2hHL2X
	 UENs2jx3BMa7pHeTPselvjt+fEdMSQz7SpTLUjUcMmUGW/cxuWWrrpqfrH9zJR0KNjhyL
	 GGE0aIhSCkp2GHC+7F4Zuj8yKy4P9oifG9QZzQ7qjZkfvM4SbI7QLBfIzFQ91RAsOROtW
	 uOJ/IOGqbJZWyOnfoRYxrk0QW1pyjk+1gLpqfDNV+mQ0Mx9VcKKg9TyTQGfVwyB4cnA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793371879;
	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=AOgKJ3hnwzeY3+jNKVK1NEjx8NuNMFS6brj6gyqCvn0=;
	b=GL/wzglCTEt/awV6+Cb4i7HQaz4xf/yeE4ADrdfGdqBOjq7Muz7mFVKc2km3YKtETp19
	 KunChck4M86D9v7NzQq4hvv18DKyGUX4DDf3YMYlDBpCp356+p7NpCDr7qu4/sFchitLa
	 RUZchJJusv1qt4+WFCzqEitC0ta+kZqMoVvSFZRUSGscPgjxp9v3h830NwYeftj4/azsu
	 R37EG6Rxx7/QUDCQ3/UsnSZKTjRExrl6m0zivGGOB9WChkv7/Lp1saxK25+11cA1rcuGW
	 L/sVO+mVbnpKpZmkY7WZSH1m/LqerspvWOp/yXZleiqwaBhJelItCilZAfFDe8eJ1zQ==
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=PSpJGOUA;
	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 2C1E5606A31F;
	Fri, 30 Oct 2026 14:51:19 +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=1793371878;
	b=YTdFJFVUbqHREL7DaU9Go16iiZqRx8M4KQ0J+JeiJ4rYUoFA2RYZ7GPQkgz5sMj/1TTr
	 D8NVZoI0NuGjZzWCr5jr34Ede0nbo+w2VQ8AdLo+cl48eFiJ4zi9UqcnBU23xl6pudUMp
	 RZx8AVFtwJsiewQ4na/ISFBZUiU0tSL0D8tJj9B6W5pjAeAHMk5PsKgcY3YBqGcLNYWar
	 HR0EOtv7oNftoMbR79XCharcC1U6WPXOsu0YowjyhFlpnkh7rWuYoiqKQlIuUF2sFUDZY
	 7rBAYkyvnQqC/qVhFaC1j9xErrqul7DDV+hCS4JWnHM62Go+CJs99q6MmU4Nfx6eTxA==
X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256;
	c=relaxed/relaxed; t=1793371878;
	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=AOgKJ3hnwzeY3+jNKVK1NEjx8NuNMFS6brj6gyqCvn0=;
	b=Vpm3kqc9O6Qo4qw37qycZWtgjbioiMRJUxcSw6B0Dead23igqKITL7JSj3Pdy1PzKgtS
	 RZwtcTT1UyK+1e4NiNDPO51AfZEvlvBhfOdjmhdDwmRhaY9AaV351BUWMFkd877v8UxHH
	 pGsxVsoi676dk/m62iBngV8jmoWeCoewgCMb1P+mCAImBkwjFGHyY36wIN6jEQq6ri6xR
	 poKBycymitplwhEQEnJ3wrx3rlD568B6tUQW7GYtkBJHqpWfVYtgvWPjGzb3PsZx17bZG
	 p0WDwLCZV21LHfEIoqJzxW54to/0Yo7kWPI7Tox4OzCWVaMT6XNtPAMkRmvI8dkvWNQ==
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 D17CC1F00A02;
	Fri, 30 Oct 2026 14:51:17 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1793371878;
	bh=AOgKJ3hnwzeY3+jNKVK1NEjx8NuNMFS6brj6gyqCvn0=;
	h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To;
	b=PSpJGOUA8FlWKlhZn5wHJA+clpNxc+NHYgCZU+6PaoYbfYlZA4r/Es9Re4l8zXHRv
	 +veQvMfG5jYryARNiCMEyJmF+bQ9uNbnZaoLdOxOuozvzloVzpqF1wj+9N8ALsX5R/
	 zcy9/8xYlClnzv0TEmAwybija1+Vu1mpq1ErHeFYXdL9kQ+tvDG5s6iOJVBlpHOK1A
	 V6Ocz+e3Aw/G5UlHhvVye52B7/JleAy6+rP22F37XBYR7QJ8WDA12FEjGosK8cW4J4
	 WPQtpsRkcqXzulbbTV/mOZs7juL9FY1fD2euOgWrqQsiVuCUCVRXtRn5YoHLLRVBfs
	 YAaOECycz3I+g==
X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1])
	by lkml.kernel.org (Postfix) with ESMTP id 4CAEB437EB;
	Fri, 30 Oct 2026 14:51:17 +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: <20261030-bonding-last-rx-v5-0-0b9b653f2f94@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>, 
 Hangbin Liu <liuhangbin@kylinos.cn>
X-Mailer: b4 0.15.2
X-Developer-Signature: v=1; a=ed25519-sha256; t=1793371876; l=4064;
 i=ramses@well-founded.dev; s=20260817; h=from:subject:message-id;
 bh=9c6Pugc3oHAUY5z5+KeFXjevrZwDeEo26HSsv07oE+o=;
 b=fX9IIktJKWRmAE5dl9+jG4WB/pqWL8pQi14+evrodqwCjGehZdYU5IixUuGD/g6AFo6ilRo/B
 tUzrxsjA/PAAQLgxP5BGg017OzZ3no88Guws0fjBh4y9P/NEINtcNZu
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