selftests/bpf: Test allowed maps for bpf_sk_select_reuseport
Subsystems (5)
PATCH 1/1 selftests/bpf: Test allowed maps for bpf_sk_select_reuseport
Check that verifier allows passing a map of type:
BPF_MAP_TYPE_REUSEPORT_SOCKARRARY, or
BPF_MAP_TYPE_SOCKMAP, or
BPF_MAP_TYPE_SOCKHASH
... to bpf_sk_select_reuseport helper.
Suggested-by John Fastabend <[email protected]>
Signed-off-by Jakub Sitnicki <[email protected]>
--- tools/testing/selftests/bpf/test_verifier.c | 12 +++++- tools/testing/selftests/bpf/verifier/sock.c | 45 +++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-)
tools/testing/selftests/bpf/test_verifier.c +11 -1
@@ -50,7 +50,7 @@#define MAX_INSNS BPF_MAXINSNS#define MAX_TEST_INSNS 1000000#define MAX_FIXUPS 8 -#define MAX_NR_MAPS 19 +#define MAX_NR_MAPS 20#define MAX_TEST_RUNS 8#define POINTER_VALUE 0xcafe4all#define TEST_DATA_LEN 64
@@ -86,6 +86,7 @@ struct bpf_test {int fixup_map_array_small[MAX_FIXUPS ];int fixup_sk_storage_map[MAX_FIXUPS ];int fixup_map_event_output[MAX_FIXUPS ]; +int fixup_map_reuseport_array[MAX_FIXUPS ];const char *errstr;const char *errstr_unpriv;uint32_t insn_processed;
@@ -637,6 +638,7 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_prog_type prog_type,int *fixup_map_array_small = test->fixup_map_array_small;int *fixup_sk_storage_map = test->fixup_sk_storage_map;int *fixup_map_event_output = test->fixup_map_event_output; +int *fixup_map_reuseport_array = test->fixup_map_reuseport_array;if (test->fill_helper) { test->fill_insns =calloc (MAX_TEST_INSNS ,sizeof (struct bpf_insn ));
@@ -806,6 +808,14 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_prog_type prog_type, fixup_map_event_output++; }while (*fixup_map_event_output); } +if (*fixup_map_reuseport_array) { + map_fds[19 ] =__create_map (BPF_MAP_TYPE_REUSEPORT_SOCKARRAY , +sizeof (u32),sizeof (u64),1 ,0 ); +do { + prog[*fixup_map_reuseport_array].imm = map_fds[19 ]; + fixup_map_reuseport_array++; + }while (*fixup_map_reuseport_array); + } }static int set_admin (bool admin)
tools/testing/selftests/bpf/verifier/sock.c +45 -0
48 lines not on this page · raw message
Signature · 1 line
2.25.3
Daniel Borkmann
maintainerQuoted 10 lines · Jakub Sitnicki
Check that verifier allows passing a map of type:
BPF_MAP_TYPE_REUSEPORT_SOCKARRARY, or
BPF_MAP_TYPE_SOCKMAP, or
BPF_MAP_TYPE_SOCKHASH... to
bpf_sk_select_reuseporthelper.Suggested-by John Fastabend <[email protected]>Signed-off-by Jakub Sitnicki <[email protected]>
Looks good, applied!