Subject: Re: linux-next: Tree for Jul 27 (kernel/bpf/syscall.o)

From: Randy Dunlap <[email-masked]>
Date: Mon, 27 Jul 2020 23:00:51 -0700

On 7/27/20 10:48 PM, Andrii Nakryiko wrote:
> On Mon, Jul 27, 2020 at 11:58 AM Randy Dunlap <[email-masked]> wrote:
>>
>> On 7/27/20 6:23 AM, Stephen Rothwell wrote:
>>> Hi all,
>>>
>>> Changes since 20200724:
>>>
>>
>> on i386:
>> when CONFIG_XPS is not set/enabled:
>>
>> ld: kernel/bpf/syscall.o: in function `__do_sys_bpf':
>> syscall.c:(.text+0x4482): undefined reference to `bpf_xdp_link_attach'
>>
> 
> I can't repro this on x86-64 with CONFIG_XPS unset. Do you mind
> sharing the exact config you've used?

No problem. I see this on i386 or x86_64. I am attaching the x86_64
randconfig file instead of the i386 one.

> I see that kernel/bpf/syscall.c doesn't include linux/netdevice.h
> directly, so something must be preventing netdevice.h to eventually
> get to bpf/syscall.c, but instead of guessing on the fix, I'd like to
> repro it first. Thanks!

The build failure was causing me to see lots of builds failing, so I made
a simple patch so that I could get past this issue.  My patch follows.
Feel free to fix it any way you like.

Thanks.
---
---
 kernel/bpf/syscall.c |    4 ++++
 1 file changed, 4 insertions(+)

--- mmotm-2020-0727-1818.orig/kernel/bpf/syscall.c
+++ mmotm-2020-0727-1818/kernel/bpf/syscall.c
@@ -3924,7 +3924,11 @@ static int link_create(union bpf_attr *a
 		ret = netns_bpf_link_create(attr, prog);
 		break;
 	case BPF_PROG_TYPE_XDP:
+#ifdef CONFIG_XPS
 		ret = bpf_xdp_link_attach(attr, prog);
+#else
+		ret = -EINVAL;
+#endif
 		break;
 	default:
 		ret = -EINVAL;