Skip to content

Commit ef803b3

Browse files
wenxuummakynes
authored andcommitted
netfilter: flowtable: add counter support in HW offload
Store the conntrack counters to the conntrack entry in the HW flowtable offload. Signed-off-by: wenxu <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 9312eab commit ef803b3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

net/netfilter/nf_flow_table_offload.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <net/netfilter/nf_flow_table.h>
1010
#include <net/netfilter/nf_tables.h>
1111
#include <net/netfilter/nf_conntrack.h>
12+
#include <net/netfilter/nf_conntrack_acct.h>
1213
#include <net/netfilter/nf_conntrack_core.h>
1314
#include <net/netfilter/nf_conntrack_tuple.h>
1415

@@ -783,6 +784,17 @@ static void flow_offload_work_stats(struct flow_offload_work *offload)
783784
lastused = max_t(u64, stats[0].lastused, stats[1].lastused);
784785
offload->flow->timeout = max_t(u64, offload->flow->timeout,
785786
lastused + NF_FLOW_TIMEOUT);
787+
788+
if (offload->flowtable->flags & NF_FLOWTABLE_COUNTER) {
789+
if (stats[0].pkts)
790+
nf_ct_acct_add(offload->flow->ct,
791+
FLOW_OFFLOAD_DIR_ORIGINAL,
792+
stats[0].pkts, stats[0].bytes);
793+
if (stats[1].pkts)
794+
nf_ct_acct_add(offload->flow->ct,
795+
FLOW_OFFLOAD_DIR_REPLY,
796+
stats[1].pkts, stats[1].bytes);
797+
}
786798
}
787799

788800
static void flow_offload_work_handler(struct work_struct *work)

0 commit comments

Comments
 (0)