diff mbox series

[bpf-next] bpf: fix build without CONFIG_NET when using BPF XDP link

Message ID 20200728190527.110830-1-andriin@fb.com
State Accepted
Delegated to: BPF Maintainers
Headers show
Series [bpf-next] bpf: fix build without CONFIG_NET when using BPF XDP link | expand

Commit Message

Andrii Nakryiko July 28, 2020, 7:05 p.m. UTC
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.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Fixes: aa8d3a716b59 ("bpf, xdp: Add bpf_link-based XDP attachment API")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 kernel/bpf/syscall.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Randy Dunlap July 28, 2020, 8:07 p.m. UTC | #1
On 7/28/20 12:05 PM, Andrii Nakryiko wrote:
> 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.
> 
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Fixes: aa8d3a716b59 ("bpf, xdp: Add bpf_link-based XDP attachment API")
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>

Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested

Thanks.

> ---
>  kernel/bpf/syscall.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 0e8c88db7e7a..cd3d599e9e90 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -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;
>  	}
>
Song Liu July 28, 2020, 8:23 p.m. UTC | #2
On Tue, Jul 28, 2020 at 1:08 PM Randy Dunlap <rdunlap@infradead.org> wrote:
>
> On 7/28/20 12:05 PM, Andrii Nakryiko wrote:
> > 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.
> >
> > Reported-by: Randy Dunlap <rdunlap@infradead.org>
> > Fixes: aa8d3a716b59 ("bpf, xdp: Add bpf_link-based XDP attachment API")
> > Signed-off-by: Andrii Nakryiko <andriin@fb.com>
>
> Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested

Acked-by: Song Liu <songliubraving@fb.com>
Daniel Borkmann July 28, 2020, 10:32 p.m. UTC | #3
On 7/28/20 9:05 PM, Andrii Nakryiko wrote:
> 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.
> 
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Fixes: aa8d3a716b59 ("bpf, xdp: Add bpf_link-based XDP attachment API")
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>

Applied, thanks!
diff mbox series

Patch

diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 0e8c88db7e7a..cd3d599e9e90 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -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;
 	}