From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 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== 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== ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 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) 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== 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) From: Ramses de Norre via B4 Relay Date: Fri, 30 Oct 2026 15:51:15 +0100 Subject: [PATCH net v5 1/2] bonding: fix initial last_rx vs ARP-monitor slack window 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 Content-Type: text/plain; charset="utf-8" Message-Id: <20261030-bonding-last-rx-v5-1-0b9b653f2f94@well-founded.dev> References: <20261030-bonding-last-rx-v5-0-0b9b653f2f94@well-founded.dev> In-Reply-To: <20261030-bonding-last-rx-v5-0-0b9b653f2f94@well-founded.dev> To: Jay Vosburgh , Andrew Lunn , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Jiri Bohac , Eric Dumazet Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nikolay Aleksandrov , Hangbin Liu , Ramses de Norre , Hangbin Liu 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 Reply-To: ramses@well-founded.dev Content-Transfer-Encoding: 7bit From: Ramses de Norre 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 Signed-off-by: Ramses de Norre --- 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