Skip to content

Commit

Permalink
selftests/bpf: Adjust data size to have ETH_HLEN
Browse files Browse the repository at this point in the history
The function bpf_test_init() now returns an error if user_size
(.data_size_in) is less than ETH_HLEN, causing the tests to
fail. Adjust the data size to ensure it meets the requirement of
ETH_HLEN.

Signed-off-by: Shigeru Yoshida <[email protected]>
Signed-off-by: Martin KaFai Lau <[email protected]>
Link: https://patch.msgid.link/[email protected]
  • Loading branch information
Shigeru Yoshida authored and Martin KaFai Lau committed Jan 24, 2025
1 parent c5e8e57 commit f9f03a0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tools/testing/selftests/bpf/prog_tests/xdp_cpumap_attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ static void test_xdp_with_cpumap_helpers(void)
ASSERT_EQ(info.id, val.bpf_prog.id, "Match program id to cpumap entry prog_id");

/* send a packet to trigger any potential bugs in there */
char data[10] = {};
char data[ETH_HLEN] = {};
DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts,
.data_in = &data,
.data_size_in = 10,
.data_size_in = sizeof(data),
.flags = BPF_F_TEST_XDP_LIVE_FRAMES,
.repeat = 1,
);
Expand Down
8 changes: 4 additions & 4 deletions tools/testing/selftests/bpf/prog_tests/xdp_devmap_attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static void test_xdp_with_devmap_helpers(void)
__u32 len = sizeof(info);
int err, dm_fd, dm_fd_redir, map_fd;
struct nstoken *nstoken = NULL;
char data[10] = {};
char data[ETH_HLEN] = {};
__u32 idx = 0;

SYS(out_close, "ip netns add %s", TEST_NS);
Expand Down Expand Up @@ -58,7 +58,7 @@ static void test_xdp_with_devmap_helpers(void)
/* send a packet to trigger any potential bugs in there */
DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts,
.data_in = &data,
.data_size_in = 10,
.data_size_in = sizeof(data),
.flags = BPF_F_TEST_XDP_LIVE_FRAMES,
.repeat = 1,
);
Expand Down Expand Up @@ -158,7 +158,7 @@ static void test_xdp_with_devmap_helpers_veth(void)
struct nstoken *nstoken = NULL;
__u32 len = sizeof(info);
int err, dm_fd, dm_fd_redir, map_fd, ifindex_dst;
char data[10] = {};
char data[ETH_HLEN] = {};
__u32 idx = 0;

SYS(out_close, "ip netns add %s", TEST_NS);
Expand Down Expand Up @@ -208,7 +208,7 @@ static void test_xdp_with_devmap_helpers_veth(void)
/* send a packet to trigger any potential bugs in there */
DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts,
.data_in = &data,
.data_size_in = 10,
.data_size_in = sizeof(data),
.flags = BPF_F_TEST_XDP_LIVE_FRAMES,
.repeat = 1,
);
Expand Down

0 comments on commit f9f03a0

Please sign in to comment.