🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #19179

[PATCH net-next v4 4/5] selftests: seg6: explicit cleanup for SRv6 End PSP test

#19179
From: Hangbin Liu
Date: Thu, 19 Nov 2026 13:55
101 lines
11325 bytes
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 the defer helper to remove the configurations installed for the
PSP tests:

  * cafe::1, cafe::1:e9, cafe::2, cafe::2:e9 routes and proxy neighs
    on rt1, rt2, and the cafe::1:e9, cafe::2:e9 addresses on the
    hosts' loopback
  * fcbb:0:x0e9::/48 End next-csid,psp policies on rt 1,2,3,4
  * fcff:x::0ef1 End psp policies on rt 1,2,4

After the change, we can wrap the whole end test with test_end_flv()
and run it separately.

Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
 .../testing/selftests/net/srv6_end_flavors_test.sh | 29 ++++++++++++++++------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/net/srv6_end_flavors_test.sh b/tools/testing/selftests/net/srv6_end_flavors_test.sh
index 250de54d8bfa..9d6b7de648da 100755
--- a/tools/testing/selftests/net/srv6_end_flavors_test.sh
+++ b/tools/testing/selftests/net/srv6_end_flavors_test.sh
@@ -763,6 +763,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>.
@@ -865,10 +867,15 @@ __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}"
 
 	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}"
 }
 
 # see __setup_rt_policy
@@ -929,10 +936,12 @@ setup_hs_lo_addr()
 	addr="${IPv6_HS_NETWORK}::${hs}:${suffix}"
 
 	ip -netns "${hsname}" addr add "${addr}/128" dev lo nodad
+	defer ip -netns "${hsname}" addr del "${addr}/128" dev lo nodad
 
 	ip -netns "${rtname}" -6 route \
 		add "${addr}" \
 		via "${IPv6_HS_NETWORK}::${hs}" dev "${RT2HS_DEVNAME}"
+	defer ip -netns "${rtname}" -6 route del "${addr}"
 }
 
 setup()
@@ -1412,6 +1421,18 @@ test_dummy_dev_or_ksft_skip()
 	ip netns del "${test_netns}"
 }
 
+test_end_flv()
+{
+	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
+}
+
 if [ "$(id -u)" -ne 0 ]; then
 	echo "SKIP: Need root privileges"
 	exit "${ksft_skip}"
@@ -1443,11 +1464,5 @@ 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
-
+test_end_flv
 print_log_test_results

-- 
2.56.0
Technical Details
Message-ID: <20261119-srv6_flavors_endx-v4-4-284cdb484eee@kylinos.cn>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367052-linux-kernel-netdev=dewy.ru
References: <20261119-srv6_flavors_endx-v4-0-284cdb484eee@kylinos.cn>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-367052-linux-kernel-netdev=dewy.ru
From: hangbin.liu@linux.dev (Hangbin Liu)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v4 4/5] selftests: seg6: explicit cleanup for SRv6
 End PSP test
Date: Thu, 19 Nov 2026 21:55:20 +0800
Organization: Usenet Network
Message-ID: <20261119-srv6_flavors_endx-v4-4-284cdb484eee@kylinos.cn>
References: <20261119-srv6_flavors_endx-v4-0-284cdb484eee@kylinos.cn>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2886822"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:opgOjFtCMmY+43Nv+GGiXXGTTUs= sha256:NYHWGImsfkPnXfVMYVVSuYvN8VfPQbc8NWRgpsKCcNA=
	sha1:C5ORFUxFBtM31YZ78sCbZLYPmu4= sha256:qpMngYu3spgMS/hGxItaEuIpum7maqhYmXK+EXZwM8o=
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 3538711567F; Thu, 19 Nov 2026 16:56:45 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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 E3zBwUriXhbp;
	Thu, 19 Nov 2026 16:56:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-367052-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 7B80611567B; Thu, 19 Nov 2026 16:56:31 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id C383E164FD3; Thu, 19 Nov 2026 13:56:27 +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=1795096587;
	b=0OXL58RWYqH1/pPdMc9TWv3xZxd3S+mMwlq0k2NigmoyRNBdRP60qF8T7KAolJmoEqs1
	 rbwLR8ua+TrryFBsIUhSbZuHeC6DJ5KdnSymFxeaPJtRY9SVYyao6gqSIYxRhTegd/FZq
	 tbHUeS6sr7QEPL2UD3/o3Bs2Dc5qO/+2t0gBgqf7cF2sUyoi7yE3kLPG38Ck7lgsy1lTe
	 ygSo1xulC6MMfUFw/O3DfBFFrXAd6xDc6Ie6aph3iwtKsepwetZzlB0RTmu7nqMiwA+tQ
	 O48eogCXdqUPMB8ZOIH1mxlfIJ6SxQxYE6M+8lIrfXpkSFqRrL/pTga9Es1BNUm6nFg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795096587;
	h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature:
	 X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:From:Date:
	 Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc:
	 X-Mailer;
	bh=kL06f/X8F0pCUsRpt4OdaQK/VJzX2vhlrvqULYx75ac=;
	b=NCCw4+rhYJXWDHvvqBCFRQ44JCzjo/Cym97UyohC7YtITrgByjodRGyc7PJW7yAc61Ue
	 DTLznIfZCZG83e5repRzB2ECrAAoDb/r6ygL0h6IAXwk4fti3g1Igi7Qy6Y2Jy5uXwPag
	 CfRsdiWimVnsD08GL1PiU9VPIOub9+AmPd4Wz4YjaCRw5kPkazmBw8rKMeKT5YReyaAxN
	 zz2bT1RQUnjlFwxSyly/1y2VM7vB534c7wfrPkAirWJbZPsS8ZOh7KMGGJlZGK8sE/lRc
	 g9zlTfIvhhV8L0p8TihRGPI+Oqg64nY2DKpfrkSzWt4udHYICXe0X1BKPY219YbXLLA==
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=cdM61rUf;
	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 13673606A32C;
	Thu, 19 Nov 2026 13:56:27 +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=cdM61rUf
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.139
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1795096581;
	b=urZeS5j3x3YCxjOuBL5fSZ0DEaecjmQ0reWazPpC9K5iUUF+8EyjalfdFXPGZ0UImr54
	 Py6koxy0023LyibpA3ueksyT4aCyT01+5XCEn4kj/djHV1guJhZcIbNXErlecLUBQ+H0j
	 DOn+yPle8bpbZR24mvN53UV02BVGngCNSLc3MMddtZB9JAtzRfgoqvIwZT8rdrwd+H2cf
	 M+01/QXMbauqqSq1wmizYvkGGuYdC4tZpt9LyzUxtmIypAhU32Lze+xPYri1Uoip+22LG
	 6Gqy89w/4aP0zGKUd6XiFcO0TrJNtb6qPXtCWbokyAbhkAzCM/g9snZCv9OQ3lb7hIQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795096581;
	h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received:
	 X-Mizu-Trace-ID:X-Migadu-Flow:From:Date:Subject:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:Message-Id:References:
	 In-Reply-To:To:Cc:X-Mailer;
	bh=kL06f/X8F0pCUsRpt4OdaQK/VJzX2vhlrvqULYx75ac=;
	b=znDN0WwRHOKBQYuAln1UX2MVHbu1mjz58jSFbkKj3Wm+OgIWBnque5Q5Uoy3Zj7H27SV
	 aPVVkLF1kTHzV5tXk9z1aaUKyEgbDn4+fr0iOAtP67X1hUK8wZmoLb/LBs03LXlplQt3T
	 +e9K0QfhQ6ZetbS0RJHYiAHaPdu8weNir3D+hs8b48V6IIku0rKFH2ntyzEVM1m5mkybn
	 Cie0CKigkpLAQqGc2b/jWPk9lkno2vGswY1mifq+6mOyfoSMJi9hJHIc+VRsUp/EX+Wgz
	 8SBtuYAlsP9axd68A/IBL3uNQPglCmvI4+VyyxEG3wzXOP6Wd/SwKOnmvnXFDlJgBhQ==
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=cdM61rUf;
	arc=none smtp.remote-ip=95.215.58.139
X-Received: from mta1.migadu.com (out-139.mta1.migadu.com [95.215.58.139])
	(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 17C46606A325
	for <netdev@vger.kernel.org>; Thu, 19 Nov 2026 13:56:19 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 17C46606A325
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=it30w/qv5FXVyLwZWDrrsl536DanKovgZRDzj670pbM=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1795096578; v=1; x=1795701378;
 b=cdM61rUfgxNt30nCABWg2jPLanVCcy6zcRxSgx09/CzkgCbi938dfep8YrEVPnve5B0B+lxl
 2OjabDBP0uCCm1O8RSHAc6O+OcIDgoxNFWgFFmz44xDoMKgvH9DsGSAiPg59vnq5rOTHIgLPA/D
 fcfD8qorZ8AbRxVKmZNCS/90=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by mta10.migadu.com with ESMTPS id e71a594a63f1d374;
	Thu, 19 Nov 2026 13:56:18 +0000
X-Mizu-Trace-ID: e71a594a63f1d374
X-Migadu-Flow: FLOW_OUT
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: <20261119-srv6_flavors_endx-v4-0-284cdb484eee@kylinos.cn>
X-Cc: Hangbin Liu <hangbin.liu@linux.dev>, netdev@vger.kernel.org, 
 linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, 
 Hangbin Liu <liuhangbin@kylinos.cn>
X-Mailer: b4 0.16.0