From nobody Wed Apr 1 23:51:47 2026 Received: from mail-dl1-f74.google.com (mail-dl1-f74.google.com [74.125.82.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70BF033CE86 for ; Wed, 1 Apr 2026 06:05:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775023574; cv=none; b=rQLRb/m/aEkkp8qiz+UxqBOfNJVseeNG4vII6d7ALW7SrUVzANNzls6kNxJYQZUPeHbwV2vP7+JWRHwzsw9Uht8pFslDgssw3gUaQ8eCkU0upc+PotMcQ8ejQ76rI+vTvAe3a4aG4dUubcXjANsFSDZhMIJnTyCfWpPn1hKYzo4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775023574; c=relaxed/simple; bh=SNQ1cmqwfV4BJUqdUAYMRXrGB4q7HaXoF31Jr1PbFFg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=poQWXId2CMlcZkIpU8mYkhF2+pqxP90fjf2W9TA/2WI6LpO8nMRZ2gY8s6na95iU9SZ7GrQF3MqYUbZv0pSa/Z77Sa3yEtka5r2MuGUcv78vK7tKejy3rGMzCuBPse8UZQOcg+ELeJbYzjmf0Yb5v/yNh0zpCqbtlgpPalllw9U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=P4KbVmhZ; arc=none smtp.client-ip=74.125.82.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--marcharvey.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="P4KbVmhZ" Received: by mail-dl1-f74.google.com with SMTP id a92af1059eb24-1273dfdaf5dso734221c88.0 for ; Tue, 31 Mar 2026 23:05:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1775023552; x=1775628352; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=9rAh4dSy2ASJ+eS7NIHZm1n3v2Lo++pBg2O5GJueRGQ=; b=P4KbVmhZZ4geQcU9MeKts/7NBJBYZquMiGrNbczYNokj0LyVJI8BCbJ1q9j4RWWbt/ 0HowFlEeqaR+2nLgaCY74N2NC1Ot3rGhKNME1mazDMpt0AfEH9K9ndZGaryQw/RIfnoJ e+LnavskaLjo7i9vHVOYdN6W3HF3OUOErDYP+2m/4HFf6uRNY1RWWgN/uDlHeBAzLJQ/ 78CG3dffbFzogz4LnY4pZ04/LFDH8/T6d2eE6RaEhVaLlI9v39zyGcbjmvlSes6e2f7I JGChMw/DjMhnxdk9umM37GI9ohk3Km6zJz60cIKxEBt4d5xyXtdTSSfdjuKHsf6V4fYc oC1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775023552; x=1775628352; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9rAh4dSy2ASJ+eS7NIHZm1n3v2Lo++pBg2O5GJueRGQ=; b=ffsvG5caGXmBVtz4ipUX8oL0qFwgSJXtQAQI4+4U1fG1BsZxC+/EEf1jABIPQsAc9A S9790hTjsYc6WHKQHdGToyNqMOo+p0+2Mdomd90v4nTmQb18RMkKTkMZ37d++WjTnddU wvF1SSHwcwODv0Cb1AuQRYqLS3pmtPyKpX646uWw/1Em9c/j+7wkiSkBus+aYXtb0eUA +YMgeJqc9WTLlUi6qb3MOQIuwpl46USxpCeGHCRPrVocu6pMd6qwKLDEw4kiHdZsGQ7g 2v9ft1rsreI5ewBxGcibn3a2fUAQy7Oh2GxxbsyGzQCZwESs3D+RAHNQ1LcY8bZDz5KF B//A== X-Forwarded-Encrypted: i=1; AJvYcCWW1xLmdcwzb6bT4LDCEeyZFjuJl/S0toUExsmb0Jz5n80qdPta9FO6me6jM+15LXRAOpDqWnuBSMUp4/c=@vger.kernel.org X-Gm-Message-State: AOJu0Ywotwo+bBPcB8h809lyPn8djq+8h8bPH3ASKVRCuIDn7QBX4J6W ZKMrd4L51IdiBKHTyFDmDL8pain0wffw/MnisqM4b5367ENrVYKD1UmUrTGGJLbNRMnC0nkPisQ wPKf0N3rF3xbcCatR+zWUOw== X-Received: from dycoi4.prod.google.com ([2002:a05:7301:da84:b0:2be:7cd3:c97c]) (user=marcharvey job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:3885:b0:123:331f:978f with SMTP id a92af1059eb24-12bdde380b8mr2708266c88.7.1775023551371; Tue, 31 Mar 2026 23:05:51 -0700 (PDT) Date: Wed, 01 Apr 2026 06:05:31 +0000 In-Reply-To: <20260401-teaming-driver-internal-v2-0-f80c1291727b@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260401-teaming-driver-internal-v2-0-f80c1291727b@google.com> X-Developer-Key: i=marcharvey@google.com; a=ed25519; pk=OzOeciadbfF5Bug/4/hyEAwfrruSY4tn0Q0LocyYUL0= X-Developer-Signature: v=1; a=ed25519-sha256; t=1775023538; l=12844; i=marcharvey@google.com; s=20260401; h=from:subject:message-id; bh=SNQ1cmqwfV4BJUqdUAYMRXrGB4q7HaXoF31Jr1PbFFg=; b=LlIkWEeKp5MFyuL3jbSSN/YEWhINfulOKg4sOZ2Dmg2sc7A+NyjxOyCnKcTm/8AGvyGdJ8pR2 YhTpwast84BDHC6RNwEgO5hJYFJFkxOfMmguheLPwcUMuncckTpwcXo X-Mailer: b4 0.14.3 Message-ID: <20260401-teaming-driver-internal-v2-7-f80c1291727b@google.com> Subject: [PATCH net-next v2 7/7] selftests: net: Add tests for team driver decoupled tx and rx control From: Marc Harvey To: Jiri Pirko , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Marc Harvey Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Use ping and tcpdump to verify that independent rx and tx enablement of team driver member interfaces works as intended. Signed-off-by: Marc Harvey --- Changes in v2: - Fixe shellcheck failures. - Link to v1: https://lore.kernel.org/all/20260331053353.2504254-8-marcha= rvey@google.com/ --- tools/testing/selftests/drivers/net/team/Makefile | 1 + .../drivers/net/team/decoupled_enablement.sh | 249 +++++++++++++++++= ++++ .../testing/selftests/drivers/net/team/options.sh | 99 +++++++- 3 files changed, 348 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/drivers/net/team/Makefile b/tools/test= ing/selftests/drivers/net/team/Makefile index dab922d7f83d..7c58cf82121e 100644 --- a/tools/testing/selftests/drivers/net/team/Makefile +++ b/tools/testing/selftests/drivers/net/team/Makefile @@ -2,6 +2,7 @@ # Makefile for net selftests =20 TEST_PROGS :=3D \ + decoupled_enablement.sh \ dev_addr_lists.sh \ non_ether_header_ops.sh \ options.sh \ diff --git a/tools/testing/selftests/drivers/net/team/decoupled_enablement.= sh b/tools/testing/selftests/drivers/net/team/decoupled_enablement.sh new file mode 100755 index 000000000000..e2944af02d57 --- /dev/null +++ b/tools/testing/selftests/drivers/net/team/decoupled_enablement.sh @@ -0,0 +1,249 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# These tests verify the decoupled RX and TX enablement of team driver mem= ber +# interfaces. +# +# Topology +# +# +---------------------+ NS1 +# | test_team1 | +# | | | +# | eth0 | +# | | | +# | | | +# +---------------------+ +# | +# +---------------------+ NS2 +# | | | +# | | | +# | eth0 | +# | | | +# | test_team2 | +# +---------------------+ + +export ALL_TESTS=3D" + team_test_tx_enablement + team_test_rx_enablement +" + +test_dir=3D"$(dirname "$0")" +# shellcheck disable=3DSC1091 +source "${test_dir}/../../../net/lib.sh" +# shellcheck disable=3DSC1091 +source "${test_dir}/team_lib.sh" + +NS1=3D"" +NS2=3D"" +export NODAD=3D"nodad" +PREFIX_LENGTH=3D"64" +NS1_IP=3D"fd00::1" +NS2_IP=3D"fd00::2" +NS1_IP4=3D"192.168.0.1" +NS2_IP4=3D"192.168.0.2" +MEMBERS=3D("eth0") +PING_COUNT=3D5 +PING_TIMEOUT_S=3D1 +PING_INTERVAL=3D0.1 + +while getopts "4" opt; do + case $opt in + 4) + echo "IPv4 mode selected." + export NODAD=3D + PREFIX_LENGTH=3D"24" + NS1_IP=3D"${NS1_IP4}" + NS2_IP=3D"${NS2_IP4}" + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + exit 1 + ;; + esac +done + +# This has to be sourced after opts are gathered... +export REQUIRE_MZ=3Dno +export NUM_NETIFS=3D0 +# shellcheck disable=3DSC1091 +source "${test_dir}/../../../net/forwarding/lib.sh" + +# Create the network namespaces, veth pair, and team devices in the specif= ied +# mode. +# Globals: +# RET - Used by test infra, set by `check_err` functions. +# Arguments: +# mode - The team driver mode to use for the team devices. +environment_create() +{ + trap cleanup_all_ns EXIT + setup_ns ns1 ns2 + NS1=3D"${NS_LIST[0]}" + NS2=3D"${NS_LIST[1]}" + + # Create the interfaces. + ip -n "${NS1}" link add eth0 type veth peer name eth0 netns "${NS2}" + ip -n "${NS1}" link add test_team1 type team + ip -n "${NS2}" link add test_team2 type team + + # Set up the receiving network namespace's team interface. + setup_team "${NS2}" test_team2 roundrobin "${NS2_IP}" \ + "${PREFIX_LENGTH}" "${MEMBERS[@]}" +} + +# Set a particular option value for team or team port. +# Arguments: +# namespace - The namespace name that has the team. +# option_name - The option name to set. +# option_value - The value to set the option to. +# team_name - The name of team to set the option for. +# member_name - The (optional) optional name of the member port. +set_option_value() +{ + local namespace=3D"$1" + local option_name=3D"$2" + local option_value=3D"$3" + local team_name=3D"$4" + local member_name=3D"$5" + local port_flag=3D"--port=3D${member_name}" + + ip netns exec "${namespace}" teamnl "${team_name}" setoption \ + "${option_name}" "${option_value}" "${port_flag}" + return $? +} + +# Send some pings and return the ping command return value. +try_ping() +{ + ip netns exec "${NS1}" ping -i "${PING_INTERVAL}" -c "${PING_COUNT}" \ + "${NS2_IP}" -W "${PING_TIMEOUT_S}" +} + +# Checks tcpdump output from net/forwarding lib, and checks if there are a= ny +# ICMP(4 or 6) packets. +# Arguments: +# interface - The interface name to search for. +# ip_address - The destination IP address (4 or 6) to search for. +did_interface_receive_icmp() +{ + local interface=3D"$1" + local ip_address=3D"$2" + local packet_count + + packet_count=3D$(tcpdump_show "$interface" | grep -c \ + "> ${ip_address}: ICMP") + echo "Packet count for ${interface} was ${packet_count}" + + if [[ "$packet_count" -gt 0 ]]; then + true + else + false + fi +} + +# Test JUST tx enablement with a given mode. +# Globals: +# RET - Used by test infra, set by `check_err` functions. +# Arguments: +# mode - The mode to set the team interfaces to. +team_test_mode_tx_enablement() +{ + local mode=3D"$1" + export RET=3D0 + + # Set up the sender team with the correct mode. + setup_team "${NS1}" test_team1 "${mode}" "${NS1_IP}" \ + "${PREFIX_LENGTH}" "${MEMBERS[@]}" + check_err $? "Failed to set up sender team" + + ### Scenario 1: Member interface initially enabled. + # Expect ping to pass + try_ping + check_err $? "Ping failed when TX enabled" + + ### Scenario 2: Once tx-side interface disabled. + # Expect ping to fail. + set_option_value "${NS1}" tx_enabled false test_team1 eth0 + check_err $? "Failed to disable TX" + tcpdump_start eth0 "${NS2}" + try_ping + check_fail $? "Ping succeeded when TX disabled" + tcpdump_stop eth0 + # Expect no packets to be transmitted, since TX is disabled. + did_interface_receive_icmp eth0 "${NS2_IP}" + check_fail $? "eth0 IS transmitting when TX disabled" + tcpdump_cleanup eth0 + + ### Scenario 3: The interface has tx re-enabled. + # Expect ping to pass. + set_option_value "${NS1}" tx_enabled true test_team1 eth0 + check_err $? "Failed to reenable TX" + try_ping + check_err $? "Ping failed when TX reenabled" + + log_test "TX failover of '${mode}' test" +} + +# Test JUST rx enablement with a given mode. +# Globals: +# RET - Used by test infra, set by `check_err` functions. +# Arguments: +# mode - The mode to set the team interfaces to. +team_test_mode_rx_enablement() +{ + local mode=3D"$1" + export RET=3D0 + + # Set up the sender team with the correct mode. + setup_team "${NS1}" test_team1 "${mode}" "${NS1_IP}" \ + "${PREFIX_LENGTH}" "${MEMBERS[@]}" + check_err $? "Failed to set up sender team" + + ### Scenario 1: Member interface initially enabled. + # Expect ping to pass + try_ping + check_err $? "Ping failed when RX enabled" + + ### Scenario 2: Once rx-side interface disabled. + # Expect ping to fail. + set_option_value "${NS1}" rx_enabled false test_team1 eth0 + check_err $? "Failed to disable RX" + tcpdump_start eth0 "${NS2}" + try_ping + check_fail $? "Ping succeeded when RX disabled" + tcpdump_stop eth0 + # Expect packets to be transmitted, since only RX is disabled. + did_interface_receive_icmp eth0 "${NS2_IP}" + check_err $? "eth0 not transmitting when RX disabled" + tcpdump_cleanup eth0 + + ### Scenario 3: The interface has rx re-enabled. + # Expect ping to pass. + set_option_value "${NS1}" rx_enabled true test_team1 eth0 + check_err $? "Failed to reenable RX" + try_ping + check_err $? "Ping failed when RX reenabled" + + log_test "RX failover of '${mode}' test" +} + +team_test_tx_enablement() +{ + team_test_mode_tx_enablement broadcast + team_test_mode_tx_enablement roundrobin + team_test_mode_tx_enablement random +} + +team_test_rx_enablement() +{ + team_test_mode_rx_enablement broadcast + team_test_mode_rx_enablement roundrobin + team_test_mode_rx_enablement random +} + +require_command teamnl +require_command tcpdump +require_command ping +environment_create +tests_run +exit "${EXIT_STATUS}" diff --git a/tools/testing/selftests/drivers/net/team/options.sh b/tools/te= sting/selftests/drivers/net/team/options.sh index 44888f32b513..c87cf998a427 100755 --- a/tools/testing/selftests/drivers/net/team/options.sh +++ b/tools/testing/selftests/drivers/net/team/options.sh @@ -11,10 +11,14 @@ if [[ $# -eq 0 ]]; then exit $? fi =20 -ALL_TESTS=3D" +export ALL_TESTS=3D" team_test_options + team_test_enabled_implicit_changes + team_test_rx_enabled_implicit_changes + team_test_tx_enabled_implicit_changes " =20 +# shellcheck disable=3DSC1091 source "${test_dir}/../../../net/lib.sh" =20 TEAM_PORT=3D"team0" @@ -176,12 +180,105 @@ team_test_options() team_test_option mcast_rejoin_count 0 5 team_test_option mcast_rejoin_interval 0 5 team_test_option enabled true false "${MEMBER_PORT}" + team_test_option rx_enabled true false "${MEMBER_PORT}" + team_test_option tx_enabled true false "${MEMBER_PORT}" team_test_option user_linkup true false "${MEMBER_PORT}" team_test_option user_linkup_enabled true false "${MEMBER_PORT}" team_test_option priority 10 20 "${MEMBER_PORT}" team_test_option queue_id 0 1 "${MEMBER_PORT}" } =20 +team_test_enabled_implicit_changes() +{ + export RET=3D0 + + attach_port_if_specified "${MEMBER_PORT}" + check_err $? "Couldn't attach ${MEMBER_PORT} to master" + + # Set enabled to true. + set_and_check_get enabled true "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'enabled' to true" + + # Show that both rx enabled and tx enabled are true. + get_and_check_value rx_enabled true "--port=3D${MEMBER_PORT}" + check_err $? "'Rx_enabled' wasn't implicitly set to true" + get_and_check_value tx_enabled true "--port=3D${MEMBER_PORT}" + check_err $? "'Tx_enabled' wasn't implicitly set to true" + + # Set enabled to false. + set_and_check_get enabled false "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'enabled' to true" + + # Show that both rx enabled and tx enabled are false. + get_and_check_value rx_enabled false "--port=3D${MEMBER_PORT}" + check_err $? "'Rx_enabled' wasn't implicitly set to false" + get_and_check_value tx_enabled false "--port=3D${MEMBER_PORT}" + check_err $? "'Tx_enabled' wasn't implicitly set to false" + + log_test "'Enabled' implicit changes" +} + +team_test_rx_enabled_implicit_changes() +{ + export RET=3D0 + + attach_port_if_specified "${MEMBER_PORT}" + check_err $? "Couldn't attach ${MEMBER_PORT} to master" + + # Set enabled to true. + set_and_check_get enabled true "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'enabled' to true" + + # Set rx_enabled to false. + set_and_check_get rx_enabled false "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'rx_enabled' to false" + + # Show that enabled is false. + get_and_check_value enabled false "--port=3D${MEMBER_PORT}" + check_err $? "'enabled' wasn't implicitly set to false" + + # Set rx_enabled to true. + set_and_check_get rx_enabled true "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'rx_enabled' to true" + + # Show that enabled is true. + get_and_check_value enabled true "--port=3D${MEMBER_PORT}" + check_err $? "'enabled' wasn't implicitly set to true" + + log_test "'Rx_enabled' implicit changes" +} + +team_test_tx_enabled_implicit_changes() +{ + export RET=3D0 + + attach_port_if_specified "${MEMBER_PORT}" + check_err $? "Couldn't attach ${MEMBER_PORT} to master" + + # Set enabled to true. + set_and_check_get enabled true "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'enabled' to true" + + # Set tx_enabled to false. + set_and_check_get tx_enabled false "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'tx_enabled' to false" + + # Show that enabled is false. + get_and_check_value enabled false "--port=3D${MEMBER_PORT}" + check_err $? "'enabled' wasn't implicitly set to false" + + # Set tx_enabled to true. + set_and_check_get tx_enabled true "--port=3D${MEMBER_PORT}" + check_err $? "Failed to set 'tx_enabled' to true" + + # Show that enabled is true. + get_and_check_value enabled true "--port=3D${MEMBER_PORT}" + check_err $? "'enabled' wasn't implicitly set to true" + + log_test "'Tx_enabled' implicit changes" +} + + require_command teamnl setup tests_run --=20 2.53.0.1118.gaef5881109-goog