mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-24 23:04:17 +08:00
selftests/bpf: Correct map_fd to data_fd in tailcalls
[ Upstream commit96daa98742
] Get and check data_fd. It should not check map_fd again. Meanwhile, correct some 'return' to 'goto out'. Thank the suggestion from Maciej in "bpf, x64: Fix tailcall infinite loop"[0] discussions. [0] https://lore.kernel.org/bpf/e496aef8-1f80-0f8e-dcdd-25a8c300319a@gmail.com/T/#m7d3b601066ba66400d436b7e7579b2df4a101033 Fixes:79d49ba048
("bpf, testing: Add various tail call test cases") Fixes:3b03791111
("selftests/bpf: Add tailcall_bpf2bpf tests") Fixes:5e0b0a4c52
("selftests/bpf: Test tail call counting with bpf2bpf and data on stack") Signed-off-by: Leon Hwang <hffilwlqm@gmail.com> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Link: https://lore.kernel.org/r/20230906154256.95461-1-hffilwlqm@gmail.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
3eefb2fbf4
commit
8f7eef3a13
@ -272,11 +272,11 @@ static void test_tailcall_3(void)
|
||||
|
||||
data_map = bpf_object__find_map_by_name(obj, "tailcall.bss");
|
||||
if (CHECK_FAIL(!data_map || !bpf_map__is_internal(data_map)))
|
||||
return;
|
||||
goto out;
|
||||
|
||||
data_fd = bpf_map__fd(data_map);
|
||||
if (CHECK_FAIL(map_fd < 0))
|
||||
return;
|
||||
if (CHECK_FAIL(data_fd < 0))
|
||||
goto out;
|
||||
|
||||
i = 0;
|
||||
err = bpf_map_lookup_elem(data_fd, &i, &val);
|
||||
@ -334,11 +334,11 @@ static void test_tailcall_4(void)
|
||||
|
||||
data_map = bpf_object__find_map_by_name(obj, "tailcall.bss");
|
||||
if (CHECK_FAIL(!data_map || !bpf_map__is_internal(data_map)))
|
||||
return;
|
||||
goto out;
|
||||
|
||||
data_fd = bpf_map__fd(data_map);
|
||||
if (CHECK_FAIL(map_fd < 0))
|
||||
return;
|
||||
if (CHECK_FAIL(data_fd < 0))
|
||||
goto out;
|
||||
|
||||
for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
|
||||
snprintf(prog_name, sizeof(prog_name), "classifier/%i", i);
|
||||
@ -422,11 +422,11 @@ static void test_tailcall_5(void)
|
||||
|
||||
data_map = bpf_object__find_map_by_name(obj, "tailcall.bss");
|
||||
if (CHECK_FAIL(!data_map || !bpf_map__is_internal(data_map)))
|
||||
return;
|
||||
goto out;
|
||||
|
||||
data_fd = bpf_map__fd(data_map);
|
||||
if (CHECK_FAIL(map_fd < 0))
|
||||
return;
|
||||
if (CHECK_FAIL(data_fd < 0))
|
||||
goto out;
|
||||
|
||||
for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
|
||||
snprintf(prog_name, sizeof(prog_name), "classifier/%i", i);
|
||||
@ -610,11 +610,11 @@ static void test_tailcall_bpf2bpf_2(void)
|
||||
|
||||
data_map = bpf_object__find_map_by_name(obj, "tailcall.bss");
|
||||
if (CHECK_FAIL(!data_map || !bpf_map__is_internal(data_map)))
|
||||
return;
|
||||
goto out;
|
||||
|
||||
data_fd = bpf_map__fd(data_map);
|
||||
if (CHECK_FAIL(map_fd < 0))
|
||||
return;
|
||||
if (CHECK_FAIL(data_fd < 0))
|
||||
goto out;
|
||||
|
||||
i = 0;
|
||||
err = bpf_map_lookup_elem(data_fd, &i, &val);
|
||||
@ -783,11 +783,11 @@ static void test_tailcall_bpf2bpf_4(bool noise)
|
||||
|
||||
data_map = bpf_object__find_map_by_name(obj, "tailcall.bss");
|
||||
if (CHECK_FAIL(!data_map || !bpf_map__is_internal(data_map)))
|
||||
return;
|
||||
goto out;
|
||||
|
||||
data_fd = bpf_map__fd(data_map);
|
||||
if (CHECK_FAIL(map_fd < 0))
|
||||
return;
|
||||
if (CHECK_FAIL(data_fd < 0))
|
||||
goto out;
|
||||
|
||||
i = 0;
|
||||
val.noise = noise;
|
||||
@ -851,7 +851,7 @@ static void test_tailcall_bpf2bpf_6(void)
|
||||
ASSERT_EQ(topts.retval, 0, "tailcall retval");
|
||||
|
||||
data_fd = bpf_map__fd(obj->maps.bss);
|
||||
if (!ASSERT_GE(map_fd, 0, "bss map fd"))
|
||||
if (!ASSERT_GE(data_fd, 0, "bss map fd"))
|
||||
goto out;
|
||||
|
||||
i = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user