bpf: Fix register_bpf_struct_ops() dummy
Subsystems (7)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/2 bpf: Fix register_bpf_struct_ops() dummy
If CONFIG_BPF_SYSCALL=y, but CONFIG_BPF_JIT=n:
net/smc/smc_hs_bpf.c: In function ‘bpf_smc_hs_ctrl_init’:
include/linux/bpf.h:2068:50: error: statement with no effect [-Werror=unused-value]
2068 | #define register_bpf_struct_ops(st_ops, type) ({ (void *)(st_ops); 0; })
| ^~~~~~~~~~~~~~~~
net/smc/smc_hs_bpf.c:139:16: note: in expansion of macro ‘register_bpf_struct_ops’
139 | return register_bpf_struct_ops(&bpf_smc_hs_ctrl_ops, smc_hs_ctrl);
| ^~~~~~~~~~~~~~~~~~~~~~~As type is not a variable, but a variable type, this cannot be fixed by just converting register_bpf_struct_ops() into a static inline function. Hence fix this by introducing a static inline intermediate dummy.
--- include/linux/bpf.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/linux/bpf.h +5 -1
@@ -2065,7 +2065,11 @@ int bpf_struct_ops_desc_init(struct bpf_struct_ops_desc *st_ops_desc,void bpf_map_struct_ops_info_fill (struct bpf_map_info *info,struct bpf_map *map);void bpf_struct_ops_desc_release (struct bpf_struct_ops_desc *st_ops_desc);#else -#define register_bpf_struct_ops (st_ops, type) ({ (void *)(st_ops); 0; }) +static inline int __register_bpf_struct_ops (struct bpf_struct_ops *st_ops) +{ +return 0 ; +} +#define register_bpf_struct_ops (st_ops, type) __register_bpf_struct_ops(st_ops)static inline bool bpf_try_module_get (const void *data,struct module *owner) {return try_module_get (owner);
Signature · 1 line
2.43.0
Martin KaFai Lau
reviewerQuoted 25 lines · Geert Uytterhoeven
If
CONFIG_BPF_SYSCALL=y, butCONFIG_BPF_JIT=n:net/smc/smc_hs_bpf.c: In function ‘bpf_smc_hs_ctrl_init’: include/linux/bpf.h:2068:50: error: statement with no effect [-Werror=unused-value] 2068 | #define register_bpf_struct_ops(st_ops, type) ({ (void *)(st_ops); 0; }) | ^~~~~~~~~~~~~~~~ net/smc/smc_hs_bpf.c:139:16: note: in expansion of macro ‘register_bpf_struct_ops’ 139 | return register_bpf_struct_ops(&bpf_smc_hs_ctrl_ops, smc_hs_ctrl); | ^~~~~~~~~~~~~~~~~~~~~~~As type is not a variable, but a variable type, this cannot be fixed by just converting
register_bpf_struct_ops()into a static inline function. Hence fix this by introducing a static inline intermediate dummy.Fixes f6be98d19985411c ("bpf, net: switch to dynamic registration")Signed-off-by Geert Uytterhoeven <[email protected]>--- include/linux/bpf.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)include/linux/bpf.h +0
-0
include/linux/bpf.h int bpf_struct_ops_desc_init(struct bpf_struct_ops_desc *st_ops_desc, · line 2072
Quoted 9 lines
include/linux/bpf.h +5
-1@@ -2065,7 +2065,11 @@ int bpf_struct_ops_desc_init(struct bpf_struct_ops_desc *st_ops_desc,void bpf_map_struct_ops_info_fill (struct bpf_map_info *info,struct bpf_map *map);void bpf_struct_ops_desc_release (struct bpf_struct_ops_desc *st_ops_desc);#else -#define register_bpf_struct_ops (st_ops, type) ({ (void *)(st_ops); 0; }) +static inline int __register_bpf_struct_ops (struct bpf_struct_ops *st_ops) +{ +return 0 ; +} +#define register_bpf_struct_ops (st_ops, type) __register_bpf_struct_ops(st_ops)
Only patch 2 is needed. This empty register_bpf_struct_ops should be removed in the bpf-next tree as a cleanup.
PATCH 2/2 net: smc: SMC_HS_CTRL_BPF should depend on BPF_JIT
In reply to a message not in the archiveIf CONFIG_BPF_SYSCALL=y, but CONFIG_BPF_JIT=n:
net/smc/smc_hs_bpf.c: In function ‘bpf_smc_hs_ctrl_init’:
include/linux/bpf.h:2068:50: error: statement with no effect [-Werror=unused-value]
2068 | #define register_bpf_struct_ops(st_ops, type) ({ (void *)(st_ops); 0; })
| ^~~~~~~~~~~~~~~~
net/smc/smc_hs_bpf.c:139:16: note: in expansion of macro ‘register_bpf_struct_ops’
139 | return register_bpf_struct_ops(&bpf_smc_hs_ctrl_ops, smc_hs_ctrl);
| ^~~~~~~~~~~~~~~~~~~~~~~While this compile error is caused by a bug in <linux/bpf.h>, none of the code in net/smc/smc_hs_bpf.c becomes effective if CONFIG_BPF_JIT is not enabled. Hence add a dependency on BPF_JIT.
While at it, add the missing newline at the end of the file.
--- net/smc/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/smc/Kconfig +2 -2
@@ -22,10 +22,10 @@ config SMC_DIAG config SMC_HS_CTRL_BPF bool "Generic eBPF hook for SMC handshake flow" - depends on SMC && BPF_SYSCALL + depends on SMC && BPF_JIT && BPF_SYSCALL default y help SMC_HS_CTRL_BPF enables support to register generic eBPF hook for SMC handshake flow, which offer much greater flexibility in modifying the behavior of the SMC protocol stack compared to a complete kernel-based approach. Select - this option if you want filtring the handshake process via eBPF programs. + this option if you want filtring the handshake process via eBPF programs.
Signature · 1 line
2.43.0
Re: [PATCH 2/2] net: smc: SMC_HS_CTRL_BPF should depend on BPF_JIT
Quoted 30 lines · Geert Uytterhoeven
If
CONFIG_BPF_SYSCALL=y, butCONFIG_BPF_JIT=n:net/smc/smc_hs_bpf.c: In function ‘bpf_smc_hs_ctrl_init’: include/linux/bpf.h:2068:50: error: statement with no effect [-Werror=unused-value] 2068 | #define register_bpf_struct_ops(st_ops, type) ({ (void *)(st_ops); 0; }) | ^~~~~~~~~~~~~~~~ net/smc/smc_hs_bpf.c:139:16: note: in expansion of macro ‘register_bpf_struct_ops’ 139 | return register_bpf_struct_ops(&bpf_smc_hs_ctrl_ops, smc_hs_ctrl); | ^~~~~~~~~~~~~~~~~~~~~~~While this compile error is caused by a bug in <
linux/bpf.h>, none of the code innet/smc/smc_hs_bpf.cbecomes effective ifCONFIG_BPF_JITis not enabled. Hence add a dependency onBPF_JIT.While at it, add the missing newline at the end of the file.
Fixes 15f295f55656658e ("net/smc: bpf: Introduce generic hook for handshake flow")Signed-off-by Geert Uytterhoeven <[email protected]>--- net/smc/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/smc/Kconfig +0
-0@@ -22,10 +22,10 @@ config SMC_DIAG config SMC_HS_CTRL_BPF bool "Generic eBPF hook for SMC handshake flow"
net/smc/Kconfig config SMC_DIAG · line 31
Quoted 10 lines
net/smc/Kconfig +2
-2- depends on SMC && BPF_SYSCALL + depends on SMC && BPF_JIT && BPF_SYSCALL default y help SMC_HS_CTRL_BPF enables support to register generic eBPF hook for SMC handshake flow, which offer much greater flexibility in modifying the behavior of the SMC protocol stack compared to a complete kernel-based approach. Select - this option if you want filtring the handshake process via eBPF programs. + this option if you want filtring the handshake process via eBPF programs.
I have applied patch 2 to the bpf tree. Thanks.