OSDN Git Service

bpf: Define cgroup_bpf_enabled for CONFIG_CGROUP_BPF=n
authorAndrey Ignatov <rdna@fb.com>
Fri, 25 May 2018 15:55:22 +0000 (08:55 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 28 May 2018 15:41:01 +0000 (17:41 +0200)
commit13193b0f392f5a65d0d54185cb95ed5e99c0a5bf
treeacffc582494e2e9dc8599bccac153de6f66020dd
parent3b296633ae6b91bfff815eb005d220b6ad4a47b1
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>
include/linux/bpf-cgroup.h