Skip to content

Commit e43248c

Browse files
pchaignoKernel Patches Daemon
authored andcommitted
selftests/bpf: Support non-linear flag in test loader
Contrary to most flags currently used in selftests, the BPF_F_TEST_SKB_NON_LINEAR flag is not passed at program loading time, but when calling BPF_PROG_TEST_RUN. This patch updates the test loader to support it. Signed-off-by: Paul Chaignon <[email protected]>
1 parent c082909 commit e43248c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tools/testing/selftests/bpf/test_loader.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ struct test_spec {
9191
const char *btf_custom_path;
9292
int log_level;
9393
int prog_flags;
94+
int run_flags;
9495
int mode_mask;
9596
int arch_mask;
9697
int load_mask;
@@ -554,6 +555,8 @@ static int parse_test_spec(struct test_loader *tester,
554555
update_flags(&spec->prog_flags, BPF_F_XDP_HAS_FRAGS, clear);
555556
} else if (strcmp(val, "BPF_F_TEST_REG_INVARIANTS") == 0) {
556557
update_flags(&spec->prog_flags, BPF_F_TEST_REG_INVARIANTS, clear);
558+
} else if (strcmp(val, "BPF_F_TEST_SKB_NON_LINEAR") == 0) {
559+
update_flags(&spec->run_flags, BPF_F_TEST_SKB_NON_LINEAR, clear);
557560
} else /* assume numeric value */ {
558561
err = parse_int(val, &flags, "test prog flags");
559562
if (err)
@@ -854,7 +857,7 @@ static bool is_unpriv_capable_map(struct bpf_map *map)
854857
}
855858
}
856859

857-
static int do_prog_test_run(int fd_prog, int *retval, bool empty_opts)
860+
static int do_prog_test_run(int fd_prog, int *retval, bool empty_opts, int run_flags)
858861
{
859862
__u8 tmp_out[TEST_DATA_LEN << 2] = {};
860863
__u8 tmp_in[TEST_DATA_LEN] = {};
@@ -864,6 +867,7 @@ static int do_prog_test_run(int fd_prog, int *retval, bool empty_opts)
864867
.data_size_in = sizeof(tmp_in),
865868
.data_out = tmp_out,
866869
.data_size_out = sizeof(tmp_out),
870+
.flags = run_flags,
867871
.repeat = 1,
868872
);
869873

@@ -1103,7 +1107,8 @@ void run_subtest(struct test_loader *tester,
11031107
}
11041108

11051109
err = do_prog_test_run(bpf_program__fd(tprog), &retval,
1106-
bpf_program__type(tprog) == BPF_PROG_TYPE_SYSCALL ? true : false);
1110+
bpf_program__type(tprog) == BPF_PROG_TYPE_SYSCALL ? true : false,
1111+
spec->run_flags);
11071112
if (!err && retval != subspec->retval && subspec->retval != POINTER_VALUE) {
11081113
PRINT_FAIL("Unexpected retval: %d != %d\n", retval, subspec->retval);
11091114
goto tobj_cleanup;

0 commit comments

Comments
 (0)