Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'bpf: Small nf_conn cleanups'

Daniel Xu says:

====================

This patchset cleans up a few small things:

* Delete unused stub
* Rename variable to be more descriptive
* Fix some `extern` declaration warnings

Past discussion:
- v2: https://lore.kernel.org/bpf/cover.1663616584.git.dxu@dxuuu.xyz/

Changes since v2:
- Remove unused #include's
- Move #include <linux/filter.h> to .c
====================

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>

+18 -30
+6
include/linux/filter.h
··· 567 567 568 568 DECLARE_STATIC_KEY_FALSE(bpf_stats_enabled_key); 569 569 570 + extern struct mutex nf_conn_btf_access_lock; 571 + extern int (*nfct_btf_struct_access)(struct bpf_verifier_log *log, const struct btf *btf, 572 + const struct btf_type *t, int off, int size, 573 + enum bpf_access_type atype, u32 *next_btf_id, 574 + enum bpf_type_flag *flag); 575 + 570 576 typedef unsigned int (*bpf_dispatcher_fn)(const void *ctx, 571 577 const struct bpf_insn *insnsi, 572 578 unsigned int (*bpf_func)(const void *,
-19
include/net/netfilter/nf_conntrack_bpf.h
··· 3 3 #ifndef _NF_CONNTRACK_BPF_H 4 4 #define _NF_CONNTRACK_BPF_H 5 5 6 - #include <linux/bpf.h> 7 - #include <linux/btf.h> 8 6 #include <linux/kconfig.h> 9 - #include <linux/mutex.h> 10 7 11 8 #if (IS_BUILTIN(CONFIG_NF_CONNTRACK) && IS_ENABLED(CONFIG_DEBUG_INFO_BTF)) || \ 12 9 (IS_MODULE(CONFIG_NF_CONNTRACK) && IS_ENABLED(CONFIG_DEBUG_INFO_BTF_MODULES)) 13 10 14 11 extern int register_nf_conntrack_bpf(void); 15 12 extern void cleanup_nf_conntrack_bpf(void); 16 - 17 - extern struct mutex nf_conn_btf_access_lock; 18 - extern int (*nfct_bsa)(struct bpf_verifier_log *log, const struct btf *btf, 19 - const struct btf_type *t, int off, int size, 20 - enum bpf_access_type atype, u32 *next_btf_id, 21 - enum bpf_type_flag *flag); 22 13 23 14 #else 24 15 ··· 20 29 21 30 static inline void cleanup_nf_conntrack_bpf(void) 22 31 { 23 - } 24 - 25 - static inline int nf_conntrack_btf_struct_access(struct bpf_verifier_log *log, 26 - const struct btf *btf, 27 - const struct btf_type *t, int off, 28 - int size, enum bpf_access_type atype, 29 - u32 *next_btf_id, 30 - enum bpf_type_flag *flag) 31 - { 32 - return -EACCES; 33 32 } 34 33 35 34 #endif
+9 -9
net/core/filter.c
··· 8608 8608 DEFINE_MUTEX(nf_conn_btf_access_lock); 8609 8609 EXPORT_SYMBOL_GPL(nf_conn_btf_access_lock); 8610 8610 8611 - int (*nfct_bsa)(struct bpf_verifier_log *log, const struct btf *btf, 8612 - const struct btf_type *t, int off, int size, 8613 - enum bpf_access_type atype, u32 *next_btf_id, 8614 - enum bpf_type_flag *flag); 8615 - EXPORT_SYMBOL_GPL(nfct_bsa); 8611 + int (*nfct_btf_struct_access)(struct bpf_verifier_log *log, const struct btf *btf, 8612 + const struct btf_type *t, int off, int size, 8613 + enum bpf_access_type atype, u32 *next_btf_id, 8614 + enum bpf_type_flag *flag); 8615 + EXPORT_SYMBOL_GPL(nfct_btf_struct_access); 8616 8616 8617 8617 static int tc_cls_act_btf_struct_access(struct bpf_verifier_log *log, 8618 8618 const struct btf *btf, ··· 8628 8628 flag); 8629 8629 8630 8630 mutex_lock(&nf_conn_btf_access_lock); 8631 - if (nfct_bsa) 8632 - ret = nfct_bsa(log, btf, t, off, size, atype, next_btf_id, flag); 8631 + if (nfct_btf_struct_access) 8632 + ret = nfct_btf_struct_access(log, btf, t, off, size, atype, next_btf_id, flag); 8633 8633 mutex_unlock(&nf_conn_btf_access_lock); 8634 8634 8635 8635 return ret; ··· 8708 8708 flag); 8709 8709 8710 8710 mutex_lock(&nf_conn_btf_access_lock); 8711 - if (nfct_bsa) 8712 - ret = nfct_bsa(log, btf, t, off, size, atype, next_btf_id, flag); 8711 + if (nfct_btf_struct_access) 8712 + ret = nfct_btf_struct_access(log, btf, t, off, size, atype, next_btf_id, flag); 8713 8713 mutex_unlock(&nf_conn_btf_access_lock); 8714 8714 8715 8715 return ret;
+3 -2
net/netfilter/nf_conntrack_bpf.c
··· 9 9 #include <linux/bpf_verifier.h> 10 10 #include <linux/bpf.h> 11 11 #include <linux/btf.h> 12 + #include <linux/filter.h> 12 13 #include <linux/mutex.h> 13 14 #include <linux/types.h> 14 15 #include <linux/btf_ids.h> ··· 503 502 ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS, &nf_conntrack_kfunc_set); 504 503 if (!ret) { 505 504 mutex_lock(&nf_conn_btf_access_lock); 506 - nfct_bsa = _nf_conntrack_btf_struct_access; 505 + nfct_btf_struct_access = _nf_conntrack_btf_struct_access; 507 506 mutex_unlock(&nf_conn_btf_access_lock); 508 507 } 509 508 ··· 513 512 void cleanup_nf_conntrack_bpf(void) 514 513 { 515 514 mutex_lock(&nf_conn_btf_access_lock); 516 - nfct_bsa = NULL; 515 + nfct_btf_struct_access = NULL; 517 516 mutex_unlock(&nf_conn_btf_access_lock); 518 517 }