Blob Blame History Raw
From: Andrii Nakryiko <andriin@fb.com>
Date: Tue, 28 Jul 2020 12:05:27 -0700
Subject: bpf: Fix build without CONFIG_NET when using BPF XDP link
Patch-mainline: v5.9-rc1
Git-commit: 310ad7970a0dec847563dc6dba9e7e587d545622
References: bsc#1177028

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")
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20200728190527.110830-1-andriin@fb.com
Acked-by: Gary Lin <glin@suse.com>
---
 kernel/bpf/syscall.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -3920,9 +3920,11 @@ static int link_create(union bpf_attr *a
 	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;
 	}