From patchwork Mon Feb 17 12:37:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bastien Curutchet (eBPF Foundation)" X-Patchwork-Id: 13977709 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39C711A5BA4; Mon, 17 Feb 2025 12:37:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739795866; cv=none; b=VDxBODCIUHeAVy/mqwpX3XKAJ3WVEOIhAhD7kV/yu5t/Qy+DKOY619s/OvPKqQ7zbYFqy1xOQsNd2dAvjHQ1GrD18q90THnVYsxporWBRITzU6L+JswKLFe7F6jkbA/7lK6os+HtWn/puHwIASesbJjEmDdcFkHNzciWW9jTGG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739795866; c=relaxed/simple; bh=mZzKihe2R4AeNltn5V5ya+wh7hY4j98NTVDIxiw5HPA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KbK6kvSw6N9h0tETb3c0lExD+v9tLBaaAmILNaeb3phWmjV0QPdONqcAPHE1QHX+nTUzADS9R0ObAMJu8iwoIqF0ioGKIamhqrr4MNkj0x3GxiK/HV07hdrdh2Mk0Kb7zgb7Fi67+NAHeVwgoeUhqR0nJw3me2HMlS/wo95155o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=eBgdJQEz; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="eBgdJQEz" Received: by mail.gandi.net (Postfix) with ESMTPSA id 51CA8442DF; Mon, 17 Feb 2025 12:37:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1739795861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6+tzLfaFZqkqHQMe4gTyO4D+W5I8sg9zaCereRpJS2A=; b=eBgdJQEzBthDRYbwStmJVO+wxfYFnnGavpQgDiKis0qd3QfD4EPlnNAuYQWubK832uyodd GOXZ+y3PVL0YoDgixgJtCIpLb2m2MwAtLmgKoWG5p045ikdaMwINhKYloU3p+0HjB2tlhw rTJtq7G8FuVqGK0jfqgYpbdOt6P6uakKeAj+udypIt9hz1Doi2To33YMei9UotIKaJGQEA GL9r/HdiAIPzpV+T233TqZp1ZB7GgGGBHiHGs2rl6UrQYVqT+LRCrrShts0zMhrVEIj3A7 jrJK5d24N1nWlxgJTC1lHaxzOYUs3RbfBj71i8XtTT8bZUwRd9UJqtvVD+UdGg== From: "Bastien Curutchet (eBPF Foundation)" Date: Mon, 17 Feb 2025 13:37:38 +0100 Subject: [PATCH bpf-next 1/3] selftests/bpf: tc_helpers: Add create_and_open_tid_ns() Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250217-tc_links-v1-1-27f7965e3dcd@bootlin.com> References: <20250217-tc_links-v1-0-27f7965e3dcd@bootlin.com> In-Reply-To: <20250217-tc_links-v1-0-27f7965e3dcd@bootlin.com> To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan Cc: Thomas Petazzoni , Alexis Lothore , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (eBPF Foundation)" X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdehkeegvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpedfuegrshhtihgvnhcuvehurhhuthgthhgvthculdgvuefrhfcuhfhouhhnuggrthhiohhnmddfuceosggrshhtihgvnhdrtghurhhuthgthhgvthessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepgeefudfhuedttdeiffetffeljeffkeevveeiuddtgeejleeftdejgedtjedttdfhnecukfhppeeltddrkeelrdduieefrdduvdejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledtrdekledrudeifedruddvjedphhgvlhhopegludelvddrudeikedrtddrudegngdpmhgrihhlfhhrohhmpegsrghsthhivghnrdgtuhhruhhttghhvghtsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvtddprhgtphhtthhopehshhhurghhsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehsohhngheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprghstheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepjhhohhhnrdhfrghsthgrsggvnhgusehgmhgrihhlrdgtohhmpdhrtghpthhtoheprghnughri hhisehkvghrnhgvlhdrohhrghdprhgtphhtthhopehsughfsehfohhmihgthhgvvhdrmhgvpdhrtghpthhtohephihonhhghhhonhhgrdhsohhngheslhhinhhugidruggvvhdprhgtphhtthhopegvugguhiiikeejsehgmhgrihhlrdgtohhm X-GND-Sasl: bastien.curutchet@bootlin.com Add a create_and_open_tid_ns() helper that creates a new network namespace and open it. Use the append_tid() helper to ensure the uniqueness of the namespace name. Signed-off-by: Bastien Curutchet (eBPF Foundation) --- tools/testing/selftests/bpf/prog_tests/tc_helpers.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/tc_helpers.h b/tools/testing/selftests/bpf/prog_tests/tc_helpers.h index 924d0e25320c71691998d6fce4d0aae367457862..8689ecd88fa89f4e622729d4f1b6d33c25fa89d8 100644 --- a/tools/testing/selftests/bpf/prog_tests/tc_helpers.h +++ b/tools/testing/selftests/bpf/prog_tests/tc_helpers.h @@ -3,6 +3,7 @@ #ifndef TC_HELPERS #define TC_HELPERS #include +#include "network_helpers.h" #ifndef loopback # define loopback 1 @@ -75,4 +76,15 @@ static inline void tc_skel_reset_all_seen(struct test_tc_link *skel) memset(skel->bss, 0, sizeof(*skel->bss)); } +static inline struct netns_obj *create_and_open_tid_ns(char *ns_name, size_t sz) +{ + if (!ns_name) + return NULL; + + if (append_tid(ns_name, sz)) + return NULL; + + return netns_new(ns_name, true); +} + #endif /* TC_HELPERS */ From patchwork Mon Feb 17 12:37:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bastien Curutchet (eBPF Foundation)" X-Patchwork-Id: 13977710 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E282F215F5F; Mon, 17 Feb 2025 12:37:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739795866; cv=none; b=EJ6XUskyyCbD6LFjJFqrl6gTr8KvaMuXk3EkzYlR+B/1W/dlAIrrS/sLUKmFAPMQY+cmodcbHCaCGbwj9omVxJ0IvIRLJ8PheXBb4l7D5lG4X7pubHGqDXneIUWFrT8wezC4Z5orO2jBSaPXbJAcn4AhjkfWTBJ4qrDQXjlvZF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739795866; c=relaxed/simple; bh=lBHKzM7wgOrvjY1S4H2VmwbZNB7CaSNAUpx/6g0spzY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pPg2VP4b+eYx750o9V+wU8Pt1jPbkqr4WO4H7xV0mTbXHD2Ik0m0QmIHgn96DY+BxdEs7SlbGOMnHk+9Sdi67uhkpOXvFc22U/mk7EvHs1Gfk+paxYShyxMC43QqJPnLRgZtj2C/oBlHi0FBmAWJTLlxxzmWM6yr7q7NARzRiGI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=k6P7047M; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="k6P7047M" Received: by mail.gandi.net (Postfix) with ESMTPSA id 53E31442DA; Mon, 17 Feb 2025 12:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1739795862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PLcEGHTZzAbYR+0qANyqNR8i14TPZB/5Yvji8iH8d9c=; b=k6P7047Mr5iarIaBRGQ7poO11LSLWLgOaNMol85OBfOtfzlJWId1MW9SwWEz9HqSgX3wit AJoV0VNCsFr4RDTA81q0WZyCY1jqkWfa/W5Is4q9vLa7rTWmVLa53RxgmgYOplA+yxAuat PPy5V/GUXg6belTVU7lxs4ljk4tkLckaCeBISNVQkjZUtu1igZ5gDazo9MArlQlep7qygO fPZuJOkaeRd0IC+BfQvrXfteZfBBMt5+XutUpX0kMv2FJnXZe1YnwWIV841ruOjL8IyYdM r9VIgMthT65yL4mi/cI4oB6HdS3r4TfqI5zgE4EHn0lYQBdCPI9TaV9n95O97Q== From: "Bastien Curutchet (eBPF Foundation)" Date: Mon, 17 Feb 2025 13:37:39 +0100 Subject: [PATCH bpf-next 2/3] selftests/bpf: tc_link/tc_opts: Use unique namespace Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250217-tc_links-v1-2-27f7965e3dcd@bootlin.com> References: <20250217-tc_links-v1-0-27f7965e3dcd@bootlin.com> In-Reply-To: <20250217-tc_links-v1-0-27f7965e3dcd@bootlin.com> To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan Cc: Thomas Petazzoni , Alexis Lothore , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (eBPF Foundation)" X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdehkeegvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpedfuegrshhtihgvnhcuvehurhhuthgthhgvthculdgvuefrhfcuhfhouhhnuggrthhiohhnmddfuceosggrshhtihgvnhdrtghurhhuthgthhgvthessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepgeefudfhuedttdeiffetffeljeffkeevveeiuddtgeejleeftdejgedtjedttdfhnecukfhppeeltddrkeelrdduieefrdduvdejnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepledtrdekledrudeifedruddvjedphhgvlhhopegludelvddrudeikedrtddrudegngdpmhgrihhlfhhrohhmpegsrghsthhivghnrdgtuhhruhhttghhvghtsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvtddprhgtphhtthhopehshhhurghhsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehsohhngheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprghstheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepjhhohhhnrdhfrghsthgrsggvnhgusehgmhgrihhlrdgtohhmpdhrtghpthhtoheprghnughri hhisehkvghrnhgvlhdrohhrghdprhgtphhtthhopehsughfsehfohhmihgthhgvvhdrmhgvpdhrtghpthhtohephihonhhghhhonhhgrdhsohhngheslhhinhhugidruggvvhdprhgtphhtthhopegvugguhiiikeejsehgmhgrihhlrdgtohhm X-GND-Sasl: bastien.curutchet@bootlin.com All the tests use the loopback interface. It prevents from running them in parallel. Use the create_and_open_tid_ns() helper to run each test in its own network namespace. Signed-off-by: Bastien Curutchet (eBPF Foundation) --- tools/testing/selftests/bpf/prog_tests/tc_links.c | 124 +++++++++++++++ tools/testing/selftests/bpf/prog_tests/tc_opts.c | 180 ++++++++++++++++++++++ 2 files changed, 304 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/tc_links.c b/tools/testing/selftests/bpf/prog_tests/tc_links.c index 1af9ec1149aab6ca5ef6986fc16a650162266966..07a2fc3d44d03e18dd3c715b0b26c7f1ac6d47cb 100644 --- a/tools/testing/selftests/bpf/prog_tests/tc_links.c +++ b/tools/testing/selftests/bpf/prog_tests/tc_links.c @@ -7,6 +7,8 @@ #define loopback 1 #define ping_cmd "ping -q -c1 -w1 127.0.0.1 > /dev/null" +#define NS_NAME_MAX_LEN 32 +#define NS_NAME "ns-tc-link-" #include "test_tc_link.skel.h" @@ -17,12 +19,18 @@ void serial_test_tc_links_basic(void) { LIBBPF_OPTS(bpf_prog_query_opts, optq); LIBBPF_OPTS(bpf_tcx_opts, optl); + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; __u32 prog_ids[2], link_ids[2]; __u32 pid1, pid2, lid1, lid2; struct test_tc_link *skel; struct bpf_link *link; + struct netns_obj *ns; int err; + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + skel = test_tc_link__open_and_load(); if (!ASSERT_OK_PTR(skel, "skel_load")) goto cleanup; @@ -110,6 +118,7 @@ void serial_test_tc_links_basic(void) assert_mprog_count(BPF_TCX_INGRESS, 0); assert_mprog_count(BPF_TCX_EGRESS, 0); + netns_free(ns); } static void test_tc_links_before_target(int target) @@ -262,8 +271,17 @@ static void test_tc_links_before_target(int target) void serial_test_tc_links_before(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_links_before_target(BPF_TCX_INGRESS); test_tc_links_before_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_links_after_target(int target) @@ -416,8 +434,17 @@ static void test_tc_links_after_target(int target) void serial_test_tc_links_after(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_links_after_target(BPF_TCX_INGRESS); test_tc_links_after_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_links_revision_target(int target) @@ -516,8 +543,17 @@ static void test_tc_links_revision_target(int target) void serial_test_tc_links_revision(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_links_revision_target(BPF_TCX_INGRESS); test_tc_links_revision_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_chain_classic(int target, bool chain_tc_old) @@ -620,10 +656,19 @@ static void test_tc_chain_classic(int target, bool chain_tc_old) void serial_test_tc_links_chain_classic(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_chain_classic(BPF_TCX_INGRESS, false); test_tc_chain_classic(BPF_TCX_EGRESS, false); test_tc_chain_classic(BPF_TCX_INGRESS, true); test_tc_chain_classic(BPF_TCX_EGRESS, true); + + netns_free(ns); } static void test_tc_links_replace_target(int target) @@ -848,8 +893,17 @@ static void test_tc_links_replace_target(int target) void serial_test_tc_links_replace(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_links_replace_target(BPF_TCX_INGRESS); test_tc_links_replace_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_links_invalid_target(int target) @@ -1160,8 +1214,17 @@ static void test_tc_links_invalid_target(int target) void serial_test_tc_links_invalid(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_links_invalid_target(BPF_TCX_INGRESS); test_tc_links_invalid_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_links_prepend_target(int target) @@ -1316,8 +1379,17 @@ static void test_tc_links_prepend_target(int target) void serial_test_tc_links_prepend(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_links_prepend_target(BPF_TCX_INGRESS); test_tc_links_prepend_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_links_append_target(int target) @@ -1472,8 +1544,17 @@ static void test_tc_links_append_target(int target) void serial_test_tc_links_append(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_links_append_target(BPF_TCX_INGRESS); test_tc_links_append_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_links_dev_cleanup_target(int target) @@ -1570,8 +1651,17 @@ static void test_tc_links_dev_cleanup_target(int target) void serial_test_tc_links_dev_cleanup(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_links_dev_cleanup_target(BPF_TCX_INGRESS); test_tc_links_dev_cleanup_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_chain_mixed(int target) @@ -1674,8 +1764,17 @@ static void test_tc_chain_mixed(int target) void serial_test_tc_links_chain_mixed(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_chain_mixed(BPF_TCX_INGRESS); test_tc_chain_mixed(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_links_ingress(int target, bool chain_tc_old, @@ -1784,9 +1883,18 @@ static void test_tc_links_ingress(int target, bool chain_tc_old, void serial_test_tc_links_ingress(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_links_ingress(BPF_TCX_INGRESS, true, true); test_tc_links_ingress(BPF_TCX_INGRESS, true, false); test_tc_links_ingress(BPF_TCX_INGRESS, false, false); + + netns_free(ns); } struct qdisc_req { @@ -1825,8 +1933,14 @@ static int qdisc_replace(int ifindex, const char *kind, bool block) void serial_test_tc_links_dev_chain0(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; int err, ifindex; + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + ASSERT_OK(system("ip link add dev foo type veth peer name bar"), "add veth"); ifindex = if_nametoindex("foo"); ASSERT_NEQ(ifindex, 0, "non_zero_ifindex"); @@ -1846,6 +1960,7 @@ void serial_test_tc_links_dev_chain0(void) ASSERT_OK(system("ip link del dev foo"), "del veth"); ASSERT_EQ(if_nametoindex("foo"), 0, "foo removed"); ASSERT_EQ(if_nametoindex("bar"), 0, "bar removed"); + netns_free(ns); } static void test_tc_links_dev_mixed(int target) @@ -1957,6 +2072,15 @@ static void test_tc_links_dev_mixed(int target) void serial_test_tc_links_dev_mixed(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_links_dev_mixed(BPF_TCX_INGRESS); test_tc_links_dev_mixed(BPF_TCX_EGRESS); + + netns_free(ns); } diff --git a/tools/testing/selftests/bpf/prog_tests/tc_opts.c b/tools/testing/selftests/bpf/prog_tests/tc_opts.c index f77f604389aabbc7afb71ac003dc952cba82c460..d38376244532026b2b3d505bcf9711c8e7948e17 100644 --- a/tools/testing/selftests/bpf/prog_tests/tc_opts.c +++ b/tools/testing/selftests/bpf/prog_tests/tc_opts.c @@ -6,6 +6,8 @@ #define loopback 1 #define ping_cmd "ping -q -c1 -w1 127.0.0.1 > /dev/null" +#define NS_NAME_MAX_LEN 32 +#define NS_NAME "ns-tc-opts-" #include "test_tc_link.skel.h" #include "tc_helpers.h" @@ -15,11 +17,17 @@ void serial_test_tc_opts_basic(void) LIBBPF_OPTS(bpf_prog_attach_opts, opta); LIBBPF_OPTS(bpf_prog_detach_opts, optd); LIBBPF_OPTS(bpf_prog_query_opts, optq); + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; __u32 fd1, fd2, id1, id2; struct test_tc_link *skel; + struct netns_obj *ns; __u32 prog_ids[2]; int err; + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + skel = test_tc_link__open_and_load(); if (!ASSERT_OK_PTR(skel, "skel_load")) goto cleanup; @@ -106,6 +114,7 @@ void serial_test_tc_opts_basic(void) cleanup: test_tc_link__destroy(skel); + netns_free(ns); } static void test_tc_opts_before_target(int target) @@ -256,8 +265,17 @@ static void test_tc_opts_before_target(int target) void serial_test_tc_opts_before(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_before_target(BPF_TCX_INGRESS); test_tc_opts_before_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_opts_after_target(int target) @@ -447,8 +465,17 @@ static void test_tc_opts_after_target(int target) void serial_test_tc_opts_after(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_after_target(BPF_TCX_INGRESS); test_tc_opts_after_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_opts_revision_target(int target) @@ -556,8 +583,17 @@ static void test_tc_opts_revision_target(int target) void serial_test_tc_opts_revision(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_revision_target(BPF_TCX_INGRESS); test_tc_opts_revision_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_chain_classic(int target, bool chain_tc_old) @@ -657,10 +693,19 @@ static void test_tc_chain_classic(int target, bool chain_tc_old) void serial_test_tc_opts_chain_classic(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_chain_classic(BPF_TCX_INGRESS, false); test_tc_chain_classic(BPF_TCX_EGRESS, false); test_tc_chain_classic(BPF_TCX_INGRESS, true); test_tc_chain_classic(BPF_TCX_EGRESS, true); + + netns_free(ns); } static void test_tc_opts_replace_target(int target) @@ -866,8 +911,17 @@ static void test_tc_opts_replace_target(int target) void serial_test_tc_opts_replace(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_replace_target(BPF_TCX_INGRESS); test_tc_opts_replace_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_opts_invalid_target(int target) @@ -1019,8 +1073,17 @@ static void test_tc_opts_invalid_target(int target) void serial_test_tc_opts_invalid(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_invalid_target(BPF_TCX_INGRESS); test_tc_opts_invalid_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_opts_prepend_target(int target) @@ -1159,8 +1222,17 @@ static void test_tc_opts_prepend_target(int target) void serial_test_tc_opts_prepend(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_prepend_target(BPF_TCX_INGRESS); test_tc_opts_prepend_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_opts_append_target(int target) @@ -1299,8 +1371,17 @@ static void test_tc_opts_append_target(int target) void serial_test_tc_opts_append(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_append_target(BPF_TCX_INGRESS); test_tc_opts_append_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_opts_dev_cleanup_target(int target) @@ -1389,8 +1470,17 @@ static void test_tc_opts_dev_cleanup_target(int target) void serial_test_tc_opts_dev_cleanup(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_dev_cleanup_target(BPF_TCX_INGRESS); test_tc_opts_dev_cleanup_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_opts_mixed_target(int target) @@ -1565,8 +1655,17 @@ static void test_tc_opts_mixed_target(int target) void serial_test_tc_opts_mixed(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_mixed_target(BPF_TCX_INGRESS); test_tc_opts_mixed_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_opts_demixed_target(int target) @@ -1644,8 +1743,17 @@ static void test_tc_opts_demixed_target(int target) void serial_test_tc_opts_demixed(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_demixed_target(BPF_TCX_INGRESS); test_tc_opts_demixed_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_opts_detach_target(int target) @@ -1815,8 +1923,17 @@ static void test_tc_opts_detach_target(int target) void serial_test_tc_opts_detach(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_detach_target(BPF_TCX_INGRESS); test_tc_opts_detach_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_opts_detach_before_target(int target) @@ -2022,8 +2139,17 @@ static void test_tc_opts_detach_before_target(int target) void serial_test_tc_opts_detach_before(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_detach_before_target(BPF_TCX_INGRESS); test_tc_opts_detach_before_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_opts_detach_after_target(int target) @@ -2238,8 +2364,17 @@ static void test_tc_opts_detach_after_target(int target) void serial_test_tc_opts_detach_after(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_detach_after_target(BPF_TCX_INGRESS); test_tc_opts_detach_after_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_opts_delete_empty(int target, bool chain_tc_old) @@ -2267,10 +2402,19 @@ static void test_tc_opts_delete_empty(int target, bool chain_tc_old) void serial_test_tc_opts_delete_empty(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_delete_empty(BPF_TCX_INGRESS, false); test_tc_opts_delete_empty(BPF_TCX_EGRESS, false); test_tc_opts_delete_empty(BPF_TCX_INGRESS, true); test_tc_opts_delete_empty(BPF_TCX_EGRESS, true); + + netns_free(ns); } static void test_tc_chain_mixed(int target) @@ -2374,8 +2518,17 @@ static void test_tc_chain_mixed(int target) void serial_test_tc_opts_chain_mixed(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_chain_mixed(BPF_TCX_INGRESS); test_tc_chain_mixed(BPF_TCX_EGRESS); + + netns_free(ns); } static int generate_dummy_prog(void) @@ -2448,6 +2601,13 @@ static void test_tc_opts_max_target(int target, int flags, bool relative) void serial_test_tc_opts_max(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_max_target(BPF_TCX_INGRESS, 0, false); test_tc_opts_max_target(BPF_TCX_EGRESS, 0, false); @@ -2456,6 +2616,8 @@ void serial_test_tc_opts_max(void) test_tc_opts_max_target(BPF_TCX_INGRESS, BPF_F_AFTER, true); test_tc_opts_max_target(BPF_TCX_EGRESS, BPF_F_AFTER, false); + + netns_free(ns); } static void test_tc_opts_query_target(int target) @@ -2750,8 +2912,17 @@ static void test_tc_opts_query_target(int target) void serial_test_tc_opts_query(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_query_target(BPF_TCX_INGRESS); test_tc_opts_query_target(BPF_TCX_EGRESS); + + netns_free(ns); } static void test_tc_opts_query_attach_target(int target) @@ -2809,6 +2980,15 @@ static void test_tc_opts_query_attach_target(int target) void serial_test_tc_opts_query_attach(void) { + char ns_name[NS_NAME_MAX_LEN] = NS_NAME; + struct netns_obj *ns; + + ns = create_and_open_tid_ns(ns_name, NS_NAME_MAX_LEN); + if (!ASSERT_OK_PTR(ns, "create and open ns")) + return; + test_tc_opts_query_attach_target(BPF_TCX_INGRESS); test_tc_opts_query_attach_target(BPF_TCX_EGRESS); + + netns_free(ns); } From patchwork Mon Feb 17 12:37:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bastien Curutchet (eBPF Foundation)" X-Patchwork-Id: 13977711 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E6629216605; Mon, 17 Feb 2025 12:37:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739795868; cv=none; b=ED+6NkXSnFvsPfNUUhUw5sGN4bQIWGil+sIL0tULiEWhpa0z1vMFQoPKkaPXjtBlamLZhqaB72kB/KmGdQIC97b9C53GawvFrFV9gK3HBy2MfAk6JmtGE5MANsVH/9VjjXxmNZf3kQTFaMiYpRhsiVqWmHxeBoTzgauUKBBoA7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739795868; c=relaxed/simple; bh=dBDzjWo6VKaha93rZaATReYixZ6fjqLkF4Ozu1zlCnU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aeTDF37TbW2Ff03f3uI2vWBbVvAIVjNsfBCtPlhqyiiJwNRjwBCqKMBl4CzVQSLT7sLdZgSa0AOM4qlg3opTW7opQ/oYicCmVjRTmtRWWevKRpPWz4x6fN2KryEGV0UtM9f2JZBXe+Mu+vjwSjP0tF1+Od9J2LeLcQL8yX45Lpw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=GeiSKRgb; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="GeiSKRgb" Received: by mail.gandi.net (Postfix) with ESMTPSA id 518C442E76; Mon, 17 Feb 2025 12:37:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1739795863; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W/PSKk2nTtn7RBvDNRW2TtzxymnJUDPRTpmAdQXQeOY=; b=GeiSKRgbqhzzq9tBG8HuVOgywAnYfyI6Pd4xP0zYJXGQdNkXTskTaYUZsiwmWNKAD3PxK6 +nRfi5dmcOyPOaz4UK3RpnL7jWquRSUBn0bPdue1Vks2eMyWOEI7QiWDwbDzm6ZV8w4CPd 4Aa8r8WIuokpT9dOTModStU3amRJpgx/Uuw/m9L5bsbg8SUGW+Z5JxeSSXOR6vqF3R5iv6 TOMdaoD42F8XuC6guVzSOOvTnH3fqIaitnl4q0KvbfxxtmhQdFpw3R81gp6dsx+2rhjdRZ gunywfbnADVNgadfTfU6+NTbMyYIBui+rbCy3HX1bbfq9y2bUe5Uvq2qW3BKlg== From: "Bastien Curutchet (eBPF Foundation)" Date: Mon, 17 Feb 2025 13:37:40 +0100 Subject: [PATCH bpf-next 3/3] selftests/bpf: tc_links/tc_opts: Serialize tests Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250217-tc_links-v1-3-27f7965e3dcd@bootlin.com> References: <20250217-tc_links-v1-0-27f7965e3dcd@bootlin.com> In-Reply-To: <20250217-tc_links-v1-0-27f7965e3dcd@bootlin.com> To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Mykola Lysenko , Shuah Khan Cc: Thomas Petazzoni , Alexis Lothore , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Bastien Curutchet (eBPF Foundation)" X-Mailer: b4 0.14.2 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdehkeegvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpedfuegrshhtihgvnhcuvehurhhuthgthhgvthculdgvuefrhfcuhfhouhhnuggrthhiohhnmddfuceosggrshhtihgvnhdrtghurhhuthgthhgvthessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnhepgeefudfhuedttdeiffetffeljeffkeevveeiuddtgeejleeftdejgedtjedttdfhnecukfhppeeltddrkeelrdduieefrdduvdejnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehinhgvthepledtrdekledrudeifedruddvjedphhgvlhhopegludelvddrudeikedrtddrudegngdpmhgrihhlfhhrohhmpegsrghsthhivghnrdgtuhhruhhttghhvghtsegsohhothhlihhnrdgtohhmpdhnsggprhgtphhtthhopedvtddprhgtphhtthhopehshhhurghhsehkvghrnhgvlhdrohhrghdprhgtphhtthhopehsohhngheskhgvrhhnvghlrdhorhhgpdhrtghpthhtoheprghstheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepjhhohhhnrdhfrghsthgrsggvnhgusehgmhgrihhlrdgtohhmpdhrtghpthhtoheprghnughri hhisehkvghrnhgvlhdrohhrghdprhgtphhtthhopehsughfsehfohhmihgthhgvvhdrmhgvpdhrtghpthhtohephihonhhghhhonhhgrdhsohhngheslhhinhhugidruggvvhdprhgtphhtthhopegvugguhiiikeejsehgmhgrihhlrdgtohhm X-GND-Sasl: bastien.curutchet@bootlin.com The tests aren't allowed to be run in parallel while they could be. Replace serial_test_*() calls by test_*() ones to allow parallelization of these tests. Rename some 'subtests' functions to avoid name conflicts with the actual tests. Signed-off-by: Bastien Curutchet (eBPF Foundation) --- tools/testing/selftests/bpf/prog_tests/tc_links.c | 40 +++++++++--------- tools/testing/selftests/bpf/prog_tests/tc_opts.c | 50 +++++++++++------------ 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/tc_links.c b/tools/testing/selftests/bpf/prog_tests/tc_links.c index 07a2fc3d44d03e18dd3c715b0b26c7f1ac6d47cb..c94fe1e1687239ed4090f53bff40ede10e501f55 100644 --- a/tools/testing/selftests/bpf/prog_tests/tc_links.c +++ b/tools/testing/selftests/bpf/prog_tests/tc_links.c @@ -269,7 +269,7 @@ static void test_tc_links_before_target(int target) assert_mprog_count(target, 0); } -void serial_test_tc_links_before(void) +void test_tc_links_before(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -432,7 +432,7 @@ static void test_tc_links_after_target(int target) assert_mprog_count(target, 0); } -void serial_test_tc_links_after(void) +void test_tc_links_after(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -541,7 +541,7 @@ static void test_tc_links_revision_target(int target) assert_mprog_count(target, 0); } -void serial_test_tc_links_revision(void) +void test_tc_links_revision(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -654,7 +654,7 @@ static void test_tc_chain_classic(int target, bool chain_tc_old) assert_mprog_count(target, 0); } -void serial_test_tc_links_chain_classic(void) +void test_tc_links_chain_classic(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -891,7 +891,7 @@ static void test_tc_links_replace_target(int target) assert_mprog_count(target, 0); } -void serial_test_tc_links_replace(void) +void test_tc_links_replace(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -1212,7 +1212,7 @@ static void test_tc_links_invalid_target(int target) assert_mprog_count(target, 0); } -void serial_test_tc_links_invalid(void) +void test_tc_links_invalid(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -1377,7 +1377,7 @@ static void test_tc_links_prepend_target(int target) assert_mprog_count(target, 0); } -void serial_test_tc_links_prepend(void) +void test_tc_links_prepend(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -1542,7 +1542,7 @@ static void test_tc_links_append_target(int target) assert_mprog_count(target, 0); } -void serial_test_tc_links_append(void) +void test_tc_links_append(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -1649,7 +1649,7 @@ static void test_tc_links_dev_cleanup_target(int target) ASSERT_EQ(if_nametoindex("tcx_opts2"), 0, "dev2_removed"); } -void serial_test_tc_links_dev_cleanup(void) +void test_tc_links_dev_cleanup(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -1762,7 +1762,7 @@ static void test_tc_chain_mixed(int target) test_tc_link__destroy(skel); } -void serial_test_tc_links_chain_mixed(void) +void test_tc_links_chain_mixed(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -1777,7 +1777,7 @@ void serial_test_tc_links_chain_mixed(void) netns_free(ns); } -static void test_tc_links_ingress(int target, bool chain_tc_old, +static void tc_links_ingress(int target, bool chain_tc_old, bool tcx_teardown_first) { LIBBPF_OPTS(bpf_tc_opts, tc_opts, @@ -1881,7 +1881,7 @@ static void test_tc_links_ingress(int target, bool chain_tc_old, assert_mprog_count(target, 0); } -void serial_test_tc_links_ingress(void) +void test_tc_links_ingress(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -1890,9 +1890,9 @@ void serial_test_tc_links_ingress(void) if (!ASSERT_OK_PTR(ns, "create and open ns")) return; - test_tc_links_ingress(BPF_TCX_INGRESS, true, true); - test_tc_links_ingress(BPF_TCX_INGRESS, true, false); - test_tc_links_ingress(BPF_TCX_INGRESS, false, false); + tc_links_ingress(BPF_TCX_INGRESS, true, true); + tc_links_ingress(BPF_TCX_INGRESS, true, false); + tc_links_ingress(BPF_TCX_INGRESS, false, false); netns_free(ns); } @@ -1931,7 +1931,7 @@ static int qdisc_replace(int ifindex, const char *kind, bool block) return err; } -void serial_test_tc_links_dev_chain0(void) +void test_tc_links_dev_chain0(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -1963,7 +1963,7 @@ void serial_test_tc_links_dev_chain0(void) netns_free(ns); } -static void test_tc_links_dev_mixed(int target) +static void tc_links_dev_mixed(int target) { LIBBPF_OPTS(bpf_tc_opts, tc_opts, .handle = 1, .priority = 1); LIBBPF_OPTS(bpf_tc_hook, tc_hook); @@ -2070,7 +2070,7 @@ static void test_tc_links_dev_mixed(int target) ASSERT_EQ(if_nametoindex("tcx_opts2"), 0, "dev2_removed"); } -void serial_test_tc_links_dev_mixed(void) +void test_tc_links_dev_mixed(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -2079,8 +2079,8 @@ void serial_test_tc_links_dev_mixed(void) if (!ASSERT_OK_PTR(ns, "create and open ns")) return; - test_tc_links_dev_mixed(BPF_TCX_INGRESS); - test_tc_links_dev_mixed(BPF_TCX_EGRESS); + tc_links_dev_mixed(BPF_TCX_INGRESS); + tc_links_dev_mixed(BPF_TCX_EGRESS); netns_free(ns); } diff --git a/tools/testing/selftests/bpf/prog_tests/tc_opts.c b/tools/testing/selftests/bpf/prog_tests/tc_opts.c index d38376244532026b2b3d505bcf9711c8e7948e17..615048fc3cd7b497b49883bf4c1ba410efce52f0 100644 --- a/tools/testing/selftests/bpf/prog_tests/tc_opts.c +++ b/tools/testing/selftests/bpf/prog_tests/tc_opts.c @@ -12,7 +12,7 @@ #include "test_tc_link.skel.h" #include "tc_helpers.h" -void serial_test_tc_opts_basic(void) +void test_tc_opts_basic(void) { LIBBPF_OPTS(bpf_prog_attach_opts, opta); LIBBPF_OPTS(bpf_prog_detach_opts, optd); @@ -263,7 +263,7 @@ static void test_tc_opts_before_target(int target) test_tc_link__destroy(skel); } -void serial_test_tc_opts_before(void) +void test_tc_opts_before(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -463,7 +463,7 @@ static void test_tc_opts_after_target(int target) test_tc_link__destroy(skel); } -void serial_test_tc_opts_after(void) +void test_tc_opts_after(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -581,7 +581,7 @@ static void test_tc_opts_revision_target(int target) test_tc_link__destroy(skel); } -void serial_test_tc_opts_revision(void) +void test_tc_opts_revision(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -691,7 +691,7 @@ static void test_tc_chain_classic(int target, bool chain_tc_old) assert_mprog_count(target, 0); } -void serial_test_tc_opts_chain_classic(void) +void test_tc_opts_chain_classic(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -909,7 +909,7 @@ static void test_tc_opts_replace_target(int target) test_tc_link__destroy(skel); } -void serial_test_tc_opts_replace(void) +void test_tc_opts_replace(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -1071,7 +1071,7 @@ static void test_tc_opts_invalid_target(int target) test_tc_link__destroy(skel); } -void serial_test_tc_opts_invalid(void) +void test_tc_opts_invalid(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -1220,7 +1220,7 @@ static void test_tc_opts_prepend_target(int target) test_tc_link__destroy(skel); } -void serial_test_tc_opts_prepend(void) +void test_tc_opts_prepend(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -1369,7 +1369,7 @@ static void test_tc_opts_append_target(int target) test_tc_link__destroy(skel); } -void serial_test_tc_opts_append(void) +void test_tc_opts_append(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -1468,7 +1468,7 @@ static void test_tc_opts_dev_cleanup_target(int target) ASSERT_EQ(if_nametoindex("tcx_opts2"), 0, "dev2_removed"); } -void serial_test_tc_opts_dev_cleanup(void) +void test_tc_opts_dev_cleanup(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -1653,7 +1653,7 @@ static void test_tc_opts_mixed_target(int target) assert_mprog_count(target, 0); } -void serial_test_tc_opts_mixed(void) +void test_tc_opts_mixed(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -1741,7 +1741,7 @@ static void test_tc_opts_demixed_target(int target) assert_mprog_count(target, 0); } -void serial_test_tc_opts_demixed(void) +void test_tc_opts_demixed(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -1921,7 +1921,7 @@ static void test_tc_opts_detach_target(int target) test_tc_link__destroy(skel); } -void serial_test_tc_opts_detach(void) +void test_tc_opts_detach(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -2137,7 +2137,7 @@ static void test_tc_opts_detach_before_target(int target) test_tc_link__destroy(skel); } -void serial_test_tc_opts_detach_before(void) +void test_tc_opts_detach_before(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -2362,7 +2362,7 @@ static void test_tc_opts_detach_after_target(int target) test_tc_link__destroy(skel); } -void serial_test_tc_opts_detach_after(void) +void test_tc_opts_detach_after(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -2377,7 +2377,7 @@ void serial_test_tc_opts_detach_after(void) netns_free(ns); } -static void test_tc_opts_delete_empty(int target, bool chain_tc_old) +static void tc_opts_delete_empty(int target, bool chain_tc_old) { LIBBPF_OPTS(bpf_tc_hook, tc_hook, .ifindex = loopback); LIBBPF_OPTS(bpf_prog_detach_opts, optd); @@ -2400,7 +2400,7 @@ static void test_tc_opts_delete_empty(int target, bool chain_tc_old) assert_mprog_count(target, 0); } -void serial_test_tc_opts_delete_empty(void) +void test_tc_opts_delete_empty(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -2409,10 +2409,10 @@ void serial_test_tc_opts_delete_empty(void) if (!ASSERT_OK_PTR(ns, "create and open ns")) return; - test_tc_opts_delete_empty(BPF_TCX_INGRESS, false); - test_tc_opts_delete_empty(BPF_TCX_EGRESS, false); - test_tc_opts_delete_empty(BPF_TCX_INGRESS, true); - test_tc_opts_delete_empty(BPF_TCX_EGRESS, true); + tc_opts_delete_empty(BPF_TCX_INGRESS, false); + tc_opts_delete_empty(BPF_TCX_EGRESS, false); + tc_opts_delete_empty(BPF_TCX_INGRESS, true); + tc_opts_delete_empty(BPF_TCX_EGRESS, true); netns_free(ns); } @@ -2516,7 +2516,7 @@ static void test_tc_chain_mixed(int target) test_tc_link__destroy(skel); } -void serial_test_tc_opts_chain_mixed(void) +void test_tc_opts_chain_mixed(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -2599,7 +2599,7 @@ static void test_tc_opts_max_target(int target, int flags, bool relative) ASSERT_EQ(if_nametoindex("tcx_opts2"), 0, "dev2_removed"); } -void serial_test_tc_opts_max(void) +void test_tc_opts_max(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -2910,7 +2910,7 @@ static void test_tc_opts_query_target(int target) test_tc_link__destroy(skel); } -void serial_test_tc_opts_query(void) +void test_tc_opts_query(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns; @@ -2978,7 +2978,7 @@ static void test_tc_opts_query_attach_target(int target) test_tc_link__destroy(skel); } -void serial_test_tc_opts_query_attach(void) +void test_tc_opts_query_attach(void) { char ns_name[NS_NAME_MAX_LEN] = NS_NAME; struct netns_obj *ns;