[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250128-redirect-multi-v3-4-c1ce69997c01@bootlin.com>
Date: Tue, 28 Jan 2025 10:57:28 +0100
From: "Bastien Curutchet (eBPF Foundation)" <bastien.curutchet@...tlin.com>
To: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
"David S. Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
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>, 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: Alexis Lothore <alexis.lothore@...tlin.com>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>, netdev@...r.kernel.org,
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 v3 04/14] selftests/bpf: test_xdp_veth: Use int to
describe next veth
In the struct veth_configuration, the next_veth string is used to tell
the next virtual interface to which packets must be redirected to. So it
has to match the local_veth string of an other veth_configuration.
Change next_veth type to int to avoid handling two identical strings.
This integer is used as an offset in the network configuration table.
Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@...tlin.com>
---
tools/testing/selftests/bpf/prog_tests/test_xdp_veth.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/test_xdp_veth.c b/tools/testing/selftests/bpf/prog_tests/test_xdp_veth.c
index d41884fdc430f1ceed53f16b0dddbdbb34f83301..942c6e99e15ef69003c033e7bc1bfc9bc9777557 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_xdp_veth.c
+++ b/tools/testing/selftests/bpf/prog_tests/test_xdp_veth.c
@@ -39,7 +39,7 @@ struct veth_configuration {
char local_veth[VETH_NAME_MAX_LEN]; /* Interface in main namespace */
char remote_veth[VETH_NAME_MAX_LEN]; /* Peer interface in dedicated namespace*/
const char *namespace; /* Namespace for the remote veth */
- char next_veth[VETH_NAME_MAX_LEN]; /* Local interface to redirect traffic to */
+ int next_veth; /* Local interface to redirect traffic to */
char *remote_addr; /* IP address of the remote veth */
};
@@ -47,21 +47,21 @@ static struct veth_configuration config[VETH_PAIRS_COUNT] = {
{
.local_veth = "veth1",
.remote_veth = "veth11",
- .next_veth = "veth2",
+ .next_veth = 1,
.remote_addr = IP_SRC,
.namespace = "ns-veth11"
},
{
.local_veth = "veth2",
.remote_veth = "veth22",
- .next_veth = "veth3",
+ .next_veth = 2,
.remote_addr = NULL,
.namespace = "ns-veth22"
},
{
.local_veth = "veth3",
.remote_veth = "veth33",
- .next_veth = "veth1",
+ .next_veth = 0,
.remote_addr = IP_DST,
.namespace = "ns-veth33"
}
@@ -144,7 +144,9 @@ static int configure_network(struct skeletons *skeletons)
if (!ASSERT_GE(map_fd, 0, "open redirect map"))
goto fail;
for (i = 0; i < VETH_PAIRS_COUNT; i++) {
- interface_id = if_nametoindex(config[i].next_veth);
+ int next_veth = config[i].next_veth;
+
+ interface_id = if_nametoindex(config[next_veth].local_veth);
if (!ASSERT_NEQ(interface_id, 0, "non zero interface index"))
goto fail;
err = bpf_map_update_elem(map_fd, &i, &interface_id, BPF_ANY);
--
2.47.1
Powered by blists - more mailing lists