From: Andrea Mayer <andrea.mayer@uniroma2.it>
To: Hangbin Liu <hangbin.liu@linux.dev>
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org,
Hangbin Liu <liuhangbin@kylinos.cn>,
Stefano Salsano <stefano.salsano@uniroma2.it>,
Justin Iurman <justin.iurman@gmail.com>,
Andrea Mayer <andrea@common-net.org>,
Andrea Mayer <andrea.mayer@uniroma2.it>
Subject: Re: [PATCH net-next v4 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X
Date: Mon, 23 Nov 2026 05:09:52 +0100 [thread overview]
Message-ID: <20261123050952.21dc46abdf5fe4fa235bb68d@uniroma2.it> (raw)
In-Reply-To: <20261119-srv6_flavors_endx-v4-5-284cdb484eee@kylinos.cn>
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
prev parent reply other threads:[~2026-11-23 4:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` [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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123050952.21dc46abdf5fe4fa235bb68d@uniroma2.it \
--to=andrea.mayer@uniroma2.it \
--cc=andrea@common-net.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hangbin.liu@linux.dev \
--cc=horms@kernel.org \
--cc=justin.iurman@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=liuhangbin@kylinos.cn \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=stefano.salsano@uniroma2.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox