[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250217-tc_links-v1-1-27f7965e3dcd@bootlin.com>
Date: Mon, 17 Feb 2025 13:37:38 +0100
From: "Bastien Curutchet (eBPF Foundation)" <bastien.curutchet@...tlin.com>
To: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Eduard Zingerman <eddyz87@...il.com>, Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>,
John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, Mykola Lysenko <mykolal@...com>,
Shuah Khan <shuah@...nel.org>
Cc: Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Alexis Lothore <alexis.lothore@...tlin.com>, bpf@...r.kernel.org,
linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org,
"Bastien Curutchet (eBPF Foundation)" <bastien.curutchet@...tlin.com>
Subject: [PATCH bpf-next 1/3] selftests/bpf: tc_helpers: Add
create_and_open_tid_ns()
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) <bastien.curutchet@...tlin.com>
---
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 <test_progs.h>
+#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 */
--
2.48.1
Powered by blists - more mailing lists