mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-25 18:30:06 +00:00
6ae7989c9a
nf_ct_put() results in a usesless indirection: nf_ct_put -> nf_conntrack_put -> nf_conntrack_destroy -> rcu readlock + indirect call of ct_hooks->destroy(). There are two _put helpers: nf_ct_put and nf_conntrack_put. The latter is what should be used in code that MUST NOT cause a linker dependency on the conntrack module (e.g. calls from core network stack). Everyone else should call nf_ct_put() instead. A followup patch will convert a few nf_conntrack_put() calls to nf_ct_put(), in particular from modules that already have a conntrack dependency such as act_ct or even nf_conntrack itself. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
45 lines
1 KiB
C
45 lines
1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _NF_CONNTRACK_COMMON_H
|
|
#define _NF_CONNTRACK_COMMON_H
|
|
|
|
#include <linux/refcount.h>
|
|
#include <uapi/linux/netfilter/nf_conntrack_common.h>
|
|
|
|
struct ip_conntrack_stat {
|
|
unsigned int found;
|
|
unsigned int invalid;
|
|
unsigned int insert;
|
|
unsigned int insert_failed;
|
|
unsigned int clash_resolve;
|
|
unsigned int drop;
|
|
unsigned int early_drop;
|
|
unsigned int error;
|
|
unsigned int expect_new;
|
|
unsigned int expect_create;
|
|
unsigned int expect_delete;
|
|
unsigned int search_restart;
|
|
unsigned int chaintoolong;
|
|
};
|
|
|
|
#define NFCT_INFOMASK 7UL
|
|
#define NFCT_PTRMASK ~(NFCT_INFOMASK)
|
|
|
|
struct nf_conntrack {
|
|
refcount_t use;
|
|
};
|
|
|
|
void nf_conntrack_destroy(struct nf_conntrack *nfct);
|
|
|
|
/* like nf_ct_put, but without module dependency on nf_conntrack */
|
|
static inline void nf_conntrack_put(struct nf_conntrack *nfct)
|
|
{
|
|
if (nfct && refcount_dec_and_test(&nfct->use))
|
|
nf_conntrack_destroy(nfct);
|
|
}
|
|
static inline void nf_conntrack_get(struct nf_conntrack *nfct)
|
|
{
|
|
if (nfct)
|
|
refcount_inc(&nfct->use);
|
|
}
|
|
|
|
#endif /* _NF_CONNTRACK_COMMON_H */
|