* [PATCH net-next v4 0/5] seg6: add End.X PSP flavor support and selftests
@ 2026-11-19 13:55 Hangbin Liu
2026-11-19 13:55 ` [PATCH net-next v4 1/5] seg6: split final End process out of flavor processing Hangbin Liu
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Hangbin Liu @ 2026-11-19 13:55 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 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 | 408 +++++++++++++++++----
2 files changed, 365 insertions(+), 74 deletions(-)
---
base-commit: c88fd6989aea9237a60a4859139a265bfb7ddc0b
change-id: 20260922-srv6_flavors_endx-9489116d50c4
Best regards,
--
Hangbin Liu <liuhangbin@kylinos.cn>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH net-next v4 1/5] seg6: split final End process out of flavor processing
2026-11-19 13:55 [PATCH net-next v4 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu
@ 2026-11-19 13:55 ` Hangbin Liu
2026-11-19 13:55 ` [PATCH net-next v4 2/5] seg6: add RFC8986 flavor support for End.X Hangbin Liu
` (3 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Hangbin Liu @ 2026-11-19 13:55 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 f71e47b5e764..65d552f87fa3 100644
--- a/net/ipv6/seg6_local.c
+++ b/net/ipv6/seg6_local.c
@@ -885,6 +885,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)
{
@@ -945,7 +948,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);
@@ -957,6 +960,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);
@@ -970,7 +974,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] 11+ messages in thread
* [PATCH net-next v4 2/5] seg6: add RFC8986 flavor support for End.X
2026-11-19 13:55 [PATCH net-next v4 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu
2026-11-19 13:55 ` [PATCH net-next v4 1/5] seg6: split final End process out of flavor processing Hangbin Liu
@ 2026-11-19 13:55 ` Hangbin Liu
2026-11-23 14:24 ` netdev-bot+sashiko
2026-11-19 13:55 ` [PATCH net-next v4 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper Hangbin Liu
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Hangbin Liu @ 2026-11-19 13:55 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 65d552f87fa3..c827a745fe17 100644
--- a/net/ipv6/seg6_local.c
+++ b/net/ipv6/seg6_local.c
@@ -121,7 +121,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 */
@@ -884,7 +885,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.
@@ -986,12 +987,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] 11+ messages in thread
* [PATCH net-next v4 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper
2026-11-19 13:55 [PATCH net-next v4 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu
2026-11-19 13:55 ` [PATCH net-next v4 1/5] seg6: split final End process out of flavor processing Hangbin Liu
2026-11-19 13:55 ` [PATCH net-next v4 2/5] seg6: add RFC8986 flavor support for End.X Hangbin Liu
@ 2026-11-19 13:55 ` Hangbin Liu
2026-11-19 13:55 ` [PATCH net-next v4 4/5] selftests: seg6: explicit cleanup for SRv6 End PSP test Hangbin Liu
2026-11-19 13:55 ` [PATCH net-next v4 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X Hangbin Liu
4 siblings, 0 replies; 11+ messages in thread
From: Hangbin Liu @ 2026-11-19 13:55 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] 11+ messages in thread
* [PATCH net-next v4 4/5] selftests: seg6: explicit cleanup for SRv6 End PSP test
2026-11-19 13:55 [PATCH net-next v4 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu
` (2 preceding siblings ...)
2026-11-19 13:55 ` [PATCH net-next v4 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper Hangbin Liu
@ 2026-11-19 13:55 ` Hangbin Liu
2026-11-19 13:55 ` [PATCH net-next v4 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X Hangbin Liu
4 siblings, 0 replies; 11+ messages in thread
From: Hangbin Liu @ 2026-11-19 13:55 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] 11+ messages in thread
* [PATCH net-next v4 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X
2026-11-19 13:55 [PATCH net-next v4 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu
` (3 preceding siblings ...)
2026-11-19 13:55 ` [PATCH net-next v4 4/5] selftests: seg6: explicit cleanup for SRv6 End PSP test Hangbin Liu
@ 2026-11-19 13:55 ` Hangbin Liu
2026-11-23 4:09 ` Andrea Mayer
2026-11-23 14:24 ` netdev-bot+sashiko
4 siblings, 2 replies; 11+ messages in thread
From: Hangbin Liu @ 2026-11-19 13:55 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/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
- __get_func() picks the correct function
- build_csid()/get_rt_sid() encode the adjacency into the C-SIDs
(e.g. fcbb:0:34a9:: is End.X on rt-3 towards rt-4).
Reuse the existing psp and next-csid,psp helpers, and add a new
consumed-SRH test that inserts the extra SRH on the ingress router,
since the End.X policy forces the next hop.
Extend test_kernel_supp_or_ksft_skip() to check kernel support for
End.X psp, 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>
---
.../testing/selftests/net/srv6_end_flavors_test.sh | 354 +++++++++++++++++----
1 file changed, 298 insertions(+), 56 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..d7fdc4e19da9 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 will be 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 |
# +---------------------------------------------------------------------+
@@ -153,10 +157,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 +192,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 +225,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 +251,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
@@ -298,15 +310,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 +341,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 forced next hop, so we insert the extra SRH on the
+# ingress router instead. e.g
+#
+# (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 +369,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
@@ -535,10 +570,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:psp", output: "1,2"
+# input: "1>2:psp", output: "1>2"
+# input: "1>2,2>3:psp:End.", output: "1>2,2>3"
__get_srv6_rtcfg_id()
{
local element="$1"
@@ -546,6 +583,32 @@ __get_srv6_rtcfg_id()
echo "${element}" | cut -d':' -f1
}
+# Given the description of a router as an input, the function returns its
+# id with the ">" and the adjacent route 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 route id, or 0 if a host adjacent.
+# i.e. input: "1", output: ""
+# input: "1>2", output: "2"
+# input: "1>h", output: "0"
+__get_srv6_adjacent_id()
+{
+ local adjacent="${1#*>}"
+
+ [[ "${adjacent}" == "${1}" ]] && return
+ [[ "${adjacent}" == "h" ]] && adjacent=0
+
+ echo "${adjacent}"
+}
+
# 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.
@@ -563,20 +626,83 @@ __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. Action End or
+# End.X) configured for the node. Return 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 route 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_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, and 0 for End and towards the host, 4 bits) and the Function (8 bits).
# args:
-# $1 - router
+# $1 - router with or without adjacent router (e.g. "4", "4>2")
# $2 - Function (e.g. "e9")
-# e.g. input: "4" "e9"
-# output: "40e9"
+# e.g. input: "4" "e9", output: "40e9"
+# input: "4>2" "a9", output: "42a9"
build_csid()
{
local nodeid="$1"
local func="$2"
+ local node
+ local adj
- printf "${LCNODE_FMT}%s" "${nodeid}" "${func}"
+ node="$(__get_srv6_node_id "${nodeid}")"
+ adj="$(__get_srv6_adjacent_id "${nodeid}")"
+ adj=${adj:-0}
+ printf "%s%s%s" "${node}" "${adj}" "${func}"
}
# Return the C-SID container with the C-SIDs of the routers listed in a
@@ -584,8 +710,8 @@ build_csid()
# 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::"
+# e.g. input: "4,2" "e9", output: "fcbb:0:40e9:20e9::"
+# input: "4>2,2>1" "e9", output: "fcbb:0:42e9:21e9::"
build_csid_container()
{
local nodeids="$1"
@@ -717,24 +843,31 @@ op_has_next_csid()
# $1 - 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"
+# e.g. input: "4" "noflv" "e", output: "fcff:4::e"
+# input: "4>2" "noflv" "a", output: "fcff:4::2a"
+# input: "4" "psp" "0ef1", output: "fcff:4::0ef1"
+# input: "4>2" "psp" "af1", output: "fcff:4::2af1"
+# input: "4" "next-csid,psp" "e9", output: "fcbb:0:40e9::/48"
+# input: "4>2" "next-csid,psp" "a9", output: "fcbb:0:42a9::/48"
get_rt_sid()
{
local rt="$1"
local op_type="$2"
local func="$3"
local csid
+ local node
+ local adj
if op_has_next_csid "${op_type}"; then
csid="$(build_csid "${rt}" "${func}")"
echo "${LCBLOCK_ADDR}:${csid}::/${LCBLOCK_NODEFUNC_BLEN}"
- return
+ elif echo "${rt}" | grep -q ">"; then
+ node="$(__get_srv6_node_id "${rt}")"
+ adj="$(__get_srv6_adjacent_id "${rt}")"
+ echo "${LOCATOR_SERVICE}:${node}::${adj}${func}"
+ else
+ echo "${LOCATOR_SERVICE}:${rt}::${func}"
fi
-
- echo "${LOCATOR_SERVICE}:${rt}::${func}"
}
# Add an SRv6 Endpoint behavior to a router, bound to a SID. Nothing is added
@@ -771,24 +904,33 @@ setup_rt_endpoint()
# 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 op_type="$2"
- local func="$3"
- local behavior_cfg="$4"
+ local act="$3"
+ local func="$4"
+ local behavior_cfg="$5"
+ local act_cfg
local sid
+ local adj
local rt
+ local n
for rt in $(echo "${node}" | sed 's/,/ /g'); do
+ n="$(__get_srv6_node_id "${rt}")"
+ adj="$(__get_srv6_adjacent_id "${rt}")"
sid="$(get_rt_sid "${rt}" "${op_type}" "${func}")"
- setup_rt_endpoint "${rt}" "${sid}" "${behavior_cfg}"
+ act_cfg="$(__get_srv6_act_cfg "${act}" "${n}" "${adj}")"
+ setup_rt_endpoint "${n}" "${sid}" "${act_cfg} ${behavior_cfg}"
done
}
@@ -801,12 +943,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 action, the <nodeid> has ">" with the adjacency, "h" for
+# the host, and the <act> with "End.X" field.
__setup_rt_policy()
{
local dst="$1"
@@ -819,33 +964,44 @@ __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
+ # Abort if policy format is incorrect:
+ # 1. "1>h:psp" that has ">" but not "End.X"
+ # 2. "1:psp:End.X" that has "End.X" but no ">"
+ if [[ "${n}" == *">"* && "${n}" != *"End.X"* ]] || \
+ [[ "${n}" != *">"* && "${n}" == *"End.X"* ]]; then
+ echo "Incorrect operation format: ${n}" && false
+ fi
+
node="$(__get_srv6_rtcfg_id "${n}")"
op_type="$(__get_srv6_rtcfg_op "${n}")"
+ act="$(__get_srv6_rtcfg_act "${n}")"
+ function="$(__get_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}" "${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}" "${function}")"
+ policy="${policy}${sid},"
+ behavior_cfg="flavors psp"
;;
"next-csid,psp")
container="$(build_csid_container "${node}" \
- "${END_CSID_PSP_FUNC}")"
+ "${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 +1010,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
@@ -1031,6 +1187,25 @@ 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 with 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"
+
+ SETUP_ERR=0
+}
+
check_rt_connectivity()
{
local rtsrc="$1"
@@ -1137,7 +1312,9 @@ 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 +1322,14 @@ 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
- 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}"
+ log_section "SRv6 connectivity test hosts (h1 <-> h2, ${act} NEXT-C-SID,PSP)"
+
+ csid_psp_func="$(__get_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 +1480,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"
@@ -1326,6 +1507,38 @@ host_srv6_end_flv_consumed_srh_tests()
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" "${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" "${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,12 +1549,19 @@ test_iproute2_supp_or_ksft_skip()
fi
}
+# exit directly if End action not supported, otherwise return 1
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"
@@ -1366,10 +1586,15 @@ test_kernel_supp_or_ksft_skip()
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}"
+
+ if [ "$action" != "End" ]; then
+ return 1
+ fi
+
exit "${ksft_skip}"
fi
@@ -1433,6 +1658,18 @@ test_end_flv()
defer_scope_pop
}
+test_endx_flv()
+{
+ 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 +1689,7 @@ 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
check_srh_match_support
set -e
@@ -1465,4 +1702,9 @@ router_tests
host2gateway_tests
test_end_flv
+
+if test_kernel_supp_or_ksft_skip End.X psp; then
+ test_endx_flv
+fi
+
print_log_test_results
--
2.56.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next v4 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X
2026-11-19 13:55 ` [PATCH net-next v4 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X Hangbin Liu
@ 2026-11-23 4:09 ` Andrea Mayer
2026-11-23 10:09 ` Hangbin Liu
2026-11-23 13:40 ` hangbin.liu
2026-11-23 14:24 ` netdev-bot+sashiko
1 sibling, 2 replies; 11+ messages in thread
From: Andrea Mayer @ 2026-11-23 4:09 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, Justin Iurman, Andrea Mayer,
Andrea Mayer
On Thu, 19 Nov 2026 21:55:21 +0800
Hangbin Liu <hangbin.liu@linux.dev> wrote:
Hi Hangbin,
thanks for the v4. I really appreciate your work on the v3 comments.
> 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/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
> - __get_func() picks the correct function
> - build_csid()/get_rt_sid() encode the adjacency into the C-SIDs
> (e.g. fcbb:0:34a9:: is End.X on rt-3 towards rt-4).
Nit: the adjacency also goes into the SIDs without NEXT-C-SID, e.g.
fcff:3::400a, not only into the C-SIDs.
>
> Reuse the existing psp and next-csid,psp helpers, and add a new
> consumed-SRH test that inserts the extra SRH on the ingress router,
> since the End.X policy forces the next hop.
>
> Extend test_kernel_supp_or_ksft_skip() to check kernel support for
> End.X psp, 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>
> [snip]
> diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> index 9d6b7de648da..d7fdc4e19da9 100755
> --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
> +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> [snip]
> +# input: "1,2:psp", output: "1,2"
> +# input: "1>2:psp", output: "1>2"
> +# input: "1>2,2>3:psp:End.", output: "1>2,2>3"
> __get_srv6_rtcfg_id()
Typo: "End.". A list of nodes is also only for next-csid, which builds
a C-SID container, and ">" only for End.X. "1,2:psp" above needs
next-csid, and "1>2:psp" needs End.X. The last one could be e.g.
"1>2,2>3:next-csid,psp:End.X".
> [snip]
> +# Given the description of a router as an input, the function returns its
> +# id with the ">" and the adjacent route id dropped.
> +# i.e. input: "1", output: "1"
> +# input: "1>2", output: "1"
> +__get_srv6_node_id()
"router" I think, here, in "adjacent route id" of
__get_srv6_adjacent_id() below, and in "current route" of
__get_srv6_act_cfg().
> [snip]
> +# Given the description of a router as an input, the function returns its
> +# adjacent route id, or 0 if a host adjacent.
> +# i.e. input: "1", output: ""
> +# input: "1>2", output: "2"
> +# input: "1>h", output: "0"
> +__get_srv6_adjacent_id()
> +{
> + local adjacent="${1#*>}"
> +
> + [[ "${adjacent}" == "${1}" ]] && return
> + [[ "${adjacent}" == "h" ]] && adjacent=0
Nit, a style preference: I would use if blocks here, as in the rest
of the selftest. With cut -s -d'>' -f2, this function could also read
the ">" as you already do in __get_srv6_node_id().
> [snip]
> # 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, and 0 for End and towards the host, 4 bits) and the Function (8 bits).
> # args:
> -# $1 - router
> +# $1 - router with or without adjacent router (e.g. "4", "4>2")
> # $2 - Function (e.g. "e9")
> -# e.g. input: "4" "e9"
> -# output: "40e9"
> +# e.g. input: "4" "e9", output: "40e9"
> +# input: "4>2" "a9", output: "42a9"
> build_csid()
> {
> local nodeid="$1"
> local func="$2"
> + local node
> + local adj
>
> - printf "${LCNODE_FMT}%s" "${nodeid}" "${func}"
> + node="$(__get_srv6_node_id "${nodeid}")"
> + adj="$(__get_srv6_adjacent_id "${nodeid}")"
> + adj=${adj:-0}
> + printf "%s%s%s" "${node}" "${adj}" "${func}"
> }
The comment says the parameter is the adjacent router for End.X and 0
for End, but build_csid() takes it from the ">", not from the
behavior. "4>2" with e9, an End Function, gives 42e9, as in the second
example of build_csid_container() below. To avoid this, the callers of
build_csid() could set the parameter from the behavior, as suggested
on v3. One new helper could return it for each behavior and node. Just
as an idea, something like this in a __get_srv6_param() that takes the
behavior and the node:
# End: 0, End.X: the adjacent router (0 for the host)
case "${act}" in
"End.X")
__get_srv6_adjacent_id "${node}"
;;
*)
echo 0
;;
esac
build_csid() would then only print the three parts it gets. Its
callers, given the behavior, would do for a node:
rt="$(__get_srv6_node_id "${node}")"
param="$(__get_srv6_param "${act}" "${node}")"
csid="$(build_csid "${rt}" "${param}" "${func}")"
setup_rt_local_sids() also calls build_csid(), for the underlay routes,
with no behavior. It would pass the 0 itself, e.g. build_csid
"${neigh}" 0 00.
This way, as suggested on v3, the nodes would be read in one place.
Only __get_srv6_node_id() and __get_srv6_adjacent_id() would read the
">", and the behavior would decide the rest. Today get_rt_sid() and
the check in __setup_rt_policy() read the ">" too, and decide from it.
> [snip]
> @@ -584,8 +710,8 @@ build_csid()
> # 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::"
> +# e.g. input: "4,2" "e9", output: "fcbb:0:40e9:20e9::"
> +# input: "4>2,2>1" "e9", output: "fcbb:0:42e9:21e9::"
> build_csid_container()
The second example gives End (e9) a parameter, which End does not
have. An End.X example would fit in its place, e.g. "4>2,2>h" with
a9, giving fcbb:0:42a9:20a9::.
> [snip]
> # $1 - 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"
> +# e.g. input: "4" "noflv" "e", output: "fcff:4::e"
> +# input: "4>2" "noflv" "a", output: "fcff:4::2a"
> +# input: "4" "psp" "0ef1", output: "fcff:4::0ef1"
> +# input: "4>2" "psp" "af1", output: "fcff:4::2af1"
> +# input: "4" "next-csid,psp" "e9", output: "fcbb:0:40e9::/48"
> +# input: "4>2" "next-csid,psp" "a9", output: "fcbb:0:42a9::/48"
The comment still says "$1 - router", but $1 can also have an
adjacency here, as in "4>2". The two noflv examples use "e" and "a",
while the script passes 000e and 00a, and "3>4" with 00a gives
fcff:3::400a.
> get_rt_sid()
> {
> local rt="$1"
> local op_type="$2"
> local func="$3"
> local csid
> + local node
> + local adj
>
> if op_has_next_csid "${op_type}"; then
> csid="$(build_csid "${rt}" "${func}")"
> echo "${LCBLOCK_ADDR}:${csid}::/${LCBLOCK_NODEFUNC_BLEN}"
> - return
> + elif echo "${rt}" | grep -q ">"; then
> + node="$(__get_srv6_node_id "${rt}")"
> + adj="$(__get_srv6_adjacent_id "${rt}")"
> + echo "${LOCATOR_SERVICE}:${node}::${adj}${func}"
> + else
> + echo "${LOCATOR_SERVICE}:${rt}::${func}"
> fi
Without NEXT-C-SID, get_rt_sid() could also take the behavior, and
drop the grep on ">". With a case on the behavior, End would keep its
SIDs as they are, e.g. fcff:3::e, and End.X would put the parameter in
front of its Function, e.g. fcff:3::400a.
> [snip]
> @@ -771,24 +904,33 @@ setup_rt_endpoint()
> # 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")
> [snip]
> setup_rt_endpoints()
The first line of this comment, just above the hunk, still says "each
router of a Policy element <nodeid:op>", while the element is now
<nodeid:op:act>.
> [snip]
> @@ -819,33 +964,44 @@ __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
> + # Abort if policy format is incorrect:
> + # 1. "1>h:psp" that has ">" but not "End.X"
> + # 2. "1:psp:End.X" that has "End.X" but no ">"
> + if [[ "${n}" == *">"* && "${n}" != *"End.X"* ]] || \
> + [[ "${n}" != *">"* && "${n}" == *"End.X"* ]]; then
> + echo "Incorrect operation format: ${n}" && false
> + fi
The check is there, but ret is not set. With "1>h:psp", the End tests
pass and then the run ends as SKIP:
Incorrect operation format: 1>h:psp
SKIP: Setting up the testing environment failed
Could it set ret to ksft_fail? Also, the check looks at the element as
a whole, while the parameter and the nh6 are computed for each node.
For example, "4>2,2:next-csid,psp:End.X" passes it although the node
"2" has no adjacency, and the setup then fails in ip, on the nh6. A
function that checks each node, called in place of this check, would
cover both:
if ! __check_srv6_rtcfg "${n}"; then
ret="${ksft_fail}"
return 1
fi
It would take the nodes and the behavior from the parsers that
__setup_rt_policy() already uses, not from the text of the element.
Just as an idea, something like this in __check_srv6_rtcfg():
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
for node in $(echo "${nodes}" | sed 's/,/ /g'); do
rt="$(__get_srv6_node_id "${node}")"
param="$(__get_srv6_param "${act}" "${node}")"
case "${act}" in
"End")
if [ "${node}" != "${rt}" ]; then
echo "${element}: End takes no parameter"
return 1
fi
;;
"End.X")
if [ -z "${param}" ]; then
echo "${element}: End.X needs an adjacency"
return 1
fi
;;
esac
done
IMO a case per behavior would also make End.T easier to add, both for
the flavor core that your 1/5 mentions for End.X/T and for NEXT-C-SID,
which I am working on.
> [snip]
> @@ -1031,6 +1187,25 @@ 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 with 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"
> +
> + SETUP_ERR=0
> +}
On v3, Sashiko asked whether the End.X tests would pass with End.X
working as End. In this topology, the nh6 of each End.X is also the
next hop that a lookup of the new DA gives, and the tests pass in both
cases. An unreachable route in table 90 for the next SID, on rt-4 for
(i.a) and on rt-3 for (i.c), would make End fail and leave End.X
working. This is close to what Sashiko suggested on v3. What do you
think about adding these two routes to the End.X scenario, each with
its defer?
> [snip]
> 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)"
> [snip]
> 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
>
> - 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}"
> + log_section "SRv6 connectivity test hosts (h1 <-> h2, ${act} NEXT-C-SID,PSP)"
Nit: NIPA's checkpatch warns on these two lines (81 and 85 columns).
It does not warn on a line that holds only a string, as in
host_srv6_end_flv_consumed_srh_tests().
> [snip]
> test_kernel_supp_or_ksft_skip()
> [snip]
> 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"
A note on this probe. On older kernels this add can succeed without
the flavor, and the tests then fail instead of being skipped. This
happens with End.X on v6.5, and with End on v6.0. I was thinking of
sending a separate patch that reads the route back, for the End and
the End.X probe. There is no need to wait for it. Does it work for
you?
> [snip]
> +if test_kernel_supp_or_ksft_skip End.X psp; then
> + test_endx_flv
> +fi
When the probe finds no End.X PSP, the End.X tests do not show up in
the summary. The v4 skips only that scenario, as suggested on v3,
which is good. On my patch that added the consumed SRH tests, you
suggested to return at once when the srh match is missing. I kept the
check in each test because log_test_skipped() then logs each test and
counts it in "Tests skipped". IMHO the End.X scenario could do the
same, to be consistent. Does it sound reasonable to you?
> [snip]
Thanks,
Andrea
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next v4 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X
2026-11-23 4:09 ` Andrea Mayer
@ 2026-11-23 10:09 ` Hangbin Liu
2026-11-23 13:40 ` hangbin.liu
1 sibling, 0 replies; 11+ messages in thread
From: Hangbin Liu @ 2026-11-23 10:09 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, Stefano Salsano, Justin Iurman, Andrea Mayer
Hi Andrea,
Thanks a lot for you detailed review. I will fix all of them in next version.
I just have some questions about a few comments.
On Mon, Nov 23, 2026 at 05:09:52AM +0100, Andrea Mayer wrote:
> > [snip]
> > +# Given the description of a router as an input, the function returns its
> > +# adjacent route id, or 0 if a host adjacent.
> > +# i.e. input: "1", output: ""
> > +# input: "1>2", output: "2"
> > +# input: "1>h", output: "0"
> > +__get_srv6_adjacent_id()
> > +{
> > + local adjacent="${1#*>}"
> > +
> > + [[ "${adjacent}" == "${1}" ]] && return
> > + [[ "${adjacent}" == "h" ]] && adjacent=0
>
> Nit, a style preference: I would use if blocks here, as in the rest
> of the selftest. With cut -s -d'>' -f2, this function could also read
> the ">" as you already do in __get_srv6_node_id().
I plan to use
echo "${element}" | cut -s -d'>' -f2 | sed 's/h/0/'
>
> > [snip]
> > @@ -819,33 +964,44 @@ __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
> > + # Abort if policy format is incorrect:
> > + # 1. "1>h:psp" that has ">" but not "End.X"
> > + # 2. "1:psp:End.X" that has "End.X" but no ">"
> > + if [[ "${n}" == *">"* && "${n}" != *"End.X"* ]] || \
> > + [[ "${n}" != *">"* && "${n}" == *"End.X"* ]]; then
> > + echo "Incorrect operation format: ${n}" && false
> > + fi
>
> The check is there, but ret is not set. With "1>h:psp", the End tests
> pass and then the run ends as SKIP:
>
> Incorrect operation format: 1>h:psp
> SKIP: Setting up the testing environment failed
>
> Could it set ret to ksft_fail? Also, the check looks at the element as
> a whole, while the parameter and the nh6 are computed for each node.
> For example, "4>2,2:next-csid,psp:End.X" passes it although the node
> "2" has no adjacency, and the setup then fails in ip, on the nh6. A
> function that checks each node, called in place of this check, would
> cover both:
>
> if ! __check_srv6_rtcfg "${n}"; then
> ret="${ksft_fail}"
> return 1
> fi
>
> It would take the nodes and the behavior from the parsers that
> __setup_rt_policy() already uses, not from the text of the element.
> Just as an idea, something like this in __check_srv6_rtcfg():
>
> 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
>
> for node in $(echo "${nodes}" | sed 's/,/ /g'); do
> rt="$(__get_srv6_node_id "${node}")"
> param="$(__get_srv6_param "${act}" "${node}")"
>
> case "${act}" in
> "End")
> if [ "${node}" != "${rt}" ]; then
> echo "${element}: End takes no parameter"
> return 1
> fi
> ;;
> "End.X")
> if [ -z "${param}" ]; then
> echo "${element}: End.X needs an adjacency"
> return 1
> fi
> ;;
This check seems not enough with error config like "4>2h:psp:End.X".
Should we limit the param to 0-4?
> esac
> done
>
> IMO a case per behavior would also make End.T easier to add, both for
> the flavor core that your 1/5 mentions for End.X/T and for NEXT-C-SID,
> which I am working on.
>
> > [snip]
> > @@ -1031,6 +1187,25 @@ 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 with 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"
> > +
> > + SETUP_ERR=0
> > +}
>
> On v3, Sashiko asked whether the End.X tests would pass with End.X
> working as End. In this topology, the nh6 of each End.X is also the
> next hop that a lookup of the new DA gives, and the tests pass in both
> cases. An unreachable route in table 90 for the next SID, on rt-4 for
> (i.a) and on rt-3 for (i.c), would make End fail and leave End.X
> working. This is close to what Sashiko suggested on v3. What do you
> think about adding these two routes to the End.X scenario, each with
> its defer?
Hmm, we add the SIDs with End.X action, and the address also has parameters.
e.g. for (1.a) we add fcff:4::2af1, which unreachable route should we add
then? Cause we don't use fcff:2::ef1 at all.
BTW, is there any reason we add the unreachable route on rt-4 for (i.a) and on
rt-3 for (i.c)? In the consumed SRH testing, we can only add the extra on
ingress route. e.g.
# (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.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
Which means we need the end action on rt-4.
>
> > [snip]
> > test_kernel_supp_or_ksft_skip()
> > [snip]
> > 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"
>
> A note on this probe. On older kernels this add can succeed without
> the flavor, and the tests then fail instead of being skipped. This
> happens with End.X on v6.5, and with End on v6.0. I was thinking of
> sending a separate patch that reads the route back, for the End and
> the End.X probe. There is no need to wait for it. Does it work for
> you?
OK, I will add a checking for the added route.
>
> > [snip]
> > +if test_kernel_supp_or_ksft_skip End.X psp; then
> > + test_endx_flv
> > +fi
>
> When the probe finds no End.X PSP, the End.X tests do not show up in
> the summary. The v4 skips only that scenario, as suggested on v3,
> which is good. On my patch that added the consumed SRH tests, you
> suggested to return at once when the srh match is missing. I kept the
> check in each test because log_test_skipped() then logs each test and
> counts it in "Tests skipped". IMHO the End.X scenario could do the
> same, to be consistent. Does it sound reasonable to you?
Sorry, I didn't get what you mean here. Do you want to run
the check before each end.x testing and report skip one by one?
e.g.
if test_kernel_supp_or_ksft_skip End.X psp; then
host_srv6_end_flv_psp_tests "End.X"
else
echo "SKIP..."
fi
if test_kernel_supp_or_ksft_skip End.X psp; then
host_srv6_end_flv_next_csid_psp_tests "End.X"
else
echo "SKIP..."
fi
if test_kernel_supp_or_ksft_skip End.X psp; then
host_srv6_endx_flv_consumed_srh_tests
else
echo "SKIP..."
fi
Thanks
Hangbin
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next v4 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X
2026-11-23 4:09 ` Andrea Mayer
2026-11-23 10:09 ` Hangbin Liu
@ 2026-11-23 13:40 ` hangbin.liu
1 sibling, 0 replies; 11+ messages in thread
From: hangbin.liu @ 2026-11-23 13:40 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, Stefano Salsano, Justin Iurman, Andrea Mayer,
Andrea Mayer
November 23, 2026 at 12:09 PM, "Andrea Mayer" <andrea.mayer@uniroma2.it> wrote:
>
> On Thu, 19 Nov 2026 21:55:21 +0800
> Hangbin Liu <hangbin.liu@linux.dev> wrote:
>
> >
> > [snip]
> > @@ -1031,6 +1187,25 @@ 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 with 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"
> > +
> > + SETUP_ERR=0
> > +}
> >
> On v3, Sashiko asked whether the End.X tests would pass with End.X
> working as End. In this topology, the nh6 of each End.X is also the
> next hop that a lookup of the new DA gives, and the tests pass in both
> cases. An unreachable route in table 90 for the next SID, on rt-4 for
> (i.a) and on rt-3 for (i.c), would make End fail and leave End.X
> working. This is close to what Sashiko suggested on v3. What do you
> think about adding these two routes to the End.X scenario, each with
> its defer?
>
Oh, for i.a), do you mean add an unreach rt-2 SID on rt-4?
e.g. fcfcff:2::/32 unreachable? If yes, based on
# (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.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 think we should add the unreach rt-4 SID on rt-3, e.g. fcff:4::/32 and fcbb:4::/32,
because we need to use the neighbour route on rt-4 to redirect packet to rt-3 after
End action. What do you think?
Thanks
Hangbin
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next v4 2/5] seg6: add RFC8986 flavor support for End.X
2026-11-19 13:55 ` [PATCH net-next v4 2/5] seg6: add RFC8986 flavor support for End.X Hangbin Liu
@ 2026-11-23 14:24 ` netdev-bot+sashiko
0 siblings, 0 replies; 11+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 14:24 UTC (permalink / raw)
To: hangbin.liu
Cc: andrea.mayer, andrea, davem, edumazet, kuba, pabeni, horms,
shuah, netdev, linux-kernel, linux-kselftest, liuhangbin
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The concern: in net/ipv6/seg6_local.c, the patch adds
SEG6_LOCAL_FLV8986_SUPP_OPS to SEG6_LOCAL_END_X_FLV_SUPP_OPS.
--
seg6: add RFC8986 flavor support for End.X
This commit adds SEG6_LOCAL_FLV8986_SUPP_OPS to the End.X supported flavor
mask, so End.X now accepts the PSP flavor. input_action_end_x() now handles
flavors the same way input_action_end() does: NEXT-C-SID is evaluated
first, then end_flv8986_core() runs, then input_action_end_x_finish().
> diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
> index 65d552f87fa39..c827a745fe176 100644
> --- a/net/ipv6/seg6_local.c
> +++ b/net/ipv6/seg6_local.c
> @@ -121,7 +121,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 */
[ ... ]
> @@ -986,12 +987,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);
> }
[Severity: Low]
This isn't a bug, but at this commit no selftest covers the new End.X
flavor configurations.
With the wider SEG6_LOCAL_END_X_FLV_SUPP_OPS, netlink now accepts End.X
with "flavors psp" and with "flavors next-csid,psp". Both used to fail with
-EOPNOTSUPP. Both now go through seg6_use_next_csid(), end_flv8986_core()
and input_action_end_x_finish().
At this point, tools/testing/selftests/net/srv6_end_flavors_test.sh only
tests "action End flavors ...".
It looks like the later patch in this series, "selftests: seg6: add PSP
flavor testing for SRv6 End.X", fills this gap. That patch:
- adds setup_endx_flv_psp(), which installs End.X policies with psp
alone and with next-csid,psp
- adds host_srv6_endx_flv_consumed_srh_tests()
- makes test_kernel_supp_or_ksft_skip() probe End.X psp
- runs the new tests from test_endx_flv()
If that patch is merged with this one, nothing more should be needed here.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119-srv6_flavors_endx-v4-0-284cdb484eee%40kylinos.cn
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH net-next v4 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X
2026-11-19 13:55 ` [PATCH net-next v4 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X Hangbin Liu
2026-11-23 4:09 ` Andrea Mayer
@ 2026-11-23 14:24 ` netdev-bot+sashiko
1 sibling, 0 replies; 11+ messages in thread
From: netdev-bot+sashiko @ 2026-11-23 14:24 UTC (permalink / raw)
To: hangbin.liu
Cc: andrea.mayer, andrea, davem, edumazet, kuba, pabeni, horms,
shuah, netdev, linux-kernel, linux-kselftest, liuhangbin
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 2
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] test_kernel_supp_or_ksft_skip() in
tools/testing/selftests/net/srv6_end_flavors_test.sh is now also used…
- [Low] The commit message does not describe several changes accurately.
- [Low] The comment above __get_srv6_rtcfg_id() gives the example element
"1>2,2>3:psp:End.".
--
selftests: seg6: add PSP flavor testing for SRv6 End.X
This commit adds an End.X scenario to srv6_end_flavors_test.sh. The new
scenario reuses the End PSP and NEXT-C-SID,PSP policies, with every SID
bound through an adjacency. It teaches the policy helpers to parse
<nodeid:op:act> elements, adds a consumed-SRH test for End.X, and checks
kernel support for End.X PSP before running the new tests.
> Add the packet path to each test section so the route taken by the
> traffic is clear.
[Severity: Low]
Is this description accurate? The Path: lines only go into the header
comment block that documents the policies. The TEST SECTION output that
log_section() prints at runtime does not show any path.
The commit message also leaves out two changes to existing End code.
First, the existing End section titles are renamed:
host_srv6_end_flv_psp_tests():
log_section "SRv6 connectivity test hosts (h1 <-> h2, ${act} PSP flavor)"
host_srv6_end_flv_next_csid_psp_tests():
log_section "SRv6 connectivity test hosts (h1 <-> h2, ${act} NEXT-C-SID,PSP)"
host_srv6_end_flv_consumed_srh_tests():
"SRv6 connectivity test hosts (h1 <-> h2, End PSP with a consumed SRH)"
Second, LCNODE_FMT ("%x0") is removed, so build_csid() now prints the node
ID with %s instead of %x:
printf "%s%s%s" "${node}" "${adj}" "${func}"
For router IDs 1-4 the output is the same.
Could the commit message mention these changes?
> diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> index 9d6b7de648da3..d7fdc4e19da9e 100755
> --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
> +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
[ ... ]
> @@ -535,10 +570,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:psp", output: "1,2"
> +# input: "1>2:psp", output: "1>2"
> +# input: "1>2,2>3:psp:End.", output: "1>2,2>3"
[Severity: Low]
This isn't a bug, but should "End." be "End.X" here? __setup_rt_policy()
in this same patch would reject the documented element:
if [[ "${n}" == *">"* && "${n}" != *"End.X"* ]] || \
[[ "${n}" != *">"* && "${n}" == *"End.X"* ]]; then
echo "Incorrect operation format: ${n}" && false
fi
Neither __get_func() nor __get_srv6_act_cfg() has a case for "End." either.
[ ... ]
> @@ -1336,12 +1549,19 @@ test_iproute2_supp_or_ksft_skip()
> fi
> }
>
> +# exit directly if End action not supported, otherwise return 1
> 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"
> @@ -1366,10 +1586,15 @@ test_kernel_supp_or_ksft_skip()
>
> 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}"
> +
> + if [ "$action" != "End" ]; then
> + return 1
> + fi
> +
> exit "${ksft_skip}"
> fi
>
[Severity: Medium]
This function is now also called as a soft probe at the end of the
script:
test_end_flv
if test_kernel_supp_or_ksft_skip End.X psp; then
test_endx_flv
fi
print_log_test_results
This call runs after trap cleanup EXIT is installed. By then router_tests,
host2gateway_tests and test_end_flv have already logged results.
Only the seg6local route add branch returns 1 for End.X. The ip netns
add, dummy link add and link set up failure branches still call
exit "${ksft_skip}" for every action. Calling the function from an if
condition does not stop that exit.
If one of those steps fails here, are the earlier results lost? The exit
runs cleanup(). SETUP_ERR is already 0 after setup_end_flv_psp(), so
cleanup() reaches:
exit "${ret}"
print_log_test_results() has not run yet. If all End tests passed, ret
still holds its initial ${ksft_skip} value, so the run exits as SKIP with
no summary. If some tests failed, it exits 1, also with no summary.
The intended return 1 path (a kernel with End.X but without End.X PSP)
only echoes a SKIP line. log_test_skipped is not called, so nskip stays 0.
Does the final "Tests skipped" summary then leave out the dropped End.X
tests?
On success, the function returns the status of ip netns del. Would a
failing delete also skip test_endx_flv without any message?
The new header comment, "exit directly if End action not supported,
otherwise return 1", also doesn't describe the netns and dummy device
failure paths, which exit for every action.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261119-srv6_flavors_endx-v4-0-284cdb484eee%40kylinos.cn
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-11-23 14:24 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 13:55 [PATCH net-next v4 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu
2026-11-19 13:55 ` [PATCH net-next v4 1/5] seg6: split final End process out of flavor processing Hangbin Liu
2026-11-19 13:55 ` [PATCH net-next v4 2/5] seg6: add RFC8986 flavor support for End.X Hangbin Liu
2026-11-23 14:24 ` netdev-bot+sashiko
2026-11-19 13:55 ` [PATCH net-next v4 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper Hangbin Liu
2026-11-19 13:55 ` [PATCH net-next v4 4/5] selftests: seg6: explicit cleanup for SRv6 End PSP test Hangbin Liu
2026-11-19 13:55 ` [PATCH net-next v4 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X Hangbin Liu
2026-11-23 4:09 ` Andrea Mayer
2026-11-23 10:09 ` Hangbin Liu
2026-11-23 13:40 ` hangbin.liu
2026-11-23 14:24 ` netdev-bot+sashiko
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®