Skip to content

Commit

Permalink
selftests/bpf: Migrate test_xdp_redirect.c to test_xdp_do_redirect.c
Browse files Browse the repository at this point in the history
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) <[email protected]>
  • Loading branch information
bastien-curutchet committed Jan 10, 2025
1 parent f99393d commit 044abb2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 30 deletions.
7 changes: 3 additions & 4 deletions tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <bpf/bpf_endian.h>
#include <uapi/linux/netdev.h>
#include "test_xdp_do_redirect.skel.h"
#include "test_xdp_redirect.skel.h"
#include "xdp_dummy.skel.h"

struct udp_packet {
Expand Down Expand Up @@ -324,7 +323,7 @@ static int ping_setup(struct test_data *data)

static void ping_test(struct test_data *data)
{
struct test_xdp_redirect *skel = NULL;
struct test_xdp_do_redirect *skel = NULL;
struct xdp_dummy *skel_dummy = NULL;
struct nstoken *nstoken = NULL;
int i, ret;
Expand All @@ -351,7 +350,7 @@ static void ping_test(struct test_data *data)
nstoken = NULL;
}

skel = test_xdp_redirect__open_and_load();
skel = test_xdp_do_redirect__open_and_load();
if (!ASSERT_OK_PTR(skel, "open and load skeleton"))
goto close;

Expand Down Expand Up @@ -383,7 +382,7 @@ static void ping_test(struct test_data *data)
close:
close_netns(nstoken);
xdp_dummy__destroy(skel_dummy);
test_xdp_redirect__destroy(skel);
test_xdp_do_redirect__destroy(skel);
}


Expand Down
12 changes: 12 additions & 0 deletions tools/testing/selftests/bpf/progs/test_xdp_do_redirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ int xdp_count_pkts(struct xdp_md *xdp)
return XDP_DROP;
}

SEC("xdp")
int xdp_redirect_to_111(struct xdp_md *xdp)
{
return bpf_redirect(111, 0);
}

SEC("xdp")
int xdp_redirect_to_222(struct xdp_md *xdp)
{
return bpf_redirect(222, 0);
}

SEC("tc")
int tc_count_pkts(struct __sk_buff *skb)
{
Expand Down
26 changes: 0 additions & 26 deletions tools/testing/selftests/bpf/progs/test_xdp_redirect.c

This file was deleted.

0 comments on commit 044abb2

Please sign in to comment.