diff options
author | Daniel Borkmann <daniel@iogearbox.net> | 2015-03-01 06:31:43 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-01 14:05:19 -0500 |
commit | f1a66f85b74c5ef7b503f746ea97742dacd56419 (patch) | |
tree | 74e50377321d7afae02ebf494ee523cb878d285a | |
parent | a2c83fff582ae133d9f5bb187404ea9ce4da1f96 (diff) |
ebpf: export BPF_PSEUDO_MAP_FD to uapi
We need to export BPF_PSEUDO_MAP_FD to user space, as it's used in the
ELF BPF loader where instructions are being loaded that need map fixups.
An initial stage loads all maps into the kernel, and later on replaces
related instructions in the eBPF blob with BPF_PSEUDO_MAP_FD as source
register and the actual fd as immediate value.
The kernel verifier recognizes this keyword and replaces the map fd with
a real pointer internally.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/filter.h | 2 | ||||
-rw-r--r-- | include/uapi/linux/bpf.h | 2 | ||||
-rw-r--r-- | samples/bpf/libbpf.h | 4 |
3 files changed, 5 insertions, 3 deletions
diff --git a/include/linux/filter.h b/include/linux/filter.h index caac2087a4d5..5e3863d5f666 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h | |||
@@ -145,8 +145,6 @@ struct bpf_prog_aux; | |||
145 | .off = 0, \ | 145 | .off = 0, \ |
146 | .imm = ((__u64) (IMM)) >> 32 }) | 146 | .imm = ((__u64) (IMM)) >> 32 }) |
147 | 147 | ||
148 | #define BPF_PSEUDO_MAP_FD 1 | ||
149 | |||
150 | /* pseudo BPF_LD_IMM64 insn used to refer to process-local map_fd */ | 148 | /* pseudo BPF_LD_IMM64 insn used to refer to process-local map_fd */ |
151 | #define BPF_LD_MAP_FD(DST, MAP_FD) \ | 149 | #define BPF_LD_MAP_FD(DST, MAP_FD) \ |
152 | BPF_LD_IMM64_RAW(DST, BPF_PSEUDO_MAP_FD, MAP_FD) | 150 | BPF_LD_IMM64_RAW(DST, BPF_PSEUDO_MAP_FD, MAP_FD) |
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 45da7ec7d274..0248180bf2e2 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h | |||
@@ -120,6 +120,8 @@ enum bpf_prog_type { | |||
120 | BPF_PROG_TYPE_SOCKET_FILTER, | 120 | BPF_PROG_TYPE_SOCKET_FILTER, |
121 | }; | 121 | }; |
122 | 122 | ||
123 | #define BPF_PSEUDO_MAP_FD 1 | ||
124 | |||
123 | /* flags for BPF_MAP_UPDATE_ELEM command */ | 125 | /* flags for BPF_MAP_UPDATE_ELEM command */ |
124 | #define BPF_ANY 0 /* create new element or update existing */ | 126 | #define BPF_ANY 0 /* create new element or update existing */ |
125 | #define BPF_NOEXIST 1 /* create new element if it didn't exist */ | 127 | #define BPF_NOEXIST 1 /* create new element if it didn't exist */ |
diff --git a/samples/bpf/libbpf.h b/samples/bpf/libbpf.h index 58c5fe1bdba1..a6bb7e9c22c3 100644 --- a/samples/bpf/libbpf.h +++ b/samples/bpf/libbpf.h | |||
@@ -92,7 +92,9 @@ extern char bpf_log_buf[LOG_BUF_SIZE]; | |||
92 | .off = 0, \ | 92 | .off = 0, \ |
93 | .imm = ((__u64) (IMM)) >> 32 }) | 93 | .imm = ((__u64) (IMM)) >> 32 }) |
94 | 94 | ||
95 | #define BPF_PSEUDO_MAP_FD 1 | 95 | #ifndef BPF_PSEUDO_MAP_FD |
96 | # define BPF_PSEUDO_MAP_FD 1 | ||
97 | #endif | ||
96 | 98 | ||
97 | /* pseudo BPF_LD_IMM64 insn used to refer to process-local map_fd */ | 99 | /* pseudo BPF_LD_IMM64 insn used to refer to process-local map_fd */ |
98 | #define BPF_LD_MAP_FD(DST, MAP_FD) \ | 100 | #define BPF_LD_MAP_FD(DST, MAP_FD) \ |