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=1796311675; b=O0TlLglBt/EGGnMIZUOKXGdqy1haU2LZbvmq3CbKCrD11jUJ+PoUQ4zzZ6JcAxj90U8V qjWtDdDbJViPivm5rcIRar9DHaWZMgZQhQJGWfMw0sJ6Vj8iM/Pxipgqe/FLc+G00r8R/ PL+GmuJoebR+A1s9joccCOFUnFNgGIDwj4V0vwcPKTOcLzE7GpPt4Q1OMXYs06TjIy5O1 U9ITAiVeQcFdF9X/eFbvBHuNc4OLiyfmbvteSS4wMSqBjxpfO/0XyD6LMmssmYzbkzBUD jnCj793lX0HpT5A2nmQg0W9vWXnILFRvvqL/EaG5IQC38PwgiAg5OVly6T12DTWPJtw== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796311675; 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=PTARFkpFi1MSXmzJdK7GKERlWY42Ddg7IesSoTvqZ3Y=; b=3ghh6vfBmLYLUcnejXqDN17NcI/Gk+tGSQZK97Z4VNZturEyRm1zmG4w/sKLibfkEy+k ulKJmY3j147s4xdplbyYY6FA9dgezoU65XZmuzfgrEjAR8Ha/lWndp/6ZI+VTePwtQcPY eS9wSNAlyXddQUAQ+PU2+cFejBBGq3EUzYBq5sl2XA+vb040Kc/GD0eK5dTS0g7Q8zV/y Q/DSYRffbH9ay2T8m+Ln8OpxRPT/oq62SUCQvhQpjI9eCNKGCd5eL+OWYoLYsAVyscVDy 9T2NkbMCrtMgzfZy8wWhqnbbvllzMAqT5RCR6uQavLO+Dg6Mxm+mA5ilHXngzUsJFFw== 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=PYJW6sZu; 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 69B05606A682; Thu, 3 Dec 2026 15:27:55 +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=PYJW6sZu 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=1796311674; b=xEDbXpuEiqO+XNYCupReNSSiI64+AmDegdSz6VnougswGzxVSY4TUN+peFSg39ZA3zAT QxPJMfXDMjzV5xWxN7+lv7ZYfHVkKXSn2EmF+gxGEY1ZxW6FORcG3DCdHD4ZJ2lCYw2vx 3kfksu9GJyDC+CwSD5JBbQO6F9UF7U4a5+FU6PDPuDJzwq299zZa/gt/Y+eHHJE4ecAqW OOn8F5biWgvZVNlnEL9C4JJEKp09Z4PWvybOZHn1/CbT7dCuN2qOo5snENV7QfO8Ki98c st08Yg20Gj5LxZ6AwIhMVRLZ1zBxGnKUyeJa+Xy5zsi6dyeDuV9h8FxAW+eemz0w7Qw== ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1796311674; 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=PTARFkpFi1MSXmzJdK7GKERlWY42Ddg7IesSoTvqZ3Y=; b=hZFuPWCv4xSbLliiBmw1VVR2cyWrd29yIoxY0sfHPMMZfryB4Ur7h98JGDySkIp1TNWn YpnV4d2tHSnzErrtEe49SFpW2XSrEB41gH1UMOati0hVO0r4VX42usQn1+0IAee3Brf5V 6C3EEjXZn7//1RJ/dOkNvZdnQG/0ttrW6fXkpmxk2AiPREW6R+H8w7HGuB2RCUQukBb1y KF4bHzzmRmwBPlm4BgEDEGwvsbZN6793VWMZkRQZ6FjvC+YiduSkc4pordo86KrAKbhzb a1z8HUmEywGeL9cqXEYG1ylhWGSYNvzijpQ1YE84HFKRmjBOIsXbrUKehixAGGGf0pg== 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 B443F1F00896; Thu, 3 Dec 2026 15:27:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796311674; bh=PTARFkpFi1MSXmzJdK7GKERlWY42Ddg7IesSoTvqZ3Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=PYJW6sZuQoC8X8foZMI38gQRl5l/2ECA4ifruYLK3B1XKI9M6JRIW3diZjsdfHk6E 2BRGmOiU/vzeyu5CUGcdItN24d283ODDUh99VrhvkS8JJWR0x6oOS6UJYm+QHojgsj RASpj0vLh4d/LD18yiYjIoCzg3iKssHhCV66riFOl7YIwDm9sQtHAWpT7ZKJLXZEno hZwEVr4NxWh/vcyT54E9cY8o4R4TIMD5D5euOoCor64uiN/3P5RdSGvy28KOohUDRh vdqD3hRFqdgplnHY/F7VPwaA2OOTyll8mDv7PebIAQztiddqH5E48awGioqCQZYlBG QjZQSe6tmn7hA== Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 4782B4FA01; Thu, 3 Dec 2026 15:27:44 +0000 (UTC) From: Ramses de Norre via B4 Relay Date: Thu, 03 Dec 2026 17:27:43 +0200 Subject: [PATCH net-next v2 2/2] selftests: bonding: test that the ARP monitor keeps UP slaves when it starts 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: <20261203-bonding-arp-reseed-v2-2-de49c2a3bb1e@well-founded.dev> References: <20261203-bonding-arp-reseed-v2-0-de49c2a3bb1e@well-founded.dev> In-Reply-To: <20261203-bonding-arp-reseed-v2-0-de49c2a3bb1e@well-founded.dev> To: Jay Vosburgh , Andrew Lunn , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Jiri Bohac , Eric Dumazet , Willem de Bruijn , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Nikolay Aleksandrov , Hangbin Liu , Shuah Khan , Ramses de Norre X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1796311662; l=5451; i=ramses@well-founded.dev; s=20260817; h=from:subject:message-id; bh=7dWA9yESpkjuVzausMOsESdvlFB+GkdTkgoWFM572Qc=; b=GyjF5JBmlTNIwvh7qk6X2iEtbzgtCNREmbaTgxPvMlw7M6Coxx+0gVz7yP0WY9nVTkKREjKyx joae+sHJbAmCGHMj1Zd6Q03HkUu10u4bgUsqhGoASBxhJcS8GVT+CmV 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 Add a test for the two ways the ARP monitor can start after the slaves were enslaved: bringing the bond up after enslaving into it while it is down, and setting arp_interval on a running bond that uses miimon. In both cases the test waits longer than the arp_missed_max window before the monitor starts, and checks that the primary stays active and that no slave gets a link failure. Without the previous patch, both cases fail: the first monitor run takes both slaves down and the bond comes back on eth1, where it stays with primary_reselect=failure. Signed-off-by: Ramses de Norre --- .../testing/selftests/drivers/net/bonding/Makefile | 1 + .../drivers/net/bonding/bond_arp_monitor_start.sh | 151 +++++++++++++++++++++ 2 files changed, 152 insertions(+) diff --git a/tools/testing/selftests/drivers/net/bonding/Makefile b/tools/testing/selftests/drivers/net/bonding/Makefile index 46d9fede59185..12276c942506e 100644 --- a/tools/testing/selftests/drivers/net/bonding/Makefile +++ b/tools/testing/selftests/drivers/net/bonding/Makefile @@ -6,6 +6,7 @@ TEST_PROGS := \ bond-break-lacpdu-tx.sh \ bond-eth-type-change.sh \ bond-lladdr-target.sh \ + bond_arp_monitor_start.sh \ bond_ipsec_offload.sh \ bond_lacp_independent_control.sh \ bond_lacp_prio.sh \ diff --git a/tools/testing/selftests/drivers/net/bonding/bond_arp_monitor_start.sh b/tools/testing/selftests/drivers/net/bonding/bond_arp_monitor_start.sh new file mode 100755 index 0000000000000..248d7279a3ced --- /dev/null +++ b/tools/testing/selftests/drivers/net/bonding/bond_arp_monitor_start.sh @@ -0,0 +1,151 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 +# +# Check that the ARP monitor does not take UP slaves down when it starts +# after the slaves were enslaved. That happens when the slaves are enslaved +# while the bond is down, or when arp_interval is set on a running bond +# that used miimon. The monitor must give the slaves a full arp_missed_max +# window from when it starts, not from when they were enslaved. +# +# +------------------------+ +# | bond0 192.0.2.1/24 | h_ns +# | eth0 eth1 | +# +---+-------------+------+ +# | | +# +---+-------------+------+ +# | sw0 sw1 | sw_ns +# | br0 192.0.2.254/24 | +# +------------------------+ + +# shellcheck disable=SC2034,SC2329 +ALL_TESTS=" + arp_monitor_start_on_open + arp_monitor_start_on_interval_set +" +lib_dir=$(dirname "$0") +# shellcheck disable=SC1091 +source "$lib_dir"/../../../net/lib.sh + +require_command jq + +# Assigned by setup_ns. +h_ns="" +sw_ns="" + +ARP_INTERVAL=100 +# Longer than the arp_missed_max window of the slaves, so that their +# enslave time seeds are stale when the monitor starts. +ENSLAVE_WAIT=1 +# Let the monitor run several times before checking the slaves. +MONITOR_WAIT=1 + +setup_prepare() +{ + setup_ns h_ns sw_ns + defer cleanup_ns "$h_ns" "$sw_ns" + + ip -n "$sw_ns" link add br0 type bridge + ip -n "$sw_ns" link set br0 up + ip -n "$sw_ns" addr add 192.0.2.254/24 dev br0 + + for i in 0 1; do + ip -n "$h_ns" link add "eth$i" type veth \ + peer name "sw$i" netns "$sw_ns" + ip -n "$sw_ns" link set "sw$i" master br0 + ip -n "$sw_ns" link set "sw$i" up + done +} + +bond_create() +{ + ip -n "$h_ns" link add bond0 type bond mode active-backup \ + primary eth0 primary_reselect failure \ + arp_ip_target 192.0.2.254 "$@" + defer ip -n "$h_ns" link del bond0 + ip -n "$h_ns" addr add 192.0.2.1/24 dev bond0 +} + +bond_enslave() +{ + ip -n "$h_ns" link set eth0 master bond0 + ip -n "$h_ns" link set eth1 master bond0 +} + +active_slave_get() +{ + ip -n "$h_ns" -d -j link show bond0 | \ + jq -r '.[].linkinfo.info_data.active_slave' +} + +link_failures_get() +{ + local dev=$1; shift + + ip -n "$h_ns" -d -j link show "$dev" | \ + jq '.[].linkinfo.info_slave_data.link_failure_count' +} + +active_slave_is() +{ + [[ $(active_slave_get) == "$1" ]] +} + +slaves_check() +{ + local dev + + slowwait 5 active_slave_is eth0 + check_err $? "eth0 did not become the active slave" + + sleep "$MONITOR_WAIT" + + active_slave_is eth0 + check_err $? "eth0 is no longer the active slave" + for dev in eth0 eth1; do + [[ $(link_failures_get "$dev") == 0 ]] + check_err $? "$dev went down when the ARP monitor started" + done +} + +arp_monitor_start_on_open() +{ + RET=0 + + bond_create arp_interval "$ARP_INTERVAL" arp_validate all + bond_enslave + sleep "$ENSLAVE_WAIT" + ip -n "$h_ns" link set bond0 up + + slaves_check + + log_test "ARP monitor started by bringing the bond up" +} + +arp_monitor_start_on_interval_set() +{ + RET=0 + + bond_create miimon 100 + ip -n "$h_ns" link set bond0 up + bond_enslave + slowwait 5 active_slave_is eth0 + check_err $? "eth0 did not become the active slave with miimon" + sleep "$ENSLAVE_WAIT" + # bond_changelink() rejects arp_validate and miimon in one request, + # so arp_validate is set here and not in bond_create. + ip -n "$h_ns" link set bond0 type bond arp_interval "$ARP_INTERVAL" \ + arp_validate all + check_err $? "Failed to switch to the ARP monitor" + + slaves_check + + log_test "ARP monitor started by setting arp_interval" +} + +trap defer_scopes_cleanup EXIT + +setup_prepare + +tests_run + +exit "$EXIT_STATUS" -- 2.56.1