NACK/CMNT: [SRU][N][PATCH 1/1] selftests: net: move wait_local_port_listen to lib.sh

Alice C. Munduruca alice.munduruca at canonical.com
Tue Jul 28 14:46:20 UTC 2026


On Tue Jun 23, 2026 at 11:27 PM EDT, ChunAn Wu via kernel-team wrote:
> From: Hangbin Liu <liuhangbin at gmail.com>
>
> BugLink: https://bugs.launchpad.net/bugs/2139460
>
> The function wait_local_port_listen() is the only function defined in
> net_helper.sh. Since some tests source both lib.sh and net_helper.sh,
> we can simplify the setup by moving wait_local_port_listen() to lib.sh.
>
> With this change, net_helper.sh becomes redundant and can be removed.
>
> Signed-off-by: Hangbin Liu <liuhangbin at gmail.com>
> Reviewed-by: Matthieu Baerts (NGI0) <matttbe at kernel.org>
> Link: https://patch.msgid.link/20250526014600.9128-1-liuhangbin@gmail.com
> Signed-off-by: Jakub Kicinski <kuba at kernel.org>
> (backported from commit d9d836bfa5e6e255c411733b4b1ce7a1f8346c54)
> [an: resolved conflicts because Noble lacks newer selftests/drivers/net files
>  and newer MPTCP selftest include changes. Applied the helper move only
>  to Noble files which sourced net_helper.sh and kept Noble MPTCP files
>  unchanged.]
> Signed-off-by: ChunAn Wu <an.wu at canonical.com>
> ---
>  tools/testing/selftests/net/Makefile          |  2 +-
>  .../net/ipv6_route_update_soft_lockup.sh      |  1 -
>  tools/testing/selftests/net/lib.sh            | 21 ++++++++++++++++
>  tools/testing/selftests/net/net_helper.sh     | 25 -------------------
>  tools/testing/selftests/net/pmtu.sh           |  1 -
>  tools/testing/selftests/net/udpgro.sh         |  2 +-
>  tools/testing/selftests/net/udpgro_bench.sh   |  2 +-
>  tools/testing/selftests/net/udpgro_frglist.sh |  2 +-
>  tools/testing/selftests/net/udpgro_fwd.sh     |  2 +-
>  9 files changed, 26 insertions(+), 32 deletions(-)
>  delete mode 100644 tools/testing/selftests/net/net_helper.sh
>
> diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
> index b2035ac8920c..8051f8311caf 100644
> --- a/tools/testing/selftests/net/Makefile
> +++ b/tools/testing/selftests/net/Makefile
> @@ -97,7 +97,7 @@ TEST_PROGS += vlan_hw_filter.sh
>  TEST_PROGS += ipv6_route_update_soft_lockup.sh
>  
>  TEST_FILES := settings
> -TEST_FILES += in_netns.sh lib.sh net_helper.sh setup_loopback.sh setup_veth.sh
> +TEST_FILES += in_netns.sh lib.sh setup_loopback.sh setup_veth.sh
>  
>  include ../lib.mk
>  
> diff --git a/tools/testing/selftests/net/ipv6_route_update_soft_lockup.sh b/tools/testing/selftests/net/ipv6_route_update_soft_lockup.sh
> index a6b2b1f9c641..c6866e42f95c 100755
> --- a/tools/testing/selftests/net/ipv6_route_update_soft_lockup.sh
> +++ b/tools/testing/selftests/net/ipv6_route_update_soft_lockup.sh
> @@ -69,7 +69,6 @@
>  # which can affect the conditions needed to trigger a soft lockup.
>  
>  source lib.sh
> -source net_helper.sh
>  
>  TEST_DURATION=300
>  ROUTING_TABLE_REFRESH_PERIOD=0.01
> diff --git a/tools/testing/selftests/net/lib.sh b/tools/testing/selftests/net/lib.sh
> index ea785a217540..449f39a7fe33 100644
> --- a/tools/testing/selftests/net/lib.sh
> +++ b/tools/testing/selftests/net/lib.sh
> @@ -196,3 +196,24 @@ tc_rule_handle_stats_get()
>  	    | jq ".[] | select(.options.handle == $handle) | \
>  		  .options.actions[0].stats$selector"
>  }
> +
> +wait_local_port_listen()
> +{
> +	local listener_ns="${1}"
> +	local port="${2}"
> +	local protocol="${3}"
> +	local pattern
> +	local i
> +
> +	pattern=":$(printf "%04X" "${port}") "
> +
> +	# for tcp protocol additionally check the socket state
> +	[ ${protocol} = "tcp" ] && pattern="${pattern}0A"
> +	for i in $(seq 10); do
> +		if ip netns exec "${listener_ns}" awk '{print $2" "$4}' \
> +		   /proc/net/"${protocol}"* | grep -q "${pattern}"; then
> +			break
> +		fi
> +		sleep 0.1
> +	done
> +}
> diff --git a/tools/testing/selftests/net/net_helper.sh b/tools/testing/selftests/net/net_helper.sh
> deleted file mode 100644
> index 6596fe03c77f..000000000000
> --- a/tools/testing/selftests/net/net_helper.sh
> +++ /dev/null
> @@ -1,25 +0,0 @@
> -#!/bin/bash
> -# SPDX-License-Identifier: GPL-2.0
> -#
> -# Helper functions
> -
> -wait_local_port_listen()
> -{
> -	local listener_ns="${1}"
> -	local port="${2}"
> -	local protocol="${3}"
> -	local pattern
> -	local i
> -
> -	pattern=":$(printf "%04X" "${port}") "
> -
> -	# for tcp protocol additionally check the socket state
> -	[ ${protocol} = "tcp" ] && pattern="${pattern}0A"
> -	for i in $(seq 10); do
> -		if ip netns exec "${listener_ns}" awk '{print $2" "$4}' \
> -		   /proc/net/"${protocol}"* | grep -q "${pattern}"; then
> -			break
> -		fi
> -		sleep 0.1
> -	done
> -}
> diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh
> index 914e061ca9cd..87fe52c63920 100755
> --- a/tools/testing/selftests/net/pmtu.sh
> +++ b/tools/testing/selftests/net/pmtu.sh
> @@ -205,7 +205,6 @@
>  #	Check that PMTU exceptions are created for both paths.
>  
>  source lib.sh
> -source net_helper.sh
>  
>  PAUSE_ON_FAIL=no
>  VERBOSE=0
> diff --git a/tools/testing/selftests/net/udpgro.sh b/tools/testing/selftests/net/udpgro.sh
> index d5ffd8c9172e..1dc337c709f8 100755
> --- a/tools/testing/selftests/net/udpgro.sh
> +++ b/tools/testing/selftests/net/udpgro.sh
> @@ -3,7 +3,7 @@
>  #
>  # Run a series of udpgro functional tests.
>  
> -source net_helper.sh
> +source lib.sh
>  
>  readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
>  
> diff --git a/tools/testing/selftests/net/udpgro_bench.sh b/tools/testing/selftests/net/udpgro_bench.sh
> index 7080eae5312b..52485d85943c 100755
> --- a/tools/testing/selftests/net/udpgro_bench.sh
> +++ b/tools/testing/selftests/net/udpgro_bench.sh
> @@ -3,7 +3,7 @@
>  #
>  # Run a series of udpgro benchmarks
>  
> -source net_helper.sh
> +source lib.sh
>  
>  readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
>  
> diff --git a/tools/testing/selftests/net/udpgro_frglist.sh b/tools/testing/selftests/net/udpgro_frglist.sh
> index e1ff645bd3d1..dd5a4972f62f 100755
> --- a/tools/testing/selftests/net/udpgro_frglist.sh
> +++ b/tools/testing/selftests/net/udpgro_frglist.sh
> @@ -3,7 +3,7 @@
>  #
>  # Run a series of udpgro benchmarks
>  
> -source net_helper.sh
> +source lib.sh
>  
>  readonly PEER_NS="ns-peer-$(mktemp -u XXXXXX)"
>  
> diff --git a/tools/testing/selftests/net/udpgro_fwd.sh b/tools/testing/selftests/net/udpgro_fwd.sh
> index f4549e6894dd..b95c198219f4 100755
> --- a/tools/testing/selftests/net/udpgro_fwd.sh
> +++ b/tools/testing/selftests/net/udpgro_fwd.sh
> @@ -1,7 +1,7 @@
>  #!/bin/bash
>  # SPDX-License-Identifier: GPL-2.0
>  
> -source net_helper.sh
> +source lib.sh
>  
>  BPF_FILE="xdp_dummy.o"
>  readonly BASE="ns-$(mktemp -u XXXXXX)"

Nacking so that this patch is removed from the KTML board, as a v3 of this
patch has already been accepted on the mailing list.

 - Alice C. Munduruca



More information about the kernel-team mailing list