Commit bfa8fe95 authored by Martin KaFai Lau's avatar Martin KaFai Lau

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: default avatarMartin KaFai Lau <martin.lau@kernel.org>
parents c31b38cb fdf21497
...@@ -567,6 +567,12 @@ struct sk_filter { ...@@ -567,6 +567,12 @@ struct sk_filter {
DECLARE_STATIC_KEY_FALSE(bpf_stats_enabled_key); DECLARE_STATIC_KEY_FALSE(bpf_stats_enabled_key);
extern struct mutex nf_conn_btf_access_lock;
extern int (*nfct_btf_struct_access)(struct bpf_verifier_log *log, const struct btf *btf,
const struct btf_type *t, int off, int size,
enum bpf_access_type atype, u32 *next_btf_id,
enum bpf_type_flag *flag);
typedef unsigned int (*bpf_dispatcher_fn)(const void *ctx, typedef unsigned int (*bpf_dispatcher_fn)(const void *ctx,
const struct bpf_insn *insnsi, const struct bpf_insn *insnsi,
unsigned int (*bpf_func)(const void *, unsigned int (*bpf_func)(const void *,
......
...@@ -3,10 +3,7 @@ ...@@ -3,10 +3,7 @@
#ifndef _NF_CONNTRACK_BPF_H #ifndef _NF_CONNTRACK_BPF_H
#define _NF_CONNTRACK_BPF_H #define _NF_CONNTRACK_BPF_H
#include <linux/bpf.h>
#include <linux/btf.h>
#include <linux/kconfig.h> #include <linux/kconfig.h>
#include <linux/mutex.h>
#if (IS_BUILTIN(CONFIG_NF_CONNTRACK) && IS_ENABLED(CONFIG_DEBUG_INFO_BTF)) || \ #if (IS_BUILTIN(CONFIG_NF_CONNTRACK) && IS_ENABLED(CONFIG_DEBUG_INFO_BTF)) || \
(IS_MODULE(CONFIG_NF_CONNTRACK) && IS_ENABLED(CONFIG_DEBUG_INFO_BTF_MODULES)) (IS_MODULE(CONFIG_NF_CONNTRACK) && IS_ENABLED(CONFIG_DEBUG_INFO_BTF_MODULES))
...@@ -14,12 +11,6 @@ ...@@ -14,12 +11,6 @@
extern int register_nf_conntrack_bpf(void); extern int register_nf_conntrack_bpf(void);
extern void cleanup_nf_conntrack_bpf(void); extern void cleanup_nf_conntrack_bpf(void);
extern struct mutex nf_conn_btf_access_lock;
extern int (*nfct_bsa)(struct bpf_verifier_log *log, const struct btf *btf,
const struct btf_type *t, int off, int size,
enum bpf_access_type atype, u32 *next_btf_id,
enum bpf_type_flag *flag);
#else #else
static inline int register_nf_conntrack_bpf(void) static inline int register_nf_conntrack_bpf(void)
...@@ -31,16 +22,6 @@ static inline void cleanup_nf_conntrack_bpf(void) ...@@ -31,16 +22,6 @@ static inline void cleanup_nf_conntrack_bpf(void)
{ {
} }
static inline int nf_conntrack_btf_struct_access(struct bpf_verifier_log *log,
const struct btf *btf,
const struct btf_type *t, int off,
int size, enum bpf_access_type atype,
u32 *next_btf_id,
enum bpf_type_flag *flag)
{
return -EACCES;
}
#endif #endif
#endif /* _NF_CONNTRACK_BPF_H */ #endif /* _NF_CONNTRACK_BPF_H */
...@@ -8608,11 +8608,11 @@ static bool tc_cls_act_is_valid_access(int off, int size, ...@@ -8608,11 +8608,11 @@ static bool tc_cls_act_is_valid_access(int off, int size,
DEFINE_MUTEX(nf_conn_btf_access_lock); DEFINE_MUTEX(nf_conn_btf_access_lock);
EXPORT_SYMBOL_GPL(nf_conn_btf_access_lock); EXPORT_SYMBOL_GPL(nf_conn_btf_access_lock);
int (*nfct_bsa)(struct bpf_verifier_log *log, const struct btf *btf, int (*nfct_btf_struct_access)(struct bpf_verifier_log *log, const struct btf *btf,
const struct btf_type *t, int off, int size, const struct btf_type *t, int off, int size,
enum bpf_access_type atype, u32 *next_btf_id, enum bpf_access_type atype, u32 *next_btf_id,
enum bpf_type_flag *flag); enum bpf_type_flag *flag);
EXPORT_SYMBOL_GPL(nfct_bsa); EXPORT_SYMBOL_GPL(nfct_btf_struct_access);
static int tc_cls_act_btf_struct_access(struct bpf_verifier_log *log, static int tc_cls_act_btf_struct_access(struct bpf_verifier_log *log,
const struct btf *btf, const struct btf *btf,
...@@ -8628,8 +8628,8 @@ static int tc_cls_act_btf_struct_access(struct bpf_verifier_log *log, ...@@ -8628,8 +8628,8 @@ static int tc_cls_act_btf_struct_access(struct bpf_verifier_log *log,
flag); flag);
mutex_lock(&nf_conn_btf_access_lock); mutex_lock(&nf_conn_btf_access_lock);
if (nfct_bsa) if (nfct_btf_struct_access)
ret = nfct_bsa(log, btf, t, off, size, atype, next_btf_id, flag); ret = nfct_btf_struct_access(log, btf, t, off, size, atype, next_btf_id, flag);
mutex_unlock(&nf_conn_btf_access_lock); mutex_unlock(&nf_conn_btf_access_lock);
return ret; return ret;
...@@ -8708,8 +8708,8 @@ static int xdp_btf_struct_access(struct bpf_verifier_log *log, ...@@ -8708,8 +8708,8 @@ static int xdp_btf_struct_access(struct bpf_verifier_log *log,
flag); flag);
mutex_lock(&nf_conn_btf_access_lock); mutex_lock(&nf_conn_btf_access_lock);
if (nfct_bsa) if (nfct_btf_struct_access)
ret = nfct_bsa(log, btf, t, off, size, atype, next_btf_id, flag); ret = nfct_btf_struct_access(log, btf, t, off, size, atype, next_btf_id, flag);
mutex_unlock(&nf_conn_btf_access_lock); mutex_unlock(&nf_conn_btf_access_lock);
return ret; return ret;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/bpf_verifier.h> #include <linux/bpf_verifier.h>
#include <linux/bpf.h> #include <linux/bpf.h>
#include <linux/btf.h> #include <linux/btf.h>
#include <linux/filter.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/btf_ids.h> #include <linux/btf_ids.h>
...@@ -502,7 +503,7 @@ int register_nf_conntrack_bpf(void) ...@@ -502,7 +503,7 @@ int register_nf_conntrack_bpf(void)
ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS, &nf_conntrack_kfunc_set); ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS, &nf_conntrack_kfunc_set);
if (!ret) { if (!ret) {
mutex_lock(&nf_conn_btf_access_lock); mutex_lock(&nf_conn_btf_access_lock);
nfct_bsa = _nf_conntrack_btf_struct_access; nfct_btf_struct_access = _nf_conntrack_btf_struct_access;
mutex_unlock(&nf_conn_btf_access_lock); mutex_unlock(&nf_conn_btf_access_lock);
} }
...@@ -512,6 +513,6 @@ int register_nf_conntrack_bpf(void) ...@@ -512,6 +513,6 @@ int register_nf_conntrack_bpf(void)
void cleanup_nf_conntrack_bpf(void) void cleanup_nf_conntrack_bpf(void)
{ {
mutex_lock(&nf_conn_btf_access_lock); mutex_lock(&nf_conn_btf_access_lock);
nfct_bsa = NULL; nfct_btf_struct_access = NULL;
mutex_unlock(&nf_conn_btf_access_lock); mutex_unlock(&nf_conn_btf_access_lock);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment