All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hangbin Liu <hangbin.liu@linux.dev>
To: Andrea Mayer <andrea.mayer@uniroma2.it>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	David Ahern <dsahern@kernel.org>, Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, Shuah Khan <shuah@kernel.org>,
	Justin Iurman <justin.iurman@gmail.com>,
	Nicolas Dichtel <nicolas.dichtel@6wind.com>,
	Ahmed Abdelsalam <ahabdels@cisco.com>,
	Stefano Salsano <stefano.salsano@uniroma2.it>
Subject: Re: [PATCH net-next 5/5] selftests: seg6: add tests for PSP with a consumed SRH
Date: Mon, 12 Oct 2026 16:19:22 +0800	[thread overview]
Message-ID: <asyYCoMwGjh6XG3S@fedora> (raw)
In-Reply-To: <20261011192310.55-6-andrea.mayer@uniroma2.it>

On Sun, Oct 11, 2026 at 09:23:10PM +0200, Andrea Mayer wrote:
> Extend srv6_end_flavors_test.sh with tests for the SRv6 End behavior
> with the PSP flavor, alone and together with NEXT-C-SID, on packets that
> carry a consumed SRH in front of the SRH to process.
> 
> Each test sends a ping along an existing SRv6 Policy, and a router on
> the path inserts an extra SRH in front of the Policy's SRH. An End
> behavior on another router consumes the extra SRH, and the router
> connected to the host must then remove only the Policy's SRH. A test
> passes if the ping succeeds.
> 
> These tests set seg6_enabled to 1 on the hosts, which must accept the
> extra SRH, and set it back to 0 at the end. PSP itself is checked
> by the other PSP tests, which run with seg6_enabled set to 0.
> 
> Signed-off-by: Andrea Mayer <andrea.mayer@uniroma2.it>
> ---
>  .../selftests/net/srv6_end_flavors_test.sh    | 144 +++++++++++++++++-
>  1 file changed, 142 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> index baa1b09a1aab..b5dbf53a7f23 100755
> --- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
> +++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
> @@ -22,8 +22,7 @@
>  # 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 outermost SRH from the IPv6
> -# header.
> +# listed in the SRv6 policy to remove (i.e. pop) the SRH from the IPv6 header.
>  # A PSP enabled SRv6 End behavior instance processes the SRH by:
>  #  - decrementing the Segment Left (SL) value from 1 to 0;
>  #  - copying the last SID from the SID List into the IPv6 Destination Address
> @@ -258,6 +257,60 @@
>  # the hosts). The loopback address of a host is reached only through the
>  # router connected to that host: the ping succeeds only if the SRH is removed
>  # by that router.
> +#
> +# Traffic with a consumed SRH
> +# ---------------------------
> +#
> +# A packet can carry more than one SRH. The SRv6 End behavior skips an SRH with
> +# SL=0 and processes the next header [1].
> +#
> +# The traffic of this section reuses the Policies (i.a), (i.b), (i.c) and (i.d).
> +# A router on the path inserts an extra SRH in front of the Policy's SRH, and
> +# another router then consumes the extra SRH.
> +#
> +# The Policy (i.a) has SID List=fcff:3::e,fcff:4::ef1,fcff:2::ef1,cafe::2. A
> +# packet from hs-1 to hs-2 goes as follows:
> +#
> +#  - rt-1 applies the Policy and sends the packet to rt-3:
> +#      IPv6 DA=fcff:3::e | Policy's SRH, SL=3 | Payload
> +#
> +#  - rt-3 (End) processes the Policy's SRH and sends the packet to rt-4:
> +#      IPv6 DA=fcff:4::ef1 | Policy's SRH, SL=2 | Payload
> +#
> +#  - rt-4 (End with PSP and SL>1, acting as End) processes the Policy's SRH.
> +#    The new DA is fcff:2::ef1:
> +#      IPv6 DA=fcff:2::ef1 | Policy's SRH, SL=1 | Payload
> +#    On rt-4, the route added by the test for fcff:2::ef1 then inserts the
> +#    extra SRH, with SID List=fcff:3::e,fcff:2::ef1, and the packet goes back to
> +#    rt-3:
> +#      IPv6 DA=fcff:3::e | extra SRH, SL=1 | Policy's SRH, SL=1 | Payload
> +#
> +#  - rt-3 (End) consumes the extra SRH and sets the DA back to fcff:2::ef1:
> +#      IPv6 DA=fcff:2::ef1 | extra SRH, SL=0 | Policy's SRH, SL=1 | Payload
> +#
> +#  - rt-2 (End with PSP) skips the extra SRH, processes the Policy's SRH and
> +#    removes it:
> +#      IPv6 DA=cafe::2 | extra SRH, SL=0 | Payload
> +#
> +# 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.
> +#   (i.c) hs-1 -> hs-2: on the packets with DA=fcbb:0:02a1::, rt-4 inserts the
> +#         extra SRH with SID List=fcff:3::e,fcbb:0:02a1::, and rt-3 consumes it.
> +#   (i.d) hs-2 -> hs-1: on the packets with DA=fcbb:0:01a1::, rt-3 inserts the
> +#         extra SRH with SID List=fcff:4::e,fcbb:0:01a1::, and rt-4 consumes it.
> +#
> +# 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:
> +#      IPv6 DA=fcff:3::e | extra SRH, SL=1 | Policy's SRH, SL=1 | Payload
> +# rt-3 consumes the extra SRH, and rt-1 removes the Policy's SRH.
> +#
> +# The hosts need seg6_enabled set to 1 to accept the extra SRH, and it is set
> +# back to 0 at the end. These tests only check that the ping succeeds: PSP
> +# itself is checked by the PSP flavor and NEXT-C-SID,PSP tests, which run with
> +# seg6_enabled set to 0.
>  
>  # shellcheck source=lib.sh
>  source lib.sh
> @@ -967,6 +1020,92 @@ host_srv6_end_flv_next_csid_psp_tests()
>  	check_and_log_hs_lo_addr_connectivity 2 1 "${END_CSID_PSP_FUNC}"
>  }
>  
> +# On a router, add a route for a SID with seg6 encap in inline mode. The packets
> +# that the router forwards to that SID get an extra SRH with the End SID of the
> +# router that consumes it.
> +# args:
> +#  $1 - router on which the route is added
> +#  $2 - SID of the route
> +#  $3 - router with the SRv6 End behavior that consumes the extra SRH
> +setup_rt_consumed_srh()
> +{
> +	local rt="$1"
> +	local sid="$2"
> +	local end_rt="$3"
> +	local nsname
> +
> +	nsname="$(get_rtname "${rt}")"
> +
> +	ip -netns "${nsname}" -6 route \
> +		add "${sid}" table "${LOCALSID_TABLE_ID}" \
> +		encap seg6 mode inline \
> +		segs "${LOCATOR_SERVICE}:${end_rt}::${END_FUNC}" \
> +		dev "${DUMMY_DEVNAME}"
> +}
> +
> +cleanup_rt_consumed_srh()
> +{
> +	local rt="$1"
> +	local sid="$2"
> +	local nsname
> +
> +	nsname="$(get_rtname "${rt}")"
> +
> +	ip -netns "${nsname}" -6 route \
> +		del "${sid}" table "${LOCALSID_TABLE_ID}"
> +}
> +
> +set_hs_seg6_enabled()
> +{
> +	local val="$1"
> +	local hsname
> +	local hs
> +
> +	for hs in ${HOSTS}; do
> +		hsname="$(get_hsname "${hs}")"
> +
> +		ip netns exec "${hsname}" \
> +			sysctl -wq net.ipv6.conf.all.seg6_enabled="${val}"
> +		ip netns exec "${hsname}" \
> +			sysctl -wq net.ipv6.conf.veth0.seg6_enabled="${val}"
> +	done
> +}
> +
> +host_srv6_end_flv_consumed_srh_tests()
> +{
> +	local sid
> +
> +	log_section "SRv6 connectivity test hosts (h1 <-> h2, consumed SRH)"
> +
> +	set_hs_seg6_enabled 1
> +
> +	# Policy (i.a): rt-4 inserts the extra SRH consumed by rt-3
> +	sid="${LOCATOR_SERVICE}:2::${END_PSP_FUNC}"
> +	setup_rt_consumed_srh 4 "${sid}" 3
> +	check_and_log_hs_connectivity 1 2
> +	cleanup_rt_consumed_srh 4 "${sid}"
> +
> +	# Policy (i.b): rt-2 inserts the extra SRH consumed by rt-3
> +	sid="${LOCATOR_SERVICE}:1::${END_PSP_FUNC}"
> +	setup_rt_consumed_srh 2 "${sid}" 3
> +	check_and_log_hs_connectivity 2 1
> +	cleanup_rt_consumed_srh 2 "${sid}"
> +
> +	# Policy (i.c): rt-4 inserts the extra SRH consumed by rt-3
> +	sid="$(build_csid_container 2 "${END_CSID_PSP_FUNC}")"
> +	setup_rt_consumed_srh 4 "${sid}" 3
> +	check_and_log_hs_lo_addr_connectivity 1 2 "${END_CSID_PSP_FUNC}"
> +	cleanup_rt_consumed_srh 4 "${sid}"
> +
> +	# Policy (i.d): rt-3 inserts the extra SRH consumed by rt-4
> +	sid="$(build_csid_container 1 "${END_CSID_PSP_FUNC}")"
> +	setup_rt_consumed_srh 3 "${sid}" 4
> +	check_and_log_hs_lo_addr_connectivity 2 1 "${END_CSID_PSP_FUNC}"
> +	cleanup_rt_consumed_srh 3 "${sid}"
> +
> +	set_hs_seg6_enabled 0
> +}
> +
>  test_iproute2_supp_or_ksft_skip()
>  {
>  	local flavor="$1"
> @@ -1071,5 +1210,6 @@ router_tests
>  host2gateway_tests
>  host_srv6_end_flv_psp_tests
>  host_srv6_end_flv_next_csid_psp_tests
> +host_srv6_end_flv_consumed_srh_tests
>  
>  print_log_test_results
> -- 
> 2.43.0
> 

Tested-by: Hangbin Liu <liuhangbin@kylinos.cn>
Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn>

Thanks
Hangbin

  reply	other threads:[~2026-10-12  8:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-11 19:23 [PATCH net-next 0/5] seg6: fixes for the PSP flavor of SRv6 End Andrea Mayer
2026-10-11 19:23 ` [PATCH net-next 1/5] seg6: handle a Fragment or AH header before the SRH consistently in PSP Andrea Mayer
2026-10-12  7:59   ` Hangbin Liu
2026-10-11 19:23 ` [PATCH net-next 2/5] seg6: handle a consumed SRH in SRv6 End with the PSP flavor Andrea Mayer
2026-10-12  9:28   ` Hangbin Liu
2026-10-12 21:40     ` Andrea Mayer
2026-10-13  0:29       ` Hangbin Liu
2026-10-11 19:23 ` [PATCH net-next 3/5] seg6: apply the PSP flavor together with NEXT-C-SID in SRv6 End Andrea Mayer
2026-10-12  8:17   ` Hangbin Liu
2026-10-11 19:23 ` [PATCH net-next 4/5] selftests: seg6: add tests for PSP together with NEXT-C-SID Andrea Mayer
2026-10-12  7:54   ` Hangbin Liu
2026-10-11 19:23 ` [PATCH net-next 5/5] selftests: seg6: add tests for PSP with a consumed SRH Andrea Mayer
2026-10-12  8:19   ` Hangbin Liu [this message]
2026-10-12 19:26   ` netdev-bot+sashiko

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=asyYCoMwGjh6XG3S@fedora \
    --to=hangbin.liu@linux.dev \
    --cc=ahabdels@cisco.com \
    --cc=andrea.mayer@uniroma2.it \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --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=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.