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 the defer helper to remove the configurations installed for the PSP tests: * cafe::1, cafe::1:e9, cafe::2, cafe::2:e9 routes and proxy neighs on rt1, rt2, and the cafe::1:e9, cafe::2:e9 addresses on the hosts' loopback * fcbb:0:x0e9::/48 End next-csid,psp policies on rt 1,2,3,4 * fcff:x::0ef1 End psp policies on rt 1,2,4 After the change, we can wrap the whole end test with test_end_flv() and run it separately. Signed-off-by: Hangbin Liu --- .../testing/selftests/net/srv6_end_flavors_test.sh | 29 ++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh index 250de54d8bfa..9d6b7de648da 100755 --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh @@ -763,6 +763,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 . @@ -865,10 +867,15 @@ __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}" 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}" } # see __setup_rt_policy @@ -929,10 +936,12 @@ setup_hs_lo_addr() addr="${IPv6_HS_NETWORK}::${hs}:${suffix}" ip -netns "${hsname}" addr add "${addr}/128" dev lo nodad + defer ip -netns "${hsname}" addr del "${addr}/128" dev lo nodad ip -netns "${rtname}" -6 route \ add "${addr}" \ via "${IPv6_HS_NETWORK}::${hs}" dev "${RT2HS_DEVNAME}" + defer ip -netns "${rtname}" -6 route del "${addr}" } setup() @@ -1412,6 +1421,18 @@ test_dummy_dev_or_ksft_skip() ip netns del "${test_netns}" } +test_end_flv() +{ + 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 +} + if [ "$(id -u)" -ne 0 ]; then echo "SKIP: Need root privileges" exit "${ksft_skip}" @@ -1443,11 +1464,5 @@ 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 - +test_end_flv print_log_test_results -- 2.56.0