* [PATCH net-next v5 0/5] seg6: add End.X PSP flavor support and selftests
@ 2026-11-26 6:27 Hangbin Liu
2026-11-26 6:27 ` [PATCH net-next v5 1/5] seg6: split final End process out of flavor processing Hangbin Liu
` (5 more replies)
0 siblings, 6 replies; 12+ messages in thread
From: Hangbin Liu @ 2026-11-26 6:27 UTC (permalink / raw)
To: Andrea Mayer, Andrea Mayer, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan
Cc: Hangbin Liu, netdev, linux-kernel, linux-kselftest, Hangbin Liu
This series adds End.X PSP flavor handling in seg6local and extends the
SRv6 selftests to cover it.
Patch 1 splits the final forwarding step out of end_flv8986_core() so
RFC8986 flavor logic can be reused outside the End path.
Patch 2 uses that to add End.X PSP support through the same
end_flv8986_core() path.
Patches 3-4 refactor the PSP selftest setup/cleanup so flavor tests can
be added more cleanly.
Patch 5 adds End.X PSP connectivity coverage and updates the selftest
policy parser to accept an explicit action field.
The goal is to make End.X PSP behavior consistent with End PSP, while
keeping the selftest structure easier to extend for later flavors.
Run all srv6 selftests on debug kernel. All passed without error.
Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
Changes in v5:
- various fixes and updates on patch 5, suggested by Andrea Mayer.
- Link to v4: https://patch.msgid.link/20261119-srv6_flavors_endx-v4-0-284cdb484eee@kylinos.cn
Changes in v4:
- Thanks for Andrea' reviewing. All the changes are based on Andrea's suggestion
- Patch 3:
- always report on every setup error
- keep adding proxy entry __setup_rt_policy
- Patch 4:
- update commit subject and description
- defer proxy route
- defer setup_hs_lo_addr
- Patch 5:
- add helper __get_srv6_node_id() and __get_srv6_adjacent_id to get
node id and adjacent id. Remove __get_srv6_rtcfg_all_id.
- merge three __get_*_func() to one __get_func() helper
- update build_csid() to use the 2 new add helper
- __setup_rt_policy
- add a check to drop incorrect policy
- use get_rt_sid() to get the policy
- read the element once, and pass only what setup_rt_endpoints() needs
- add a check of the kernel support for End.X PSP.
- add a own SID for each adjacency
- add consumed SRH testing for End.X
- Link to v3: https://patch.msgid.link/20261112-srv6_flavors_endx-v3-0-c9177bbbd965@kylinos.cn
Changes in v3:
- Rebase on Andrea's "seg6: fixes for the PSP flavor of SRv6 End"
- Update selftest to support the new SID format
- Link to v2: https://lore.kernel.org/r/20261009-srv6_flavors_endx-v2-0-56ac7f838f41@kylinos.cn
Changes in v2:
- rebase on Andrea's "seg6: ensure packet data is writable before modifying SRH and IPv6 DA"
- Patch 2: Update end_flv8986_core() comment for End.X
- Patch 3: Move ret check in this patch
- Patch 4: Do not remove noflv route
- Link to v1: https://lore.kernel.org/r/20260922-srv6_flavors_endx-v1-0-4d01c05c47b7@kylinos.cn
---
Hangbin Liu (5):
seg6: split final End process out of flavor processing
seg6: add RFC8986 flavor support for End.X
selftests: seg6: move SRv6 End PSP setup into its own helper
selftests: seg6: explicit cleanup for SRv6 End PSP test
selftests: seg6: add PSP flavor testing for SRv6 End.X
net/ipv6/seg6_local.c | 31 +-
.../testing/selftests/net/srv6_end_flavors_test.sh | 614 +++++++++++++++++----
2 files changed, 543 insertions(+), 102 deletions(-)
---
base-commit: 4cd558c2f1de7f1800f7d9065303ca5833cbad56
change-id: 20260922-srv6_flavors_endx-9489116d50c4
Best regards,
--
Hangbin Liu <liuhangbin@kylinos.cn>
^ permalink raw reply [flat|nested] 12+ messages in thread* [PATCH net-next v5 1/5] seg6: split final End process out of flavor processing 2026-11-26 6:27 [PATCH net-next v5 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu @ 2026-11-26 6:27 ` Hangbin Liu 2026-11-30 3:55 ` Andrea Mayer 2026-11-26 6:27 ` [PATCH net-next v5 2/5] seg6: add RFC8986 flavor support for End.X Hangbin Liu ` (4 subsequent siblings) 5 siblings, 1 reply; 12+ messages in thread From: Hangbin Liu @ 2026-11-26 6:27 UTC (permalink / raw) To: Andrea Mayer, Andrea Mayer, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan Cc: Hangbin Liu, netdev, linux-kernel, linux-kselftest, Hangbin Liu From: Hangbin Liu <liuhangbin@kylinos.cn> Move the final End forwarding step out of end_flv8986_core() and return success to the caller instead. Currently end_flv8986_core() performs both RFC8986 flavor processing and final End forwarding by calling input_action_end_finish(). That couples flavor handling with the End-specific forwarding path, which makes it unable to reuse the same flavor logic for other End variants. Split the two steps so input_action_end() does: 1) end_flv8986_core() for flavor processing 2) input_action_end_finish() for final forwarding This keeps end_flv8986_core() focused on RFC8986/PSP flavor semantics and makes it easier to plug the same flavor core into End.X/T later. Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn> --- net/ipv6/seg6_local.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c index cd93b72a0b22..fc651a83e4b7 100644 --- a/net/ipv6/seg6_local.c +++ b/net/ipv6/seg6_local.c @@ -940,6 +940,9 @@ static struct ipv6_sr_hdr *seg6_flv8986_get_srh(struct sk_buff *skb) /* process the packet on the basis of the RFC8986 flavors set for the given * SRv6 End behavior instance. + * + * Returns with skb freed on failure. On success, the caller must complete + * final processing and forward the packet. */ static int end_flv8986_core(struct sk_buff *skb, struct seg6_local_lwt *slwt) { @@ -1000,7 +1003,7 @@ static int end_flv8986_core(struct sk_buff *skb, struct seg6_local_lwt *slwt) goto drop; } - return input_action_end_finish(skb, slwt); + return 0; drop: kfree_skb_reason(skb, reason); @@ -1012,6 +1015,7 @@ static int input_action_end(struct sk_buff *skb, struct seg6_local_lwt *slwt) { const struct seg6_flavors_info *finfo = &slwt->flv_info; __u32 fops = finfo->flv_ops; + int ret; if (!fops) return input_action_end_core(skb, slwt); @@ -1025,7 +1029,11 @@ static int input_action_end(struct sk_buff *skb, struct seg6_local_lwt *slwt) * information extracted from the packet, e.g. presence/absence of SRH, * Segment Left = 0, etc. */ - return end_flv8986_core(skb, slwt); + ret = end_flv8986_core(skb, slwt); + if (ret) + return ret; + + return input_action_end_finish(skb, slwt); } /* regular endpoint, and forward to specified nexthop */ -- 2.56.0 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v5 1/5] seg6: split final End process out of flavor processing 2026-11-26 6:27 ` [PATCH net-next v5 1/5] seg6: split final End process out of flavor processing Hangbin Liu @ 2026-11-30 3:55 ` Andrea Mayer 0 siblings, 0 replies; 12+ messages in thread From: Andrea Mayer @ 2026-11-30 3:55 UTC (permalink / raw) To: Hangbin Liu Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan, netdev, linux-kernel, linux-kselftest, Hangbin Liu, Stefano Salsano, Andrea Mayer, Andrea Mayer On Thu, 26 Nov 2026 14:27:23 +0800 Hangbin Liu <hangbin.liu@linux.dev> wrote: > From: Hangbin Liu <liuhangbin@kylinos.cn> > > Move the final End forwarding step out of end_flv8986_core() and return > success to the caller instead. > > Currently end_flv8986_core() performs both RFC8986 flavor processing and > final End forwarding by calling input_action_end_finish(). That couples > flavor handling with the End-specific forwarding path, which makes it > unable to reuse the same flavor logic for other End variants. > > Split the two steps so input_action_end() does: > 1) end_flv8986_core() for flavor processing > 2) input_action_end_finish() for final forwarding > > This keeps end_flv8986_core() focused on RFC8986/PSP flavor semantics > and makes it easier to plug the same flavor core into End.X/T later. > > Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn> > [snip] Reviewed-by: Andrea Mayer <andrea.mayer@uniroma2.it> Thanks, Andrea ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net-next v5 2/5] seg6: add RFC8986 flavor support for End.X 2026-11-26 6:27 [PATCH net-next v5 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu 2026-11-26 6:27 ` [PATCH net-next v5 1/5] seg6: split final End process out of flavor processing Hangbin Liu @ 2026-11-26 6:27 ` Hangbin Liu 2026-11-30 4:03 ` Andrea Mayer 2026-11-26 6:27 ` [PATCH net-next v5 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper Hangbin Liu ` (3 subsequent siblings) 5 siblings, 1 reply; 12+ messages in thread From: Hangbin Liu @ 2026-11-26 6:27 UTC (permalink / raw) To: Andrea Mayer, Andrea Mayer, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan Cc: Hangbin Liu, netdev, linux-kernel, linux-kselftest, Hangbin Liu From: Hangbin Liu <liuhangbin@kylinos.cn> The End.X behavior only advertises NEXT-C-SID and falls back to plain input_action_end_x_core() for anything else, so "End.X flavors psp" is rejected at present. RFC 8986 defines PSP for End.X as well, and end_flv8986_core() already implements the flavor dispatch used by End. Add SEG6_LOCAL_FLV8986_SUPP_OPS to SEG6_LOCAL_END_X_FLV_SUPP_OPS and process flavors in input_action_end_x() the same way input_action_end() does. With no flavor configured the behavior is unchanged. Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn> --- net/ipv6/seg6_local.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c index fc651a83e4b7..6830f7d5e066 100644 --- a/net/ipv6/seg6_local.c +++ b/net/ipv6/seg6_local.c @@ -122,7 +122,8 @@ struct bpf_lwt_prog { #define SEG6_LOCAL_END_FLV_SUPP_OPS (SEG6_F_LOCAL_FLV_NEXT_CSID | \ SEG6_LOCAL_FLV8986_SUPP_OPS) -#define SEG6_LOCAL_END_X_FLV_SUPP_OPS SEG6_F_LOCAL_FLV_NEXT_CSID +#define SEG6_LOCAL_END_X_FLV_SUPP_OPS (SEG6_F_LOCAL_FLV_NEXT_CSID | \ + SEG6_LOCAL_FLV8986_SUPP_OPS) struct seg6_flavors_info { /* Flavor operations */ @@ -939,7 +940,7 @@ static struct ipv6_sr_hdr *seg6_flv8986_get_srh(struct sk_buff *skb) } /* process the packet on the basis of the RFC8986 flavors set for the given - * SRv6 End behavior instance. + * SRv6 End, End.X behavior instance. * * Returns with skb freed on failure. On success, the caller must complete * final processing and forward the packet. @@ -1041,12 +1042,20 @@ static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt) { const struct seg6_flavors_info *finfo = &slwt->flv_info; __u32 fops = finfo->flv_ops; + int ret; + + if (!fops) + return input_action_end_x_core(skb, slwt); - /* check for the presence of NEXT-C-SID since it applies first */ - if (seg6_next_csid_enabled(fops)) + /* NEXT-C-SID is evaluated first, when configured */ + if (seg6_use_next_csid(skb, finfo)) return end_x_next_csid_core(skb, slwt); - return input_action_end_x_core(skb, slwt); + ret = end_flv8986_core(skb, slwt); + if (ret) + return ret; + + return input_action_end_x_finish(skb, slwt); } static int input_action_end_t(struct sk_buff *skb, struct seg6_local_lwt *slwt) -- 2.56.0 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v5 2/5] seg6: add RFC8986 flavor support for End.X 2026-11-26 6:27 ` [PATCH net-next v5 2/5] seg6: add RFC8986 flavor support for End.X Hangbin Liu @ 2026-11-30 4:03 ` Andrea Mayer 0 siblings, 0 replies; 12+ messages in thread From: Andrea Mayer @ 2026-11-30 4:03 UTC (permalink / raw) To: Hangbin Liu Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan, netdev, linux-kernel, linux-kselftest, Hangbin Liu, Stefano Salsano, Andrea Mayer, Andrea Mayer On Thu, 26 Nov 2026 14:27:24 +0800 Hangbin Liu <hangbin.liu@linux.dev> wrote: > From: Hangbin Liu <liuhangbin@kylinos.cn> > > The End.X behavior only advertises NEXT-C-SID and falls back to plain > input_action_end_x_core() for anything else, so "End.X flavors psp" is > rejected at present. RFC 8986 defines PSP for End.X as well, and > end_flv8986_core() already implements the flavor dispatch used by End. > > Add SEG6_LOCAL_FLV8986_SUPP_OPS to SEG6_LOCAL_END_X_FLV_SUPP_OPS and > process flavors in input_action_end_x() the same way input_action_end() > does. With no flavor configured the behavior is unchanged. > > Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn> > [snip] Reviewed-by: Andrea Mayer <andrea.mayer@uniroma2.it> Thanks, Andrea ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net-next v5 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper 2026-11-26 6:27 [PATCH net-next v5 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu 2026-11-26 6:27 ` [PATCH net-next v5 1/5] seg6: split final End process out of flavor processing Hangbin Liu 2026-11-26 6:27 ` [PATCH net-next v5 2/5] seg6: add RFC8986 flavor support for End.X Hangbin Liu @ 2026-11-26 6:27 ` Hangbin Liu 2026-11-30 3:47 ` Andrea Mayer 2026-11-26 6:27 ` [PATCH net-next v5 4/5] selftests: seg6: explicit cleanup for SRv6 End PSP test Hangbin Liu ` (2 subsequent siblings) 5 siblings, 1 reply; 12+ messages in thread From: Hangbin Liu @ 2026-11-26 6:27 UTC (permalink / raw) To: Andrea Mayer, Andrea Mayer, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan Cc: Hangbin Liu, netdev, linux-kernel, linux-kselftest, Hangbin Liu 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 | 33 ++++++++++++++++------ 1 file changed, 25 insertions(+), 8 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..250de54d8bfa 100755 --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh @@ -488,10 +488,15 @@ 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". + # the selftest is considered as "skipped", unless a test has already + # recorded a failure. if [ "${SETUP_ERR}" -ne 0 ]; then - echo "SKIP: Setting up the testing environment failed" - exit "${ksft_skip}" + 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}" @@ -962,17 +967,25 @@ 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}" + # 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 +1442,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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v5 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper 2026-11-26 6:27 ` [PATCH net-next v5 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper Hangbin Liu @ 2026-11-30 3:47 ` Andrea Mayer 0 siblings, 0 replies; 12+ messages in thread From: Andrea Mayer @ 2026-11-30 3:47 UTC (permalink / raw) To: Hangbin Liu Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan, netdev, linux-kernel, linux-kselftest, Hangbin Liu, Stefano Salsano, Andrea Mayer, Andrea Mayer On Thu, 26 Nov 2026 14:27:25 +0800 Hangbin Liu <hangbin.liu@linux.dev> wrote: Hi Hangbin, > 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> > [snip] > @@ -488,10 +488,15 @@ 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". > + # the selftest is considered as "skipped", unless a test has already > + # recorded a failure. > if [ "${SETUP_ERR}" -ne 0 ]; then > - echo "SKIP: Setting up the testing environment failed" > - exit "${ksft_skip}" > + 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}" Nit, a style preference: "${ret}" and "${ksft_fail}", as for the other variables here. Thanks, Andrea ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net-next v5 4/5] selftests: seg6: explicit cleanup for SRv6 End PSP test 2026-11-26 6:27 [PATCH net-next v5 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu ` (2 preceding siblings ...) 2026-11-26 6:27 ` [PATCH net-next v5 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper Hangbin Liu @ 2026-11-26 6:27 ` Hangbin Liu 2026-11-26 6:27 ` [PATCH net-next v5 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X Hangbin Liu 2026-11-29 2:38 ` [PATCH net-next v5 0/5] seg6: add End.X PSP flavor support and selftests Andrea Mayer 5 siblings, 0 replies; 12+ messages in thread From: Hangbin Liu @ 2026-11-26 6:27 UTC (permalink / raw) To: Andrea Mayer, Andrea Mayer, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan Cc: Hangbin Liu, netdev, linux-kernel, linux-kselftest, Hangbin Liu 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 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 <liuhangbin@kylinos.cn> --- .../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 <nodeid:op>. @@ -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 ^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net-next v5 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X 2026-11-26 6:27 [PATCH net-next v5 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu ` (3 preceding siblings ...) 2026-11-26 6:27 ` [PATCH net-next v5 4/5] selftests: seg6: explicit cleanup for SRv6 End PSP test Hangbin Liu @ 2026-11-26 6:27 ` Hangbin Liu 2026-12-01 0:14 ` Andrea Mayer 2026-11-29 2:38 ` [PATCH net-next v5 0/5] seg6: add End.X PSP flavor support and selftests Andrea Mayer 5 siblings, 1 reply; 12+ messages in thread From: Hangbin Liu @ 2026-11-26 6:27 UTC (permalink / raw) To: Andrea Mayer, Andrea Mayer, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan Cc: Hangbin Liu, netdev, linux-kernel, linux-kselftest, Hangbin Liu From: Hangbin Liu <liuhangbin@kylinos.cn> Add an End.X flavor scenario to srv6_end_flavors_test.sh that applies the same PSP policies as the End scenario, alone and combined with NEXT-C-SID, with every node bound through its adjacency (e.g. 4>2 for rt-4 towards rt-2, 2>h towards the host). Teach the policy helpers about <nodeid:op:act> elements: - __get_srv6_node_id() and __get_srv6_adjacent_id() return the node and adjacent id - __get_srv6_rtcfg_act() extracts the action - __get_srv6_act_cfg() derives the End.X next hop (nh6) - __get_srv6_param() takes the behavior parameter (adjacency for End.X, 0 for End) - __get_srv6_func() picks the Function for an <act> <op> pair - build_csid()/get_rt_sid() encode the parameter and adjacency into the SIDs (e.g. fcbb:0:34a9:: is End.X on rt-3 towards rt-4) - __check_srv6_rtcfg() validates each element node against the behavior with a per-act regular expression Reuse the existing psp and next-csid,psp helpers for End.X, and add a consumed-SRH test that inserts the extra SRH on the ingress router, since the End.X policy forces the next hop. Install unreachable routes in table 90 for the next SID of each End.X hop under test, so that a broken End.X that falls back to End fails the lookup while a working End.X still forwards via nh6. Extend test_kernel_supp_or_ksft_skip() to probe End.X psp as well as End psp. Failures after a successful probe no longer abort the run, and when End.X psp is missing the scenario is skipped through log_test_skipped() so it still appears in the summary. iproute2 already supports the PSP flavor with End.X. Add the packet path to each test section so the route taken by the traffic is clear. Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn> --- Hi Andrea, The changelog line is getting extremely long. Please let me know if you'd like me to split this into smaller pieces. Thanks a lot for your kind review. --- .../testing/selftests/net/srv6_end_flavors_test.sh | 560 +++++++++++++++++---- 1 file changed, 476 insertions(+), 84 deletions(-) diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh index 9d6b7de648da..ab26233d9e2a 100755 --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh @@ -5,7 +5,7 @@ # author: Paolo Lungaroni <paolo.lungaroni@uniroma2.it> # # This script is designed to test the support for "flavors" in the SRv6 End -# behavior. +# and End.X behaviors. # # Flavors defined in RFC8986 [1] represent additional operations that can modify # or extend the existing SRv6 End, End.X and End.T behaviors. For the sake of @@ -16,10 +16,10 @@ # # The End, End.X, and End.T behaviors can support these flavors either # individually or in combinations. -# Currently in this selftest we consider the PSP flavor for the SRv6 End -# behavior, both alone and combined with the NEXT-C-SID flavor defined in -# RFC9800 [2]. However, it is possible to extend the script as soon as other -# flavors will be supported in the kernel. +# Currently in this selftest we consider the PSP flavor for the SRv6 End and +# End.X behaviors, both alone and combined with the NEXT-C-SID flavor defined +# in RFC9800 [2]. However, it is possible to extend the script as soon as +# other flavors are supported in the kernel. # # The purpose of the PSP flavor consists in instructing the penultimate node # listed in the SRv6 policy to remove (i.e. pop) the SRH from the IPv6 header. @@ -127,7 +127,11 @@ # Local SID table for SRv6 router rt-x # +---------------------------------------------------------------------+ # |fcff:x::e is associated with the SRv6 End behavior | +# |fcff:x::y00a is associated with the SRv6 End.X behavior, with | +# | adjacency to rt-y, towards the host the 0 stays. | # |fcff:x::ef1 is associated with the SRv6 End behavior with PSP flavor | +# |fcff:x::yaf1 is associated with the SRv6 End.X behavior with PSP | +# | flavor, with adjacency to rt-y, towards the host the 0 stays. | # |fcbb:0:xpyy::/48 is associated with the SRv6 behavior and flavors | # | given by the Function yy, and with parameter p of the behavior | # +---------------------------------------------------------------------+ @@ -140,11 +144,12 @@ # containers and it is used as their Locator-Block. # A C-SID (16 bits) is written as xpyy, where: # - x is the Locator-Node (4 bits), i.e. the ID of the router; -# - p is a parameter of the behavior (4 bits), 0 for End, which has none; +# - p is a parameter of the behavior (4 bits), 0 for End, the adjacent router +# for End.X (0 towards the host); # - yy is the Function (8 bits). Its first digit selects the SRv6 behavior -# (e for End, as in fcff:x::e). Its second digit is the set of flavors, as -# a bit mask: 1 for PSP, 2 for USP, 4 for USD and 8 for NEXT-C-SID (as the -# f1 of fcff:x::ef1 for PSP). +# (e for End, as in fcff:x::e; a for End.X, as in fcff:x::y00a). Its second +# digit is the set of flavors, as a bit mask: 1 for PSP, 2 for USP, 4 for +# USD and 8 for NEXT-C-SID (as the f1 of fcff:x::ef1 for PSP). # In the terms of RFC9800 [2], p and yy together are the Function of the C-SID # (12 bits), and p is not part of the Argument: # @@ -153,10 +158,14 @@ # +----------+----------+--------------------+ # | e9 | End | NEXT-C-SID and PSP | # +----------+----------+--------------------+ +# | a9 | End.X | NEXT-C-SID and PSP | +# +----------+----------+--------------------+ # # For example, fcbb:0:40e9:20e9:: is a C-SID container carrying the C-SID of # rt-4 followed by the C-SID of rt-2, both with the NEXT-C-SID and PSP flavors. # +# fcbb:0:34a9:: is End.X on rt-3, adjacency to rt-4, with NEXT-C-SID and PSP +# flavors. # # SRv6 Policies # ============= @@ -184,6 +193,7 @@ # handled by rt-1 which applies the following SRv6 Policy: # # i.a) IPv6 traffic, SID List=fcff:3::e,fcff:4::ef1,fcff:2::ef1,cafe::2 +# Path: hs-1 -> rt-1 -> rt-3 -> rt-4 -> rt-2 -> hs-2 # # Router rt-1 is configured to enforce the Policy (i.a) through the SRv6 # H.Insert behavior which pushes the SRH after the existing IPv6 header. This @@ -216,6 +226,7 @@ # applies the following SRv6 Policy: # # i.b) IPv6 traffic, SID List=fcff:1::ef1,cafe::1 +# Path: hs-2 -> rt-2 -> rt-1 -> hs-1 # # Router rt-2 is configured to enforce the Policy (i.b) through the SRv6 # H.Insert behavior which pushes the SRH after the existing IPv6 header. This @@ -241,7 +252,9 @@ # cafe::1:e9 (i.d): # # i.c) IPv6 traffic, SID List=fcbb:0:30e9::,fcbb:0:40e9:20e9::,cafe::2:e9 +# Path: hs-1 -> rt-1 -> rt-3 -> rt-4 -> rt-2 -> hs-2 # i.d) IPv6 traffic, SID List=fcbb:0:40e9:30e9:10e9::,cafe::1:e9 +# Path: hs-2 -> rt-2 -> rt-4 -> rt-3 -> rt-1 -> hs-1 # # In the Policy (i.c), rt-3 receives a zero Argument with SL=2 and applies the # "standard" End processing. rt-4 receives a non-zero Argument with SL=1: it @@ -258,6 +271,9 @@ # are tested first. This way, each ping checks a single Policy with the # NEXT-C-SID flavor, and a failure points directly to that Policy. # +# The End.X scenario reuses the same paths, with every node bound through its +# adjacency and the Functions 00a, af1, and a9 in place of 000e, 0ef1, and e9. +# # The hosts drop the packets that carry an SRH (seg6_enabled is set to 0 on # the hosts). The loopback address of a host is reached only through the # router connected to that host: the ping succeeds only if the SRH is removed @@ -298,15 +314,20 @@ # instead of the Policy's SRH: # IPv6 DA=cafe::2 | extra SRH, SL=0 | Payload # +# Path: hs-1 -> rt-1 -> rt-3 -> rt-4 [ -> rt-3 ] -> rt-2 -> hs-2 +# # The extra SRH reaches hs-2, which skips it as its SL is 0. The other # Policies work in the same way: # # (i.b) hs-2 -> hs-1: on the packets with DA=fcff:1::ef1, rt-2 inserts the # extra SRH with SID List=fcff:3::e,fcff:1::ef1, and rt-3 consumes it. +# Path: hs-2 -> rt-2 [ -> rt-3 ] -> rt-1 -> hs-1 # (i.c) hs-1 -> hs-2: on the packets with DA=fcbb:0:20e9::, rt-4 inserts the # extra SRH with SID List=fcff:3::e,fcbb:0:20e9::, and rt-3 consumes it. +# Path: hs-1 -> rt-1 -> rt-3 -> rt-4 [ -> rt-3 ] -> rt-2 -> hs-2 # (i.d) hs-2 -> hs-1: on the packets with DA=fcbb:0:10e9::, rt-3 inserts the # extra SRH with SID List=fcff:4::e,fcbb:0:10e9::, and rt-4 consumes it. +# Path: hs-2 -> rt-2 -> rt-4 -> rt-3 [ -> rt-4 ] -> rt-1 -> hs-1 # # The Policy (i.b) has no router between rt-2 and rt-1. For this reason, rt-2 # applies the Policy, inserts the extra SRH and sends the packet to rt-3: @@ -324,7 +345,24 @@ # fcff:2::ef1 for the Policy (i.a)). # These tests need ip6tables with the srh match, and they are skipped without # it. - +# +# The End.X policy has a forced next hop, so we insert the extra SRH on the +# ingress router instead. For example: +# +# (i.a) hs-1 -> hs-2: on the packets with DA=fcff:3::400a, rt-1 inserts the +# extra SRH with SID List=fcff:4::e,fcff:3::400a, and rt-4 consumes it. +# Path: hs-1 -> rt-1 [ -> rt-4 ] -> rt-3 -> rt-4 -> rt-2 -> hs-2 +# (i.b) hs-2 -> hs-1: on the packets with DA=fcff:1::0af1, rt-2 inserts the +# extra SRH with SID List=fcff:3::e,fcff:1::0af1, and rt-3 consumes it. +# Path: hs-2 -> rt-2 [ -> rt-3 ] -> rt-1 -> hs-1 +# (i.c) hs-1 -> hs-2: on the packets with DA=fcbb:0:34a9::, rt-1 inserts the +# extra SRH with SID List=fcff:4::e,fcbb:0:34a9::, and rt-4 consumes it. +# Path: hs-1 -> rt-1 [ -> rt-4 ] -> rt-3 -> rt-4 -> rt-2 -> hs-2 +# (i.d) hs-2 -> hs-1: on the packets with DA=fcbb:0:43a9:31a9:10a9::, rt-2 +# inserts the extra SRH with SID List=fcff:3::e,fcbb:0:43a9:31a9:10a9::, +# and rt-3 consumes it. +# Path: hs-2 -> rt-2 [ -> rt-3 ] -> rt-4 -> rt-3 -> rt-1 -> hs-1 +# # shellcheck source=lib.sh source lib.sh @@ -335,16 +373,17 @@ readonly LOCALSID_TABLE_ID=90 readonly IPv6_RT_NETWORK=fcf0:0 readonly IPv6_HS_NETWORK=cafe readonly IPv6_TESTS_ADDR=2001:db8::1 +readonly IPv6_TESTS_NH6=2001:db8::2 readonly LOCATOR_SERVICE=fcff readonly END_FUNC=000e readonly END_PSP_FUNC=0ef1 readonly END_CSID_PSP_FUNC=e9 +readonly ENDX_FUNC=00a +readonly ENDX_PSP_FUNC=af1 +readonly ENDX_CSID_PSP_FUNC=a9 readonly LCBLOCK_ADDR=fcbb:0 readonly LCBLOCK_BLEN=32 -# do not add ':' as separator. The Locator-Node is followed by the parameter -# of the behavior, 0 for End. -readonly LCNODE_FMT="%x0" readonly LCNODE_BLEN=4 readonly LCNODEFUNC_BLEN=16 @@ -365,6 +404,8 @@ SETUP_ERR=1 # set by check_srh_match_support HAS_SRH_MATCH=false +# set by the End.X kernel support probe +HAS_ENDX_PSP=false ret=${ksft_skip} nsuccess=0 @@ -535,10 +576,12 @@ get_network_prefix() echo "${IPv6_RT_NETWORK}:${p}:${q}" } -# Given the description of a router <id:op> as an input, the function returns -# the <id> token which represents the ID of the router. -# i.e. input: "12:psp" -# output: "12" +# Given the description of a router <id:op:act> as an input, the function +# returns its <id> field with the <op> and <act> fields dropped. +# i.e. input: "12:psp", output: "12" +# input: "1,2:next-csid,psp", output: "1,2" +# input: "1>2:psp:End.X", output: "1>2" +# input: "1>2,2>3:next-csid,psp:End.X", output: "1>2,2>3" __get_srv6_rtcfg_id() { local element="$1" @@ -546,10 +589,32 @@ __get_srv6_rtcfg_id() echo "${element}" | cut -d':' -f1 } -# Given the description of a router <id:op> as an input, the function returns -# the <op> token which represents the operation (e.g. End behavior with or -# without flavors) configured for the node. +# Given the description of a router as an input, the function returns its +# id with the ">" and the adjacent router id dropped. +# i.e. input: "1", output: "1" +# input: "1>2", output: "1" +__get_srv6_node_id() +{ + local element="$1" + echo "${element}" | cut -d'>' -f1 +} + +# Given the description of a router as an input, the function returns its +# adjacent router id, or 0 if the adjacency is a host. +# i.e. input: "1", output: "" +# input: "1>2", output: "2" +# input: "1>h", output: "0" +__get_srv6_adjacent_id() +{ + local element="$1" + + echo "${element}" | cut -s -d'>' -f2 | sed 's/h/0/' +} + +# Given the description of a router <id:op:act> as an input, the function +# returns the <op> token which represents the operation (e.g. End behavior +# with or without flavors) configured for the node. # Note that when the operation represents an End behavior with a list of # flavors, the output is the ordered version of that list. # i.e. input: "5:usp,psp,usd" @@ -563,40 +628,128 @@ __get_srv6_rtcfg_op() xargs | sed 's/ /,/g' } +# Given the description of a router <id:op:act> as an input, the function +# returns the <act> token which represents the action (e.g. End or End.X) +# configured for the node. Returns End by default if not supplied. +# i.e. input: "3>4:noflv:End.X", output: "End.X" +__get_srv6_rtcfg_act() +{ + local element="$1" + + echo "${element}" | cut -d':' -f3 | sed -e 's/^$/End/' +} + +# Given the encapsulation action, current router and next hop as input, the +# function will return the action-specific configuration. +# i.e. input: "End.X 2 0", output: "End.X nh6 cafe::2" +# input: "End.X 4 2", output: "End.X nh6 fcf0:0:2:4::2" +__get_srv6_act_cfg() +{ + local act="$1" + local rt="$2" + local neigh="$3" + local net_prefix + local nh + + case "${act}" in + "End") + echo "End" ;; + "End.X") + if [ "${neigh}" == "0" ]; then + net_prefix="${IPv6_HS_NETWORK}" + nh="${rt}" + else + net_prefix="$(get_network_prefix "${rt}" "${neigh}")" + nh="${neigh}" + fi + echo "End.X nh6 ${net_prefix}::${nh}" ;; + esac +} + +# Get the parameter from behavior. +# End: 0, End.X: the adjacent router (0 for the host) +# i.e. input: "End" "2", output: "0" +# input: "End.X" "4>2", output: "2" +__get_srv6_param() +{ + local act="$1" + local node="$2" + + case "${act}" in + "End.X") + __get_srv6_adjacent_id "${node}" + ;; + *) + echo 0 + ;; + esac +} + +# Return the Function for a given "<act> <op>" pair +# (e.g. "End.X psp" -> af1). +__get_srv6_func() +{ + local act_opt="$1" + + case "${act_opt}" in + "End noflv") + echo "${END_FUNC}" ;; + "End psp") + echo "${END_PSP_FUNC}" ;; + "End next-csid,psp") + echo "${END_CSID_PSP_FUNC}" ;; + "End.X noflv") + echo "${ENDX_FUNC}" ;; + "End.X psp") + echo "${ENDX_PSP_FUNC}" ;; + "End.X next-csid,psp") + echo "${ENDX_CSID_PSP_FUNC}" ;; + esac +} + # Return the C-SID of a router: the Locator-Node (4 bits), i.e. the ID of the -# router, followed by the parameter of the behavior (4 bits, 0) and the -# Function (8 bits). +# router, followed by the parameter of the behavior (the adjacent router for +# End.X, 0 for End and for End.X towards the host, 4 bits) and the Function +# (8 bits). # args: # $1 - router -# $2 - Function (e.g. "e9") -# e.g. input: "4" "e9" -# output: "40e9" +# $2 - parameter of the behavior +# $3 - Function (e.g. "e9") +# e.g. input: "4" "0" "e9", output: "40e9" +# input: "4" "2" "a9", output: "42a9" build_csid() { - local nodeid="$1" - local func="$2" + local rt="$1" + local param="$2" + local func="$3" - printf "${LCNODE_FMT}%s" "${nodeid}" "${func}" + printf "%s%s%s" "${rt}" "${param}" "${func}" } # Return the C-SID container with the C-SIDs of the routers listed in a # "next-csid,<flavors>" element, in the same order. # args: # $1 - <nodeid> of the element: a comma-separated list of routers -# $2 - Function (e.g. "e9") -# e.g. input: "4,2" "e9" -# output: "fcbb:0:40e9:20e9::" +# $2 - <act> of the element +# $3 - Function (e.g. "e9") +# e.g. input: "4,2" "End" "e9", output: "fcbb:0:40e9:20e9::" +# input: "4>2,2>h" "End.X" "a9", output: "fcbb:0:42a9:20a9::" build_csid_container() { local nodeids="$1" - local func="$2" + local act="$2" + local func="$3" local csids='' local nodes + local param local node + local rt nodes="$(echo "${nodeids}" | sed 's/,/ /g')" for node in ${nodes}; do - csids="${csids}:$(build_csid "${node}" "${func}")" + rt="$(__get_srv6_node_id "${node}")" + param="$(__get_srv6_param "${act}" "${node}")" + csids="${csids}:$(build_csid "${rt}" "${param}" "${func}")" done echo "${LCBLOCK_ADDR}${csids}::" @@ -662,7 +815,7 @@ setup_rt_local_sids() # set underlay network routes to reach the C-SID containers # that start with a C-SID of the neighbor, for any parameter and # Function. - csid="$(build_csid "${neigh}" 00)" + csid="$(build_csid "${neigh}" 0 00)" ip -netns "${nsname}" -6 route \ add "${LCBLOCK_ADDR}:${csid}::/${LCBLOCK_NODE_BLEN}" \ table "${LOCALSID_TABLE_ID}" \ @@ -714,27 +867,43 @@ op_has_next_csid() # With NEXT-C-SID, it is the C-SID of the router as a prefix: on rt-4, # fcbb:0:40e9::/48 also matches the DA fcbb:0:40e9:20e9::. # args: -# $1 - router +# $1 - router with or without adjacency router # $2 - operation <op> of the element (e.g. "next-csid,psp") -# $3 - Function (e.g. "0ef1", or "e9" with NEXT-C-SID) -# e.g. input: "4" "psp" "0ef1" -# output: "fcff:4::0ef1" -# input: "4" "next-csid,psp" "e9" -# output: "fcbb:0:40e9::/48" +# $3 - action <act> of the element (e.g. "End" or "End.X") +# $4 - Function (e.g. "0ef1", or "e9" with NEXT-C-SID) +# e.g. input: "4" "noflv" "End" "000e", output: "fcff:4::000e" +# input: "4>2" "noflv" "End.X" "00a", output: "fcff:4::200a" +# input: "4" "psp" "End" "0ef1", output: "fcff:4::0ef1" +# input: "4>2" "psp" "End.X" "af1", output: "fcff:4::2af1" +# input: "4" "next-csid,psp" "End" "e9", output: "fcbb:0:40e9::/48" +# input: "4>2" "next-csid,psp" "End.X" "a9", output: "fcbb:0:42a9::/48" get_rt_sid() { - local rt="$1" + local node="$1" local op_type="$2" - local func="$3" + local act="$3" + local func="$4" + local param local csid if op_has_next_csid "${op_type}"; then - csid="$(build_csid "${rt}" "${func}")" + rt="$(__get_srv6_node_id "${node}")" + param="$(__get_srv6_param "${act}" "${node}")" + csid="$(build_csid "${rt}" "${param}" "${func}")" echo "${LCBLOCK_ADDR}:${csid}::/${LCBLOCK_NODEFUNC_BLEN}" return fi - echo "${LOCATOR_SERVICE}:${rt}::${func}" + case "${act}" in + "End.X") + rt="$(__get_srv6_node_id "${node}")" + param="$(__get_srv6_param "${act}" "${node}")" + echo "${LOCATOR_SERVICE}:${rt}::${param}${func}" + ;; + *) + echo "${LOCATOR_SERVICE}:${node}::${func}" + ;; + esac } # Add an SRv6 Endpoint behavior to a router, bound to a SID. Nothing is added @@ -767,28 +936,38 @@ setup_rt_endpoint() del "${sid}" table "${LOCALSID_TABLE_ID}" } -# Add an SRv6 Endpoint behavior to each router of a Policy element <nodeid:op>. +# Add an SRv6 Endpoint behavior to each router of a Policy element +# <nodeid:op:act>. # args: # $1 - <nodeid> of the element: one router, or a comma-separated list # $2 - operation <op> of the element (e.g. "next-csid,psp") -# $3 - Function (e.g. "0ef1", or "e9" with NEXT-C-SID) -# $4 - SRv6 Endpoint behavior and flavors (e.g. "End flavors psp") -# e.g. input: "4,2" "next-csid,psp" "e9" -# "End flavors next-csid,psp lblen 32 nflen 16" +# $3 - <act> of the element (e.g. "End" or "End.X") +# $4 - Function (e.g. "0ef1", or "e9" with NEXT-C-SID) +# $5 - flavor configuration of the behavior, without the action +# (e.g. "flavors psp") +# e.g. input: "4,2" "next-csid,psp" "End" "e9" +# "flavors next-csid,psp lblen 32 nflen 16" # result: the behavior is added on rt-4, bound to fcbb:0:40e9::/48, and # on rt-2, bound to fcbb:0:20e9::/48 setup_rt_endpoints() { - local node="$1" + local nodes="$1" local op_type="$2" - local func="$3" - local behavior_cfg="$4" + local act="$3" + local func="$4" + local behavior_cfg="$5" + local act_cfg + local node local sid + local adj local rt - for rt in $(echo "${node}" | sed 's/,/ /g'); do - sid="$(get_rt_sid "${rt}" "${op_type}" "${func}")" - setup_rt_endpoint "${rt}" "${sid}" "${behavior_cfg}" + for node in $(echo "${nodes}" | sed 's/,/ /g'); do + rt="$(__get_srv6_node_id "${node}")" + adj="$(__get_srv6_adjacent_id "${node}")" + sid="$(get_rt_sid "${node}" "${op_type}" "${act}" "${func}")" + act_cfg="$(__get_srv6_act_cfg "${act}" "${rt}" "${adj}")" + setup_rt_endpoint "${rt}" "${sid}" "${act_cfg} ${behavior_cfg}" done } @@ -801,12 +980,15 @@ setup_rt_endpoints() # cafe::x:yy on the loopback of the host (e.g. 2:e9) # $2 - SRv6 router configured for enforcing the SRv6 Policy # $3 - compact way to represent a list of SRv6 routers with their operations -# (i.e. behaviors) that each of them needs to perform. Every <nodeid:op> +# (i.e. behaviors) that each of them needs to perform. Every +# <nodeid:op:act> # element constructs a SID that is associated with the behavior <op> on # the <nodeid> node. The list of such elements forms an SRv6 Policy. # For "next-csid,psp", <nodeid> is a comma-separated list of node IDs. # The element constructs a C-SID container with the C-SIDs of these # nodes, e.g. "4,2:next-csid,psp" gives fcbb:0:40e9:20e9::. +# For End.X, the <nodeid> includes ">" and the adjacency ("h" for the +# host), and <act> is "End.X". __setup_rt_policy() { local dst="$1" @@ -819,33 +1001,43 @@ __setup_rt_policy() local function local op_type local node + local act + local sid local n in_nsname="$(get_rtname "${encap_rt}")" for n in ${policy_rts}; do + if ! __check_srv6_rtcfg "${n}"; then + ret="${ksft_fail}" + return 1 + fi + node="$(__get_srv6_rtcfg_id "${n}")" op_type="$(__get_srv6_rtcfg_op "${n}")" + act="$(__get_srv6_rtcfg_act "${n}")" + function="$(__get_srv6_func "${act} ${op_type}")" case "${op_type}" in "noflv") - policy="${policy}${LOCATOR_SERVICE}:${node}::${END_FUNC}," - function="${END_FUNC}" - behavior_cfg="End" + sid="$(get_rt_sid "${node}" "${op_type}" "${act}" \ + "${function}")" + policy="${policy}${sid}," + behavior_cfg="" ;; "psp") - policy="${policy}${LOCATOR_SERVICE}:${node}::${END_PSP_FUNC}," - function="${END_PSP_FUNC}" - behavior_cfg="End flavors psp" + sid="$(get_rt_sid "${node}" "${op_type}" "${act}" \ + "${function}")" + policy="${policy}${sid}," + behavior_cfg="flavors psp" ;; "next-csid,psp") - container="$(build_csid_container "${node}" \ - "${END_CSID_PSP_FUNC}")" + container="$(build_csid_container "${node}" "${act}" \ + "${function}")" policy="${policy}${container}," - function="${END_CSID_PSP_FUNC}" - behavior_cfg="End flavors next-csid,psp ${CSID_CFG}" + behavior_cfg="flavors next-csid,psp ${CSID_CFG}" ;; *) @@ -854,8 +1046,8 @@ __setup_rt_policy() esac # add SRv6 Endpoint behavior to the selected routers - setup_rt_endpoints "${node}" \ - "${op_type}" "${function}" "${behavior_cfg}" + setup_rt_endpoints "${node}" "${op_type}" "${act}" \ + "${function}" "${behavior_cfg}" done # we need to remove the trailing comma to avoid inserting an empty @@ -884,6 +1076,50 @@ setup_rt_policy_ipv6() __setup_rt_policy "$1" "$2" "$3" } +# Set up an unreachable route on a router so that a lookup of the next SID +# fails under End, while End.X still forwards via its adjacency (nh6). +# args: +# $1 - router to configure +# $2 - adjacent router, or a NEXT-C-SID node list (e.g. "4" or "4>2,2>h") +# $3 - operation <op> of the element (e.g. "psp" or "next-csid,psp") +setup_rt_unreachable() +{ + local rt="$1" + local adj="$2" + local op_type="$3" + local net_prefix + local devname + local nsname + local sid + + nsname="$(get_rtname "${rt}")" + + case "${op_type}" in + "psp") + sid="${LOCATOR_SERVICE}:${adj}::/32" + devname="veth-rt-${rt}-${adj}" + net_prefix="$(get_network_prefix "${rt}" "${adj}")" + ip -netns "${nsname}" -6 route \ + change unreachable "${sid}" \ + table "${LOCALSID_TABLE_ID}" + defer ip -netns "${nsname}" -6 route \ + change "${sid}" \ + table "${LOCALSID_TABLE_ID}" \ + via "${net_prefix}::${adj}" dev "${devname}" + ;; + "next-csid,psp") + sid="$(build_csid_container "${adj}" "End.X" \ + "${ENDX_CSID_PSP_FUNC}")" + ip -netns "${nsname}" -6 route \ + add unreachable "${sid}" \ + table "${LOCALSID_TABLE_ID}" + defer ip -netns "${nsname}" -6 route \ + delete "${sid}" \ + table "${LOCALSID_TABLE_ID}" + ;; + esac +} + setup_hs() { local hs="$1" @@ -1031,6 +1267,32 @@ setup_end_flv_psp() SETUP_ERR=0 } +setup_endx_flv_psp() +{ + SETUP_ERR=1 + + setup_hs_lo_addr 1 1 "${ENDX_CSID_PSP_FUNC}" + setup_hs_lo_addr 2 2 "${ENDX_CSID_PSP_FUNC}" + + # The same SRv6 policies as in setup_end_flv_psp, except using End.X + setup_rt_policy_ipv6 2 1 "3>4:noflv:End.X 4>2:psp:End.X 2>h:psp:End.X" + setup_rt_policy_ipv6 1 2 "1>h:psp:End.X" + + setup_rt_policy_ipv6 "2:${ENDX_CSID_PSP_FUNC}" 1 \ + "3>4:next-csid,psp:End.X 4>2,2>h:next-csid,psp:End.X" + setup_rt_policy_ipv6 "1:${ENDX_CSID_PSP_FUNC}" 2 \ + "4>3,3>1,1>h:next-csid,psp:End.X" + + # (i.a) add fcff:4::/32 unreachable on rt-3 and fcff:2::/32 on rt-4 + # (i.c) add fcbb:0:42a9:20a9:: unreachable on rt-3 and fcbb:0:20a9:: + # on rt-4 + setup_rt_unreachable 3 4 "psp" + setup_rt_unreachable 4 2 "psp" + setup_rt_unreachable 3 "4>2,2>h" "next-csid,psp" + setup_rt_unreachable 4 "2>h" "next-csid,psp" + SETUP_ERR=0 +} + check_rt_connectivity() { local rtsrc="$1" @@ -1106,6 +1368,45 @@ check_and_log_hs_lo_addr_connectivity() "IPv6 Hosts connectivity: hs-${hssrc} -> hs-${hsdst} (${dst})" } +__check_srv6_rtcfg() +{ + local element="$1" + local op_type + local node_re + local nodes + local act + + nodes="$(__get_srv6_rtcfg_id "${element}")" + op_type="$(__get_srv6_rtcfg_op "${element}")" + act="$(__get_srv6_rtcfg_act "${element}")" + + if ! op_has_next_csid "${op_type}" && \ + echo "${nodes}" | grep -q ","; then + echo "${element}: only NEXT-C-SID takes more than one node" + return 1 + fi + + case "${act}" in + "End") + node_re='^[1-4]$' + ;; + "End.X") + node_re='^[1-4]>([1-4]|h)$' + ;; + *) + echo "${element}: ${act} is not a behavior" + return 1 + ;; + esac + + for node in $(echo "${nodes}" | sed 's/,/ /g'); do + if [[ ! "${node}" =~ ${node_re} ]]; then + echo "${element}: ${node} is not valid for ${act}" + return 1 + fi + done +} + router_tests() { local i @@ -1137,7 +1438,10 @@ host2gateway_tests() host_srv6_end_flv_psp_tests() { - log_section "SRv6 connectivity test hosts (h1 <-> h2, PSP flavor)" + local act=${1:-"End"} + + log_section \ + "SRv6 connectivity test hosts (h1 <-> h2, ${act} PSP flavor)" check_and_log_hs_connectivity 1 2 check_and_log_hs_connectivity 2 1 @@ -1145,10 +1449,15 @@ host_srv6_end_flv_psp_tests() host_srv6_end_flv_next_csid_psp_tests() { - log_section "SRv6 connectivity test hosts (h1 <-> h2, NEXT-C-SID,PSP)" + local act=${1:-"End"} + local csid_psp_func + + log_section \ + "SRv6 connectivity test hosts (h1 <-> h2, ${act} NEXT-C-SID,PSP)" - check_and_log_hs_lo_addr_connectivity 1 2 "${END_CSID_PSP_FUNC}" - check_and_log_hs_lo_addr_connectivity 2 1 "${END_CSID_PSP_FUNC}" + csid_psp_func="$(__get_srv6_func "${act} next-csid,psp")" + check_and_log_hs_lo_addr_connectivity 1 2 "${csid_psp_func}" + check_and_log_hs_lo_addr_connectivity 2 1 "${csid_psp_func}" } # On a router, add a route for a SID with seg6 encap in inline mode. The packets @@ -1299,7 +1608,7 @@ host_srv6_end_flv_consumed_srh_tests() local sid log_section \ - "SRv6 connectivity test hosts (h1 <-> h2, PSP with a consumed SRH)" + "SRv6 connectivity test hosts (h1 <-> h2, End PSP with a consumed SRH)" if ! ${HAS_SRH_MATCH}; then echo "SKIP: ip6tables srh match not available" @@ -1316,16 +1625,49 @@ host_srv6_end_flv_consumed_srh_tests() check_and_log_consumed_srh 2 "${sid}" 3 2 1 # Policy (i.c): rt-4 inserts the extra SRH consumed by rt-3 - sid="$(build_csid_container 2 "${END_CSID_PSP_FUNC}")" + sid="$(build_csid_container 2 "End" "${END_CSID_PSP_FUNC}")" check_and_log_consumed_srh 4 "${sid}" 3 1 2 "${END_CSID_PSP_FUNC}" # Policy (i.d): rt-3 inserts the extra SRH consumed by rt-4 - sid="$(build_csid_container 1 "${END_CSID_PSP_FUNC}")" + sid="$(build_csid_container 1 "End" "${END_CSID_PSP_FUNC}")" check_and_log_consumed_srh 3 "${sid}" 4 2 1 "${END_CSID_PSP_FUNC}" set_hs_seg6_enabled 0 } +host_srv6_endx_flv_consumed_srh_tests() +{ + local sid + + log_section \ + "SRv6 connectivity test hosts (h1 <-> h2, End.X PSP with a consumed SRH)" + + if ! ${HAS_SRH_MATCH}; then + echo "SKIP: ip6tables srh match not available" + fi + + set_hs_seg6_enabled 1 + + # Policy (i.a): rt-1 inserts the extra SRH consumed by rt-4 + sid="${LOCATOR_SERVICE}:3::4${ENDX_FUNC}" + check_and_log_consumed_srh 1 "${sid}" 4 1 2 + + # Policy (i.b): rt-2 inserts the extra SRH consumed by rt-3 + sid="${LOCATOR_SERVICE}:1::0${ENDX_PSP_FUNC}" + check_and_log_consumed_srh 2 "${sid}" 3 2 1 + + # Policy (i.c): rt-1 inserts the extra SRH consumed by rt-4 + sid="$(build_csid_container "3>4" "End.X" "${ENDX_CSID_PSP_FUNC}")" + check_and_log_consumed_srh 1 "${sid}" 4 1 2 "${ENDX_CSID_PSP_FUNC}" + + # Policy (i.d): rt-2 inserts the extra SRH consumed by rt-3 + sid="$(build_csid_container "4>3,3>1,1>h" "End.X" \ + "${ENDX_CSID_PSP_FUNC}")" + check_and_log_consumed_srh 2 "${sid}" 3 2 1 "${ENDX_CSID_PSP_FUNC}" + + set_hs_seg6_enabled 0 +} + test_iproute2_supp_or_ksft_skip() { local flavor="$1" @@ -1336,16 +1678,22 @@ test_iproute2_supp_or_ksft_skip() fi } -test_kernel_supp_or_ksft_skip() +__test_kernel_supp_or_ksft_skip() { - local flavor="$1" + local action="$1" + local flavor="$2" local test_netns + local policy=() test_netns="kflv-$(mktemp -u XXXXXXXX)" + policy=(action "${action}" flavors "${flavor}") + if [ "$action" == "End.X" ]; then + policy+=(nh6 "${IPv6_TESTS_NH6}") + fi if ! ip netns add "${test_netns}"; then echo "SKIP: Cannot set up netns to test kernel support for flavors" - exit "${ksft_skip}" + return 1 fi if ! ip -netns "${test_netns}" link \ @@ -1353,7 +1701,7 @@ test_kernel_supp_or_ksft_skip() echo "SKIP: Cannot set up dummy dev to test kernel support for flavors" ip netns del "${test_netns}" - exit "${ksft_skip}" + return 1 fi if ! ip -netns "${test_netns}" link \ @@ -1361,19 +1709,42 @@ test_kernel_supp_or_ksft_skip() echo "SKIP: Cannot activate dummy dev to test kernel support for flavors" ip netns del "${test_netns}" - exit "${ksft_skip}" + return 1 fi if ! ip -netns "${test_netns}" -6 route \ add "${IPv6_TESTS_ADDR}" encap seg6local \ - action End flavors "${flavor}" dev "${DUMMY_DEVNAME}"; then - echo "SKIP: ${flavor} flavor not supported in kernel" + "${policy[@]}" dev "${DUMMY_DEVNAME}"; then + echo "SKIP: ${action} flavor ${flavor} not supported in kernel" ip netns del "${test_netns}" + return 1 + fi + + if ! ip -netns "${test_netns}" -6 route show | grep -q "${flavor}"; then + echo "SKIP: ${action} flavor ${flavor} not supported in kernel" + + ip netns del "${test_netns}" + return 1 + fi + + ip netns del "${test_netns}" || true +} + +# Exit directly if the End action is not supported; return 1 for other +# actions when they are not supported. +test_kernel_supp_or_ksft_skip() +{ + local ret + + __test_kernel_supp_or_ksft_skip "$1" "$2" + ret="$?" + + if [ "$ret" -ne 0 ] && [ "$1" == "End" ]; then exit "${ksft_skip}" fi - ip netns del "${test_netns}" + return $ret } # Before enabling the tests with a consumed SRH, make sure that the rules they @@ -1433,6 +1804,24 @@ test_end_flv() defer_scope_pop } +test_endx_flv() +{ + if ! ${HAS_ENDX_PSP}; then + log_section "SRv6 connectivity test hosts (h1 <-> h2, End.X)" + log_test_skipped "SRv6 End.X tests, no End.X PSP in the kernel" + return + fi + + defer_scope_push + set -e + setup_endx_flv_psp + set +e + host_srv6_end_flv_psp_tests "End.X" + host_srv6_end_flv_next_csid_psp_tests "End.X" + host_srv6_endx_flv_consumed_srh_tests + defer_scope_pop +} + if [ "$(id -u)" -ne 0 ]; then echo "SKIP: Need root privileges" exit "${ksft_skip}" @@ -1452,7 +1841,8 @@ test_dummy_dev_or_ksft_skip # NEXT-C-SID is not checked: every kernel and iproute2 version that # supports PSP also supports NEXT-C-SID. test_iproute2_supp_or_ksft_skip psp -test_kernel_supp_or_ksft_skip psp +test_kernel_supp_or_ksft_skip End psp +test_kernel_supp_or_ksft_skip End.X psp && HAS_ENDX_PSP=true check_srh_match_support set -e @@ -1465,4 +1855,6 @@ router_tests host2gateway_tests test_end_flv +test_endx_flv + print_log_test_results -- 2.56.0 ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v5 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X 2026-11-26 6:27 ` [PATCH net-next v5 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X Hangbin Liu @ 2026-12-01 0:14 ` Andrea Mayer 2026-12-01 2:53 ` Hangbin Liu 0 siblings, 1 reply; 12+ messages in thread From: Andrea Mayer @ 2026-12-01 0:14 UTC (permalink / raw) To: Hangbin Liu Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan, netdev, linux-kernel, linux-kselftest, Hangbin Liu, Justin Iurman, Stefano Salsano, Andrea Mayer, Andrea Mayer On Thu, 26 Nov 2026 14:27:27 +0800 Hangbin Liu <hangbin.liu@linux.dev> wrote: Hi Hangbin, thanks for the v5, and for all the work across the versions. The main points are on the commit message, setup_rt_unreachable() and the probe helper. The rest are smaller points. > From: Hangbin Liu <liuhangbin@kylinos.cn> > > Add an End.X flavor scenario to srv6_end_flavors_test.sh that applies > the same PSP policies as the End scenario, alone and combined with > NEXT-C-SID, with every node bound through its adjacency (e.g. 4>2 for > rt-4 towards rt-2, 2>h towards the host). > > Teach the policy helpers about <nodeid:op:act> elements: > - __get_srv6_node_id() and __get_srv6_adjacent_id() return the node > and adjacent id > - __get_srv6_rtcfg_act() extracts the action > - __get_srv6_act_cfg() derives the End.X next hop (nh6) > - __get_srv6_param() takes the behavior parameter (adjacency for > End.X, 0 for End) > - __get_srv6_func() picks the Function for an <act> <op> pair > - build_csid()/get_rt_sid() encode the parameter and adjacency into > the SIDs (e.g. fcbb:0:34a9:: is End.X on rt-3 towards rt-4) > - __check_srv6_rtcfg() validates each element node against the > behavior with a per-act regular expression > > Reuse the existing psp and next-csid,psp helpers for End.X, and add a > consumed-SRH test that inserts the extra SRH on the ingress router, > since the End.X policy forces the next hop. > > Install unreachable routes in table 90 for the next SID of each End.X > hop under test, so that a broken End.X that falls back to End fails the > lookup while a working End.X still forwards via nh6. If I read the setup right, the routes are not for each End.X hop, only for the ones on rt-3 and rt-4 from hs-1 to hs-2. These seem to be enough, as on these hops the packets take the paths of input_action_end_x() without flavors, with the RFC 8986 flavors and with the NEXT-C-SID shift. Thanks also for the route on rt-4 for (i.c), which is the one for the shift. > > Extend test_kernel_supp_or_ksft_skip() to probe End.X psp as well as > End psp. Failures after a successful probe no longer abort the run, and > when End.X psp is missing the scenario is skipped through > log_test_skipped() so it still appears in the summary. iproute2 already > supports the PSP flavor with End.X. > > Add the packet path to each test section so the route taken by the > traffic is clear. > > Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn> > --- > > Hi Andrea, The changelog line is getting extremely long. Please let me > know if you'd like me to split this into smaller pieces. Thanks a lot > for your kind review. To me most of the changes look tied together. The new helpers are added for the End.X elements, and without the End.X scenario their End.X parts would have no user. One part that could be split out is the read back of the route in the probe. It also applies to the End probe, which is already in the tree, so it could be its own patch, before this one. Just an idea on the length of the message. The other paragraphs already say what the tests cover, how they catch an End.X that falls back to End, and when they are skipped. IMHO the list of the helpers is the part that could be shorter, for example a few lines on what changes in the elements and in the SIDs, such as the adjacency in the End.X SIDs (e.g. fcff:3::400a, fcbb:0:34a9::). > [snip] > +# Given the encapsulation action, current router and next hop as input, the > +# function will return the action-specific configuration. > +# i.e. input: "End.X 2 0", output: "End.X nh6 cafe::2" > +# input: "End.X 4 2", output: "End.X nh6 fcf0:0:2:4::2" > +__get_srv6_act_cfg() > +{ > + local act="$1" > + local rt="$2" > + local neigh="$3" Nit: as in the examples of the other helpers, the three arguments could be quoted one by one, "End.X" "2" "0". > [snip] > get_rt_sid() > { > - local rt="$1" > + local node="$1" > local op_type="$2" > - local func="$3" > + local act="$3" > + local func="$4" > + local param > local csid > > if op_has_next_csid "${op_type}"; then > - csid="$(build_csid "${rt}" "${func}")" > + rt="$(__get_srv6_node_id "${node}")" > + param="$(__get_srv6_param "${act}" "${node}")" > + csid="$(build_csid "${rt}" "${param}" "${func}")" > echo "${LCBLOCK_ADDR}:${csid}::/${LCBLOCK_NODEFUNC_BLEN}" > return > fi > > - echo "${LOCATOR_SERVICE}:${rt}::${func}" > + case "${act}" in > + "End.X") > + rt="$(__get_srv6_node_id "${node}")" > + param="$(__get_srv6_param "${act}" "${node}")" > + echo "${LOCATOR_SERVICE}:${rt}::${param}${func}" > + ;; > + *) > + echo "${LOCATOR_SERVICE}:${node}::${func}" > + ;; > + esac > } rt is not local anymore. > [snip] > # cafe::x:yy on the loopback of the host (e.g. 2:e9) > # $2 - SRv6 router configured for enforcing the SRv6 Policy > # $3 - compact way to represent a list of SRv6 routers with their operations > -# (i.e. behaviors) that each of them needs to perform. Every <nodeid:op> > +# (i.e. behaviors) that each of them needs to perform. Every > +# <nodeid:op:act> Nit: "<nodeid:op:act>" is alone on its line. The lines of this paragraph could be rewrapped. > # element constructs a SID that is associated with the behavior <op> on > # the <nodeid> node. The list of such elements forms an SRv6 Policy. Nit: with <act>, the behavior no longer comes from <op>, which now gives only its flavors. "(i.e. behaviors)" and "associated with the behavior <op>" need an update, and so does the comment of __get_srv6_rtcfg_op(). > # For "next-csid,psp", <nodeid> is a comma-separated list of node IDs. > # The element constructs a C-SID container with the C-SIDs of these > # nodes, e.g. "4,2:next-csid,psp" gives fcbb:0:40e9:20e9::. > +# For End.X, the <nodeid> includes ">" and the adjacency ("h" for the > +# host), and <act> is "End.X". > __setup_rt_policy() > [snip] > +# Set up an unreachable route on a router so that a lookup of the next SID > +# fails under End, while End.X still forwards via its adjacency (nh6). > +# args: > +# $1 - router to configure > +# $2 - adjacent router, or a NEXT-C-SID node list (e.g. "4" or "4>2,2>h") > +# $3 - operation <op> of the element (e.g. "psp" or "next-csid,psp") > +setup_rt_unreachable() > +{ > + local rt="$1" > + local adj="$2" > + local op_type="$3" > + local net_prefix > + local devname > + local nsname > + local sid > + > + nsname="$(get_rtname "${rt}")" > + > + case "${op_type}" in > + "psp") > + sid="${LOCATOR_SERVICE}:${adj}::/32" > + devname="veth-rt-${rt}-${adj}" > + net_prefix="$(get_network_prefix "${rt}" "${adj}")" > + ip -netns "${nsname}" -6 route \ > + change unreachable "${sid}" \ > + table "${LOCALSID_TABLE_ID}" > + defer ip -netns "${nsname}" -6 route \ > + change "${sid}" \ > + table "${LOCALSID_TABLE_ID}" \ > + via "${net_prefix}::${adj}" dev "${devname}" > + ;; This case changes the underlay /32 into an unreachable route and restores it in the defer. As in the next-csid,psp case below, an unreachable route for the exact address, e.g. fcff:4::2af1, would leave the underlay /32 as it is. Or am I missing something? > + "next-csid,psp") > + sid="$(build_csid_container "${adj}" "End.X" \ > + "${ENDX_CSID_PSP_FUNC}")" > + ip -netns "${nsname}" -6 route \ > + add unreachable "${sid}" \ > + table "${LOCALSID_TABLE_ID}" > + defer ip -netns "${nsname}" -6 route \ > + delete "${sid}" \ > + table "${LOCALSID_TABLE_ID}" > + ;; > + esac > +} If the /32 is not needed, why not make the function take two arguments, the router and the element of the next SID, as in the Policies? For example: setup_rt_unreachable 3 "4>2:psp:End.X" setup_rt_unreachable 3 "4>2,2>h:next-csid,psp:End.X" The SID could then come from get_rt_sid() or build_csid_container(), as in __setup_rt_policy(). > [snip] > +setup_endx_flv_psp() > +{ > + SETUP_ERR=1 > + > + setup_hs_lo_addr 1 1 "${ENDX_CSID_PSP_FUNC}" > + setup_hs_lo_addr 2 2 "${ENDX_CSID_PSP_FUNC}" > + > + # The same SRv6 policies as in setup_end_flv_psp, except using End.X > + setup_rt_policy_ipv6 2 1 "3>4:noflv:End.X 4>2:psp:End.X 2>h:psp:End.X" > + setup_rt_policy_ipv6 1 2 "1>h:psp:End.X" > + > + setup_rt_policy_ipv6 "2:${ENDX_CSID_PSP_FUNC}" 1 \ > + "3>4:next-csid,psp:End.X 4>2,2>h:next-csid,psp:End.X" > + setup_rt_policy_ipv6 "1:${ENDX_CSID_PSP_FUNC}" 2 \ > + "4>3,3>1,1>h:next-csid,psp:End.X" > + > + # (i.a) add fcff:4::/32 unreachable on rt-3 and fcff:2::/32 on rt-4 > + # (i.c) add fcbb:0:42a9:20a9:: unreachable on rt-3 and fcbb:0:20a9:: > + # on rt-4 Nit: "on rt-4" could be aligned under "add" with spaces after the "#", rather than a space and a tab, as in the rest of the file. > + setup_rt_unreachable 3 4 "psp" > + setup_rt_unreachable 4 2 "psp" > + setup_rt_unreachable 3 "4>2,2>h" "next-csid,psp" > + setup_rt_unreachable 4 "2>h" "next-csid,psp" If the function keeps its three arguments, the exact address could come from "4>2" in $2, and "2>h" would keep the two calls in the same form: setup_rt_unreachable 3 "4>2" "psp" setup_rt_unreachable 4 "2>h" "psp" "psp" can stay, as it is already the <op> of the element of the next SID, 4>2:psp:End.X. > [snip] > +__check_srv6_rtcfg() > +{ > + local element="$1" > + local op_type > + local node_re > + local nodes > + local act > + > [snip] > + for node in $(echo "${nodes}" | sed 's/,/ /g'); do > + if [[ ! "${node}" =~ ${node_re} ]]; then node is not local, so the loop writes the node of its caller, __setup_rt_policy(). > [snip] > -test_kernel_supp_or_ksft_skip() > +__test_kernel_supp_or_ksft_skip() > { > - local flavor="$1" > + local action="$1" > + local flavor="$2" > local test_netns > + local policy=() > > test_netns="kflv-$(mktemp -u XXXXXXXX)" > + policy=(action "${action}" flavors "${flavor}") > + if [ "$action" == "End.X" ]; then Nit, a style preference: "${action}" here, as on the line above. > [snip] > +# Exit directly if the End action is not supported; return 1 for other > +# actions when they are not supported. > +test_kernel_supp_or_ksft_skip() > +{ > + local ret > + > + __test_kernel_supp_or_ksft_skip "$1" "$2" > + ret="$?" > + > + if [ "$ret" -ne 0 ] && [ "$1" == "End" ]; then > exit "${ksft_skip}" > fi > > - ip netns del "${test_netns}" > + return $ret > } > [snip] > +test_endx_flv() > +{ > + if ! ${HAS_ENDX_PSP}; then > + log_section "SRv6 connectivity test hosts (h1 <-> h2, End.X)" > + log_test_skipped "SRv6 End.X tests, no End.X PSP in the kernel" Nit: in v4 the probe exited when it could not set up its netns or its dummy device. In v5 it returns, so this message is also printed in these cases, and the kernel is not checked. A message like "End.X PSP probe failed" would be accurate in every case, as the probe already prints the reason. > [snip] > +test_kernel_supp_or_ksft_skip End psp > +test_kernel_supp_or_ksft_skip End.X psp && HAS_ENDX_PSP=true Here the helper exits for End and returns for End.X when the action is not supported, but its name says that it skips. In v4 the probe was inside this helper, while in v5 it is on its own, in __test_kernel_supp_or_ksft_skip(), and returns on every path. Could the probe be renamed, for example to check_kernel_support(), and called directly by the End.X line, as check_srh_match_support() is? Then the helper could always exit when the probe fails, and the test results stay the same: # Exit with ksft_skip when check_kernel_support() fails, e.g. when # the action with the flavor is not supported. test_kernel_supp_or_ksft_skip() { local action="$1" local flavor="$2" if ! check_kernel_support "${action}" "${flavor}"; then exit "${ksft_skip}" fi } ... test_kernel_supp_or_ksft_skip End psp if check_kernel_support End.X psp; then HAS_ENDX_PSP=true fi Thanks again, Ciao, Andrea ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v5 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X 2026-12-01 0:14 ` Andrea Mayer @ 2026-12-01 2:53 ` Hangbin Liu 0 siblings, 0 replies; 12+ messages in thread From: Hangbin Liu @ 2026-12-01 2:53 UTC (permalink / raw) To: Andrea Mayer Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan, netdev, linux-kernel, linux-kselftest, Hangbin Liu, Justin Iurman, Stefano Salsano, Andrea Mayer Hi Andrea, On Tue, Dec 01, 2026 at 01:14:21AM +0100, Andrea Mayer wrote: > On Thu, 26 Nov 2026 14:27:27 +0800 > Hangbin Liu <hangbin.liu@linux.dev> wrote: > > Hi Hangbin, > thanks for the v5, and for all the work across the versions. > > The main points are on the commit message, setup_rt_unreachable() and > the probe helper. The rest are smaller points. Thanks for your review. I'm really not good at documentation :) I appreciate your help. I will update them with my best effort. > > > From: Hangbin Liu <liuhangbin@kylinos.cn> > > > > Add an End.X flavor scenario to srv6_end_flavors_test.sh that applies > > the same PSP policies as the End scenario, alone and combined with > > NEXT-C-SID, with every node bound through its adjacency (e.g. 4>2 for > > rt-4 towards rt-2, 2>h towards the host). > > > > Teach the policy helpers about <nodeid:op:act> elements: > > - __get_srv6_node_id() and __get_srv6_adjacent_id() return the node > > and adjacent id > > - __get_srv6_rtcfg_act() extracts the action > > - __get_srv6_act_cfg() derives the End.X next hop (nh6) > > - __get_srv6_param() takes the behavior parameter (adjacency for > > End.X, 0 for End) > > - __get_srv6_func() picks the Function for an <act> <op> pair > > - build_csid()/get_rt_sid() encode the parameter and adjacency into > > the SIDs (e.g. fcbb:0:34a9:: is End.X on rt-3 towards rt-4) > > - __check_srv6_rtcfg() validates each element node against the > > behavior with a per-act regular expression > > > > Reuse the existing psp and next-csid,psp helpers for End.X, and add a > > consumed-SRH test that inserts the extra SRH on the ingress router, > > since the End.X policy forces the next hop. > > > > Install unreachable routes in table 90 for the next SID of each End.X > > hop under test, so that a broken End.X that falls back to End fails the > > lookup while a working End.X still forwards via nh6. > > If I read the setup right, the routes are not for each End.X hop, > only for the ones on rt-3 and rt-4 from hs-1 to hs-2. These seem to > be enough, as on these hops the packets take the paths of > input_action_end_x() without flavors, with the RFC 8986 flavors and > with the NEXT-C-SID shift. Thanks also for the route on rt-4 for > (i.c), which is the one for the shift. Yes, I will update it. > > > > > Extend test_kernel_supp_or_ksft_skip() to probe End.X psp as well as > > End psp. Failures after a successful probe no longer abort the run, and > > when End.X psp is missing the scenario is skipped through > > log_test_skipped() so it still appears in the summary. iproute2 already > > supports the PSP flavor with End.X. > > > > Add the packet path to each test section so the route taken by the > > traffic is clear. > > > > Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn> > > --- > > > > Hi Andrea, The changelog line is getting extremely long. Please let me > > know if you'd like me to split this into smaller pieces. Thanks a lot > > for your kind review. > > To me most of the changes look tied together. The new helpers are > added for the End.X elements, and without the End.X scenario their > End.X parts would have no user. > > One part that could be split out is the read back of the route in > the probe. It also applies to the End probe, which is already in the > tree, so it could be its own patch, before this one. Sorry, which probe do you mean? I didn't get. > > Just an idea on the length of the message. The other paragraphs > already say what the tests cover, how they catch an End.X that falls > back to End, and when they are skipped. IMHO the list of the helpers > is the part that could be shorter, for example a few lines on what > changes in the elements and in the SIDs, such as the adjacency in > the End.X SIDs (e.g. fcff:3::400a, fcbb:0:34a9::). Will do. > > [snip] > > +# Set up an unreachable route on a router so that a lookup of the next SID > > +# fails under End, while End.X still forwards via its adjacency (nh6). > > +# args: > > +# $1 - router to configure > > +# $2 - adjacent router, or a NEXT-C-SID node list (e.g. "4" or "4>2,2>h") > > +# $3 - operation <op> of the element (e.g. "psp" or "next-csid,psp") > > +setup_rt_unreachable() > > +{ > > + local rt="$1" > > + local adj="$2" > > + local op_type="$3" > > + local net_prefix > > + local devname > > + local nsname > > + local sid > > + > > + nsname="$(get_rtname "${rt}")" > > + > > + case "${op_type}" in > > + "psp") > > + sid="${LOCATOR_SERVICE}:${adj}::/32" > > + devname="veth-rt-${rt}-${adj}" > > + net_prefix="$(get_network_prefix "${rt}" "${adj}")" > > + ip -netns "${nsname}" -6 route \ > > + change unreachable "${sid}" \ > > + table "${LOCALSID_TABLE_ID}" > > + defer ip -netns "${nsname}" -6 route \ > > + change "${sid}" \ > > + table "${LOCALSID_TABLE_ID}" \ > > + via "${net_prefix}::${adj}" dev "${devname}" > > + ;; > > This case changes the underlay /32 into an unreachable route and > restores it in the defer. As in the next-csid,psp case below, an > unreachable route for the exact address, e.g. fcff:4::2af1, would > leave the underlay /32 as it is. Or am I missing something? The psp and next-csid,psp use different unreach route psp use fcff:4::/32 or fcff:2::/32 next-csid,,psp use exact route like fcbb:0:42a9:20a9:: or fcbb:0:20a9:: The previous routing on rt3 for End is fcff:4::/32 table 90 via fcf0:0:3:4::4 dev veth-rt-3-4 I changed it to unreachable so End.X doesn't read the nh via it. > > > + "next-csid,psp") > > + sid="$(build_csid_container "${adj}" "End.X" \ > > + "${ENDX_CSID_PSP_FUNC}")" > > + ip -netns "${nsname}" -6 route \ > > + add unreachable "${sid}" \ > > + table "${LOCALSID_TABLE_ID}" > > + defer ip -netns "${nsname}" -6 route \ > > + delete "${sid}" \ > > + table "${LOCALSID_TABLE_ID}" > > + ;; > > + esac > > +} > > If the /32 is not needed, why not make the function take two > arguments, the router and the element of the next SID, as in the > Policies? For example: > > setup_rt_unreachable 3 "4>2:psp:End.X" > setup_rt_unreachable 3 "4>2,2>h:next-csid,psp:End.X" > > The SID could then come from get_rt_sid() or build_csid_container(), > as in __setup_rt_policy(). The when defer the PSP route, we need nh6 addr and device name. If we take the total element like "4>2:psp:End.X", we still need to get the "4>2" part first then call __get_srv6_adjacent_id() to get the "${adj}", I think it takes 2 more efforts. I can make the function take 2 arguments if you want. > > > + setup_rt_unreachable 3 4 "psp" > > + setup_rt_unreachable 4 2 "psp" > > + setup_rt_unreachable 3 "4>2,2>h" "next-csid,psp" > > + setup_rt_unreachable 4 "2>h" "next-csid,psp" > > If the function keeps its three arguments, the exact address could come > from "4>2" in $2, and "2>h" would keep the two calls in the same form: Hmm, you want to add exact unreach route for PSP. e.g. unreachable fcff:4::2af1 on rt3? That OK for me. I think unreachable fcff:4::2af1 and unreachable fcff:4::/32 take the same effect on rt-3, no? > > setup_rt_unreachable 3 "4>2" "psp" > setup_rt_unreachable 4 "2>h" "psp" > > "psp" can stay, as it is already the <op> of the element of the next > SID, 4>2:psp:End.X. > > > [snip] > > +test_kernel_supp_or_ksft_skip End psp > > +test_kernel_supp_or_ksft_skip End.X psp && HAS_ENDX_PSP=true > > Here the helper exits for End and returns for End.X when the action > is not supported, but its name says that it skips. In v4 the probe > was inside this helper, while in v5 it is on its own, in > __test_kernel_supp_or_ksft_skip(), and returns on every path. Could > the probe be renamed, for example to check_kernel_support(), and called > directly by the End.X line, as check_srh_match_support() is? Then the > helper could always exit when the probe fails, and the test results > stay the same: > > # Exit with ksft_skip when check_kernel_support() fails, e.g. when > # the action with the flavor is not supported. > test_kernel_supp_or_ksft_skip() > { > local action="$1" > local flavor="$2" > > if ! check_kernel_support "${action}" "${flavor}"; then > exit "${ksft_skip}" > fi > } > ... > test_kernel_supp_or_ksft_skip End psp > if check_kernel_support End.X psp; then > HAS_ENDX_PSP=true > fi OK, with this, the End is the only caller of test_kernel_supp_or_ksft_skip(). Maybe let End also calls check_kernel_support and exit directly? e.g. if ! check_kernel_support End psp; then exit "${ksft_skip}" fi if check_kernel_support End.X psp; then HAS_ENDX_PSP=true fi If make it shorter ! check_kernel_support End psp && exit "${ksft_skip}" check_kernel_support End.X psp && HAS_ENDX_PSP=true Thanks Hangbin ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next v5 0/5] seg6: add End.X PSP flavor support and selftests 2026-11-26 6:27 [PATCH net-next v5 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu ` (4 preceding siblings ...) 2026-11-26 6:27 ` [PATCH net-next v5 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X Hangbin Liu @ 2026-11-29 2:38 ` Andrea Mayer 5 siblings, 0 replies; 12+ messages in thread From: Andrea Mayer @ 2026-11-29 2:38 UTC (permalink / raw) To: Hangbin Liu Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan, netdev, linux-kernel, linux-kselftest, Hangbin Liu, Stefano Salsano, Andrea Mayer, Andrea Mayer On Thu, 26 Nov 2026 14:27:22 +0800 Hangbin Liu <hangbin.liu@linux.dev> wrote: > This series adds End.X PSP flavor handling in seg6local and extends the > SRv6 selftests to cover it. > > Patch 1 splits the final forwarding step out of end_flv8986_core() so > RFC8986 flavor logic can be reused outside the End path. > > Patch 2 uses that to add End.X PSP support through the same > end_flv8986_core() path. > > Patches 3-4 refactor the PSP selftest setup/cleanup so flavor tests can > be added more cleanly. > > Patch 5 adds End.X PSP connectivity coverage and updates the selftest > policy parser to accept an explicit action field. > > The goal is to make End.X PSP behavior consistent with End PSP, while > keeping the selftest structure easier to extend for later flavors. > > Run all srv6 selftests on debug kernel. All passed without error. > > Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn> > [snip] Hi Hangbin, thanks for the v5. I'm looking at the whole series and I will follow up. Ciao, Andrea ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-12-01 2:53 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-11-26 6:27 [PATCH net-next v5 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu 2026-11-26 6:27 ` [PATCH net-next v5 1/5] seg6: split final End process out of flavor processing Hangbin Liu 2026-11-30 3:55 ` Andrea Mayer 2026-11-26 6:27 ` [PATCH net-next v5 2/5] seg6: add RFC8986 flavor support for End.X Hangbin Liu 2026-11-30 4:03 ` Andrea Mayer 2026-11-26 6:27 ` [PATCH net-next v5 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper Hangbin Liu 2026-11-30 3:47 ` Andrea Mayer 2026-11-26 6:27 ` [PATCH net-next v5 4/5] selftests: seg6: explicit cleanup for SRv6 End PSP test Hangbin Liu 2026-11-26 6:27 ` [PATCH net-next v5 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X Hangbin Liu 2026-12-01 0:14 ` Andrea Mayer 2026-12-01 2:53 ` Hangbin Liu 2026-11-29 2:38 ` [PATCH net-next v5 0/5] seg6: add End.X PSP flavor support and selftests Andrea Mayer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®