Skip to content

Commit c7f2188

Browse files
Shigeru YoshidaAlexei Starovoitov
authored andcommitted
selftests/bpf: Adjust data size to have ETH_HLEN
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] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 6b3d638 commit c7f2188

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ static void test_xdp_with_cpumap_helpers(void)
5252
ASSERT_EQ(info.id, val.bpf_prog.id, "Match program id to cpumap entry prog_id");
5353

5454
/* send a packet to trigger any potential bugs in there */
55-
char data[10] = {};
55+
char data[ETH_HLEN] = {};
5656
DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts,
5757
.data_in = &data,
58-
.data_size_in = 10,
58+
.data_size_in = sizeof(data),
5959
.flags = BPF_F_TEST_XDP_LIVE_FRAMES,
6060
.repeat = 1,
6161
);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static void test_xdp_with_devmap_helpers(void)
2323
__u32 len = sizeof(info);
2424
int err, dm_fd, dm_fd_redir, map_fd;
2525
struct nstoken *nstoken = NULL;
26-
char data[10] = {};
26+
char data[ETH_HLEN] = {};
2727
__u32 idx = 0;
2828

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

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

0 commit comments

Comments
 (0)