From: Ido Schimmel <idosch@nvidia.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@kernel.org, jv@jvosburgh.net, andrew+netdev@lunn.ch,
petrm@nvidia.com, sridhar.samudrala@intel.com, jiri@resnulli.us,
horms@kernel.org, shuah@kernel.org,
linux-kselftest@vger.kernel.org, razor@blackwall.org,
Ido Schimmel <idosch@nvidia.com>
Subject: [PATCH net-next 6/6] selftests: bonding: Test that Collecting is advertised after notification
Date: Wed, 18 Nov 2026 10:34:42 +0200 [thread overview]
Message-ID: <20261118083442.1061289-7-idosch@nvidia.com> (raw)
In-Reply-To: <20261118083442.1061289-1-idosch@nvidia.com>
Test that with coupled control disabled, a port only advertises the
Collecting bit after a notification about its Rx state change was
emitted.
Use a slow LACP rate on the partner so that the port only transmits
periodic LACPDUs every 30 seconds and is therefore not rate limited when
entering COLLECTING state.
Output without "bonding: 3ad: Advertise Collecting only after collection
is enabled":
# ./bond_lacp_independent_control.sh
TEST: Receive in COLLECTING state [ OK ]
TEST: Notifications in COLLECTING state [ OK ]
TEST: Collecting advertised after notification [FAIL]
Collecting bit advertised before notification
TEST: Ping in DISTRIBUTING state [ OK ]
Output with the fix:
# ./bond_lacp_independent_control.sh
TEST: Receive in COLLECTING state [ OK ]
TEST: Notifications in COLLECTING state [ OK ]
TEST: Collecting advertised after notification [ OK ]
TEST: Ping in DISTRIBUTING state [ OK ]
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
Notes:
The test compares a user space timestamp (ip monitor) with a kernel
timestamp (tcpdump). This cannot hide a bug since a delay in ip can only
make the notification appear later. A false failure requires ip to stall
for longer than the gap between the notification and the LACPDU, which
is at least one state machine tick (100 ms). Did not observe such a
failure with normal or debug kernels.
.../bonding/bond_lacp_independent_control.sh | 53 ++++++++++++++++++-
1 file changed, 51 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh b/tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh
index a2b83b581e40..b86f39f31d0c 100755
--- a/tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh
+++ b/tools/testing/selftests/drivers/net/bonding/bond_lacp_independent_control.sh
@@ -4,7 +4,7 @@
# +-------------------------+ +-------------------------+
# | H1 (vrf) | | H2 (vrf) |
# | + bond1 (802.3ad) | | + bond2 (802.3ad) |
-# | | coupled_control off | | | |
+# | | coupled_control off | | | lacp_rate slow |
# | | 192.0.2.1/28 | | | 192.0.2.2/28 |
# | | | | | |
# | + $h1 | | + $h2 |
@@ -16,6 +16,7 @@
ALL_TESTS="
collecting
collecting_notify
+ collecting_advertise
distributing
"
NUM_NETIFS=2
@@ -24,6 +25,8 @@ lib_dir=$(dirname "$0")
# shellcheck disable=SC1091
source "$lib_dir"/../../../net/forwarding/lib.sh
+require_command tcpdump
+
lacp_state_get()
{
local dev=$1; shift
@@ -75,7 +78,9 @@ h1_create()
h2_create()
{
- adf_ip_link_add bond2 type bond mode 802.3ad lacp_rate fast
+ # Slow rate makes $h1 transmit periodic LACPDUs every 30 seconds, so
+ # that it is not rate limited when entering COLLECTING state.
+ adf_ip_link_add bond2 type bond mode 802.3ad lacp_rate slow
adf_ip_link_set_master "$h2" bond2
adf_simple_if_init bond2 192.0.2.2/28
}
@@ -162,6 +167,50 @@ collecting_notify()
log_test "Notifications in COLLECTING state"
}
+collecting_advertise()
+{
+ local lacpdu_ts notify_ts tmp_dir
+
+ RET=0
+
+ partner_state_clear 0x18
+ defer tc filter del dev "$h1" ingress pref 1 handle 101 flower
+ lacp_state_wait "$h1" 0x0f
+ check_err $? "Port did not reach ATTACHED state"
+
+ tmp_dir=$(mktemp -d)
+ defer rm -rf "$tmp_dir"
+ ip -ts -o -d monitor link dev "$h1" > "$tmp_dir"/notify &
+ defer kill_process $!
+ # Capture transmitted LACPDUs with the Collecting (0x10) bit set in
+ # the actor state.
+ tcpdump -tt -n -l -p -Q out -i "$h1" \
+ "ether proto 0x8809 and ether[32] & 0x10 != 0" \
+ > "$tmp_dir"/lacpdu 2> /dev/null &
+ defer kill_process $!
+ sleep 1
+
+ partner_state_clear 0x10
+ lacp_state_wait "$h1" 0x1f
+ check_err $? "Port did not reach COLLECTING state"
+
+ slowwait "$WAIT_TIMEOUT" grep -qw \
+ "ad_actor_oper_port_state $((0x1f))" "$tmp_dir"/notify
+ check_err $? "No notification upon entering COLLECTING state"
+
+ slowwait "$WAIT_TIMEOUT" grep -q . "$tmp_dir"/lacpdu
+ check_err $? "Collecting bit not advertised"
+
+ notify_ts=$(grep -m1 -w "ad_actor_oper_port_state $((0x1f))" \
+ "$tmp_dir"/notify | sed 's/^\[\([^]]*\)\].*/\1/')
+ notify_ts=$(date -d "$notify_ts" +%s%6N)
+ lacpdu_ts=$(head -n1 "$tmp_dir"/lacpdu | cut -d' ' -f1 | tr -d .)
+ ((lacpdu_ts > notify_ts))
+ check_err $? "Collecting bit advertised before notification"
+
+ log_test "Collecting advertised after notification"
+}
+
distributing()
{
RET=0
--
2.56.0
prev parent reply other threads:[~2026-11-18 8:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 8:34 [PATCH net-next 0/6] bonding: 3ad: Support independent control with LAG offload Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 1/6] net: Add Rx enabled state to LAG lower state information Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 2/6] bonding: 3ad: Notify Rx state changes Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 3/6] mlxsw: Enable LAG collector independently of distributor Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 4/6] selftests: bonding: Test notifications in COLLECTING state Ido Schimmel
2026-11-18 8:34 ` [PATCH net-next 5/6] bonding: 3ad: Advertise Collecting only after collection is enabled Ido Schimmel
2026-11-18 8:34 ` Ido Schimmel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118083442.1061289-7-idosch@nvidia.com \
--to=idosch@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=jv@jvosburgh.net \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=razor@blackwall.org \
--cc=shuah@kernel.org \
--cc=sridhar.samudrala@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox