selftests/bpf: Adjust data size to have ETH_HLEN
authorShigeru Yoshida <syoshida@redhat.com>
Tue, 21 Jan 2025 15:06:43 +0000 (00:06 +0900)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 29 Jan 2025 16:51:51 +0000 (08:51 -0800)
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 <syoshida@redhat.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/20250121150643.671650-2-syoshida@redhat.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/prog_tests/xdp_cpumap_attach.c
tools/testing/selftests/bpf/prog_tests/xdp_devmap_attach.c

index c7f74f068e78835329f0b1e35c2dffb54adfe3ae..df27535995af8d5fb9823f114b6ed5ac3847d826 100644 (file)
@@ -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,
                );
index 27ffed17d4be33fab8776baa1dd1a6055e7194bf..461ab18705d5c0f15ad0b0f4e8869d1e92de2854 100644 (file)
@@ -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);
@@ -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,
                );
@@ -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);
@@ -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,
                );