Commit 7cce782e authored by Arnd Bergmann's avatar Arnd Bergmann Committed by David S. Miller

bpf: fix link error without CONFIG_NET

I ran into this link error with the latest net-next plus linux-next
trees when networking is disabled:

kernel/bpf/verifier.o:(.rodata+0x2958): undefined reference to `tc_cls_act_analyzer_ops'
kernel/bpf/verifier.o:(.rodata+0x2970): undefined reference to `xdp_analyzer_ops'

It seems that the code was written to deal with varying contents of
the arrray, but the actual #ifdef was missing. Both tc_cls_act_analyzer_ops
and xdp_analyzer_ops are defined in the core networking code, so adding
a check for CONFIG_NET seems appropriate here, and I've verified this with
many randconfig builds

Fixes: 4f9218aa ("bpf: move knowledge about post-translation offsets out of verifier")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 05428729
...@@ -4588,8 +4588,10 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr) ...@@ -4588,8 +4588,10 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr)
} }
static const struct bpf_verifier_ops * const bpf_analyzer_ops[] = { static const struct bpf_verifier_ops * const bpf_analyzer_ops[] = {
#ifdef CONFIG_NET
[BPF_PROG_TYPE_XDP] = &xdp_analyzer_ops, [BPF_PROG_TYPE_XDP] = &xdp_analyzer_ops,
[BPF_PROG_TYPE_SCHED_CLS] = &tc_cls_act_analyzer_ops, [BPF_PROG_TYPE_SCHED_CLS] = &tc_cls_act_analyzer_ops,
#endif
}; };
int bpf_analyzer(struct bpf_prog *prog, const struct bpf_ext_analyzer_ops *ops, int bpf_analyzer(struct bpf_prog *prog, const struct bpf_ext_analyzer_ops *ops,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment