🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #11553

Re: [PATCH net-next v2 5/5] selftests: seg6: add tests for PSP with a consumed SRH

#11553
From: Hangbin Liu
Date: Thu, 05 Nov 2026 09:24
126 lines
13130 bytes
Hi Andrea,
On Thu, Nov 05, 2026 at 02:57:15AM +0100, 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.
> 
> 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. With seg6_enabled set to 1,
> a host also accepts the packet when the Policy's SRH is not removed, or
> when the extra SRH is removed in its place. For this reason, the
> receiving host accepts the echo request only when its first SRH is the
> extra SRH, with Segments Left 0 and followed by the ICMPv6 header. Any
> other echo request is dropped, including one without any SRH. The extra
> SRH is recognized by its last segment, which is the SID that triggered
> its insertion.
> 
> The check on the receiving host uses the ip6tables srh match. Without
> it, these tests are skipped. A test fails if the route that inserts the
> extra SRH, or the rules on the receiving host, cannot be added.
> 
> Signed-off-by: Andrea Mayer <andrea.mayer@uniroma2.it>
> ---
>  tools/testing/selftests/net/config            |   1 +
>  .../selftests/net/srv6_end_flavors_test.sh    | 280 +++++++++++++++++-
>  2 files changed, 279 insertions(+), 2 deletions(-)
> 

[...]

> +
> +# Test a Policy with a consumed SRH: a router inserts the extra SRH on the
> +# packets towards a SID, and another router consumes it. The destination host
> +# accepts only the echo requests that carry the extra SRH alone.
> +# args:
> +#  $1 - router that inserts the extra SRH
> +#  $2 - SID that triggers the insertion
> +#  $3 - router with the SRv6 End behavior that consumes the extra SRH
> +#  $4 - source host
> +#  $5 - destination host
> +#  $6 - suffix of the address on the loopback of the destination host
> +#       (i.e. cafe::<host>:<suffix>), if any
> +check_and_log_consumed_srh()
> +{
> +	local rt="$1"
> +	local sid="$2"
> +	local end_rt="$3"
> +	local hssrc="$4"
> +	local hsdst="$5"
> +	local suffix="$6"
> +	local msg
> +
> +	if ! ${HAS_SRH_MATCH}; then
> +		msg="IPv6 Hosts connectivity: hs-${hssrc} -> hs-${hsdst}"
> +		if [ -n "${suffix}" ]; then
> +			msg="${msg} (${IPv6_HS_NETWORK}::${hsdst}:${suffix})"
> +		fi
> +		log_test_skipped "${msg}"
> +		return
> +	fi
> +
> +	if ! setup_rt_consumed_srh "${rt}" "${sid}" "${end_rt}"; then
> +		log_test 1 0 "Extra SRH on rt-${rt} for ${sid}"
> +		return
> +	fi
> +
> +	if ! setup_hs_srh_check "${hsdst}" "${sid}"; then
> +		log_test 1 0 "SRH check on hs-${hsdst} for ${sid}"
> +	elif [ -n "${suffix}" ]; then
> +		check_and_log_hs_lo_addr_connectivity "${hssrc}" "${hsdst}" \
> +			"${suffix}"
> +	else
> +		check_and_log_hs_connectivity "${hssrc}" "${hsdst}"
> +	fi
> +
> +	cleanup_hs_srh_check "${hsdst}"
> +	cleanup_rt_consumed_srh "${rt}" "${sid}"
> +}
> +
> +host_srv6_end_flv_consumed_srh_tests()
> +{
> +	local sid
> +
> +	log_section \
> +		"SRv6 connectivity test hosts (h1 <-> h2, PSP with a consumed SRH)"
> +
> +	if ! ${HAS_SRH_MATCH}; then
> +		echo "SKIP: ip6tables srh match not available"
> +	fi

Ah, forgot to say. We can return directly here if srh match not available.
There is no need to check $HAS_SRH_MATCH again in each
check_and_log_consumed_srh() testing.

Not need to update for another version if you don't plan to change other
stuff.

Thanks
Hangbin

> +
> +	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}"
> +	check_and_log_consumed_srh 4 "${sid}" 3 1 2
> +
> +	# Policy (i.b): rt-2 inserts the extra SRH consumed by rt-3
> +	sid="${LOCATOR_SERVICE}:1::${END_PSP_FUNC}"
> +	check_and_log_consumed_srh 2 "${sid}" 3 2 1
> +
> +	# Policy (i.c): rt-4 inserts the extra SRH consumed by rt-3
> +	sid="$(build_csid_container 2 "${END_CSID_PSP_FUNC}")"
> +	check_and_log_consumed_srh 4 "${sid}" 3 1 2 "${END_CSID_PSP_FUNC}"
> +
> +	# Policy (i.d): rt-3 inserts the extra SRH consumed by rt-4
> +	sid="$(build_csid_container 1 "${END_CSID_PSP_FUNC}")"
> +	check_and_log_consumed_srh 3 "${sid}" 4 2 1 "${END_CSID_PSP_FUNC}"
> +
> +	set_hs_seg6_enabled 0
> +}
Technical Details
Message-ID: <auxLOoW97AQ55QdH@fedora>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357172-linux-kernel-netdev=dewy.ru
References: <20261105015715.57-1-andrea.mayer@uniroma2.it> <20261105015715.57-6-andrea.mayer@uniroma2.it>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-357172-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2 5/5] selftests: seg6: add tests for PSP with
 a consumed SRH
Date: Thu, 5 Nov 2026 17:24:10 +0800
Organization: Usenet Network
Message-ID: <auxLOoW97AQ55QdH@fedora>
References: <20261105015715.57-1-andrea.mayer@uniroma2.it>
 <20261105015715.57-6-andrea.mayer@uniroma2.it>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="3600855"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:I8/BM8CxDc9ANyPXLb6ljjqRgA8= sha256:cBuU0nhUpi7++a4btiungl8Nth4ENVkUDLcinHcwoik=
	sha1:MX5QwjCZE5aMVFxgcHPoLJtsG9w= sha256:VuLn/U+bS8rLu52ZcLtj0WQzn/eMv1cDPbjo5gzJW0o=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 99037112EE8; Thu,  5 Nov 2026 12:24:43 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.15
X-Spam-Status: No, score=-3.15 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key)
	header.d=linux.dev
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 54S3GV3KVfYD;
	Thu,  5 Nov 2026 12:24:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-357172-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 90932112EE4; Thu,  5 Nov 2026 12:24:30 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 309A2605C34; Thu,  5 Nov 2026 09:24:30 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1793870668;
	b=L2OkM5SR9fImR61xfEeoF+XNCjOY8QtQnRYKBp0xtJDfzHxHLkWWD78hjDPqZ7JKRCMH
	 OqbMfIUM1i9rm6ZzAnsJQmehnF3fVq1uRjOxNeT8MKMbCrynpjcgUQpupriJ8nncOc2sV
	 vBY1V6OkuhIYo8AtvzLmvdnIRzUiSrFpJIOQIZQz2ZN61vLdFfoSN1KpyGSMiTze5vKJ1
	 0RhZGLLkxb2ARdixzwGUN/kjsRS0x30TUnuvuHTbh3BjSNMatLMuMRf4AgIGfySbFlbK2
	 qLaicja2FAVvL2OsvWVfeB7Qz/SNhJhBj3JZKB9n7I07IW+bU0o2WtxS3l2TojLxKog==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793870668;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:
	 Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post:
	 List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
	 MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=47z7brSo33mlypnLaxbaxwk/bykGGQ/mpDgwuXRnuwQ=;
	b=UdvtyySfAZYU2+puz9kcK1sarRDKvLlo809n4Yz3230tT0DAETT74DZgLGWp3UUVqc7c
	 1NimEvBB9H+GK6hJ/LVfyPx/+WgcqWAYGXMz+aM48FcmM3NaeuszKNEW4j20rAWYeQDZh
	 KpKwFwT4UfqgCm0sQPs3rc9/leR9qHsE1aVIGY8g8sO7NNq45PnUb+N3OQBOeK6CDkWjp
	 EMx3KeMKV8nZ3mOE8pMTAb17U+Fstt34EUxdq3wQzRHEp8Pnm9F1erKxV7NSPhjw/z64k
	 MLhTySP2Tb7V1QjSSkGC1UzI0oXbn3SVLNtEXK5lu54VzXBM1maQTY7EVbKwFkmbEEA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="fGwM2W/j";
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F358606A32C;
	Thu,  5 Nov 2026 09:24:28 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=fGwM2W/j
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.125
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793870667;
	b=T+7XkEgYSwj0HSXGZkdqCJ8nt8DLPe0DJoyy7p7fXjgPXw6zIOw+H7mL6FnoOFBv3/4o
	 oJvq5qU76xN6dxonOeeUli3REBtqNyzw2ej+i6TfK/mOgp+PuOm9U2U4LGif5K0bYOCdY
	 tjdte8AKfhAZttulJoH0hAWaR5On7sHX9gdARMnJ0fbo/jtwwqn2LXouuOMoBMWPjaNhG
	 RHGOdPKO+9+/1a3+902QuT0pftVYi1JqMkMeq5TcbZMUeWGpxZMA0SgX2cmYmT5fZKurg
	 2oDLsAcsDTSN1uQZplMERu5Ph31leN0l8OlK4oKLQHS/c1TGGu1IYD1uQHRcphY4LyA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793870667;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID:
	 References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To;
	bh=47z7brSo33mlypnLaxbaxwk/bykGGQ/mpDgwuXRnuwQ=;
	b=nzvXSaDSnCIEBFFpNwgNmrYhf3upXvoxIZajhlhXcx9ZxJnUK6lfGG9FRcyN3oBkdNH3
	 6vI0rNPlBBw75HzHrZiqoL+loX2F5mJuonFhCikT7F4ZbMVXp0+3lUia9RINpI2hNrj4n
	 To/AxPv/s2SgApmc4h5qigJ8VG1jDrvx1SgezjxCjnKn7/PdA9hWWDXTDRorp/g9XOmWj
	 ZyRmmlMj9h3858P8CT8iB6G2X8EvHAjyl/hIk7xEdCY7Nn/5C16QjnsOZcMCrl+Wy7sZ3
	 8nq64GX4pbizd70XU5/HCX4QbK/cX2peVPe/yTy/O71FKT2qYLCO1Qs3XQpc5XXKtPw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=linux.dev;
	spf=pass smtp.mailfrom=linux.dev;
	dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="fGwM2W/j";
	arc=none smtp.remote-ip=91.218.175.125
X-Received: from mta0.migadu.com (out-125.mta0.migadu.com [91.218.175.125])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBE25606A329
	for <netdev@vger.kernel.org>; Thu,  5 Nov 2026 09:24:25 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CBE25606A329
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev
X-Envelope-To: netdev@vger.kernel.org
X-DKIM-Signature: a=rsa-sha256; bh=7RHOYddhHtUsTVy8AhY3X82ztUTMixuxCKf0uz2Jqk4=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1793870663; v=1; x=1794475463;
 b=fGwM2W/j9kP0lpvLeqQs+swxCGFHVVeLE2G6FhV+GAI6Lseae1T/pmTo/Oc/KAmho42/Zlv0
 RPDTUxeD/zC27iq3iI8IFMqrlH5dscMSA6Hd/NRVZ6cioTfE3D4b4jy6QsaONeDyEhxGm79VMEO
 5QIzAVHzsTTdadsYzO8OOPo4=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta11.migadu.com with ESMTPS id 19424a7b2f638b1c;
	Thu, 05 Nov 2026 09:24:23 +0000
X-Mizu-Trace-ID: 19424a7b2f638b1c
X-Migadu-Flow: FLOW_OUT
X-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>,
	andrea@common-net.org
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261105015715.57-6-andrea.mayer@uniroma2.it>