Skip to content

Commit 4e537f7

Browse files
borkmannIngo Molnar
authored andcommitted
bpf: Make internal bpf API independent of CONFIG_BPF_SYSCALL #ifdefs
Socket filter code and other subsystems with upcoming eBPF support should not need to deal with the fact that we have CONFIG_BPF_SYSCALL defined or not. Having the bpf syscall as a config option is a nice thing and I'd expect it to stay that way for expert users (I presume one day the default setting of it might change, though), but code making use of it should not care if it's actually enabled or not. Instead, hide this via header files and let the rest deal with it. Signed-off-by: Daniel Borkmann <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Reviewed-by: Masami Hiramatsu <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: David S. Miller <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 223aa64 commit 4e537f7

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

include/linux/bpf.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,6 @@ struct bpf_prog_type_list {
113113
enum bpf_prog_type type;
114114
};
115115

116-
void bpf_register_prog_type(struct bpf_prog_type_list *tl);
117-
118116
struct bpf_prog;
119117

120118
struct bpf_prog_aux {
@@ -129,11 +127,25 @@ struct bpf_prog_aux {
129127
};
130128

131129
#ifdef CONFIG_BPF_SYSCALL
130+
void bpf_register_prog_type(struct bpf_prog_type_list *tl);
131+
132132
void bpf_prog_put(struct bpf_prog *prog);
133+
struct bpf_prog *bpf_prog_get(u32 ufd);
133134
#else
134-
static inline void bpf_prog_put(struct bpf_prog *prog) {}
135+
static inline void bpf_register_prog_type(struct bpf_prog_type_list *tl)
136+
{
137+
}
138+
139+
static inline struct bpf_prog *bpf_prog_get(u32 ufd)
140+
{
141+
return ERR_PTR(-EOPNOTSUPP);
142+
}
143+
144+
static inline void bpf_prog_put(struct bpf_prog *prog)
145+
{
146+
}
135147
#endif
136-
struct bpf_prog *bpf_prog_get(u32 ufd);
148+
137149
/* verify correctness of eBPF program */
138150
int bpf_check(struct bpf_prog *fp, union bpf_attr *attr);
139151

0 commit comments

Comments
 (0)