Skip to content

Commit 3e99fa9

Browse files
bastien-curutchetMartin KaFai Lau
authored andcommitted
selftests/bpf: Migrate test_xdp_redirect.c to test_xdp_do_redirect.c
prog_tests/xdp_do_redirect.c is the only user of the BPF programs located in progs/test_xdp_do_redirect.c and progs/test_xdp_redirect.c. There is no need to keep both files with such close names. Move test_xdp_redirect.c contents to test_xdp_do_redirect.c and remove progs/test_xdp_redirect.c Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com> Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Link: https://patch.msgid.link/20250110-xdp_redirect-v2-3-b8f3ae53e894@bootlin.com
1 parent a94df60 commit 3e99fa9

File tree

3 files changed

+15
-30
lines changed

3 files changed

+15
-30
lines changed

tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <bpf/bpf_endian.h>
1212
#include <uapi/linux/netdev.h>
1313
#include "test_xdp_do_redirect.skel.h"
14-
#include "test_xdp_redirect.skel.h"
1514
#include "xdp_dummy.skel.h"
1615

1716
struct udp_packet {
@@ -324,7 +323,7 @@ static int ping_setup(struct test_data *data)
324323

325324
static void ping_test(struct test_data *data)
326325
{
327-
struct test_xdp_redirect *skel = NULL;
326+
struct test_xdp_do_redirect *skel = NULL;
328327
struct xdp_dummy *skel_dummy = NULL;
329328
struct nstoken *nstoken = NULL;
330329
int i, ret;
@@ -351,7 +350,7 @@ static void ping_test(struct test_data *data)
351350
nstoken = NULL;
352351
}
353352

354-
skel = test_xdp_redirect__open_and_load();
353+
skel = test_xdp_do_redirect__open_and_load();
355354
if (!ASSERT_OK_PTR(skel, "open and load skeleton"))
356355
goto close;
357356

@@ -383,7 +382,7 @@ static void ping_test(struct test_data *data)
383382
close:
384383
close_netns(nstoken);
385384
xdp_dummy__destroy(skel_dummy);
386-
test_xdp_redirect__destroy(skel);
385+
test_xdp_do_redirect__destroy(skel);
387386
}
388387

389388

tools/testing/selftests/bpf/progs/test_xdp_do_redirect.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ int xdp_count_pkts(struct xdp_md *xdp)
9898
return XDP_DROP;
9999
}
100100

101+
SEC("xdp")
102+
int xdp_redirect_to_111(struct xdp_md *xdp)
103+
{
104+
return bpf_redirect(111, 0);
105+
}
106+
107+
SEC("xdp")
108+
int xdp_redirect_to_222(struct xdp_md *xdp)
109+
{
110+
return bpf_redirect(222, 0);
111+
}
112+
101113
SEC("tc")
102114
int tc_count_pkts(struct __sk_buff *skb)
103115
{

tools/testing/selftests/bpf/progs/test_xdp_redirect.c

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)