Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: conntrack: add nf_ct_acct_add()

Add nf_ct_acct_add function to update the conntrack counter
with packets and bytes.

Signed-off-by: wenxu <wenxu@ucloud.cn>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

wenxu and committed by
Pablo Neira Ayuso
9312eaba d56aab26

+14 -4
+10 -1
include/net/netfilter/nf_conntrack_acct.h
··· 65 65 #endif 66 66 } 67 67 68 - void nf_ct_acct_update(struct nf_conn *ct, u32 dir, unsigned int bytes); 68 + void nf_ct_acct_add(struct nf_conn *ct, u32 dir, unsigned int packets, 69 + unsigned int bytes); 70 + 71 + static inline void nf_ct_acct_update(struct nf_conn *ct, u32 dir, 72 + unsigned int bytes) 73 + { 74 + #if IS_ENABLED(CONFIG_NF_CONNTRACK) 75 + nf_ct_acct_add(ct, dir, 1, bytes); 76 + #endif 77 + } 69 78 70 79 void nf_conntrack_acct_pernet_init(struct net *net); 71 80
+4 -3
net/netfilter/nf_conntrack_core.c
··· 865 865 } 866 866 EXPORT_SYMBOL_GPL(nf_conntrack_hash_check_insert); 867 867 868 - void nf_ct_acct_update(struct nf_conn *ct, u32 dir, unsigned int bytes) 868 + void nf_ct_acct_add(struct nf_conn *ct, u32 dir, unsigned int packets, 869 + unsigned int bytes) 869 870 { 870 871 struct nf_conn_acct *acct; 871 872 ··· 874 873 if (acct) { 875 874 struct nf_conn_counter *counter = acct->counter; 876 875 877 - atomic64_inc(&counter[dir].packets); 876 + atomic64_add(packets, &counter[dir].packets); 878 877 atomic64_add(bytes, &counter[dir].bytes); 879 878 } 880 879 } 881 - EXPORT_SYMBOL_GPL(nf_ct_acct_update); 880 + EXPORT_SYMBOL_GPL(nf_ct_acct_add); 882 881 883 882 static void nf_ct_acct_merge(struct nf_conn *ct, enum ip_conntrack_info ctinfo, 884 883 const struct nf_conn *loser_ct)