netfilter: nf_flow_table_offload: add nf_conn_acct for flowtable offload
Subsystems (4)
cover netfilter: nf_flow_table_offload: add nf_conn_acct for flowtable offload
From: wenxu <[email protected]>
An offloaded conntrack in flowtable will never count the nf_conn_act counter after the flow is offloaded in SW or HW.
wenxu (3):
netfilter: nf_flow_table: add nf_conn_acct for SW flowtable offload
netfilter: nf_flow_table: add nf_conn_acct for HW flowtable offload net/sched: act_ct: add nf_conn_acct for SW act_ct flowtable offload
include/net/netfilter/nf_flow_table.h | 4 ++++ net/netfilter/nf_flow_table_core.c | 19 +++++++++++++++++++ net/netfilter/nf_flow_table_ip.c | 4 ++++ net/netfilter/nf_flow_table_offload.c | 8 ++++++++ net/sched/act_ct.c | 1 + 5 files changed, 36 insertions(+)
Signature · 1 line
1.8.3.1
PATCH 1/3 netfilter: nf_flow_table: add nf_conn_acct for SW flowtable offload
From: wenxu <[email protected]>
Add nf_conn_acct counter for the software flowtable offload
--- include/net/netfilter/nf_flow_table.h | 4 ++++ net/netfilter/nf_flow_table_core.c | 19 +++++++++++++++++++ net/netfilter/nf_flow_table_ip.c | 4 ++++ 3 files changed, 27 insertions(+)
include/net/netfilter/nf_flow_table.h +4 -0
@@ -180,6 +180,10 @@ struct flow_offload_tuple_rhash *flow_offload_lookup(struct nf_flowtable *flow_tvoid flow_offload_teardown (struct flow_offload *flow); +void flow_offload_update_acct (struct flow_offload *flow,unsigned int pkts, +unsigned int bytes, +enum flow_offload_tuple_dir dir); +int nf_flow_snat_port (const struct flow_offload *flow,struct sk_buff *skb,unsigned int thoff,u8 protocol,enum flow_offload_tuple_dir dir);
net/netfilter/nf_flow_table_core.c +19 -0
@@ -13,6 +13,7 @@#include <net/netfilter/nf_conntrack_core.h> #include <net/netfilter/nf_conntrack_l4proto.h> #include <net/netfilter/nf_conntrack_tuple.h> +#include <net/netfilter/nf_conntrack_acct.h> static DEFINE_MUTEX (flowtable_lock);static LIST_HEAD (flowtables);
@@ -618,6 +619,24 @@ void nf_flow_table_free(struct nf_flowtable *flow_table) }EXPORT_SYMBOL_GPL (nf_flow_table_free); +void flow_offload_update_acct (struct flow_offload *flow,unsigned int pkts, +unsigned int bytes, +enum flow_offload_tuple_dir dir) +{ +struct nf_conn_acct *acct; + +if (flow && flow->ct) { + acct =nf_conn_acct_find (flow->ct); +if (acct) { +struct nf_conn_counter *counter = acct->counter; + +atomic64_add (pkts, &counter[dir].packets); +atomic64_add (bytes, &counter[dir].bytes); + } + } +} +EXPORT_SYMBOL_GPL (flow_offload_update_acct); +static int __init nf_flow_table_module_init (void ) {return nf_flow_table_offload_init ();
net/netfilter/nf_flow_table_ip.c +4 -0
@@ -279,6 +279,8 @@ static unsigned int nf_flow_xmit_xfrm(struct sk_buff *skb,return NF_ACCEPT ; } +flow_offload_update_acct (flow,1 , skb->len, dir); +if (nf_flow_nat_ip (flow, skb, thoff, dir) <0 )return NF_DROP ;
@@ -506,6 +508,8 @@ static int nf_flow_tuple_ipv6(struct sk_buff *skb, const struct net_device *dev,return NF_ACCEPT ; } +flow_offload_update_acct (flow,1 , skb->len, dir); +if (skb_try_make_writable (skb,sizeof (*ip6h)))return NF_DROP ;
Signature · 1 line
1.8.3.1
PATCH 2/3 netfilter: nf_flow_table: add nf_conn_acct for HW flowtable offload
In reply to [email protected]From: wenxu <[email protected]>
Add nf_conn_acct counter for the hardware flowtable offload
--- net/netfilter/nf_flow_table_offload.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/netfilter/nf_flow_table_offload.c +8 -0
@@ -784,6 +784,14 @@ static void flow_offload_work_stats(struct flow_offload_work *offload) lastused =max_t (u64, stats[0 ].lastused, stats[1 ].lastused); offload->flow->timeout =max_t (u64, offload->flow->timeout, lastused +NF_FLOW_TIMEOUT ); +if (stats[0 ].pkts) +flow_offload_update_acct (offload->flow, stats[0 ].pkts, + stats[0 ].bytes, +FLOW_OFFLOAD_DIR_ORIGINAL ); +if (stats[1 ].pkts) +flow_offload_update_acct (offload->flow, stats[1 ].pkts, + stats[1 ].bytes, +FLOW_OFFLOAD_DIR_REPLY ); }static void flow_offload_work_handler (struct work_struct *work)
Signature · 1 line
1.8.3.1
PATCH 3/3 net/sched: act_ct: add nf_conn_acct for SW act_ct flowtable offload
In reply to [email protected]From: wenxu <[email protected]>
Add nf_conn_acct counter for the software act_ct flowtable offload
--- net/sched/act_ct.c | 1 + 1 file changed, 1 insertion(+)
net/sched/act_ct.c +1 -0
@@ -536,6 +536,7 @@ static bool tcf_ct_flow_table_lookup(struct tcf_ct_params *p,flow_offload_refresh (nf_ft, flow);nf_conntrack_get (&ct->ct_general);nf_ct_set (skb, ct, ctinfo); +flow_offload_update_acct (flow,1 , skb->len, dir);return true; }
Signature · 1 line
1.8.3.1