From patchwork Thu Oct 1 10:39:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Whitfield X-Patchwork-Id: 2314829 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hwkLT075bz1yGJ for ; Fri, 02 Oct 2026 06:40:00 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1xCNZL-0001aj-38; Thu, 01 Oct 2026 20:39:55 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1xCNZI-0001ZA-Vw for kernel-team@lists.ubuntu.com; Thu, 01 Oct 2026 20:39:53 +0000 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id BC1353F8B2 for ; Thu, 1 Oct 2026 20:39:52 +0000 (UTC) Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-93cab33cb20so368221185a.2 for ; Thu, 01 Oct 2026 13:39:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790887192; x=1791491992; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=KhXfewgIXh4fcjeMm/IdFWsfoWl7Zf3WzBREvBC6xKI=; b=Gfqhp/FmfEqetX9bKJY6XJQ2ITCFLUWIipmx+PXPi9r6qPqrEZPgWEh/GW7X+ZOPo4 IYGsNjyW+Pz4gKGONawg0HNemx6hMWQLljdSsqGQsMy73zKp0k3Eq7CECOqeY5fc8nQu loYQ3Md7RG/tyPCtiQ4xSG5Kioqj9YIg+Sk6b20AC1nH+hvtaNN8UiLgilxk2TYloprK WTXk9Tp9N8EvuX4RwdvYPkOn/SUO/ytrPWpiWGGbMXxo0aL5ZHjsBvfwbBR7ZzIORYtg OGi//8XmzLph/YwxXoclIHg7jNBdY75+YJZNaldih3vAh90qBqccgQerJlYtSQHrfAMP Prxg== X-Gm-Message-State: AFuF++lM/RPycGZdmFNdgPa3NMlmd4oZAWISS0kag7Gsx8u4hRR98FX/ l8OK3VKMXI/heuB+mB6EKE1Ir9T44CVfXlV6ku8Q51RaZrzdjFcCtTHaD/Gl6edvaUorcSq9FP6 LtRmR6IJpctsIcSsEtoT0GijwGacr++K/Dc7Zz9CLx0p06q2NRy9+tMRO3HP+lbQRhl3RYR0mcf voV7ufuP/bDiN/gA== X-Gm-Gg: AYBFou2eo+eDKBbjafg+/y0TzAviUCIR7kp08gxhufxq82LDaHboo+vGGg51EpnLPQU wLxuh3dqmlaQg2yMNdsElvmr4eLgkuSmxmkP99ygs4ZlfPTFYLEEE7IbdMLOrQhUliwFu/7+jXW 7Qys5ge2osctEQgnmXYPH7TUk7QOHP6lFIklVuotNMnUHi/RZpOoNdgGPbpwf7pDh+RM8p58Qdy kWIHcsfUP2p10+FyTAjWFKtRlSfalfT0jorV2yM6ZVS+iaURsck/PLN4VtA3W4mK+DXTEeLdUKv iDykVDcHqYUgNLanwU9rQi9YpAys0a3ozGTjNfaP/U2nXiRXnDQgv3QX7QXFc4H/ldc2068evpI hj6Y1l5GC2w== X-Received: by 2002:a05:620a:7119:b0:93c:6e7d:da68 with SMTP id af79cd13be357-93ce7a9d9e9mr77841585a.3.1790887191587; Thu, 01 Oct 2026 13:39:51 -0700 (PDT) X-Received: by 2002:a05:620a:7119:b0:93c:6e7d:da68 with SMTP id af79cd13be357-93ce7a9d9e9mr77837085a.3.1790887191130; Thu, 01 Oct 2026 13:39:51 -0700 (PDT) Received: from localhost ([2600:4041:e2:4500:4d23:3ec6:61b5:8c68]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93cca038e6fsm44187785a.6.2026.10.01.13.39.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2026 13:39:50 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 1/6] selftests/net: add lib.sh Date: Thu, 1 Oct 2026 16:39:43 -0400 Message-ID: <20261001203948.36961-2-ian.whitfield@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261001203948.36961-1-ian.whitfield@canonical.com> References: <20261001203931.36891-1-ian.whitfield@canonical.com> <20261001203948.36961-1-ian.whitfield@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ian Whitfield via kernel-team From: Ian Whitfield Reply-To: Ian Whitfield Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Hangbin Liu BugLink: https://bugs.launchpad.net/bugs/2055473 Add a lib.sh for net selftests. This file can be used to define commonly used variables and functions. Some commonly used functions can be moved from forwarding/lib.sh to this lib file. e.g. busywait(). Add function setup_ns() for user to create unique namespaces with given prefix name. Reviewed-by: Petr Machata Signed-off-by: Hangbin Liu Signed-off-by: Paolo Abeni (backported from commit 25ae948b447881bf689d459cd5bd4629d9c04b20) [ijwhitfield: Merged changes with those added by our backport of d83a580675927 ("selftests: net: use slowwait to stabilize vrf_route_leaking test") which had added some of the changes from: 25ae948b44788 ("selftests/net: add lib.sh") (this commit) a4022a332f437 ("selftests: net: Unify code of busywait() and slowwait()") ea63ac1429256 ("selftests/net: use tc rule to filter the na packet")] Signed-off-by: Ian Whitfield --- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/forwarding/lib.sh | 27 +-------- tools/testing/selftests/net/lib.sh | 59 +++++++++++++++++++ 3 files changed, 61 insertions(+), 27 deletions(-) diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index 93aad7188796a..a849f69d719b6 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -33,7 +33,7 @@ TEST_PROGS += srv6_end_dt4_l3vpn_test.sh TEST_PROGS += srv6_end_dt6_l3vpn_test.sh TEST_PROGS += vrf_strict_mode_test.sh TEST_PROGS_EXTENDED := in_netns.sh setup_loopback.sh setup_veth.sh -TEST_PROGS_EXTENDED += toeplitz_client.sh toeplitz.sh +TEST_PROGS_EXTENDED += toeplitz_client.sh toeplitz.sh lib.sh TEST_GEN_FILES = socket nettest TEST_GEN_FILES += psock_fanout psock_tpacket msg_zerocopy reuseport_addr_any TEST_GEN_FILES += tcp_mmap tcp_inq psock_snd txring_overwrite diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index c570d8f65a0ce..e3d3a104bdc4e 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -4,9 +4,6 @@ ############################################################################## # Defines -# Kselftest framework requirement - SKIP code is 4. -ksft_skip=4 - # Can be overridden by the configuration file. PING=${PING:=ping} PING6=${PING6:=ping6} @@ -33,6 +30,7 @@ if [[ -f $relative_path/forwarding.config ]]; then source "$relative_path/forwarding.config" fi +source ../lib.sh ############################################################################## # Sanity checks @@ -303,29 +301,6 @@ log_info() echo "INFO: $msg" } -busywait() -{ - local timeout=$1; shift - - local start_time="$(date -u +%s%3N)" - while true - do - local out - out=$("$@") - local ret=$? - if ((!ret)); then - echo -n "$out" - return 0 - fi - - local current_time="$(date -u +%s%3N)" - if ((current_time - start_time > timeout)); then - echo -n "$out" - return 1 - fi - done -} - not() { "$@" diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index 5e31809ff7b3c..4167125df55f5 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -1,6 +1,14 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +############################################################################## +# Defines + +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +############################################################################## +# Helpers loopy_wait() { local sleep_cmd=$1; shift @@ -40,3 +48,54 @@ slowwait() loopy_wait "sleep 0.1" "$((timeout_sec * 1000))" "$@" } +cleanup_ns() +{ + local ns="" + local errexit=0 + local ret=0 + + # disable errexit temporary + if [[ $- =~ "e" ]]; then + errexit=1 + set +e + fi + + for ns in "$@"; do + ip netns delete "${ns}" &> /dev/null + if ! busywait 2 ip netns list \| grep -vq "^$ns$" &> /dev/null; then + echo "Warn: Failed to remove namespace $ns" + ret=1 + fi + done + + [ $errexit -eq 1 ] && set -e + return $ret +} + +# setup netns with given names as prefix. e.g +# setup_ns local remote +setup_ns() +{ + local ns="" + local ns_name="" + local ns_list="" + for ns_name in "$@"; do + # Some test may setup/remove same netns multi times + if unset ${ns_name} 2> /dev/null; then + ns="${ns_name,,}-$(mktemp -u XXXXXX)" + eval readonly ${ns_name}="$ns" + else + eval ns='$'${ns_name} + cleanup_ns "$ns" + + fi + + if ! ip netns add "$ns"; then + echo "Failed to create namespace $ns_name" + cleanup_ns "$ns_list" + return $ksft_skip + fi + ip -n "$ns" link set lo up + ns_list="$ns_list $ns" + done +} From patchwork Thu Oct 1 10:39:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Whitfield X-Patchwork-Id: 2314830 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hwkLX0l0Lz1xvt for ; Fri, 02 Oct 2026 06:40:04 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1xCNZN-0001dy-MK; Thu, 01 Oct 2026 20:39:57 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1xCNZK-0001aK-JT for kernel-team@lists.ubuntu.com; Thu, 01 Oct 2026 20:39:54 +0000 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 6260D44DE4 for ; Thu, 1 Oct 2026 20:39:54 +0000 (UTC) Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-936708f129aso1367176385a.0 for ; Thu, 01 Oct 2026 13:39:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790887193; x=1791491993; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=pvhzt2ra5aJ0nAsVp5zTnpBmkku+Q4Njj7QmQ/5ZhMs=; b=c7AdBsjxqHPw052ru+KDqrqpEv7AQ0hWphvOg7vlDJ4UvSdS+6qi8ByiLM7KG2RVUS rsZNcboilAzXm6i/mqEESdYK0sY4HIZH94Akb+et65qX1PFhqcZv0MGl+5y8uPJ0bTxf lItF5RGMFVlwzLcHy6ft+vT+uWnXYBNkh5qKM0Fy+kQZ0/qtheMdyJuJ0DMurhxttwjx /ChpV2oBdLpS5Wi+daaPgjucPskgocTK6GkTFMCeDz3glbsT4EBjVZtEOyNLyOtNnO2m 414/EAKNYGAG/7p3b2wKFkRj/AcwLSs49pquUkVNAv1t29cTiQgbLs/NzVXz+tnBbBWK 3jSw== X-Gm-Message-State: AFuF++l46x+CeNmJlcYX6/Y4F96gxT+wBsxVAgUwrRd0ImdUYONu+tP5 pf9C7tmH9hwZyN9NVsT7nbhdJWSBT263p5Vs/Zhai2yDFc+ap6wgWjaC3P8SrnlSY0JHjen3Iw7 E6AGvBiwWnVYPd3QndTMNcsCWihML6L31Hp8tSpPMXeVHjVAv3nZtt0E4Hm5PzlUPLTsBk26HKl p5tRXvfyXU7brTGg== X-Gm-Gg: AYBFou2fIqGQQjbU+UqvJ7X6CrE32ISAZ3+LqXuMaoaBUIb5fUVZqGq/3uwK/72TaKp CqbTj87RBhZTGaOpwzJ2EFqmNot+KMsv/W80HOtjAXk+CtAdYdmCDxk9bDIeU3scNloujZN/tHk u0HDzA/e3+Jub4AsjrQ8nbJUGbISaU5/1r5Czr6gkFS4B8NlPX5j5PDV8u3JcHRDnjyK3PIZzuI u6GfTHJA6wKO1ZWyXQ3qIl+i7OSHcMjJJzuPpOOVw7rwJIU8pYs3gOdL/k5vn/+VGHtNmUGX36B gKTmkraiEXZl/PrJ3t2cqnF51eFtcZNnpOUSksRSTEORQ0A/2TEfCiqzlN7n0P0KZWXy2/0rR3N 4F2sEyUwDnQ== X-Received: by 2002:a05:620a:a0c4:10b0:939:fc74:b6af with SMTP id af79cd13be357-93cf16b3fdbmr56028385a.11.1790887193158; Thu, 01 Oct 2026 13:39:53 -0700 (PDT) X-Received: by 2002:a05:620a:a0c4:10b0:939:fc74:b6af with SMTP id af79cd13be357-93cf16b3fdbmr56023585a.11.1790887192497; Thu, 01 Oct 2026 13:39:52 -0700 (PDT) Received: from localhost ([2600:4041:e2:4500:4d23:3ec6:61b5:8c68]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93cca1a6271sm42732985a.8.2026.10.01.13.39.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2026 13:39:51 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 2/6] selftests/net: convert unicast_extensions.sh to run it in unique namespace Date: Thu, 1 Oct 2026 16:39:44 -0400 Message-ID: <20261001203948.36961-3-ian.whitfield@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261001203948.36961-1-ian.whitfield@canonical.com> References: <20261001203931.36891-1-ian.whitfield@canonical.com> <20261001203948.36961-1-ian.whitfield@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ian Whitfield via kernel-team From: Ian Whitfield Reply-To: Ian Whitfield Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Hangbin Liu BugLink: https://bugs.launchpad.net/bugs/2055473 Here is the test result after conversion. # ./unicast_extensions.sh /usr/bin/which: no nettest in (/root/.local/bin:/root/bin:/usr/share/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin) ########################################################################### Unicast address extensions tests (behavior of reserved IPv4 addresses) ########################################################################### TEST: assign and ping within 240/4 (1 of 2) (is allowed) [ OK ] TEST: assign and ping within 240/4 (2 of 2) (is allowed) [ OK ] TEST: assign and ping within 0/8 (1 of 2) (is allowed) [ OK ] ... TEST: assign and ping class D address (is forbidden) [ OK ] TEST: routing using class D (is forbidden) [ OK ] TEST: routing using 127/8 (is forbidden) [ OK ] Acked-by: David Ahern Signed-off-by: Hangbin Liu Signed-off-by: Paolo Abeni (cherry picked from commit 0f4765d0b48d90ede9788c7edb2e072eee20f88e) Signed-off-by: Ian Whitfield --- .../selftests/net/unicast_extensions.sh | 99 +++++++++---------- 1 file changed, 46 insertions(+), 53 deletions(-) diff --git a/tools/testing/selftests/net/unicast_extensions.sh b/tools/testing/selftests/net/unicast_extensions.sh index 2d10ccac898a7..b7a2cb9e74778 100755 --- a/tools/testing/selftests/net/unicast_extensions.sh +++ b/tools/testing/selftests/net/unicast_extensions.sh @@ -28,8 +28,7 @@ # These tests provide an easy way to flip the expected result of any # of these behaviors for testing kernel patches that change them. -# Kselftest framework requirement - SKIP code is 4. -ksft_skip=4 +source ./lib.sh # nettest can be run from PATH or from same directory as this selftest if ! which nettest >/dev/null; then @@ -61,20 +60,20 @@ _do_segmenttest(){ # foo --- bar # Arguments: ip_a ip_b prefix_length test_description # - # Caller must set up foo-ns and bar-ns namespaces + # Caller must set up $foo_ns and $bar_ns namespaces # containing linked veth devices foo and bar, # respectively. - ip -n foo-ns address add $1/$3 dev foo || return 1 - ip -n foo-ns link set foo up || return 1 - ip -n bar-ns address add $2/$3 dev bar || return 1 - ip -n bar-ns link set bar up || return 1 + ip -n $foo_ns address add $1/$3 dev foo || return 1 + ip -n $foo_ns link set foo up || return 1 + ip -n $bar_ns address add $2/$3 dev bar || return 1 + ip -n $bar_ns link set bar up || return 1 - ip netns exec foo-ns timeout 2 ping -c 1 $2 || return 1 - ip netns exec bar-ns timeout 2 ping -c 1 $1 || return 1 + ip netns exec $foo_ns timeout 2 ping -c 1 $2 || return 1 + ip netns exec $bar_ns timeout 2 ping -c 1 $1 || return 1 - nettest -B -N bar-ns -O foo-ns -r $1 || return 1 - nettest -B -N foo-ns -O bar-ns -r $2 || return 1 + nettest -B -N $bar_ns -O $foo_ns -r $1 || return 1 + nettest -B -N $foo_ns -O $bar_ns -r $2 || return 1 return 0 } @@ -88,31 +87,31 @@ _do_route_test(){ # Arguments: foo_ip foo1_ip bar1_ip bar_ip prefix_len test_description # Displays test result and returns success or failure. - # Caller must set up foo-ns, bar-ns, and router-ns + # Caller must set up $foo_ns, $bar_ns, and $router_ns # containing linked veth devices foo-foo1, bar1-bar - # (foo in foo-ns, foo1 and bar1 in router-ns, and - # bar in bar-ns). - - ip -n foo-ns address add $1/$5 dev foo || return 1 - ip -n foo-ns link set foo up || return 1 - ip -n foo-ns route add default via $2 || return 1 - ip -n bar-ns address add $4/$5 dev bar || return 1 - ip -n bar-ns link set bar up || return 1 - ip -n bar-ns route add default via $3 || return 1 - ip -n router-ns address add $2/$5 dev foo1 || return 1 - ip -n router-ns link set foo1 up || return 1 - ip -n router-ns address add $3/$5 dev bar1 || return 1 - ip -n router-ns link set bar1 up || return 1 - - echo 1 | ip netns exec router-ns tee /proc/sys/net/ipv4/ip_forward - - ip netns exec foo-ns timeout 2 ping -c 1 $2 || return 1 - ip netns exec foo-ns timeout 2 ping -c 1 $4 || return 1 - ip netns exec bar-ns timeout 2 ping -c 1 $3 || return 1 - ip netns exec bar-ns timeout 2 ping -c 1 $1 || return 1 - - nettest -B -N bar-ns -O foo-ns -r $1 || return 1 - nettest -B -N foo-ns -O bar-ns -r $4 || return 1 + # (foo in $foo_ns, foo1 and bar1 in $router_ns, and + # bar in $bar_ns). + + ip -n $foo_ns address add $1/$5 dev foo || return 1 + ip -n $foo_ns link set foo up || return 1 + ip -n $foo_ns route add default via $2 || return 1 + ip -n $bar_ns address add $4/$5 dev bar || return 1 + ip -n $bar_ns link set bar up || return 1 + ip -n $bar_ns route add default via $3 || return 1 + ip -n $router_ns address add $2/$5 dev foo1 || return 1 + ip -n $router_ns link set foo1 up || return 1 + ip -n $router_ns address add $3/$5 dev bar1 || return 1 + ip -n $router_ns link set bar1 up || return 1 + + echo 1 | ip netns exec $router_ns tee /proc/sys/net/ipv4/ip_forward + + ip netns exec $foo_ns timeout 2 ping -c 1 $2 || return 1 + ip netns exec $foo_ns timeout 2 ping -c 1 $4 || return 1 + ip netns exec $bar_ns timeout 2 ping -c 1 $3 || return 1 + ip netns exec $bar_ns timeout 2 ping -c 1 $1 || return 1 + + nettest -B -N $bar_ns -O $foo_ns -r $1 || return 1 + nettest -B -N $foo_ns -O $bar_ns -r $4 || return 1 return 0 } @@ -121,17 +120,15 @@ segmenttest(){ # Sets up veth link and tries to connect over it. # Arguments: ip_a ip_b prefix_len test_description hide_output - ip netns add foo-ns - ip netns add bar-ns - ip link add foo netns foo-ns type veth peer name bar netns bar-ns + setup_ns foo_ns bar_ns + ip link add foo netns $foo_ns type veth peer name bar netns $bar_ns test_result=0 _do_segmenttest "$@" || test_result=1 - ip netns pids foo-ns | xargs -r kill -9 - ip netns pids bar-ns | xargs -r kill -9 - ip netns del foo-ns - ip netns del bar-ns + ip netns pids $foo_ns | xargs -r kill -9 + ip netns pids $bar_ns | xargs -r kill -9 + cleanup_ns $foo_ns $bar_ns show_output # inverted tests will expect failure instead of success @@ -147,21 +144,17 @@ route_test(){ # Returns success or failure. hide_output - ip netns add foo-ns - ip netns add bar-ns - ip netns add router-ns - ip link add foo netns foo-ns type veth peer name foo1 netns router-ns - ip link add bar netns bar-ns type veth peer name bar1 netns router-ns + setup_ns foo_ns bar_ns router_ns + ip link add foo netns $foo_ns type veth peer name foo1 netns $router_ns + ip link add bar netns $bar_ns type veth peer name bar1 netns $router_ns test_result=0 _do_route_test "$@" || test_result=1 - ip netns pids foo-ns | xargs -r kill -9 - ip netns pids bar-ns | xargs -r kill -9 - ip netns pids router-ns | xargs -r kill -9 - ip netns del foo-ns - ip netns del bar-ns - ip netns del router-ns + ip netns pids $foo_ns | xargs -r kill -9 + ip netns pids $bar_ns | xargs -r kill -9 + ip netns pids $router_ns | xargs -r kill -9 + cleanup_ns $foo_ns $bar_ns $router_ns show_output From patchwork Thu Oct 1 10:39:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Whitfield X-Patchwork-Id: 2314831 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hwkLX6NnJz1yGJ for ; Fri, 02 Oct 2026 06:40:04 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1xCNZN-0001dU-Co; Thu, 01 Oct 2026 20:39:57 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1xCNZL-0001bB-HJ for kernel-team@lists.ubuntu.com; Thu, 01 Oct 2026 20:39:55 +0000 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 65E3844DE4 for ; Thu, 1 Oct 2026 20:39:55 +0000 (UTC) Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-936708f129aso1367178785a.0 for ; Thu, 01 Oct 2026 13:39:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790887194; x=1791491994; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=7ISpA2Fb4w6ukLy85U5YZvgN4bif87j2SRlVJf+7jJE=; b=iMbr5cJYpg4/mqI2drujAagj3OtEde0r+dSkUudctvnl8LIPKlkxYRWbehXl+8hADk wxSxp/YcjKAvrrAUfHv00L4Uc+VRQnHHgb0f9POG/C35wuvGapkTDJDrKhc64tjBQVbx mkkeTUJuRqg6FllbNZsIX+tHQU1kkFjGHyUhoStsbC7QaG3GE1WZdtVmBz0N0q60c0mu 4J41VorYbqap1aOI0lJ+JdwoTNLEjELHigZmEjKnM2FjHrvzR4vkwd0MXlhUPZqES+LF h56d4HWL+9uTyQA5XXgQxe5cy8kKIuhI9dz1qRCAieOTaEG9gdCkS5ls0iM2nRv2kp4s N6Tw== X-Gm-Message-State: AFuF++l/uOZG2WKaD/RoL2lG+JTXAuhN87auGno9Y7O4Sttu3s2yRJrm JB8ZiFEhhrfeWfrs94hOWScRmVkV/wS8lxLtA8ce2W13mqbAvLMaFBXNa+s83hpwMzd+koVO1gn fIAIQ1Mgi4mEQnEeJOpG4u1wChux2r+UBzq7PvrF/OdzIrHbgNk5wo/GxpvnBjvnhVwr+nosjuv 7wx39E6hF9RBOAcQ== X-Gm-Gg: AYBFou3TKIosS+Mc+gUjzsWPKc7S19NiIJF8IQ42dZ7d4YLr8Dk2cOB06LTgojskOvt c8ZIWTKaBy7x+7EXzNkTUJarSKuuRLroXYIhaOoj5KIOjCYZcha+sbfyQ6KUH/nnzlyAeS+09Hs tdsjowYNj38iZOe2MAo77CB1FcWjpm+FoyE5eK+oc89iosFbHXCGkEMVYIXuVqp1LX29Em6bxMz tMn1gSpISY1xU4wmgTW4xxLLJ3xuEyd3YNOxPpv19g4iHtb51gnCY//YvA5Ny5qTIpYe5s0QxUy 8suiJQm37dod/qUB3UDEWUekxjk54rPLRgLNiKLX7NpX2nSfPjqihQR4BhFzqgnWKhnvjh7yb9T lssJmke3Ltg== X-Received: by 2002:a05:620a:4113:b0:93b:cb6d:6d73 with SMTP id af79cd13be357-93cf1740459mr62987485a.32.1790887194325; Thu, 01 Oct 2026 13:39:54 -0700 (PDT) X-Received: by 2002:a05:620a:4113:b0:93b:cb6d:6d73 with SMTP id af79cd13be357-93cf1740459mr62983685a.32.1790887193857; Thu, 01 Oct 2026 13:39:53 -0700 (PDT) Received: from localhost ([2600:4041:e2:4500:4d23:3ec6:61b5:8c68]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93cca1f72a3sm41596885a.17.2026.10.01.13.39.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2026 13:39:53 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 3/6] selftests/net: add variable NS_LIST for lib.sh Date: Thu, 1 Oct 2026 16:39:45 -0400 Message-ID: <20261001203948.36961-4-ian.whitfield@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261001203948.36961-1-ian.whitfield@canonical.com> References: <20261001203931.36891-1-ian.whitfield@canonical.com> <20261001203948.36961-1-ian.whitfield@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ian Whitfield via kernel-team From: Ian Whitfield Reply-To: Ian Whitfield Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Hangbin Liu BugLink: https://bugs.launchpad.net/bugs/2055473 Add a global variable NS_LIST to store all the namespaces that setup_ns created, so the caller could call cleanup_all_ns() instead of remember all the netns names when using cleanup_ns(). Signed-off-by: Hangbin Liu Link: https://lore.kernel.org/r/20231213060856.4030084-2-liuhangbin@gmail.com Signed-off-by: Jakub Kicinski (cherry picked from commit b6925b4ed57cccf42ca0fb46c7446f0859e7ad4b) Signed-off-by: Ian Whitfield --- tools/testing/selftests/net/lib.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index 4167125df55f5..7c5a267517be6 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -6,6 +6,8 @@ # Kselftest framework requirement - SKIP code is 4. ksft_skip=4 +# namespace list created by setup_ns +NS_LIST="" ############################################################################## # Helpers @@ -72,6 +74,11 @@ cleanup_ns() return $ret } +cleanup_all_ns() +{ + cleanup_ns $NS_LIST +} + # setup netns with given names as prefix. e.g # setup_ns local remote setup_ns() @@ -98,4 +105,5 @@ setup_ns() ip -n "$ns" link set lo up ns_list="$ns_list $ns" done + NS_LIST="$NS_LIST $ns_list" } From patchwork Thu Oct 1 10:39:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Whitfield X-Patchwork-Id: 2314832 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hwkLZ5nqDz1xvt for ; Fri, 02 Oct 2026 06:40:06 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1xCNZP-0001h8-5K; Thu, 01 Oct 2026 20:39:59 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1xCNZN-0001d5-6l for kernel-team@lists.ubuntu.com; Thu, 01 Oct 2026 20:39:57 +0000 Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id F14C63F8B2 for ; Thu, 1 Oct 2026 20:39:56 +0000 (UTC) Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-93cb98809caso201558385a.1 for ; Thu, 01 Oct 2026 13:39:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790887196; x=1791491996; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=yz/cbN2FnQA5is/kd3IGy8+GTQjrCtGmCKfh+6eGHSg=; b=eQZjNoVxyi7bM2u1Yi2a07/NgCXYtP+Ltm+/F06BVZB2riARAbQSNKXgcBgLyUpDVr 1f34fYW0UMXEOvgua37LE6fWMA3mqvytn5fLtV6agGcG+Us2CmdDdZFuwxxbq+MyXSeH JGk9k6zyZYNGAUK6BkxESkQJ7jbhKVe+I8Jg8aB1yvdj9VHH9H07E6eC9S96Z0ASuSiv Fpok7YOU9ksxFi+kcf9z3XnUTXiEynnIgFaCuJ/zt5E1H154VmwhnjQnC3bt7JcJU/3O LTBh0nG2Mg3etIGtEOwkyN6DIPARgHALA131IrVOf0Jby9zYNi02YSfRft9wzEtHpoui HkXQ== X-Gm-Message-State: AFuF++kXdH/39mtOERz7VMw+MZWp1EtuCn9hHochpq2K1ao+8upQdU1e p5almnH1NFJ8rltKCmYecYzk2UB5U0YL6DXlxtJa5jqMZ/TMX9UEjGH4w1YM701tJCErgDTUHjN qrDFhK6phxNW/stfKvLnp3tC7liQkYkQc7MFrocJ2TfrGU6nY/c3AJlgLIQJkizfUGPoJxzRpr2 Ozbb8pvuyAIKnMZQ== X-Gm-Gg: AYBFou3wDRoLf1eiGf4V8LUKyAusJsflaFpGSF6vogNHA7XQyeeL9If8GVg/QmZ/2BZ y97qHhpjqwjCi5GVdW8li6CQfa0BA4rF7Nqnjnr7G/P6qsBTmkRz4sVecaLoUxj1j4+FfBH4d07 /onl9CXjKu7gY6HBGPkZPrbhnY13fSAarBj/zKUSd4peUdgnF/Hvdie+lPYMYiV/btwzX/PkZSI DHXjjmSN5Q2MfVl7Q2x9Zva4Z/XBxkWoc9s8TkFc3zLhQyMetKPEAvQj3vwK/v4RggAFlhyHcYh tE+LY+ylj94IzBzXlxeI1mABAUJc2vFtniJVSdDnWO7Ak9P8cF5FzG5kTv2YCIXEc570HOjahi5 OTGcS9gWGnQ== X-Received: by 2002:a05:620a:2550:b0:93a:3d71:c9ec with SMTP id af79cd13be357-93ce7a964e4mr72224985a.7.1790887195714; Thu, 01 Oct 2026 13:39:55 -0700 (PDT) X-Received: by 2002:a05:620a:2550:b0:93a:3d71:c9ec with SMTP id af79cd13be357-93ce7a964e4mr72221385a.7.1790887195259; Thu, 01 Oct 2026 13:39:55 -0700 (PDT) Received: from localhost ([2600:4041:e2:4500:4d23:3ec6:61b5:8c68]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93cca24e65fsm41972985a.27.2026.10.01.13.39.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2026 13:39:54 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 4/6] selftests/net: convert pmtu.sh to run it in unique namespace Date: Thu, 1 Oct 2026 16:39:46 -0400 Message-ID: <20261001203948.36961-5-ian.whitfield@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261001203948.36961-1-ian.whitfield@canonical.com> References: <20261001203931.36891-1-ian.whitfield@canonical.com> <20261001203948.36961-1-ian.whitfield@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ian Whitfield via kernel-team From: Ian Whitfield Reply-To: Ian Whitfield Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Hangbin Liu BugLink: https://bugs.launchpad.net/bugs/2055473 pmtu test use /bin/sh, so we need to source ./lib.sh instead of lib.sh Here is the test result after conversion. # ./pmtu.sh TEST: ipv4: PMTU exceptions [ OK ] TEST: ipv4: PMTU exceptions - nexthop objects [ OK ] TEST: ipv6: PMTU exceptions [ OK ] TEST: ipv6: PMTU exceptions - nexthop objects [ OK ] ... TEST: ipv4: list and flush cached exceptions - nexthop objects [ OK ] TEST: ipv6: list and flush cached exceptions [ OK ] TEST: ipv6: list and flush cached exceptions - nexthop objects [ OK ] TEST: ipv4: PMTU exception w/route replace [ OK ] TEST: ipv4: PMTU exception w/route replace - nexthop objects [ OK ] TEST: ipv6: PMTU exception w/route replace [ OK ] TEST: ipv6: PMTU exception w/route replace - nexthop objects [ OK ] Signed-off-by: Hangbin Liu Signed-off-by: David S. Miller (cherry picked from commit 378f082eaf3760cd7430fbcb1e4f8626bb6bc0ae) Signed-off-by: Ian Whitfield --- tools/testing/selftests/net/pmtu.sh | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index 33f4fb34ac9b2..b431e9a2d2115 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -204,8 +204,7 @@ # addresses have multipath routes to each other, b_r1 mtu = 1500. # Check that PMTU exceptions are created for both paths. -# Kselftest framework requirement - SKIP code is 4. -ksft_skip=4 +source ./lib.sh PAUSE_ON_FAIL=no VERBOSE=0 @@ -275,16 +274,6 @@ tests=" pmtu_ipv6_route_change ipv6: PMTU exception w/route replace 1 pmtu_ipv4_mp_exceptions ipv4: PMTU multipath nh exceptions 1" -NS_A="ns-A" -NS_B="ns-B" -NS_C="ns-C" -NS_R1="ns-R1" -NS_R2="ns-R2" -ns_a="ip netns exec ${NS_A}" -ns_b="ip netns exec ${NS_B}" -ns_c="ip netns exec ${NS_C}" -ns_r1="ip netns exec ${NS_R1}" -ns_r2="ip netns exec ${NS_R2}" # Addressing and routing for tests with routers: four network segments, with # index SEGMENT between 1 and 4, a common prefix (PREFIX4 or PREFIX6) and an # identifier ID, which is 1 for hosts (A and B), 2 for routers (R1 and R2). @@ -552,13 +541,17 @@ setup_ip6ip6() { } setup_namespaces() { + setup_ns NS_A NS_B NS_C NS_R1 NS_R2 for n in ${NS_A} ${NS_B} ${NS_C} ${NS_R1} ${NS_R2}; do - ip netns add ${n} || return 1 - # Disable DAD, so that we don't have to wait to use the # configured IPv6 addresses ip netns exec ${n} sysctl -q net/ipv6/conf/default/accept_dad=0 done + ns_a="ip netns exec ${NS_A}" + ns_b="ip netns exec ${NS_B}" + ns_c="ip netns exec ${NS_C}" + ns_r1="ip netns exec ${NS_R1}" + ns_r2="ip netns exec ${NS_R2}" } setup_veth() { @@ -848,7 +841,7 @@ setup_bridge() { run_cmd ${ns_a} ip link set br0 up run_cmd ${ns_c} ip link add veth_C-A type veth peer name veth_A-C - run_cmd ${ns_c} ip link set veth_A-C netns ns-A + run_cmd ${ns_c} ip link set veth_A-C netns ${NS_A} run_cmd ${ns_a} ip link set veth_A-C up run_cmd ${ns_c} ip link set veth_C-A up @@ -999,9 +992,7 @@ cleanup() { done socat_pids= - for n in ${NS_A} ${NS_B} ${NS_C} ${NS_R1} ${NS_R2}; do - ip netns del ${n} 2> /dev/null - done + cleanup_all_ns ip link del veth_A-C 2>/dev/null ip link del veth_A-R1 2>/dev/null From patchwork Thu Oct 1 10:39:47 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Whitfield X-Patchwork-Id: 2314833 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hwkLb75Qnz1xvt for ; Fri, 02 Oct 2026 06:40:07 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1xCNZR-0001nA-G5; Thu, 01 Oct 2026 20:40:01 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1xCNZO-0001fC-66 for kernel-team@lists.ubuntu.com; Thu, 01 Oct 2026 20:39:58 +0000 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 05F6F3F98C for ; Thu, 1 Oct 2026 20:39:58 +0000 (UTC) Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-5338f659170so18011221cf.0 for ; Thu, 01 Oct 2026 13:39:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790887197; x=1791491997; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=DCkirSKSn40CVgDTr/lJVuIxYqlKL/sXMcTGWsOMx9M=; b=BZJPqflXLU4jotSWtehwnGFg4q2a2YxFSRTA2YQyAmZaUtSAu/3BTOMAggRVhy6rIm VGSJuUdVBRJvjkl+/J75zaKuZyH3Vzcb7FeJW9i1vih0xmoDtX8HmHbusSAzEC18BJva dGSvfv6MemylR4/GA/pZ17vsHPIs6DyBHCJLmHc6vpUHLw4RE7p9qyIGVj+gjlsdUbNi IOtEHcuJarga1fxHBWvVHDXoIgbIpFPyl+WAwtg0IEy7SHtJjhzHsp43JhAwZBVHPrQN hrePtYzRonN7c3HuU/lTB3s2RvJEMetFySvDG7dRi87g37QHjtKuQK0bMJ+8+sB+7RJp ik6w== X-Gm-Message-State: AFuF++l3VuXvULLiLNxW/NLhkiDg8Kr4Rv/XcG7Fr5w7FLW367aNw8p9 nRmx9lglLqoj5M2Z1IzZ/g4h5UkqB3HfOteuYevpXlN99iEwsEvkedI4XduGXEDcqdoSTfsxhdC 5X579G9ksl4oeCCB72whVJkYVnnPpT88Iw0NEhdoHm1VAeQbGea/UO1mCH0XNogbTHM/vOzhb1q XMD/3DtuS+9vCEIA== X-Gm-Gg: AYBFou0JY069MD8lM+i5+BOLN93LjLH+JYDX6jjoIQBbjbnOnS++gjnQi9aaKaUGV+A GkmfmKn2nH9fLMs72R0qvN/mJQKmGdl9Zsh76zfHFFIFTCv0Vb2NLn7UqsLyk8FjoTUP9FUIZ5r mU9E9KYevjjoQ0R7xTfzxr5L+ACbwp/4jmeyVSK2g+75m3WYcfVa9FByTpi4WwwDzKZ93+sxkkj jjxpbylsQIdfwNCkPJWgReKoEee+3HuFc2w8UirTLMeA8awQhXYBF36Dtn6zXypVj0Z4MteTbUE kwM7i1Kjzs7ca/4NRfi3AUVzix7GvmjUjanfK7OgpsArIfYSk3MA0wHds96Mh6JmhCx0CX4btgk q4Pd1sTc0/w== X-Received: by 2002:a05:622a:1ba9:b0:532:cbfe:384d with SMTP id d75a77b69052e-533bd45ef13mr6956341cf.1.1790887196930; Thu, 01 Oct 2026 13:39:56 -0700 (PDT) X-Received: by 2002:a05:622a:1ba9:b0:532:cbfe:384d with SMTP id d75a77b69052e-533bd45ef13mr6955931cf.1.1790887196416; Thu, 01 Oct 2026 13:39:56 -0700 (PDT) Received: from localhost ([2600:4041:e2:4500:4d23:3ec6:61b5:8c68]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-5339883034csm7897551cf.3.2026.10.01.13.39.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2026 13:39:55 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 5/6] selftests/net: change shebang to bash to support "source" Date: Thu, 1 Oct 2026 16:39:47 -0400 Message-ID: <20261001203948.36961-6-ian.whitfield@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261001203948.36961-1-ian.whitfield@canonical.com> References: <20261001203931.36891-1-ian.whitfield@canonical.com> <20261001203948.36961-1-ian.whitfield@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ian Whitfield via kernel-team From: Ian Whitfield Reply-To: Ian Whitfield Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Yujie Liu BugLink: https://bugs.launchpad.net/bugs/2055473 The patch set [1] added a general lib.sh in net selftests, and converted several test scripts to source the lib.sh. unicast_extensions.sh (converted in [1]) and pmtu.sh (converted in [2]) have a /bin/sh shebang which may point to various shells in different distributions, but "source" is only available in some of them. For example, "source" is a built-it function in bash, but it cannot be used in dash. Refer to other scripts that were converted together, simply change the shebang to bash to fix the following issues when the default /bin/sh points to other shells. not ok 51 selftests: net: unicast_extensions.sh # exit=1 v1 -> v2: - Fix pmtu.sh which has the same issue as unicast_extensions.sh, suggested by Hangbin - Change the style of the "source" line to be consistent with other tests, suggested by Hangbin Link: https://lore.kernel.org/all/20231202020110.362433-1-liuhangbin@gmail.com/ [1] Link: https://lore.kernel.org/all/20231219094856.1740079-1-liuhangbin@gmail.com/ [2] Reported-by: kernel test robot Fixes: 378f082eaf37 ("selftests/net: convert pmtu.sh to run it in unique namespace") Fixes: 0f4765d0b48d ("selftests/net: convert unicast_extensions.sh to run it in unique namespace") Signed-off-by: Yujie Liu Reviewed-by: Przemek Kitszel Reviewed-by: Hangbin Liu Reviewed-by: Muhammad Usama Anjum Link: https://lore.kernel.org/r/20231229131931.3961150-1-yujie.liu@intel.com Signed-off-by: Jakub Kicinski (cherry picked from commit 05d92cb0e919239c29b3a26da1f76f1e18fed7d3) Signed-off-by: Ian Whitfield --- tools/testing/selftests/net/pmtu.sh | 4 ++-- tools/testing/selftests/net/unicast_extensions.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh index b431e9a2d2115..a1002c387fbfd 100755 --- a/tools/testing/selftests/net/pmtu.sh +++ b/tools/testing/selftests/net/pmtu.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # Check that route PMTU values match expectations, and that initial device MTU @@ -204,7 +204,7 @@ # addresses have multipath routes to each other, b_r1 mtu = 1500. # Check that PMTU exceptions are created for both paths. -source ./lib.sh +source lib.sh PAUSE_ON_FAIL=no VERBOSE=0 diff --git a/tools/testing/selftests/net/unicast_extensions.sh b/tools/testing/selftests/net/unicast_extensions.sh index b7a2cb9e74778..f52aa5f7da524 100755 --- a/tools/testing/selftests/net/unicast_extensions.sh +++ b/tools/testing/selftests/net/unicast_extensions.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # SPDX-License-Identifier: GPL-2.0 # # By Seth Schoen (c) 2021, for the IPv4 Unicast Extensions Project @@ -28,7 +28,7 @@ # These tests provide an easy way to flip the expected result of any # of these behaviors for testing kernel patches that change them. -source ./lib.sh +source lib.sh # nettest can be run from PATH or from same directory as this selftest if ! which nettest >/dev/null; then From patchwork Thu Oct 1 10:39:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Whitfield X-Patchwork-Id: 2314834 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hwkLc1CDsz1yGJ for ; Fri, 02 Oct 2026 06:40:08 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1xCNZS-0001oe-10; Thu, 01 Oct 2026 20:40:02 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1xCNZP-0001iN-II for kernel-team@lists.ubuntu.com; Thu, 01 Oct 2026 20:39:59 +0000 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 7505444DE4 for ; Thu, 1 Oct 2026 20:39:59 +0000 (UTC) Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-530d43c9a55so172411061cf.2 for ; Thu, 01 Oct 2026 13:39:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790887198; x=1791491998; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=xGZyseSr9VCgcc9zn5clVGl6qu8uoplIfiKh2KGXArE=; b=SPVAgIPt4eomNviVSKP5xcjCiIi/AWtQSDXFxGfF9As9celsAIBoRhv1mBtgQzt6sr qWhyGiZguW9ft0KiyB9ECqiOjv6KunrzRpl29UxXkpr9l3FxsF9OK00haW5BXno06B7L dWTX/ZBOyj/jbtSv7+rpA3nMuaRKJxr1MxJkePPZSIhDiXy6W69ha7UxS4ujKyfoC+h/ dprueXUStSZgixJF986TWFhpbxWFf8+paYriSeeIpPtpq7vuUpgiGm5a+xXwWShnwCKZ /2taqgi/bn89OOsgTPVEkX+ctFzAvillANNmV+28TkKZJS70km8+S7Zzxd8GR5ovkR0p L72g== X-Gm-Message-State: AFuF++m4pcUbSC445UreQhvGhYROvK6T3m/+1B86+F9hC8Mvw26xS8PI VXM7AquyVNxvgChZXC+kLP39ucrNqFo5stEZSsnUEa6WXwJtUYyUvgVXN6VCkzIIt5xD5I8M6v+ EV99FKWzu4Jm7yiYPi7EoOcXr4Z6DV0vs/xYcz75MsfBdYULxeVeJ2Ok6cEymKnRtYFuSg6dk3e Ld/HbG0sLy5aZ/8w== X-Gm-Gg: AYBFou2aUdVGAb/A75g+8fx5qoxEYUZ/wPJf6kCzTl/0Chr68p2FSXGq4iV62EYl1bJ ah5FtFe933TbSbS1ofERkrsyGkT5WLwkugt4511xef8MVPzXhKy18u7LlITbc41aSnRwEN1znYP oNkxgsdT+YJIXT724a11bmcrpksrzaBOVN2pcEnZaj7VqWJQULP92lQ17gtZHjbSWaRgas9a+GN kwe2nqFUlQaiJlvqfez+8g3GqWWDZXNmM4iWqZy24xc0mqGOTWbunocYc29rFSfkddF0gVyemJo vSewpfsilUO2yCFKc2MxDlSECgBQXqNUi8jvHjUrt0kSWUKgnbHytTosejI6njEdlvgnHkFqhmD hGbomVTo3jQ== X-Received: by 2002:a05:622a:298c:b0:532:84d3:ac0 with SMTP id d75a77b69052e-533cbc9ab5dmr6781201cf.43.1790887198261; Thu, 01 Oct 2026 13:39:58 -0700 (PDT) X-Received: by 2002:a05:622a:298c:b0:532:84d3:ac0 with SMTP id d75a77b69052e-533cbc9ab5dmr6780681cf.43.1790887197754; Thu, 01 Oct 2026 13:39:57 -0700 (PDT) Received: from localhost ([2600:4041:e2:4500:4d23:3ec6:61b5:8c68]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-917e0bc98fbsm2891116d6.29.2026.10.01.13.39.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Oct 2026 13:39:57 -0700 (PDT) To: kernel-team@lists.ubuntu.com Subject: [SRU][J][PATCH 6/6] selftests: net: disable rp_filter after namespace initialization Date: Thu, 1 Oct 2026 16:39:48 -0400 Message-ID: <20261001203948.36961-7-ian.whitfield@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261001203948.36961-1-ian.whitfield@canonical.com> References: <20261001203931.36891-1-ian.whitfield@canonical.com> <20261001203948.36961-1-ian.whitfield@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ian Whitfield via kernel-team From: Ian Whitfield Reply-To: Ian Whitfield Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Hangbin Liu BugLink: https://bugs.launchpad.net/bugs/2055473 Some distributions enable rp_filter globally by default. To ensure consistent behavior across environments, we explicitly disable it in several test cases. This patch moves the rp_filter disabling logic to immediately after the network namespace is initialized. With this change, individual test cases with creating namespace via setup_ns no longer need to disable rp_filter again. This helps avoid redundancy and ensures test consistency. Signed-off-by: Hangbin Liu Reviewed-by: Simon Horman Link: https://patch.msgid.link/20250508081910.84216-2-liuhangbin@gmail.com Signed-off-by: Jakub Kicinski (backported from commit ce17831f8e970cadaba88605b4b1b1a8b2b50808) [ijwhitfield: Adjusted context due to missing unrelated functions from: 4d0dac499bf38 ("selftests/net: test tcp connection load balancing") b219bcfcc92e9 ("selftests: net: lib: Move logging from forwarding/lib.sh here") 601d9d70a40a8 ("selftests: net: lib: Move tests_run from forwarding/lib.sh here") 56c8a23f8a0f3 ("selftests: net: use netdevsim in netns test") There was also previously a partial backport of ea63ac1429256 ("selftests/net: use tc rule to filter the na packet") in our backport of d83a580675927 ("selftests: net: use slowwait to stabilize vrf_route_leaking test") which led to similar context adjustment due to missing unrelated functions. There are also three missing small fixes/changes in the affected function: f8a2d2f874b71 ("selftests: net: lib: remove 'ns' var in setup_ns") 92fe5670271a5 ("selftests: net: lib: remove ns from list after clean-up")] 79322174bcc78 ("selftests: net: lib: avoid error removing empty netns name") which required adjusting context of the patch.] Signed-off-by: Ian Whitfield --- tools/testing/selftests/net/lib.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh index 7c5a267517be6..9c26297dffbeb 100644 --- a/tools/testing/selftests/net/lib.sh +++ b/tools/testing/selftests/net/lib.sh @@ -103,6 +103,8 @@ setup_ns() return $ksft_skip fi ip -n "$ns" link set lo up + ip netns exec "${!ns_name}" sysctl -wq net.ipv4.conf.all.rp_filter=0 + ip netns exec "${!ns_name}" sysctl -wq net.ipv4.conf.default.rp_filter=0 ns_list="$ns_list $ns" done NS_LIST="$NS_LIST $ns_list"