🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
3 messages
3 total messages Started by Hangbin Liu Thu, 12 Nov 2026 09:27
[PATCH net-next v3 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper
#14994
Author: Hangbin Liu
Date: Thu, 12 Nov 2026 09:27
125 lines
12363 bytes
From: Hangbin Liu <liuhangbin@kylinos.cn>

setup() installs both the base topology and the End PSP policies. That
couples general test setup with one specific flavor scenario and makes
it hard to add further flavor cases cleanly.

Extract the End PSP policy setup into setup_end_flv_psp() so flavor
tests can set up and later tear down independently (the matching
cleanup arrives in a following patch).

Run the block under set -e so a setup failure is treated as an error
instead of falling through into the connectivity checks. When deciding
to report the run as skipped, keep any failure already recorded by a
test, so a real failure is not converted into a skip.

Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
 .../testing/selftests/net/srv6_end_flavors_test.sh | 56 +++++++++++++++++-----
 1 file changed, 45 insertions(+), 11 deletions(-)

diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh
index 157baa8ecb0b..0ed5bfe99029 100755
--- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
+++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
@@ -488,8 +488,9 @@ cleanup()
 
 	# check whether the setup phase was completed successfully or not. In
 	# case of an error during the setup phase of the testing environment,
-	# the selftest is considered as "skipped".
-	if [ "${SETUP_ERR}" -ne 0 ]; then
+	# the selftest is considered as "skipped", unless a test has already
+	# recorded a failure.
+	if [ "${SETUP_ERR}" -ne 0 ] && [ "$ret" -ne "$ksft_fail" ]; then
 		echo "SKIP: Setting up the testing environment failed"
 		exit "${ksft_skip}"
 	fi
@@ -785,6 +786,27 @@ setup_rt_endpoints()
 	done
 }
 
+# setup proxy on route entries for hosts
+# args:
+#  $1 - ingress router that enforces the SRv6 Policy
+#  $2 - destination host whose addresses are proxied
+#  $3 - suffix of the address on the loopback of the destination host
+#       (i.e. cafe::<host>:<suffix>)
+setup_rt_host_proxy()
+{
+	local rt=$1
+	local hs=$2
+	local func=$3
+
+	ip -netns "$(get_rtname "${rt}")" -6 neigh add \
+		proxy "${IPv6_HS_NETWORK}::${hs}" \
+		dev "${RT2HS_DEVNAME}"
+
+	ip -netns "$(get_rtname "${rt}")" -6 neigh add \
+		proxy "${IPv6_HS_NETWORK}::${hs}:${func}" \
+		dev "${RT2HS_DEVNAME}"
+}
+
 # This helper function builds and installs the SID List (i.e. SRv6 Policy)
 # to be applied on incoming packets at the ingress node. Moreover, it
 # configures the SRv6 nodes specified in the SID List to process the traffic
@@ -860,10 +882,6 @@ __setup_rt_policy()
 		add "${IPv6_HS_NETWORK}::${dst}" \
 		encap seg6 mode inline segs "${policy}" \
 		dev "${DUMMY_DEVNAME}"
-
-	ip -netns "${in_nsname}" -6 neigh \
-		add proxy "${IPv6_HS_NETWORK}::${dst}" \
-		dev "${RT2HS_DEVNAME}"
 }
 
 # see __setup_rt_policy
@@ -962,17 +980,29 @@ setup()
 	setup_hs 1 1
 	setup_hs 2 2
 
-	# set up the loopback addresses of the hosts used by the Policies (i.c)
-	# and (i.d).
-	setup_hs_lo_addr 1 1 "${END_CSID_PSP_FUNC}"
-	setup_hs_lo_addr 2 2 "${END_CSID_PSP_FUNC}"
-
 	# set up default SRv6 Endpoints (i.e. SRv6 End behavior)
 	setup_rt_local_sids 1 "2 3 4"
 	setup_rt_local_sids 2 "1 3 4"
 	setup_rt_local_sids 3 "1 2 4"
 	setup_rt_local_sids 4 "1 2 3"
 
+	# testing environment was set up successfully
+	SETUP_ERR=0
+}
+
+setup_end_flv_psp()
+{
+	SETUP_ERR=1
+
+	# set up the loopback addresses of the hosts used by the Policies (i.c)
+	# and (i.d).
+	setup_hs_lo_addr 1 1 "${END_CSID_PSP_FUNC}"
+	setup_hs_lo_addr 2 2 "${END_CSID_PSP_FUNC}"
+
+	# setup proxy on route entries for hosts
+	setup_rt_host_proxy 1 2 "${END_CSID_PSP_FUNC}"
+	setup_rt_host_proxy 2 1 "${END_CSID_PSP_FUNC}"
+
 	# set up SRv6 policies
 	# create a connection between hosts hs-1 and hs-2.
 	# The path between hs-1 and hs-2 traverses SRv6 aware routers.
@@ -1429,6 +1459,10 @@ set +e
 
 router_tests
 host2gateway_tests
+
+set -e
+setup_end_flv_psp
+set +e
 host_srv6_end_flv_psp_tests
 host_srv6_end_flv_next_csid_psp_tests
 host_srv6_end_flv_consumed_srh_tests

-- 
2.56.0
Re: [PATCH net-next v3 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper
#16942
Author: Andrea Mayer
Date: Mon, 16 Nov 2026 04:26
152 lines
15431 bytes
On Thu, 12 Nov 2026 17:27:58 +0800
Hangbin Liu <hangbin.liu@linux.dev> wrote:

> setup() installs both the base topology and the End PSP policies. That
> couples general test setup with one specific flavor scenario and makes
> it hard to add further flavor cases cleanly.
>
> Extract the End PSP policy setup into setup_end_flv_psp() so flavor
> tests can set up and later tear down independently (the matching
> cleanup arrives in a following patch).
>
> Run the block under set -e so a setup failure is treated as an error
> instead of falling through into the connectivity checks. When deciding
> to report the run as skipped, keep any failure already recorded by a
> test, so a real failure is not converted into a skip.

Hi Hangbin,
thanks for the v3.

>
> Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
> [snip]
> diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> index 157baa8ecb0b..0ed5bfe99029 100755
> --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
> +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> @@ -488,8 +488,9 @@ cleanup()
>  
>  	# check whether the setup phase was completed successfully or not. In
>  	# case of an error during the setup phase of the testing environment,
> -	# the selftest is considered as "skipped".
> -	if [ "${SETUP_ERR}" -ne 0 ]; then
> +	# the selftest is considered as "skipped", unless a test has already
> +	# recorded a failure.
> +	if [ "${SETUP_ERR}" -ne 0 ] && [ "$ret" -ne "$ksft_fail" ]; then
>  		echo "SKIP: Setting up the testing environment failed"
>  		exit "${ksft_skip}"
>  	fi

When a test has already failed and the setup then fails, the script
exits with 1 and does not say that the setup failed. For example, with
hs-2 -> gw failing and then an error in setup_end_flv_psp(), the last
TEST lines in the log are:

    TEST: IPv6 Hosts connectivity: hs-1 -> gw                           [ OK ]
    TEST: IPv6 Hosts connectivity: hs-2 -> gw                           [FAIL]

The End PSP tests did not run. Before this patch, the setup ran before
any test, and cleanup() printed "Setting up the testing environment
failed" on every setup error. Could cleanup() print it also in this
case, keeping the exit code 1? Something like:

	if [ "${SETUP_ERR}" -ne 0 ]; then
		if [ "${ret}" -ne "${ksft_fail}" ]; then
			echo "SKIP: Setting up the testing environment failed"
			exit "${ksft_skip}"
		fi

		echo "FAIL: Setting up the testing environment failed"
	fi

	exit "${ret}"

> @@ -785,6 +786,27 @@ setup_rt_endpoints()
>  	done
>  }
>  
> +# setup proxy on route entries for hosts
> +# args:
> +#  $1 - ingress router that enforces the SRv6 Policy
> +#  $2 - destination host whose addresses are proxied
> +#  $3 - suffix of the address on the loopback of the destination host
> +#       (i.e. cafe::<host>:<suffix>)
> +setup_rt_host_proxy()
> +{
> +	local rt=$1
> +	local hs=$2
> +	local func=$3
> +
> +	ip -netns "$(get_rtname "${rt}")" -6 neigh add \
> +		proxy "${IPv6_HS_NETWORK}::${hs}" \
> +		dev "${RT2HS_DEVNAME}"
> +
> +	ip -netns "$(get_rtname "${rt}")" -6 neigh add \
> +		proxy "${IPv6_HS_NETWORK}::${hs}:${func}" \
> +		dev "${RT2HS_DEVNAME}"
> +}
> +
>  # This helper function builds and installs the SID List (i.e. SRv6 Policy)
>  # to be applied on incoming packets at the ingress node. Moreover, it
>  # configures the SRv6 nodes specified in the SID List to process the traffic
> @@ -860,10 +882,6 @@ __setup_rt_policy()
>  		add "${IPv6_HS_NETWORK}::${dst}" \
>  		encap seg6 mode inline segs "${policy}" \
>  		dev "${DUMMY_DEVNAME}"
> -
> -	ip -netns "${in_nsname}" -6 neigh \
> -		add proxy "${IPv6_HS_NETWORK}::${dst}" \
> -		dev "${RT2HS_DEVNAME}"
>  }
>  
>  # see __setup_rt_policy
> @@ -962,17 +980,29 @@ setup()
>  	setup_hs 1 1
>  	setup_hs 2 2
>  
> -	# set up the loopback addresses of the hosts used by the Policies (i.c)
> -	# and (i.d).
> -	setup_hs_lo_addr 1 1 "${END_CSID_PSP_FUNC}"
> -	setup_hs_lo_addr 2 2 "${END_CSID_PSP_FUNC}"
> -
>  	# set up default SRv6 Endpoints (i.e. SRv6 End behavior)
>  	setup_rt_local_sids 1 "2 3 4"
>  	setup_rt_local_sids 2 "1 3 4"
>  	setup_rt_local_sids 3 "1 2 4"
>  	setup_rt_local_sids 4 "1 2 3"
>  
> +	# testing environment was set up successfully
> +	SETUP_ERR=0
> +}
> +
> +setup_end_flv_psp()
> +{
> +	SETUP_ERR=1
> +
> +	# set up the loopback addresses of the hosts used by the Policies (i.c)
> +	# and (i.d).
> +	setup_hs_lo_addr 1 1 "${END_CSID_PSP_FUNC}"
> +	setup_hs_lo_addr 2 2 "${END_CSID_PSP_FUNC}"
> +
> +	# setup proxy on route entries for hosts
> +	setup_rt_host_proxy 1 2 "${END_CSID_PSP_FUNC}"
> +	setup_rt_host_proxy 2 1 "${END_CSID_PSP_FUNC}"
> +
>  	# set up SRv6 policies
>  	# create a connection between hosts hs-1 and hs-2.
>  	# The path between hs-1 and hs-2 traverses SRv6 aware routers.

Before this patch, __setup_rt_policy() added the proxy entry together
with the route of each Policy. With this patch, each scenario calls
setup_rt_host_proxy() instead.

In this v3, 4/5 deletes the proxies when the scenario ends, like the
routes of the Policies. So I think the proxy entry can stay in
__setup_rt_policy(), and in 4/5 its defer can go next to the defer of
the route. What do you think?

> [snip]

Thanks,
Andrea
Re: [PATCH net-next v3 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper
#16961
Author: Hangbin Liu
Date: Mon, 16 Nov 2026 06:20
97 lines
12195 bytes
Hi Andrea,
On Mon, Nov 16, 2026 at 05:26:59AM +0100, Andrea Mayer wrote:
> > [snip]
> > diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> > index 157baa8ecb0b..0ed5bfe99029 100755
> > --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
> > +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> > @@ -488,8 +488,9 @@ cleanup()
> >  
> >  	# check whether the setup phase was completed successfully or not. In
> >  	# case of an error during the setup phase of the testing environment,
> > -	# the selftest is considered as "skipped".
> > -	if [ "${SETUP_ERR}" -ne 0 ]; then
> > +	# the selftest is considered as "skipped", unless a test has already
> > +	# recorded a failure.
> > +	if [ "${SETUP_ERR}" -ne 0 ] && [ "$ret" -ne "$ksft_fail" ]; then
> >  		echo "SKIP: Setting up the testing environment failed"
> >  		exit "${ksft_skip}"
> >  	fi
> 
> When a test has already failed and the setup then fails, the script
> exits with 1 and does not say that the setup failed. For example, with
> hs-2 -> gw failing and then an error in setup_end_flv_psp(), the last
> TEST lines in the log are:
> 
>     TEST: IPv6 Hosts connectivity: hs-1 -> gw                           [ OK ]
>     TEST: IPv6 Hosts connectivity: hs-2 -> gw                           [FAIL]
> 
> The End PSP tests did not run. Before this patch, the setup ran before
> any test, and cleanup() printed "Setting up the testing environment
> failed" on every setup error. Could cleanup() print it also in this
> case, keeping the exit code 1? Something like:
> 
> 	if [ "${SETUP_ERR}" -ne 0 ]; then
> 		if [ "${ret}" -ne "${ksft_fail}" ]; then
> 			echo "SKIP: Setting up the testing environment failed"
> 			exit "${ksft_skip}"
> 		fi
> 
> 		echo "FAIL: Setting up the testing environment failed"
> 	fi
> 
> 	exit "${ret}"

OK, I will fix it.

> >  # see __setup_rt_policy
> > @@ -962,17 +980,29 @@ setup()
> >  	setup_hs 1 1
> >  	setup_hs 2 2
> >  
> > -	# set up the loopback addresses of the hosts used by the Policies (i.c)
> > -	# and (i.d).
> > -	setup_hs_lo_addr 1 1 "${END_CSID_PSP_FUNC}"
> > -	setup_hs_lo_addr 2 2 "${END_CSID_PSP_FUNC}"
> > -
> >  	# set up default SRv6 Endpoints (i.e. SRv6 End behavior)
> >  	setup_rt_local_sids 1 "2 3 4"
> >  	setup_rt_local_sids 2 "1 3 4"
> >  	setup_rt_local_sids 3 "1 2 4"
> >  	setup_rt_local_sids 4 "1 2 3"
> >  
> > +	# testing environment was set up successfully
> > +	SETUP_ERR=0
> > +}
> > +
> > +setup_end_flv_psp()
> > +{
> > +	SETUP_ERR=1
> > +
> > +	# set up the loopback addresses of the hosts used by the Policies (i.c)
> > +	# and (i.d).
> > +	setup_hs_lo_addr 1 1 "${END_CSID_PSP_FUNC}"
> > +	setup_hs_lo_addr 2 2 "${END_CSID_PSP_FUNC}"
> > +
> > +	# setup proxy on route entries for hosts
> > +	setup_rt_host_proxy 1 2 "${END_CSID_PSP_FUNC}"
> > +	setup_rt_host_proxy 2 1 "${END_CSID_PSP_FUNC}"
> > +
> >  	# set up SRv6 policies
> >  	# create a connection between hosts hs-1 and hs-2.
> >  	# The path between hs-1 and hs-2 traverses SRv6 aware routers.
> 
> Before this patch, __setup_rt_policy() added the proxy entry together
> with the route of each Policy. With this patch, each scenario calls
> setup_rt_host_proxy() instead.
> 
> In this v3, 4/5 deletes the proxies when the scenario ends, like the
> routes of the Policies. So I think the proxy entry can stay in
> __setup_rt_policy(), and in 4/5 its defer can go next to the defer of
> the route. What do you think?

OK, I will keep the proxy set up in __setup_rt_policy.

Thanks
Hangbin
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads