diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2015-03-01 06:31:41 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-01 14:05:18 -0500 |
commit | f91fe17e243d1f279d425071a35e3d41290758a0 (patch) | |
tree | be27553798f8f3490487814275e09644e446c88f /kernel | |
parent | b656cc64cf815d8ff6e99883a531fafc48199bd0 (diff) |
ebpf: remove kernel test stubs
Now that we have BPF_PROG_TYPE_SOCKET_FILTER up and running, we can
remove the test stubs which were added to get the verifier suite up.
We can just let the test cases probe under socket filter type instead.
In the fill/spill test case, we cannot (yet) access fields from the
context (skb), but we may adapt that test case in future.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/bpf/Makefile | 3 | ||||
-rw-r--r-- | kernel/bpf/test_stub.c | 78 |
2 files changed, 0 insertions, 81 deletions
diff --git a/kernel/bpf/Makefile b/kernel/bpf/Makefile index a5ae60f0b0a2..e6983be12bd3 100644 --- a/kernel/bpf/Makefile +++ b/kernel/bpf/Makefile | |||
@@ -1,5 +1,2 @@ | |||
1 | obj-y := core.o | 1 | obj-y := core.o |
2 | obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o hashtab.o arraymap.o helpers.o | 2 | obj-$(CONFIG_BPF_SYSCALL) += syscall.o verifier.o hashtab.o arraymap.o helpers.o |
3 | ifdef CONFIG_TEST_BPF | ||
4 | obj-$(CONFIG_BPF_SYSCALL) += test_stub.o | ||
5 | endif | ||
diff --git a/kernel/bpf/test_stub.c b/kernel/bpf/test_stub.c deleted file mode 100644 index 0ceae1e6e8b5..000000000000 --- a/kernel/bpf/test_stub.c +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | /* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com | ||
2 | * | ||
3 | * This program is free software; you can redistribute it and/or | ||
4 | * modify it under the terms of version 2 of the GNU General Public | ||
5 | * License as published by the Free Software Foundation. | ||
6 | */ | ||
7 | #include <linux/kernel.h> | ||
8 | #include <linux/types.h> | ||
9 | #include <linux/slab.h> | ||
10 | #include <linux/err.h> | ||
11 | #include <linux/bpf.h> | ||
12 | |||
13 | /* test stubs for BPF_MAP_TYPE_UNSPEC and for BPF_PROG_TYPE_UNSPEC | ||
14 | * to be used by user space verifier testsuite | ||
15 | */ | ||
16 | struct bpf_context { | ||
17 | u64 arg1; | ||
18 | u64 arg2; | ||
19 | }; | ||
20 | |||
21 | static const struct bpf_func_proto *test_func_proto(enum bpf_func_id func_id) | ||
22 | { | ||
23 | switch (func_id) { | ||
24 | case BPF_FUNC_map_lookup_elem: | ||
25 | return &bpf_map_lookup_elem_proto; | ||
26 | case BPF_FUNC_map_update_elem: | ||
27 | return &bpf_map_update_elem_proto; | ||
28 | case BPF_FUNC_map_delete_elem: | ||
29 | return &bpf_map_delete_elem_proto; | ||
30 | default: | ||
31 | return NULL; | ||
32 | } | ||
33 | } | ||
34 | |||
35 | static const struct bpf_context_access { | ||
36 | int size; | ||
37 | enum bpf_access_type type; | ||
38 | } test_ctx_access[] = { | ||
39 | [offsetof(struct bpf_context, arg1)] = { | ||
40 | FIELD_SIZEOF(struct bpf_context, arg1), | ||
41 | BPF_READ | ||
42 | }, | ||
43 | [offsetof(struct bpf_context, arg2)] = { | ||
44 | FIELD_SIZEOF(struct bpf_context, arg2), | ||
45 | BPF_READ | ||
46 | }, | ||
47 | }; | ||
48 | |||
49 | static bool test_is_valid_access(int off, int size, enum bpf_access_type type) | ||
50 | { | ||
51 | const struct bpf_context_access *access; | ||
52 | |||
53 | if (off < 0 || off >= ARRAY_SIZE(test_ctx_access)) | ||
54 | return false; | ||
55 | |||
56 | access = &test_ctx_access[off]; | ||
57 | if (access->size == size && (access->type & type)) | ||
58 | return true; | ||
59 | |||
60 | return false; | ||
61 | } | ||
62 | |||
63 | static struct bpf_verifier_ops test_ops = { | ||
64 | .get_func_proto = test_func_proto, | ||
65 | .is_valid_access = test_is_valid_access, | ||
66 | }; | ||
67 | |||
68 | static struct bpf_prog_type_list tl_prog = { | ||
69 | .ops = &test_ops, | ||
70 | .type = BPF_PROG_TYPE_UNSPEC, | ||
71 | }; | ||
72 | |||
73 | static int __init register_test_ops(void) | ||
74 | { | ||
75 | bpf_register_prog_type(&tl_prog); | ||
76 | return 0; | ||
77 | } | ||
78 | late_initcall(register_test_ops); | ||