netfilter: conntrack: avoid useless indirection during conntrack destruction
[platform/kernel/linux-rpi.git] / include / linux / netfilter / nf_conntrack_common.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _NF_CONNTRACK_COMMON_H
3 #define _NF_CONNTRACK_COMMON_H
4
5 #include <linux/refcount.h>
6 #include <uapi/linux/netfilter/nf_conntrack_common.h>
7
8 struct ip_conntrack_stat {
9         unsigned int found;
10         unsigned int invalid;
11         unsigned int insert;
12         unsigned int insert_failed;
13         unsigned int clash_resolve;
14         unsigned int drop;
15         unsigned int early_drop;
16         unsigned int error;
17         unsigned int expect_new;
18         unsigned int expect_create;
19         unsigned int expect_delete;
20         unsigned int search_restart;
21         unsigned int chaintoolong;
22 };
23
24 #define NFCT_INFOMASK   7UL
25 #define NFCT_PTRMASK    ~(NFCT_INFOMASK)
26
27 struct nf_conntrack {
28         refcount_t use;
29 };
30
31 void nf_conntrack_destroy(struct nf_conntrack *nfct);
32
33 /* like nf_ct_put, but without module dependency on nf_conntrack */
34 static inline void nf_conntrack_put(struct nf_conntrack *nfct)
35 {
36         if (nfct && refcount_dec_and_test(&nfct->use))
37                 nf_conntrack_destroy(nfct);
38 }
39 static inline void nf_conntrack_get(struct nf_conntrack *nfct)
40 {
41         if (nfct)
42                 refcount_inc(&nfct->use);
43 }
44
45 #endif /* _NF_CONNTRACK_COMMON_H */