mirror of
https://github.com/raspberrypi/linux.git
synced 2026-01-04 18:27:36 +00:00
selftests/bpf: expose all subtests from flow_dissector
The flow_dissector test integrated in test_progs actually runs a wide matrix of tests over different packets types and bpf programs modes, but exposes only 3 main tests, preventing tests users from running specific subtests with a specific input only. Expose all subtests executed by flow_dissector by using test__start_subtest(). Acked-by: Stanislav Fomichev <sdf@fomichev.me> Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com> Link: https://lore.kernel.org/r/20241120-flow_dissector-v3-5-45b46494f937@bootlin.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
committed by
Alexei Starovoitov
parent
2b044dd186
commit
a2cc66bb93
@@ -8,6 +8,7 @@
|
||||
#include "bpf_flow.skel.h"
|
||||
|
||||
#define FLOW_CONTINUE_SADDR 0x7f00007f /* 127.0.0.127 */
|
||||
#define TEST_NAME_MAX_LEN 64
|
||||
|
||||
#ifndef IP_MF
|
||||
#define IP_MF 0x2000
|
||||
@@ -505,8 +506,10 @@ static int init_prog_array(struct bpf_object *obj, struct bpf_map *prog_array)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void run_tests_skb_less(int tap_fd, struct bpf_map *keys)
|
||||
static void run_tests_skb_less(int tap_fd, struct bpf_map *keys,
|
||||
char *test_suffix)
|
||||
{
|
||||
char test_name[TEST_NAME_MAX_LEN];
|
||||
int i, err, keys_fd;
|
||||
|
||||
keys_fd = bpf_map__fd(keys);
|
||||
@@ -520,6 +523,10 @@ static void run_tests_skb_less(int tap_fd, struct bpf_map *keys)
|
||||
struct bpf_flow_keys flow_keys = {};
|
||||
__u32 key = (__u32)(tests[i].keys.sport) << 16 |
|
||||
tests[i].keys.dport;
|
||||
snprintf(test_name, TEST_NAME_MAX_LEN, "%s-%s", tests[i].name,
|
||||
test_suffix);
|
||||
if (!test__start_subtest(test_name))
|
||||
continue;
|
||||
|
||||
/* For skb-less case we can't pass input flags; run
|
||||
* only the tests that have a matching set of flags.
|
||||
@@ -582,7 +589,8 @@ void test_flow_dissector_skb_less_direct_attach(void)
|
||||
if (!ASSERT_OK(err, "ifup"))
|
||||
goto out_close_tap;
|
||||
|
||||
run_tests_skb_less(tap_fd, skel->maps.last_dissection);
|
||||
run_tests_skb_less(tap_fd, skel->maps.last_dissection,
|
||||
"non-skb-direct-attach");
|
||||
|
||||
err = bpf_prog_detach2(prog_fd, 0, BPF_FLOW_DISSECTOR);
|
||||
ASSERT_OK(err, "bpf_prog_detach2");
|
||||
@@ -629,7 +637,8 @@ void test_flow_dissector_skb_less_indirect_attach(void)
|
||||
if (!ASSERT_OK_PTR(link, "attach_netns"))
|
||||
goto out_close_tap;
|
||||
|
||||
run_tests_skb_less(tap_fd, skel->maps.last_dissection);
|
||||
run_tests_skb_less(tap_fd, skel->maps.last_dissection,
|
||||
"non-skb-indirect-attach");
|
||||
|
||||
err = bpf_link__destroy(link);
|
||||
ASSERT_OK(err, "bpf_link__destroy");
|
||||
@@ -646,6 +655,7 @@ out_clean_ns:
|
||||
|
||||
void test_flow_dissector_skb(void)
|
||||
{
|
||||
char test_name[TEST_NAME_MAX_LEN];
|
||||
struct bpf_flow *skel;
|
||||
int i, err, prog_fd;
|
||||
|
||||
@@ -670,6 +680,10 @@ void test_flow_dissector_skb(void)
|
||||
);
|
||||
static struct bpf_flow_keys ctx = {};
|
||||
|
||||
snprintf(test_name, TEST_NAME_MAX_LEN, "%s-skb", tests[i].name);
|
||||
if (!test__start_subtest(test_name))
|
||||
continue;
|
||||
|
||||
if (tests[i].flags) {
|
||||
topts.ctx_in = &ctx;
|
||||
topts.ctx_size_in = sizeof(ctx);
|
||||
|
||||
Reference in New Issue
Block a user