summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRicardo B. Marlière <rbm@suse.com>2025-08-29 16:33:49 -0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-15 12:03:24 +0200
commit39051d7c9d6eb6c4210895c36ae50ce1a92f999d (patch)
tree0b6595854c89db4e6591b407a3dfcee6cf441933 /tools
parent6df16e7cebb1df37bb3a1ba923770aa7576081f1 (diff)
downloadlinux-39051d7c9d6eb6c4210895c36ae50ce1a92f999d.tar.gz
linux-39051d7c9d6eb6c4210895c36ae50ce1a92f999d.tar.bz2
linux-39051d7c9d6eb6c4210895c36ae50ce1a92f999d.zip
selftests/bpf: Fix count write in testapp_xdp_metadata_copy()
[ Upstream commit c9110e6f7237f4a314e2b87b75a8a158b9877a7b ] Commit 4b302092553c ("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: 4b302092553c ("selftests/xsk: Add tail adjustment tests and support check") Signed-off-by: Ricardo B. Marlière <rbm@suse.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20250829-selftests-bpf-xsk_regression_fix-v1-1-5f5acdb9fe6b@suse.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/bpf/xskxceiver.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
index a29de0713f19..352adc8df2d1 100644
--- a/tools/testing/selftests/bpf/xskxceiver.c
+++ b/tools/testing/selftests/bpf/xskxceiver.c
@@ -2276,25 +2276,13 @@ static int testapp_xdp_metadata_copy(struct test_spec *test)
{
struct xsk_xdp_progs *skel_rx = test->ifobj_rx->xdp_progs;
struct xsk_xdp_progs *skel_tx = test->ifobj_tx->xdp_progs;
- struct bpf_map *data_map;
- int count = 0;
- int key = 0;
test_spec_set_xdp_prog(test, skel_rx->progs.xsk_xdp_populate_metadata,
skel_tx->progs.xsk_xdp_populate_metadata,
skel_rx->maps.xsk, skel_tx->maps.xsk);
test->ifobj_rx->use_metadata = true;
- data_map = bpf_object__find_map_by_name(skel_rx->obj, "xsk_xdp_.bss");
- if (!data_map || !bpf_map__is_internal(data_map)) {
- ksft_print_msg("Error: could not find bss section of XDP program\n");
- return TEST_FAILURE;
- }
-
- if (bpf_map_update_elem(bpf_map__fd(data_map), &key, &count, BPF_ANY)) {
- ksft_print_msg("Error: could not update count element\n");
- return TEST_FAILURE;
- }
+ skel_rx->bss->count = 0;
return testapp_validate_traffic(test);
}