Commit 8ac2bd35 authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso

netfilter: conntrack: export nf_ct_acct_update()

This function allows you to update the conntrack counters.
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 73348fed
...@@ -65,6 +65,8 @@ static inline void nf_ct_set_acct(struct net *net, bool enable) ...@@ -65,6 +65,8 @@ static inline void nf_ct_set_acct(struct net *net, bool enable)
#endif #endif
} }
void nf_ct_acct_update(struct nf_conn *ct, u32 dir, unsigned int bytes);
void nf_conntrack_acct_pernet_init(struct net *net); void nf_conntrack_acct_pernet_init(struct net *net);
int nf_conntrack_acct_init(void); int nf_conntrack_acct_init(void);
......
...@@ -865,9 +865,7 @@ nf_conntrack_hash_check_insert(struct nf_conn *ct) ...@@ -865,9 +865,7 @@ nf_conntrack_hash_check_insert(struct nf_conn *ct)
} }
EXPORT_SYMBOL_GPL(nf_conntrack_hash_check_insert); EXPORT_SYMBOL_GPL(nf_conntrack_hash_check_insert);
static inline void nf_ct_acct_update(struct nf_conn *ct, void nf_ct_acct_update(struct nf_conn *ct, u32 dir, unsigned int bytes)
enum ip_conntrack_info ctinfo,
unsigned int len)
{ {
struct nf_conn_acct *acct; struct nf_conn_acct *acct;
...@@ -875,10 +873,11 @@ static inline void nf_ct_acct_update(struct nf_conn *ct, ...@@ -875,10 +873,11 @@ static inline void nf_ct_acct_update(struct nf_conn *ct,
if (acct) { if (acct) {
struct nf_conn_counter *counter = acct->counter; struct nf_conn_counter *counter = acct->counter;
atomic64_inc(&counter[CTINFO2DIR(ctinfo)].packets); atomic64_inc(&counter[dir].packets);
atomic64_add(len, &counter[CTINFO2DIR(ctinfo)].bytes); atomic64_add(bytes, &counter[dir].bytes);
} }
} }
EXPORT_SYMBOL_GPL(nf_ct_acct_update);
static void nf_ct_acct_merge(struct nf_conn *ct, enum ip_conntrack_info ctinfo, static void nf_ct_acct_merge(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
const struct nf_conn *loser_ct) const struct nf_conn *loser_ct)
...@@ -892,7 +891,7 @@ static void nf_ct_acct_merge(struct nf_conn *ct, enum ip_conntrack_info ctinfo, ...@@ -892,7 +891,7 @@ static void nf_ct_acct_merge(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
/* u32 should be fine since we must have seen one packet. */ /* u32 should be fine since we must have seen one packet. */
bytes = atomic64_read(&counter[CTINFO2DIR(ctinfo)].bytes); bytes = atomic64_read(&counter[CTINFO2DIR(ctinfo)].bytes);
nf_ct_acct_update(ct, ctinfo, bytes); nf_ct_acct_update(ct, CTINFO2DIR(ctinfo), bytes);
} }
} }
...@@ -1933,7 +1932,7 @@ void __nf_ct_refresh_acct(struct nf_conn *ct, ...@@ -1933,7 +1932,7 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,
WRITE_ONCE(ct->timeout, extra_jiffies); WRITE_ONCE(ct->timeout, extra_jiffies);
acct: acct:
if (do_acct) if (do_acct)
nf_ct_acct_update(ct, ctinfo, skb->len); nf_ct_acct_update(ct, CTINFO2DIR(ctinfo), skb->len);
} }
EXPORT_SYMBOL_GPL(__nf_ct_refresh_acct); EXPORT_SYMBOL_GPL(__nf_ct_refresh_acct);
...@@ -1941,7 +1940,7 @@ bool nf_ct_kill_acct(struct nf_conn *ct, ...@@ -1941,7 +1940,7 @@ bool nf_ct_kill_acct(struct nf_conn *ct,
enum ip_conntrack_info ctinfo, enum ip_conntrack_info ctinfo,
const struct sk_buff *skb) const struct sk_buff *skb)
{ {
nf_ct_acct_update(ct, ctinfo, skb->len); nf_ct_acct_update(ct, CTINFO2DIR(ctinfo), skb->len);
return nf_ct_delete(ct, 0, 0); return nf_ct_delete(ct, 0, 0);
} }
......
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