This source file includes following definitions.
- nf_conn_acct_find
- nf_ct_acct_ext_add
- nf_ct_acct_enabled
- nf_ct_set_acct
1
2
3
4
5
6 #ifndef _NF_CONNTRACK_ACCT_H
7 #define _NF_CONNTRACK_ACCT_H
8 #include <net/net_namespace.h>
9 #include <linux/netfilter/nf_conntrack_common.h>
10 #include <linux/netfilter/nf_conntrack_tuple_common.h>
11 #include <net/netfilter/nf_conntrack.h>
12 #include <net/netfilter/nf_conntrack_extend.h>
13
14 struct nf_conn_counter {
15 atomic64_t packets;
16 atomic64_t bytes;
17 };
18
19 struct nf_conn_acct {
20 struct nf_conn_counter counter[IP_CT_DIR_MAX];
21 };
22
23 static inline
24 struct nf_conn_acct *nf_conn_acct_find(const struct nf_conn *ct)
25 {
26 return nf_ct_ext_find(ct, NF_CT_EXT_ACCT);
27 }
28
29 static inline
30 struct nf_conn_acct *nf_ct_acct_ext_add(struct nf_conn *ct, gfp_t gfp)
31 {
32 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
33 struct net *net = nf_ct_net(ct);
34 struct nf_conn_acct *acct;
35
36 if (!net->ct.sysctl_acct)
37 return NULL;
38
39 acct = nf_ct_ext_add(ct, NF_CT_EXT_ACCT, gfp);
40 if (!acct)
41 pr_debug("failed to add accounting extension area");
42
43
44 return acct;
45 #else
46 return NULL;
47 #endif
48 }
49
50
51 static inline bool nf_ct_acct_enabled(struct net *net)
52 {
53 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
54 return net->ct.sysctl_acct != 0;
55 #else
56 return false;
57 #endif
58 }
59
60
61 static inline void nf_ct_set_acct(struct net *net, bool enable)
62 {
63 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
64 net->ct.sysctl_acct = enable;
65 #endif
66 }
67
68 void nf_conntrack_acct_pernet_init(struct net *net);
69
70 int nf_conntrack_acct_init(void);
71 void nf_conntrack_acct_fini(void);
72
73 #endif