bpf, netns: Fix build without CONFIG_INET
Subsystems (3)
PATCH 1/1 bpf, netns: Fix build without CONFIG_INET
When CONFIG_NET is set but CONFIG_INET isn't, build fails with:
ld: kernel/bpf/net_namespace.o: in function `netns_bpf_attach_type_unneed':
kernel/bpf/net_namespace.c:32: undefined reference to `bpf_sk_lookup_enabled'
ld: kernel/bpf/net_namespace.o: in function `netns_bpf_attach_type_need':
kernel/bpf/net_namespace.c:43: undefined reference to `bpf_sk_lookup_enabled'
This is because without CONFIG_INET bpf_sk_lookup_enabled symbol is not available. Wrap references to bpf_sk_lookup_enabled with preprocessor conditionals.
--- kernel/bpf/net_namespace.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/bpf/net_namespace.c +4 -0
@@ -28,9 +28,11 @@ DEFINE_MUTEX(netns_bpf_mutex);static void netns_bpf_attach_type_unneed (enum netns_bpf_attach_type type) {switch (type) { +#ifdef CONFIG_INET case NETNS_BPF_SK_LOOKUP :static_branch_dec (&bpf_sk_lookup_enabled);break ; +#endif default :break ; }
@@ -39,9 +41,11 @@ static void netns_bpf_attach_type_unneed(enum netns_bpf_attach_type type)static void netns_bpf_attach_type_need (enum netns_bpf_attach_type type) {switch (type) { +#ifdef CONFIG_INET case NETNS_BPF_SK_LOOKUP :static_branch_inc (&bpf_sk_lookup_enabled);break ; +#endif default :break ; }
Signature · 1 line
2.25.4
Quoted 7 lines · Jakub Sitnicki
When
CONFIG_NETis set butCONFIG_INETisn't, build fails with:ld:
kernel/bpf/net_namespace.o: in function `netns_bpf_attach_type_unneed':
kernel/bpf/net_namespace.c:32: undefined reference to `bpf_sk_lookup_enabled'
ld:kernel/bpf/net_namespace.o: in function `netns_bpf_attach_type_need':
kernel/bpf/net_namespace.c:43: undefined reference to `bpf_sk_lookup_enabled'
Quoted 8 lines
This is because without
CONFIG_INETbpf_sk_lookup_enabledsymbol is not available. Wrap references tobpf_sk_lookup_enabledwith preprocessor conditionals.Fixes 1559b4aa1db4 ("inet: Run SK_LOOKUP BPF program on socket lookup")Reported-by Randy Dunlap <[email protected]>Reported-by Stephen Rothwell <[email protected]>Signed-off-by Jakub Sitnicki <[email protected]>
Thanks.
Quoted 33 lines
--- kernel/bpf/net_namespace.c | 4 ++++ 1 file changed, 4 insertions(+)kernel/bpf/net_namespace.c +4
-0@@ -28,9 +28,11 @@ DEFINE_MUTEX(netns_bpf_mutex);static void netns_bpf_attach_type_unneed (enum netns_bpf_attach_type type) {switch (type) { +#ifdef CONFIG_INET case NETNS_BPF_SK_LOOKUP :static_branch_dec (&bpf_sk_lookup_enabled);break ; +#endif default :break ; }@@ -39,9 +41,11 @@ static void netns_bpf_attach_type_unneed(enum netns_bpf_attach_type type)static void netns_bpf_attach_type_need (enum netns_bpf_attach_type type) {switch (type) { +#ifdef CONFIG_INET case NETNS_BPF_SK_LOOKUP :static_branch_inc (&bpf_sk_lookup_enabled);break ; +#endif default :break ; }
Signature · 1 line
~Randy
Alexei Starovoitov
AppliedQuoted 13 lines · Randy Dunlap
Quoted 11 lines · Jakub Sitnicki
When
CONFIG_NETis set butCONFIG_INETisn't, build fails with:ld:
kernel/bpf/net_namespace.o: in function `netns_bpf_attach_type_unneed':
kernel/bpf/net_namespace.c:32: undefined reference to `bpf_sk_lookup_enabled'
ld:kernel/bpf/net_namespace.o: in function `netns_bpf_attach_type_need':
kernel/bpf/net_namespace.c:43: undefined reference to `bpf_sk_lookup_enabled'This is because without
CONFIG_INETbpf_sk_lookup_enabledsymbol is not available. Wrap references tobpf_sk_lookup_enabledwith preprocessor conditionals.
Quoted 6 lines
Quoted 4 lines
Fixes 1559b4aa1db4 ("inet: Run SK_LOOKUP BPF program on socket lookup")Reported-by Randy Dunlap <[email protected]>Reported-by Stephen Rothwell <[email protected]>Signed-off-by Jakub Sitnicki <[email protected]>
Applied. Thanks