🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
4 messages
4 total messages Started by Hangbin Liu Thu, 12 Nov 2026 09:27
[PATCH net-next v3 4/5] selftest: seg6: explicit cleanup for SRv6 End PSP test
#14997
Author: Hangbin Liu
Date: Thu, 12 Nov 2026 09:27
75 lines
10714 bytes
From: Hangbin Liu <liuhangbin@kylinos.cn>

The End PSP tests install policy and localsid state but rely on the
global namespace teardown to remove it. That leaves flavor-specific
state behind once more tests share this script.

Use defer and defer_scopes_cleanup to remove the PSP specified
configurations. i.e.

  * cafe::1, cafe::1:e9, cafe::2, cafe::2:e9 route and proxy on rt1, rt2
  * fcbb:0::x0e9 End next-csid,psp policies on rt 1,2,3,4
  * fcff:x::0ef1 End psp polices on rt 1,2,4

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

diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh
index 0ed5bfe99029..374b43661c28 100755
--- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
+++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
@@ -759,6 +759,8 @@ setup_rt_endpoint()
 		add "${sid}" table "${LOCALSID_TABLE_ID}" \
 		encap seg6local action ${behavior_cfg} \
 		dev "${DUMMY_DEVNAME}"
+	defer ip -netns "${nsname}" -6 route \
+		del "${sid}" table "${LOCALSID_TABLE_ID}"
 }
 
 # Add an SRv6 Endpoint behavior to each router of a Policy element <nodeid:op>.
@@ -801,10 +803,16 @@ setup_rt_host_proxy()
 	ip -netns "$(get_rtname "${rt}")" -6 neigh add \
 		proxy "${IPv6_HS_NETWORK}::${hs}" \
 		dev "${RT2HS_DEVNAME}"
+	defer ip -netns "$(get_rtname "${rt}")" -6 neigh del \
+		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}"
+	defer ip -netns "$(get_rtname "${rt}")" -6 neigh del \
+		proxy "${IPv6_HS_NETWORK}::${hs}:${func}" \
+		dev "${RT2HS_DEVNAME}"
 }
 
 # This helper function builds and installs the SID List (i.e. SRv6 Policy)
@@ -882,6 +890,8 @@ __setup_rt_policy()
 		add "${IPv6_HS_NETWORK}::${dst}" \
 		encap seg6 mode inline segs "${policy}" \
 		dev "${DUMMY_DEVNAME}"
+	defer ip -netns "${in_nsname}" -6 route \
+		del "${IPv6_HS_NETWORK}::${dst}"
 }
 
 # see __setup_rt_policy
@@ -1460,11 +1470,13 @@ set +e
 router_tests
 host2gateway_tests
 
+defer_scope_push
 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
+defer_scope_pop
 
 print_log_test_results

-- 
2.56.0
Re: [PATCH net-next v3 4/5] selftest: seg6: explicit cleanup for SRv6 End PSP test
#16943
Author: Andrea Mayer
Date: Mon, 16 Nov 2026 04:34
117 lines
14170 bytes
On Thu, 12 Nov 2026 17:27:59 +0800
Hangbin Liu <hangbin.liu@linux.dev> wrote:

> The End PSP tests install policy and localsid state but rely on the
> global namespace teardown to remove it. That leaves flavor-specific
> state behind once more tests share this script.
>
> Use defer and defer_scopes_cleanup to remove the PSP specified
> configurations. i.e.
>
>   * cafe::1, cafe::1:e9, cafe::2, cafe::2:e9 route and proxy on rt1, rt2
>   * fcbb:0::x0e9 End next-csid,psp policies on rt 1,2,3,4
>   * fcff:x::0ef1 End psp polices on rt 1,2,4

Hi Hangbin,

A few nits on the message:
- The code uses defer_scope_pop, not defer_scopes_cleanup.
- The NEXT-C-SID End SIDs are fcbb:0:x0e9::/48, not fcbb:0::x0e9.
- "polices" is a typo.
- The subject prefix is "selftest: seg6:", while the other selftest
  patches of the series use "selftests: seg6:".

>
> 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 0ed5bfe99029..374b43661c28 100755
> --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
> +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> @@ -759,6 +759,8 @@ setup_rt_endpoint()
>  		add "${sid}" table "${LOCALSID_TABLE_ID}" \
>  		encap seg6local action ${behavior_cfg} \
>  		dev "${DUMMY_DEVNAME}"
> +	defer ip -netns "${nsname}" -6 route \
> +		del "${sid}" table "${LOCALSID_TABLE_ID}"
>  }
>  
>  # Add an SRv6 Endpoint behavior to each router of a Policy element <nodeid:op>.
> @@ -801,10 +803,16 @@ setup_rt_host_proxy()
>  	ip -netns "$(get_rtname "${rt}")" -6 neigh add \
>  		proxy "${IPv6_HS_NETWORK}::${hs}" \
>  		dev "${RT2HS_DEVNAME}"
> +	defer ip -netns "$(get_rtname "${rt}")" -6 neigh del \
> +		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}"
> +	defer ip -netns "$(get_rtname "${rt}")" -6 neigh del \
> +		proxy "${IPv6_HS_NETWORK}::${hs}:${func}" \
> +		dev "${RT2HS_DEVNAME}"
>  }
>  
>  # This helper function builds and installs the SID List (i.e. SRv6 Policy)
> @@ -882,6 +890,8 @@ __setup_rt_policy()
>  		add "${IPv6_HS_NETWORK}::${dst}" \
>  		encap seg6 mode inline segs "${policy}" \
>  		dev "${DUMMY_DEVNAME}"
> +	defer ip -netns "${in_nsname}" -6 route \
> +		del "${IPv6_HS_NETWORK}::${dst}"
>  }
>  
>  # see __setup_rt_policy

If you agree to keep the proxy entry in __setup_rt_policy(), as
proposed on patch 3, its defer can go next to the defer of the route.
Something like:

	ip -netns "${in_nsname}" -6 route \
		add "${IPv6_HS_NETWORK}::${dst}" \
		encap seg6 mode inline segs "${policy}" \
		dev "${DUMMY_DEVNAME}"
	defer ip -netns "${in_nsname}" -6 route \
		del "${IPv6_HS_NETWORK}::${dst}"

	ip -netns "${in_nsname}" -6 neigh \
		add proxy "${IPv6_HS_NETWORK}::${dst}" \
		dev "${RT2HS_DEVNAME}"
	defer ip -netns "${in_nsname}" -6 neigh \
		del proxy "${IPv6_HS_NETWORK}::${dst}" \
		dev "${RT2HS_DEVNAME}"

> @@ -1460,11 +1470,13 @@ set +e
>  router_tests
>  host2gateway_tests
>  
> +defer_scope_push
>  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
> +defer_scope_pop
>  
>  print_log_test_results

setup_hs_lo_addr() has no defer. The loopback addresses cafe::1:e9
and cafe::2:e9, and the routes that setup_hs_lo_addr() adds on rt-1
and rt-2, stay after defer_scope_pop. Only the End PSP scenario uses
them. Could setup_hs_lo_addr() defer their removal too, like the
Policies? Something like:

	ip -netns "${hsname}" addr add "${addr}/128" dev lo nodad
	defer ip -netns "${hsname}" addr del "${addr}/128" dev lo

	ip -netns "${rtname}" -6 route \
		add "${addr}" \
		via "${IPv6_HS_NETWORK}::${hs}" dev "${RT2HS_DEVNAME}"
	defer ip -netns "${rtname}" -6 route \
		del "${addr}"

Thanks,
Andrea
Re: [PATCH net-next v3 4/5] selftest: seg6: explicit cleanup for SRv6 End PSP test
#16965
Author: Hangbin Liu
Date: Mon, 16 Nov 2026 06:27
124 lines
13052 bytes
Hi Andrea,
On Mon, Nov 16, 2026 at 05:34:07AM +0100, Andrea Mayer wrote:
> On Thu, 12 Nov 2026 17:27:59 +0800
> Hangbin Liu <hangbin.liu@linux.dev> wrote:
> 
> > The End PSP tests install policy and localsid state but rely on the
> > global namespace teardown to remove it. That leaves flavor-specific
> > state behind once more tests share this script.
> >
> > Use defer and defer_scopes_cleanup to remove the PSP specified
> > configurations. i.e.
> >
> >   * cafe::1, cafe::1:e9, cafe::2, cafe::2:e9 route and proxy on rt1, rt2
> >   * fcbb:0::x0e9 End next-csid,psp policies on rt 1,2,3,4
> >   * fcff:x::0ef1 End psp polices on rt 1,2,4
> 
> Hi Hangbin,
> 
> A few nits on the message:
> - The code uses defer_scope_pop, not defer_scopes_cleanup.
> - The NEXT-C-SID End SIDs are fcbb:0:x0e9::/48, not fcbb:0::x0e9.
> - "polices" is a typo.
> - The subject prefix is "selftest: seg6:", while the other selftest
>   patches of the series use "selftests: seg6:".

Thanks for the detailed review, I will fix them.

> 
> >
> > 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 0ed5bfe99029..374b43661c28 100755
> > --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
> > +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> > @@ -759,6 +759,8 @@ setup_rt_endpoint()
> >  		add "${sid}" table "${LOCALSID_TABLE_ID}" \
> >  		encap seg6local action ${behavior_cfg} \
> >  		dev "${DUMMY_DEVNAME}"
> > +	defer ip -netns "${nsname}" -6 route \
> > +		del "${sid}" table "${LOCALSID_TABLE_ID}"
> >  }
> >  
> >  # Add an SRv6 Endpoint behavior to each router of a Policy element <nodeid:op>.
> > @@ -801,10 +803,16 @@ setup_rt_host_proxy()
> >  	ip -netns "$(get_rtname "${rt}")" -6 neigh add \
> >  		proxy "${IPv6_HS_NETWORK}::${hs}" \
> >  		dev "${RT2HS_DEVNAME}"
> > +	defer ip -netns "$(get_rtname "${rt}")" -6 neigh del \
> > +		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}"
> > +	defer ip -netns "$(get_rtname "${rt}")" -6 neigh del \
> > +		proxy "${IPv6_HS_NETWORK}::${hs}:${func}" \
> > +		dev "${RT2HS_DEVNAME}"
> >  }
> >  
> >  # This helper function builds and installs the SID List (i.e. SRv6 Policy)
> > @@ -882,6 +890,8 @@ __setup_rt_policy()
> >  		add "${IPv6_HS_NETWORK}::${dst}" \
> >  		encap seg6 mode inline segs "${policy}" \
> >  		dev "${DUMMY_DEVNAME}"
> > +	defer ip -netns "${in_nsname}" -6 route \
> > +		del "${IPv6_HS_NETWORK}::${dst}"
> >  }
> >  
> >  # see __setup_rt_policy
> 
> If you agree to keep the proxy entry in __setup_rt_policy(), as
> proposed on patch 3, its defer can go next to the defer of the route.
> Something like:
> 
> 	ip -netns "${in_nsname}" -6 route \
> 		add "${IPv6_HS_NETWORK}::${dst}" \
> 		encap seg6 mode inline segs "${policy}" \
> 		dev "${DUMMY_DEVNAME}"
> 	defer ip -netns "${in_nsname}" -6 route \
> 		del "${IPv6_HS_NETWORK}::${dst}"
> 
> 	ip -netns "${in_nsname}" -6 neigh \
> 		add proxy "${IPv6_HS_NETWORK}::${dst}" \
> 		dev "${RT2HS_DEVNAME}"
> 	defer ip -netns "${in_nsname}" -6 neigh \
> 		del proxy "${IPv6_HS_NETWORK}::${dst}" \
> 		dev "${RT2HS_DEVNAME}"
> 
> > @@ -1460,11 +1470,13 @@ set +e
> >  router_tests
> >  host2gateway_tests
> >  
> > +defer_scope_push
> >  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
> > +defer_scope_pop
> >  
> >  print_log_test_results
> 
> setup_hs_lo_addr() has no defer. The loopback addresses cafe::1:e9
> and cafe::2:e9, and the routes that setup_hs_lo_addr() adds on rt-1
> and rt-2, stay after defer_scope_pop. Only the End PSP scenario uses
> them. Could setup_hs_lo_addr() defer their removal too, like the
> Policies? Something like:
> 
> 	ip -netns "${hsname}" addr add "${addr}/128" dev lo nodad
> 	defer ip -netns "${hsname}" addr del "${addr}/128" dev lo
> 
> 	ip -netns "${rtname}" -6 route \
> 		add "${addr}" \
> 		via "${IPv6_HS_NETWORK}::${hs}" dev "${RT2HS_DEVNAME}"
> 	defer ip -netns "${rtname}" -6 route \
> 		del "${addr}"

I will update the defer with your suggestions.

Thanks
Hangbin
Re: [PATCH net-next v3 4/5] selftest: seg6: explicit cleanup for SRv6 End PSP test
#17145
Author: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 12:29
103 lines
11709 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In tools/testing/selftests/net/srv6_end_flavors_test.sh, the
  PSP defer scope does not remove everything the PSP block sets up.
- [Low] The commit message says the patch uses "defer and
  defer_scopes_cleanup", but srv6_end_flavors_test.sh never calls…

--

selftest: seg6: explicit cleanup for SRv6 End PSP test

This commit adds defer calls to setup_rt_endpoint(), setup_rt_host_proxy()
and __setup_rt_policy() in srv6_end_flavors_test.sh. It also wraps the End
PSP setup and tests in a defer_scope_push/defer_scope_pop pair, so the
PSP-specific configuration is removed when that scope ends instead of at
namespace teardown.

> Use defer and defer_scopes_cleanup to remove the PSP specified
> configurations. i.e.

[Severity: Low]
Is this description accurate? The script never calls defer_scopes_cleanup.

The patch uses defer_scope_push and defer_scope_pop in the main script
body. The EXIT handler is unchanged:

trap cleanup EXIT

and cleanup() only deletes the namespaces. net/lib.sh does not install a
trap that runs pending defers either. If setup_end_flv_psp fails under
set -e before defer_scope_pop, the queued jobs are simply dropped.

This doesn't leak anything today, because every deferred command is an
ip -netns command and cleanup() deletes those namespaces anyway.

Could the commit message refer to defer_scope_push/defer_scope_pop instead?

> diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> index 0ed5bfe99029b..374b43661c285 100755
> --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
> +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh

[ ... ]

> @@ -1460,11 +1470,13 @@ set +e
>  router_tests
>  host2gateway_tests
>  
> +defer_scope_push
>  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
> +defer_scope_pop

[Severity: Medium]
Does this scope pop leave the cafe::1:e9 and cafe::2:e9 addresses and
routes in place?

Inside this scope, setup_end_flv_psp() calls setup_hs_lo_addr() for both
hosts:

	setup_hs_lo_addr 1 1 "${END_CSID_PSP_FUNC}"
	setup_hs_lo_addr 2 2 "${END_CSID_PSP_FUNC}"

setup_hs_lo_addr() did not get any defer calls:

	ip -netns "${hsname}" addr add "${addr}/128" dev lo nodad

	ip -netns "${rtname}" -6 route \
		add "${addr}" \
		via "${IPv6_HS_NETWORK}::${hs}" dev "${RT2HS_DEVNAME}"

So after defer_scope_pop, hs-1 and hs-2 still have cafe::<hs>:e9/128 on lo,
and rt-1 and rt-2 still have their routes to those addresses. The commit
message lists the cafe::1:e9 and cafe::2:e9 routes as state this patch
removes.

A later block that calls setup_hs_lo_addr with the same suffix under set -e
would fail with EEXIST and be reported as a setup skip. Nothing fails yet:
the End.X block added later in the series ("selftests: seg6: add PSP
flavor testing for SRv6 End.X") uses a different suffix (a9). But
setup_hs_lo_addr() is still not deferred at the end of the series.

Would adding something like this to setup_hs_lo_addr() fix it?

	defer ip -netns "${hsname}" addr del "${addr}/128" dev lo
	defer ip -netns "${rtname}" -6 route del "${addr}"

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112-srv6_flavors_endx-v3-0-c9177bbbd965%40kylinos.cn
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