Skip to contentSkip to conversation

bpf: fix build without CONFIG_NET when using BPF XDP link

PATCH Applied Andrii Nakryiko 4 participants 4 messages Jul 28, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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.

Fixes aa8d3a716b59 ("bpf, xdp: Add bpf_link-based XDP attachment API")
---
 kernel/bpf/syscall.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/bpf/syscall.c +2 -0
index 0e8c88db7e7a..cd3d599e9e90 100644
@@ -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
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Andrii Nakryiko

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.

Fixes aa8d3a716b59 ("bpf, xdp: Add bpf_link-based XDP attachment API")

Thanks.

Quoted 21 lines
---
 kernel/bpf/syscall.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/bpf/syscall.c +2 -0
index 0e8c88db7e7a..cd3d599e9e90 100644
@@ -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
reviewer Acked-by
#2 lore raw
Quoted 11 lines · Randy Dunlap
Quoted 7 lines · Andrii Nakryiko

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.

Fixes aa8d3a716b59 ("bpf, xdp: Add bpf_link-based XDP attachment API")
maintainer Applied
#3 lore raw
In reply to Andrii Nakryiko
Quoted 7 lines · Andrii Nakryiko

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.

Fixes aa8d3a716b59 ("bpf, xdp: Add bpf_link-based XDP attachment API")

Applied, thanks!