Re: [PATCH net-next v4 5/5] selftests: seg6: add PSP flavor testing for SRv6 End.X

From: Hangbin Liu

Date: Mon Nov 23 2026 - 05:09:26 EST


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