Skip to content

Commit 02c1d05

Browse files
rbmarliereKernel Patches Daemon
authored andcommitted
selftests/bpf: Fix count write in testapp_xdp_metadata_copy()
Commit 4b30209 ("selftests/xsk: Add tail adjustment tests and support check") added a new global to xsk_xdp_progs.c, but left out the access in the testapp_xdp_metadata_copy() function. Since bpf_map_update_elem() will write to the whole bss section, it gets truncated. Fix by writing to skel_rx->bss->count directly. Fixes: 4b30209 ("selftests/xsk: Add tail adjustment tests and support check") Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
1 parent 17f7415 commit 02c1d05

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

tools/testing/selftests/bpf/xskxceiver.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2276,25 +2276,13 @@ static int testapp_xdp_metadata_copy(struct test_spec *test)
22762276
{
22772277
struct xsk_xdp_progs *skel_rx = test->ifobj_rx->xdp_progs;
22782278
struct xsk_xdp_progs *skel_tx = test->ifobj_tx->xdp_progs;
2279-
struct bpf_map *data_map;
2280-
int count = 0;
2281-
int key = 0;
22822279

22832280
test_spec_set_xdp_prog(test, skel_rx->progs.xsk_xdp_populate_metadata,
22842281
skel_tx->progs.xsk_xdp_populate_metadata,
22852282
skel_rx->maps.xsk, skel_tx->maps.xsk);
22862283
test->ifobj_rx->use_metadata = true;
22872284

2288-
data_map = bpf_object__find_map_by_name(skel_rx->obj, "xsk_xdp_.bss");
2289-
if (!data_map || !bpf_map__is_internal(data_map)) {
2290-
ksft_print_msg("Error: could not find bss section of XDP program\n");
2291-
return TEST_FAILURE;
2292-
}
2293-
2294-
if (bpf_map_update_elem(bpf_map__fd(data_map), &key, &count, BPF_ANY)) {
2295-
ksft_print_msg("Error: could not update count element\n");
2296-
return TEST_FAILURE;
2297-
}
2285+
skel_rx->bss->count = 0;
22982286

22992287
return testapp_validate_traffic(test);
23002288
}

0 commit comments

Comments
 (0)