]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ebpf: export BPF_PSEUDO_MAP_FD to uapi
authorDaniel Borkmann <daniel@iogearbox.net>
Sun, 1 Mar 2015 11:31:43 +0000 (12:31 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 1 Mar 2015 19:05:19 +0000 (14:05 -0500)
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>
include/linux/filter.h
include/uapi/linux/bpf.h
samples/bpf/libbpf.h

index caac2087a4d5e7479e272b6dc5da23d7c90c9fd7..5e3863d5f666ce62389e9d4cea4fccfa534b6f69 100644 (file)
@@ -145,8 +145,6 @@ struct bpf_prog_aux;
                .off   = 0,                                     \
                .imm   = ((__u64) (IMM)) >> 32 })
 
-#define BPF_PSEUDO_MAP_FD      1
-
 /* pseudo BPF_LD_IMM64 insn used to refer to process-local map_fd */
 #define BPF_LD_MAP_FD(DST, MAP_FD)                             \
        BPF_LD_IMM64_RAW(DST, BPF_PSEUDO_MAP_FD, MAP_FD)
index 45da7ec7d2742235e05b2ea53ab19d80af64794f..0248180bf2e2276cb27174d9686eeb6a4d303d6c 100644 (file)
@@ -120,6 +120,8 @@ enum bpf_prog_type {
        BPF_PROG_TYPE_SOCKET_FILTER,
 };
 
+#define BPF_PSEUDO_MAP_FD      1
+
 /* flags for BPF_MAP_UPDATE_ELEM command */
 #define BPF_ANY                0 /* create new element or update existing */
 #define BPF_NOEXIST    1 /* create new element if it didn't exist */
index 58c5fe1bdba1f08c278a750e69a7a32f706f819c..a6bb7e9c22c39b046dc97be982ab17b9d983b1b1 100644 (file)
@@ -92,7 +92,9 @@ extern char bpf_log_buf[LOG_BUF_SIZE];
                .off   = 0,                                     \
                .imm   = ((__u64) (IMM)) >> 32 })
 
-#define BPF_PSEUDO_MAP_FD      1
+#ifndef BPF_PSEUDO_MAP_FD
+# define BPF_PSEUDO_MAP_FD     1
+#endif
 
 /* pseudo BPF_LD_IMM64 insn used to refer to process-local map_fd */
 #define BPF_LD_MAP_FD(DST, MAP_FD)                             \