mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 04:30:52 +07:00
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 <john.fastabend@gmail.com> Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20200430104738.494180-1-jakub@cloudflare.com
This commit is contained in:
parent
063e688133
commit
c321022244
@ -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)
|
||||
|
@ -586,3 +586,48 @@
|
||||
.prog_type = BPF_PROG_TYPE_SK_SKB,
|
||||
.result = ACCEPT,
|
||||
},
|
||||
{
|
||||
"bpf_sk_select_reuseport(ctx, reuseport_array, &key, flags)",
|
||||
.insns = {
|
||||
BPF_MOV64_IMM(BPF_REG_4, 0),
|
||||
BPF_ST_MEM(BPF_W, BPF_REG_10, -4, 0),
|
||||
BPF_MOV64_REG(BPF_REG_3, BPF_REG_10),
|
||||
BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, -4),
|
||||
BPF_LD_MAP_FD(BPF_REG_2, 0),
|
||||
BPF_EMIT_CALL(BPF_FUNC_sk_select_reuseport),
|
||||
BPF_EXIT_INSN(),
|
||||
},
|
||||
.fixup_map_reuseport_array = { 4 },
|
||||
.prog_type = BPF_PROG_TYPE_SK_REUSEPORT,
|
||||
.result = ACCEPT,
|
||||
},
|
||||
{
|
||||
"bpf_sk_select_reuseport(ctx, sockmap, &key, flags)",
|
||||
.insns = {
|
||||
BPF_MOV64_IMM(BPF_REG_4, 0),
|
||||
BPF_ST_MEM(BPF_W, BPF_REG_10, -4, 0),
|
||||
BPF_MOV64_REG(BPF_REG_3, BPF_REG_10),
|
||||
BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, -4),
|
||||
BPF_LD_MAP_FD(BPF_REG_2, 0),
|
||||
BPF_EMIT_CALL(BPF_FUNC_sk_select_reuseport),
|
||||
BPF_EXIT_INSN(),
|
||||
},
|
||||
.fixup_map_sockmap = { 4 },
|
||||
.prog_type = BPF_PROG_TYPE_SK_REUSEPORT,
|
||||
.result = ACCEPT,
|
||||
},
|
||||
{
|
||||
"bpf_sk_select_reuseport(ctx, sockhash, &key, flags)",
|
||||
.insns = {
|
||||
BPF_MOV64_IMM(BPF_REG_4, 0),
|
||||
BPF_ST_MEM(BPF_W, BPF_REG_10, -4, 0),
|
||||
BPF_MOV64_REG(BPF_REG_3, BPF_REG_10),
|
||||
BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, -4),
|
||||
BPF_LD_MAP_FD(BPF_REG_2, 0),
|
||||
BPF_EMIT_CALL(BPF_FUNC_sk_select_reuseport),
|
||||
BPF_EXIT_INSN(),
|
||||
},
|
||||
.fixup_map_sockmap = { 4 },
|
||||
.prog_type = BPF_PROG_TYPE_SK_REUSEPORT,
|
||||
.result = ACCEPT,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user