From: Hangbin Liu 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 --- 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 . @@ -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