* [PATCH net-next v3 0/5] seg6: add End.X PSP flavor support and selftests
@ 2026-11-12 9:27 Hangbin Liu
2026-11-12 9:27 ` [PATCH net-next v3 1/5] seg6: split final End process out of flavor processing Hangbin Liu
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Hangbin Liu @ 2026-11-12 9: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 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
selftest: 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 | 322 +++++++++++++++++----
2 files changed, 284 insertions(+), 69 deletions(-)
---
base-commit: c88fd6989aea9237a60a4859139a265bfb7ddc0b
change-id: 20260922-srv6_flavors_endx-9489116d50c4
Best regards,
--
Hangbin Liu <liuhangbin@kylinos.cn>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net-next v3 1/5] seg6: split final End process out of flavor processing
2026-11-12 9:27 [PATCH net-next v3 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu
@ 2026-11-12 9:27 ` Hangbin Liu
2026-11-12 9:27 ` [PATCH net-next v3 2/5] seg6: add RFC8986 flavor support for End.X Hangbin Liu
` (3 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Hangbin Liu @ 2026-11-12 9: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 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 related [flat|nested] 10+ messages in thread
* [PATCH net-next v3 2/5] seg6: add RFC8986 flavor support for End.X
2026-11-12 9:27 [PATCH net-next v3 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu
2026-11-12 9:27 ` [PATCH net-next v3 1/5] seg6: split final End process out of flavor processing Hangbin Liu
@ 2026-11-12 9:27 ` Hangbin Liu
2026-11-12 9:27 ` [PATCH net-next v3 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper Hangbin Liu
` (2 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Hangbin Liu @ 2026-11-12 9: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 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 related [flat|nested] 10+ messages in thread
* [PATCH net-next v3 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper
2026-11-12 9:27 [PATCH net-next v3 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu
2026-11-12 9:27 ` [PATCH net-next v3 1/5] seg6: split final End process out of flavor processing Hangbin Liu
2026-11-12 9:27 ` [PATCH net-next v3 2/5] seg6: add RFC8986 flavor support for End.X Hangbin Liu
@ 2026-11-12 9:27 ` Hangbin Liu
2026-11-16 4:26 ` Andrea Mayer
2026-11-12 9:27 ` [PATCH net-next v3 4/5] selftest: seg6: explicit cleanup for SRv6 End PSP test Hangbin Liu
2026-11-12 9:28 ` [PATCH net-next v3 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X Hangbin Liu
4 siblings, 1 reply; 10+ messages in thread
From: Hangbin Liu @ 2026-11-12 9: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 | 56 +++++++++++++++++-----
1 file changed, 45 insertions(+), 11 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..0ed5bfe99029 100755
--- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
+++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
@@ -488,8 +488,9 @@ 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".
- if [ "${SETUP_ERR}" -ne 0 ]; then
+ # the selftest is considered as "skipped", unless a test has already
+ # recorded a failure.
+ if [ "${SETUP_ERR}" -ne 0 ] && [ "$ret" -ne "$ksft_fail" ]; then
echo "SKIP: Setting up the testing environment failed"
exit "${ksft_skip}"
fi
@@ -785,6 +786,27 @@ setup_rt_endpoints()
done
}
+# setup proxy on route entries for hosts
+# args:
+# $1 - ingress router that enforces the SRv6 Policy
+# $2 - destination host whose addresses are proxied
+# $3 - suffix of the address on the loopback of the destination host
+# (i.e. cafe::<host>:<suffix>)
+setup_rt_host_proxy()
+{
+ local rt=$1
+ local hs=$2
+ local func=$3
+
+ ip -netns "$(get_rtname "${rt}")" -6 neigh add \
+ proxy "${IPv6_HS_NETWORK}::${hs}" \
+ dev "${RT2HS_DEVNAME}"
+
+ ip -netns "$(get_rtname "${rt}")" -6 neigh add \
+ proxy "${IPv6_HS_NETWORK}::${hs}:${func}" \
+ dev "${RT2HS_DEVNAME}"
+}
+
# This helper function builds and installs the SID List (i.e. SRv6 Policy)
# to be applied on incoming packets at the ingress node. Moreover, it
# configures the SRv6 nodes specified in the SID List to process the traffic
@@ -860,10 +882,6 @@ __setup_rt_policy()
add "${IPv6_HS_NETWORK}::${dst}" \
encap seg6 mode inline segs "${policy}" \
dev "${DUMMY_DEVNAME}"
-
- ip -netns "${in_nsname}" -6 neigh \
- add proxy "${IPv6_HS_NETWORK}::${dst}" \
- dev "${RT2HS_DEVNAME}"
}
# see __setup_rt_policy
@@ -962,17 +980,29 @@ 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}"
+
+ # setup proxy on route entries for hosts
+ setup_rt_host_proxy 1 2 "${END_CSID_PSP_FUNC}"
+ setup_rt_host_proxy 2 1 "${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 +1459,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 related [flat|nested] 10+ messages in thread
* [PATCH net-next v3 4/5] selftest: seg6: explicit cleanup for SRv6 End PSP test
2026-11-12 9:27 [PATCH net-next v3 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu
` (2 preceding siblings ...)
2026-11-12 9:27 ` [PATCH net-next v3 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper Hangbin Liu
@ 2026-11-12 9:27 ` Hangbin Liu
2026-11-16 4:34 ` Andrea Mayer
2026-11-12 9:28 ` [PATCH net-next v3 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X Hangbin Liu
4 siblings, 1 reply; 10+ messages in thread
From: Hangbin Liu @ 2026-11-12 9: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 defer and defer_scopes_cleanup to remove the PSP specified
configurations. i.e.
* cafe::1, cafe::1:e9, cafe::2, cafe::2:e9 route and proxy on rt1, rt2
* fcbb:0::x0e9 End next-csid,psp policies on rt 1,2,3,4
* fcff:x::0ef1 End psp polices on rt 1,2,4
Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
tools/testing/selftests/net/srv6_end_flavors_test.sh | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh
index 0ed5bfe99029..374b43661c28 100755
--- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
+++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
@@ -759,6 +759,8 @@ setup_rt_endpoint()
add "${sid}" table "${LOCALSID_TABLE_ID}" \
encap seg6local action ${behavior_cfg} \
dev "${DUMMY_DEVNAME}"
+ defer ip -netns "${nsname}" -6 route \
+ del "${sid}" table "${LOCALSID_TABLE_ID}"
}
# Add an SRv6 Endpoint behavior to each router of a Policy element <nodeid:op>.
@@ -801,10 +803,16 @@ setup_rt_host_proxy()
ip -netns "$(get_rtname "${rt}")" -6 neigh add \
proxy "${IPv6_HS_NETWORK}::${hs}" \
dev "${RT2HS_DEVNAME}"
+ defer ip -netns "$(get_rtname "${rt}")" -6 neigh del \
+ proxy "${IPv6_HS_NETWORK}::${hs}" \
+ dev "${RT2HS_DEVNAME}"
ip -netns "$(get_rtname "${rt}")" -6 neigh add \
proxy "${IPv6_HS_NETWORK}::${hs}:${func}" \
dev "${RT2HS_DEVNAME}"
+ defer ip -netns "$(get_rtname "${rt}")" -6 neigh del \
+ proxy "${IPv6_HS_NETWORK}::${hs}:${func}" \
+ dev "${RT2HS_DEVNAME}"
}
# This helper function builds and installs the SID List (i.e. SRv6 Policy)
@@ -882,6 +890,8 @@ __setup_rt_policy()
add "${IPv6_HS_NETWORK}::${dst}" \
encap seg6 mode inline segs "${policy}" \
dev "${DUMMY_DEVNAME}"
+ defer ip -netns "${in_nsname}" -6 route \
+ del "${IPv6_HS_NETWORK}::${dst}"
}
# see __setup_rt_policy
@@ -1460,11 +1470,13 @@ set +e
router_tests
host2gateway_tests
+defer_scope_push
set -e
setup_end_flv_psp
set +e
host_srv6_end_flv_psp_tests
host_srv6_end_flv_next_csid_psp_tests
host_srv6_end_flv_consumed_srh_tests
+defer_scope_pop
print_log_test_results
--
2.56.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net-next v3 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X
2026-11-12 9:27 [PATCH net-next v3 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu
` (3 preceding siblings ...)
2026-11-12 9:27 ` [PATCH net-next v3 4/5] selftest: seg6: explicit cleanup for SRv6 End PSP test Hangbin Liu
@ 2026-11-12 9:28 ` Hangbin Liu
4 siblings, 0 replies; 10+ messages in thread
From: Hangbin Liu @ 2026-11-12 9:28 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), and exercise it with the
existing host connectivity tests.
Teach the policy and endpoint helpers about <nodeid:op:act> elements:
__get_srv6_rtcfg_act() extracts the action, the __get_*_func()
helpers pick the Function for the action, __get_act_cfg() derives the
End.X next hop, and build_csid()/get_rt_sid() keep the adjacency so
it is encoded into the C-SIDs (e.g. fcbb:0:34a9:: is End.X on rt-3
towards rt-4).
There is no need to re-check the ip command capability as it already
supports setting PSP flavor with End.X.
Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
I didn't add `host_srv6_end_flv_consumed_srh_tests()` for End.X because
the extra policy insertion does not work with the End.X policy. The packet
resolves the destination via the next hop directly, rather than doing a
re-lookup in table 90.
---
.../testing/selftests/net/srv6_end_flavors_test.sh | 254 ++++++++++++++++-----
1 file changed, 203 insertions(+), 51 deletions(-)
diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh
index 374b43661c28..5b1b13586df0 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.
@@ -125,12 +125,14 @@
# configured in the Local SID table:
#
# Local SID table for SRv6 router rt-x
-# +---------------------------------------------------------------------+
-# |fcff:x::e is associated with the SRv6 End behavior |
-# |fcff:x::ef1 is associated with the SRv6 End behavior with PSP flavor |
-# |fcbb:0:xpyy::/48 is associated with the SRv6 behavior and flavors |
-# | given by the Function yy, and with parameter p of the behavior |
-# +---------------------------------------------------------------------+
+# +-----------------------------------------------------------------------+
+# |fcff:x::e is associated with the SRv6 End behavior |
+# |fcff:x::a is associated with the SRv6 End.X behavior |
+# |fcff:x::ef1 is associated with the SRv6 End behavior with PSP flavor |
+# |fcff:x::af1 is associated with the SRv6 End.X behavior with PSP flavor |
+# |fcbb:0:xpyy::/48 is associated with the SRv6 behavior and flavors |
+# | given by the Function yy, and with parameter p of the behavior |
+# +-----------------------------------------------------------------------+
#
# The fcff::/16 prefix is reserved by the operator for the SIDs. Reachability of
# SIDs is ensured by proper configuration of the IPv6 operator's network and
@@ -153,10 +155,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
# =============
@@ -339,12 +345,12 @@ readonly LOCATOR_SERVICE=fcff
readonly END_FUNC=000e
readonly END_PSP_FUNC=0ef1
readonly END_CSID_PSP_FUNC=e9
+readonly ENDX_FUNC=000a
+readonly ENDX_PSP_FUNC=0af1
+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
@@ -531,14 +537,34 @@ 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. From each
+# element of the list, the ">" together with the following router ID or
+# "h" (the adjacency) is dropped as well.
+# i.e. input: "12:psp", output: "12"
+# input: "1,2:psp", output: "1,2"
+# input: "1>2:psp", output: "1"
+# input: "1>2,2>3:psp", output: "1,2"
+# input: "2>h:psp:End.X", output: "2"
__get_srv6_rtcfg_id()
{
local element="$1"
+ echo "${element}" | sed 's/:.*//; s/>[1234h]//g'
+}
+
+# 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. Unlike
+# __get_srv6_rtcfg_id(), the ">" and the following router ID or "h" are
+# kept in each element. The callers that need the adjacency use this variant,
+# e.g. to encode it into a C-SID or to derive the End.X next hop.
+# i.e. input: "1,2:psp", output: "1,2"
+# input: "1>2,2>3:psp", output: "1>2,2>3"
+# input: "4>2,2>h:psp:End.X", output: "4>2,2>h"
+__get_srv6_rtcfg_all_id()
+{
+ local element="$1"
+
echo "${element}" | cut -d':' -f1
}
@@ -559,20 +585,95 @@ __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/'
+}
+
+__get_noflv_func()
+{
+ local act="$1"
+
+ case "${act}" in
+ "End")
+ echo "${END_FUNC}" ;;
+ "End.X")
+ echo "${ENDX_FUNC}" ;;
+ esac
+}
+
+__get_psp_func()
+{
+ local act="$1"
+
+ case "${act}" in
+ "End")
+ echo "${END_PSP_FUNC}" ;;
+ "End.X")
+ echo "${ENDX_PSP_FUNC}" ;;
+ esac
+}
+
+__get_csid_psp_func()
+{
+ local act="$1"
+
+ case "${act}" in
+ "End")
+ echo "${END_CSID_PSP_FUNC}" ;;
+ "End.X")
+ echo "${ENDX_CSID_PSP_FUNC}" ;;
+ esac
+}
+
+# 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 h", output: "End.X nh6 cafe::2"
+# input: "End.X 4 2", output: "End.X nh6 fcf0:0:2:4::2"
+__get_act_cfg()
+{
+ local act="$1"
+ local rt="$2"
+ local neigh="$3"
+ local net_prefix nh
+
+ case "${act}" in
+ "End")
+ echo "End" ;;
+ "End.X")
+ if [ "${neigh}" == "h" ]; 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
+}
+
# 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).
# args:
# $1 - router
# $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"
- printf "${LCNODE_FMT}%s" "${nodeid}" "${func}"
+ nodeid=$(echo "${nodeid}" | sed 's/>//; s/h/0/')
+ [[ ${#nodeid} -eq 1 ]] && mid=0 || mid=""
+ printf "%s%s%s" "${nodeid}" "$mid" "${func}"
}
# Return the C-SID container with the C-SIDs of the routers listed in a
@@ -580,8 +681,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"
@@ -713,10 +814,10 @@ 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" "psp" "0ef1", output: "fcff:4::0ef1"
+# input: "4>2" "psp" "0af1", output: "fcff:4::0af1"
+# 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"
@@ -730,6 +831,7 @@ get_rt_sid()
return
fi
+ rt=$(echo "${rt}" | sed 's/>.*//')
echo "${LOCATOR_SERVICE}:${rt}::${func}"
}
@@ -765,26 +867,34 @@ setup_rt_endpoint()
# Add an SRv6 Endpoint behavior to each router of a Policy element <nodeid:op>.
# args:
-# $1 - <nodeid> of the element: one router, or a comma-separated list
+# $1 - <nodeid:op:act> element
# $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"
+# $4 - flavor configuration of the behavior, without the action
+# (e.g. "flavors psp")
+# e.g. input: "4,2:next-csid,psp" "next-csid,psp" "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 nodeid="$1"
local op_type="$2"
local func="$3"
local behavior_cfg="$4"
+ local nodes node next_node
+ local act act_cfg
local sid
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}"
+ nodes="$(__get_srv6_rtcfg_all_id "${nodeid}")"
+ act="$(__get_srv6_rtcfg_act "${nodeid}")"
+ for node in $(echo "${nodes}" | sed 's/,/ /g'); do
+ rt=$(echo "${node}" | cut -d'>' -f1)
+ next_node=$(echo "${node}" | cut -d'>' -f2)
+ act_cfg="$(__get_act_cfg "${act}" "${rt}" "${next_node}")"
+ sid="$(get_rt_sid "${node}" "${op_type}" "${func}")"
+ setup_rt_endpoint "${rt}" "${sid}" "${act_cfg} ${behavior_cfg}"
done
}
@@ -824,7 +934,8 @@ setup_rt_host_proxy()
# 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.
@@ -841,34 +952,38 @@ __setup_rt_policy()
local container
local function
local op_type
+ local nodes
local node
+ local act
local n
in_nsname="$(get_rtname "${encap_rt}")"
for n in ${policy_rts}; do
node="$(__get_srv6_rtcfg_id "${n}")"
+ nodes="$(__get_srv6_rtcfg_all_id "${n}")"
op_type="$(__get_srv6_rtcfg_op "${n}")"
+ act="$(__get_srv6_rtcfg_act "${n}")"
case "${op_type}" in
"noflv")
- policy="${policy}${LOCATOR_SERVICE}:${node}::${END_FUNC},"
- function="${END_FUNC}"
- behavior_cfg="End"
+ function="$(__get_noflv_func "${act}")"
+ policy="${policy}${LOCATOR_SERVICE}:${node}::${function},"
+ behavior_cfg=""
;;
"psp")
- policy="${policy}${LOCATOR_SERVICE}:${node}::${END_PSP_FUNC},"
- function="${END_PSP_FUNC}"
- behavior_cfg="End flavors psp"
+ function="$(__get_psp_func "${act}")"
+ policy="${policy}${LOCATOR_SERVICE}:${node}::${function},"
+ behavior_cfg="flavors psp"
;;
"next-csid,psp")
- container="$(build_csid_container "${node}" \
- "${END_CSID_PSP_FUNC}")"
+ function="$(__get_csid_psp_func "${act}")"
+ container="$(build_csid_container "${nodes}" \
+ "${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}"
;;
*)
@@ -877,7 +992,7 @@ __setup_rt_policy()
esac
# add SRv6 Endpoint behavior to the selected routers
- setup_rt_endpoints "${node}" \
+ setup_rt_endpoints "${n}" \
"${op_type}" "${function}" "${behavior_cfg}"
done
@@ -1049,6 +1164,29 @@ 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}"
+
+ setup_rt_host_proxy 1 2 "${ENDX_CSID_PSP_FUNC}"
+ setup_rt_host_proxy 2 1 "${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"
@@ -1155,7 +1293,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
@@ -1163,10 +1303,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_csid_psp_func "${act}")"
+ 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
@@ -1479,4 +1623,12 @@ host_srv6_end_flv_next_csid_psp_tests
host_srv6_end_flv_consumed_srh_tests
defer_scope_pop
+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"
+defer_scope_pop
+
print_log_test_results
--
2.56.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH net-next v3 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper
2026-11-12 9:27 ` [PATCH net-next v3 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper Hangbin Liu
@ 2026-11-16 4:26 ` Andrea Mayer
2026-11-16 6:20 ` Hangbin Liu
0 siblings, 1 reply; 10+ messages in thread
From: Andrea Mayer @ 2026-11-16 4:26 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, 12 Nov 2026 17:27:58 +0800
Hangbin Liu <hangbin.liu@linux.dev> wrote:
> 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.
Hi Hangbin,
thanks for the v3.
>
> 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 157baa8ecb0b..0ed5bfe99029 100755
> --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
> +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> @@ -488,8 +488,9 @@ 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".
> - if [ "${SETUP_ERR}" -ne 0 ]; then
> + # the selftest is considered as "skipped", unless a test has already
> + # recorded a failure.
> + if [ "${SETUP_ERR}" -ne 0 ] && [ "$ret" -ne "$ksft_fail" ]; then
> echo "SKIP: Setting up the testing environment failed"
> exit "${ksft_skip}"
> fi
When a test has already failed and the setup then fails, the script
exits with 1 and does not say that the setup failed. For example, with
hs-2 -> gw failing and then an error in setup_end_flv_psp(), the last
TEST lines in the log are:
TEST: IPv6 Hosts connectivity: hs-1 -> gw [ OK ]
TEST: IPv6 Hosts connectivity: hs-2 -> gw [FAIL]
The End PSP tests did not run. Before this patch, the setup ran before
any test, and cleanup() printed "Setting up the testing environment
failed" on every setup error. Could cleanup() print it also in this
case, keeping the exit code 1? Something like:
if [ "${SETUP_ERR}" -ne 0 ]; then
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}"
> @@ -785,6 +786,27 @@ setup_rt_endpoints()
> done
> }
>
> +# setup proxy on route entries for hosts
> +# args:
> +# $1 - ingress router that enforces the SRv6 Policy
> +# $2 - destination host whose addresses are proxied
> +# $3 - suffix of the address on the loopback of the destination host
> +# (i.e. cafe::<host>:<suffix>)
> +setup_rt_host_proxy()
> +{
> + local rt=$1
> + local hs=$2
> + local func=$3
> +
> + ip -netns "$(get_rtname "${rt}")" -6 neigh add \
> + proxy "${IPv6_HS_NETWORK}::${hs}" \
> + dev "${RT2HS_DEVNAME}"
> +
> + ip -netns "$(get_rtname "${rt}")" -6 neigh add \
> + proxy "${IPv6_HS_NETWORK}::${hs}:${func}" \
> + dev "${RT2HS_DEVNAME}"
> +}
> +
> # This helper function builds and installs the SID List (i.e. SRv6 Policy)
> # to be applied on incoming packets at the ingress node. Moreover, it
> # configures the SRv6 nodes specified in the SID List to process the traffic
> @@ -860,10 +882,6 @@ __setup_rt_policy()
> add "${IPv6_HS_NETWORK}::${dst}" \
> encap seg6 mode inline segs "${policy}" \
> dev "${DUMMY_DEVNAME}"
> -
> - ip -netns "${in_nsname}" -6 neigh \
> - add proxy "${IPv6_HS_NETWORK}::${dst}" \
> - dev "${RT2HS_DEVNAME}"
> }
>
> # see __setup_rt_policy
> @@ -962,17 +980,29 @@ 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}"
> +
> + # setup proxy on route entries for hosts
> + setup_rt_host_proxy 1 2 "${END_CSID_PSP_FUNC}"
> + setup_rt_host_proxy 2 1 "${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.
Before this patch, __setup_rt_policy() added the proxy entry together
with the route of each Policy. With this patch, each scenario calls
setup_rt_host_proxy() instead.
In this v3, 4/5 deletes the proxies when the scenario ends, like the
routes of the Policies. So I think the proxy entry can stay in
__setup_rt_policy(), and in 4/5 its defer can go next to the defer of
the route. What do you think?
> [snip]
Thanks,
Andrea
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next v3 4/5] selftest: seg6: explicit cleanup for SRv6 End PSP test
2026-11-12 9:27 ` [PATCH net-next v3 4/5] selftest: seg6: explicit cleanup for SRv6 End PSP test Hangbin Liu
@ 2026-11-16 4:34 ` Andrea Mayer
2026-11-16 6:27 ` Hangbin Liu
0 siblings, 1 reply; 10+ messages in thread
From: Andrea Mayer @ 2026-11-16 4:34 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, 12 Nov 2026 17:27:59 +0800
Hangbin Liu <hangbin.liu@linux.dev> wrote:
> The End PSP tests install policy and localsid state but rely on the
> global namespace teardown to remove it. That leaves flavor-specific
> state behind once more tests share this script.
>
> Use defer and defer_scopes_cleanup to remove the PSP specified
> configurations. i.e.
>
> * cafe::1, cafe::1:e9, cafe::2, cafe::2:e9 route and proxy on rt1, rt2
> * fcbb:0::x0e9 End next-csid,psp policies on rt 1,2,3,4
> * fcff:x::0ef1 End psp polices on rt 1,2,4
Hi Hangbin,
A few nits on the message:
- The code uses defer_scope_pop, not defer_scopes_cleanup.
- The NEXT-C-SID End SIDs are fcbb:0:x0e9::/48, not fcbb:0::x0e9.
- "polices" is a typo.
- The subject prefix is "selftest: seg6:", while the other selftest
patches of the series use "selftests: seg6:".
>
> Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
> [snip]
> diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> index 0ed5bfe99029..374b43661c28 100755
> --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
> +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> @@ -759,6 +759,8 @@ setup_rt_endpoint()
> add "${sid}" table "${LOCALSID_TABLE_ID}" \
> encap seg6local action ${behavior_cfg} \
> dev "${DUMMY_DEVNAME}"
> + defer ip -netns "${nsname}" -6 route \
> + del "${sid}" table "${LOCALSID_TABLE_ID}"
> }
>
> # Add an SRv6 Endpoint behavior to each router of a Policy element <nodeid:op>.
> @@ -801,10 +803,16 @@ setup_rt_host_proxy()
> ip -netns "$(get_rtname "${rt}")" -6 neigh add \
> proxy "${IPv6_HS_NETWORK}::${hs}" \
> dev "${RT2HS_DEVNAME}"
> + defer ip -netns "$(get_rtname "${rt}")" -6 neigh del \
> + proxy "${IPv6_HS_NETWORK}::${hs}" \
> + dev "${RT2HS_DEVNAME}"
>
> ip -netns "$(get_rtname "${rt}")" -6 neigh add \
> proxy "${IPv6_HS_NETWORK}::${hs}:${func}" \
> dev "${RT2HS_DEVNAME}"
> + defer ip -netns "$(get_rtname "${rt}")" -6 neigh del \
> + proxy "${IPv6_HS_NETWORK}::${hs}:${func}" \
> + dev "${RT2HS_DEVNAME}"
> }
>
> # This helper function builds and installs the SID List (i.e. SRv6 Policy)
> @@ -882,6 +890,8 @@ __setup_rt_policy()
> add "${IPv6_HS_NETWORK}::${dst}" \
> encap seg6 mode inline segs "${policy}" \
> dev "${DUMMY_DEVNAME}"
> + defer ip -netns "${in_nsname}" -6 route \
> + del "${IPv6_HS_NETWORK}::${dst}"
> }
>
> # see __setup_rt_policy
If you agree to keep the proxy entry in __setup_rt_policy(), as
proposed on patch 3, its defer can go next to the defer of the route.
Something like:
ip -netns "${in_nsname}" -6 route \
add "${IPv6_HS_NETWORK}::${dst}" \
encap seg6 mode inline segs "${policy}" \
dev "${DUMMY_DEVNAME}"
defer ip -netns "${in_nsname}" -6 route \
del "${IPv6_HS_NETWORK}::${dst}"
ip -netns "${in_nsname}" -6 neigh \
add proxy "${IPv6_HS_NETWORK}::${dst}" \
dev "${RT2HS_DEVNAME}"
defer ip -netns "${in_nsname}" -6 neigh \
del proxy "${IPv6_HS_NETWORK}::${dst}" \
dev "${RT2HS_DEVNAME}"
> @@ -1460,11 +1470,13 @@ set +e
> router_tests
> host2gateway_tests
>
> +defer_scope_push
> set -e
> setup_end_flv_psp
> set +e
> host_srv6_end_flv_psp_tests
> host_srv6_end_flv_next_csid_psp_tests
> host_srv6_end_flv_consumed_srh_tests
> +defer_scope_pop
>
> print_log_test_results
setup_hs_lo_addr() has no defer. The loopback addresses cafe::1:e9
and cafe::2:e9, and the routes that setup_hs_lo_addr() adds on rt-1
and rt-2, stay after defer_scope_pop. Only the End PSP scenario uses
them. Could setup_hs_lo_addr() defer their removal too, like the
Policies? Something like:
ip -netns "${hsname}" addr add "${addr}/128" dev lo nodad
defer ip -netns "${hsname}" addr del "${addr}/128" dev lo
ip -netns "${rtname}" -6 route \
add "${addr}" \
via "${IPv6_HS_NETWORK}::${hs}" dev "${RT2HS_DEVNAME}"
defer ip -netns "${rtname}" -6 route \
del "${addr}"
Thanks,
Andrea
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next v3 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper
2026-11-16 4:26 ` Andrea Mayer
@ 2026-11-16 6:20 ` Hangbin Liu
0 siblings, 0 replies; 10+ messages in thread
From: Hangbin Liu @ 2026-11-16 6:20 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, Andrea Mayer
Hi Andrea,
On Mon, Nov 16, 2026 at 05:26:59AM +0100, Andrea Mayer wrote:
> > [snip]
> > diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> > index 157baa8ecb0b..0ed5bfe99029 100755
> > --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
> > +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> > @@ -488,8 +488,9 @@ 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".
> > - if [ "${SETUP_ERR}" -ne 0 ]; then
> > + # the selftest is considered as "skipped", unless a test has already
> > + # recorded a failure.
> > + if [ "${SETUP_ERR}" -ne 0 ] && [ "$ret" -ne "$ksft_fail" ]; then
> > echo "SKIP: Setting up the testing environment failed"
> > exit "${ksft_skip}"
> > fi
>
> When a test has already failed and the setup then fails, the script
> exits with 1 and does not say that the setup failed. For example, with
> hs-2 -> gw failing and then an error in setup_end_flv_psp(), the last
> TEST lines in the log are:
>
> TEST: IPv6 Hosts connectivity: hs-1 -> gw [ OK ]
> TEST: IPv6 Hosts connectivity: hs-2 -> gw [FAIL]
>
> The End PSP tests did not run. Before this patch, the setup ran before
> any test, and cleanup() printed "Setting up the testing environment
> failed" on every setup error. Could cleanup() print it also in this
> case, keeping the exit code 1? Something like:
>
> if [ "${SETUP_ERR}" -ne 0 ]; then
> 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}"
OK, I will fix it.
> > # see __setup_rt_policy
> > @@ -962,17 +980,29 @@ 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}"
> > +
> > + # setup proxy on route entries for hosts
> > + setup_rt_host_proxy 1 2 "${END_CSID_PSP_FUNC}"
> > + setup_rt_host_proxy 2 1 "${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.
>
> Before this patch, __setup_rt_policy() added the proxy entry together
> with the route of each Policy. With this patch, each scenario calls
> setup_rt_host_proxy() instead.
>
> In this v3, 4/5 deletes the proxies when the scenario ends, like the
> routes of the Policies. So I think the proxy entry can stay in
> __setup_rt_policy(), and in 4/5 its defer can go next to the defer of
> the route. What do you think?
OK, I will keep the proxy set up in __setup_rt_policy.
Thanks
Hangbin
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net-next v3 4/5] selftest: seg6: explicit cleanup for SRv6 End PSP test
2026-11-16 4:34 ` Andrea Mayer
@ 2026-11-16 6:27 ` Hangbin Liu
0 siblings, 0 replies; 10+ messages in thread
From: Hangbin Liu @ 2026-11-16 6:27 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, Andrea Mayer
Hi Andrea,
On Mon, Nov 16, 2026 at 05:34:07AM +0100, Andrea Mayer wrote:
> On Thu, 12 Nov 2026 17:27:59 +0800
> Hangbin Liu <hangbin.liu@linux.dev> wrote:
>
> > The End PSP tests install policy and localsid state but rely on the
> > global namespace teardown to remove it. That leaves flavor-specific
> > state behind once more tests share this script.
> >
> > Use defer and defer_scopes_cleanup to remove the PSP specified
> > configurations. i.e.
> >
> > * cafe::1, cafe::1:e9, cafe::2, cafe::2:e9 route and proxy on rt1, rt2
> > * fcbb:0::x0e9 End next-csid,psp policies on rt 1,2,3,4
> > * fcff:x::0ef1 End psp polices on rt 1,2,4
>
> Hi Hangbin,
>
> A few nits on the message:
> - The code uses defer_scope_pop, not defer_scopes_cleanup.
> - The NEXT-C-SID End SIDs are fcbb:0:x0e9::/48, not fcbb:0::x0e9.
> - "polices" is a typo.
> - The subject prefix is "selftest: seg6:", while the other selftest
> patches of the series use "selftests: seg6:".
Thanks for the detailed review, I will fix them.
>
> >
> > Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
> > [snip]
> > diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> > index 0ed5bfe99029..374b43661c28 100755
> > --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
> > +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> > @@ -759,6 +759,8 @@ setup_rt_endpoint()
> > add "${sid}" table "${LOCALSID_TABLE_ID}" \
> > encap seg6local action ${behavior_cfg} \
> > dev "${DUMMY_DEVNAME}"
> > + defer ip -netns "${nsname}" -6 route \
> > + del "${sid}" table "${LOCALSID_TABLE_ID}"
> > }
> >
> > # Add an SRv6 Endpoint behavior to each router of a Policy element <nodeid:op>.
> > @@ -801,10 +803,16 @@ setup_rt_host_proxy()
> > ip -netns "$(get_rtname "${rt}")" -6 neigh add \
> > proxy "${IPv6_HS_NETWORK}::${hs}" \
> > dev "${RT2HS_DEVNAME}"
> > + defer ip -netns "$(get_rtname "${rt}")" -6 neigh del \
> > + proxy "${IPv6_HS_NETWORK}::${hs}" \
> > + dev "${RT2HS_DEVNAME}"
> >
> > ip -netns "$(get_rtname "${rt}")" -6 neigh add \
> > proxy "${IPv6_HS_NETWORK}::${hs}:${func}" \
> > dev "${RT2HS_DEVNAME}"
> > + defer ip -netns "$(get_rtname "${rt}")" -6 neigh del \
> > + proxy "${IPv6_HS_NETWORK}::${hs}:${func}" \
> > + dev "${RT2HS_DEVNAME}"
> > }
> >
> > # This helper function builds and installs the SID List (i.e. SRv6 Policy)
> > @@ -882,6 +890,8 @@ __setup_rt_policy()
> > add "${IPv6_HS_NETWORK}::${dst}" \
> > encap seg6 mode inline segs "${policy}" \
> > dev "${DUMMY_DEVNAME}"
> > + defer ip -netns "${in_nsname}" -6 route \
> > + del "${IPv6_HS_NETWORK}::${dst}"
> > }
> >
> > # see __setup_rt_policy
>
> If you agree to keep the proxy entry in __setup_rt_policy(), as
> proposed on patch 3, its defer can go next to the defer of the route.
> Something like:
>
> ip -netns "${in_nsname}" -6 route \
> add "${IPv6_HS_NETWORK}::${dst}" \
> encap seg6 mode inline segs "${policy}" \
> dev "${DUMMY_DEVNAME}"
> defer ip -netns "${in_nsname}" -6 route \
> del "${IPv6_HS_NETWORK}::${dst}"
>
> ip -netns "${in_nsname}" -6 neigh \
> add proxy "${IPv6_HS_NETWORK}::${dst}" \
> dev "${RT2HS_DEVNAME}"
> defer ip -netns "${in_nsname}" -6 neigh \
> del proxy "${IPv6_HS_NETWORK}::${dst}" \
> dev "${RT2HS_DEVNAME}"
>
> > @@ -1460,11 +1470,13 @@ set +e
> > router_tests
> > host2gateway_tests
> >
> > +defer_scope_push
> > set -e
> > setup_end_flv_psp
> > set +e
> > host_srv6_end_flv_psp_tests
> > host_srv6_end_flv_next_csid_psp_tests
> > host_srv6_end_flv_consumed_srh_tests
> > +defer_scope_pop
> >
> > print_log_test_results
>
> setup_hs_lo_addr() has no defer. The loopback addresses cafe::1:e9
> and cafe::2:e9, and the routes that setup_hs_lo_addr() adds on rt-1
> and rt-2, stay after defer_scope_pop. Only the End PSP scenario uses
> them. Could setup_hs_lo_addr() defer their removal too, like the
> Policies? Something like:
>
> ip -netns "${hsname}" addr add "${addr}/128" dev lo nodad
> defer ip -netns "${hsname}" addr del "${addr}/128" dev lo
>
> ip -netns "${rtname}" -6 route \
> add "${addr}" \
> via "${IPv6_HS_NETWORK}::${hs}" dev "${RT2HS_DEVNAME}"
> defer ip -netns "${rtname}" -6 route \
> del "${addr}"
I will update the defer with your suggestions.
Thanks
Hangbin
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-11-16 6:27 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 9:27 [PATCH net-next v3 0/5] seg6: add End.X PSP flavor support and selftests Hangbin Liu
2026-11-12 9:27 ` [PATCH net-next v3 1/5] seg6: split final End process out of flavor processing Hangbin Liu
2026-11-12 9:27 ` [PATCH net-next v3 2/5] seg6: add RFC8986 flavor support for End.X Hangbin Liu
2026-11-12 9:27 ` [PATCH net-next v3 3/5] selftests: seg6: move SRv6 End PSP setup into its own helper Hangbin Liu
2026-11-16 4:26 ` Andrea Mayer
2026-11-16 6:20 ` Hangbin Liu
2026-11-12 9:27 ` [PATCH net-next v3 4/5] selftest: seg6: explicit cleanup for SRv6 End PSP test Hangbin Liu
2026-11-16 4:34 ` Andrea Mayer
2026-11-16 6:27 ` Hangbin Liu
2026-11-12 9:28 ` [PATCH net-next v3 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X Hangbin Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox