Skip to content

Commit 13193b0

Browse files
rdnaborkmann
authored andcommitted
bpf: Define cgroup_bpf_enabled for CONFIG_CGROUP_BPF=n
Static key is used to enable/disable cgroup-bpf related code paths at run time. Though it's not defined when cgroup-bpf is disabled at compile time, i.e. CONFIG_CGROUP_BPF=n, and if some code wants to use it, it has to do this: #ifdef CONFIG_CGROUP_BPF if (cgroup_bpf_enabled) { /* ... some work ... */ } #endif This code can be simplified by setting cgroup_bpf_enabled to 0 for CONFIG_CGROUP_BPF=n case: if (cgroup_bpf_enabled) { /* ... some work ... */ } And it aligns well with existing BPF_CGROUP_RUN_PROG_* macros that defined for both states of CONFIG_CGROUP_BPF. Signed-off-by: Andrey Ignatov <rdna@fb.com> Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent 3b29663 commit 13193b0

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

include/linux/bpf-cgroup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ struct cgroup_bpf {};
185185
static inline void cgroup_bpf_put(struct cgroup *cgrp) {}
186186
static inline int cgroup_bpf_inherit(struct cgroup *cgrp) { return 0; }
187187

188+
#define cgroup_bpf_enabled (0)
188189
#define BPF_CGROUP_PRE_CONNECT_ENABLED(sk) (0)
189190
#define BPF_CGROUP_RUN_PROG_INET_INGRESS(sk,skb) ({ 0; })
190191
#define BPF_CGROUP_RUN_PROG_INET_EGRESS(sk,skb) ({ 0; })

0 commit comments

Comments
 (0)