bpf: fix build without CONFIG_NET when using BPF XDP link
Subsystems (4)
PATCH 1/1 bpf: fix build without CONFIG_NET when using BPF XDP link
Entire net/core subsystem is not built without CONFIG_NET. linux/netdevice.h just assumes that it's always there, so the easiest way to fix this is to conditionally compile out bpf_xdp_link_attach() use in bpf/syscall.c.
--- kernel/bpf/syscall.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/bpf/syscall.c +2 -0
@@ -3923,9 +3923,11 @@ static int link_create(union bpf_attr *attr)case BPF_PROG_TYPE_SK_LOOKUP : ret =netns_bpf_link_create (attr, prog);break ; +#ifdef CONFIG_NET case BPF_PROG_TYPE_XDP : ret =bpf_xdp_link_attach (attr, prog);break ; +#endif default : ret = -EINVAL ; }
Signature · 1 line
2.24.1
Quoted 7 lines · Andrii Nakryiko
Entire net/core subsystem is not built without
CONFIG_NET.linux/netdevice.hjust assumes that it's always there, so the easiest way to fix this is to conditionally compile outbpf_xdp_link_attach()use inbpf/syscall.c.Reported-by Randy Dunlap <[email protected]>Fixes aa8d3a716b59 ("bpf, xdp: Add bpf_link-based XDP attachment API")Signed-off-by Andrii Nakryiko <[email protected]>
Thanks.
Quoted 21 lines
--- kernel/bpf/syscall.c | 2 ++ 1 file changed, 2 insertions(+)kernel/bpf/syscall.c +2
-0@@ -3923,9 +3923,11 @@ static int link_create(union bpf_attr *attr)case BPF_PROG_TYPE_SK_LOOKUP : ret =netns_bpf_link_create (attr, prog);break ; +#ifdef CONFIG_NET case BPF_PROG_TYPE_XDP : ret =bpf_xdp_link_attach (attr, prog);break ; +#endif default : ret = -EINVAL ; }
Signature · 1 line
~Randy
Quoted 11 lines · Randy Dunlap
Quoted 7 lines · Andrii Nakryiko
Entire net/core subsystem is not built without
CONFIG_NET.linux/netdevice.hjust assumes that it's always there, so the easiest way to fix this is to conditionally compile outbpf_xdp_link_attach()use inbpf/syscall.c.Reported-by Randy Dunlap <[email protected]>Fixes aa8d3a716b59 ("bpf, xdp: Add bpf_link-based XDP attachment API")Signed-off-by Andrii Nakryiko <[email protected]>
Quoted 7 lines · Andrii Nakryiko
Entire net/core subsystem is not built without
CONFIG_NET.linux/netdevice.hjust assumes that it's always there, so the easiest way to fix this is to conditionally compile outbpf_xdp_link_attach()use inbpf/syscall.c.Reported-by Randy Dunlap <[email protected]>Fixes aa8d3a716b59 ("bpf, xdp: Add bpf_link-based XDP attachment API")Signed-off-by Andrii Nakryiko <[email protected]>
Applied, thanks!