Skip to content

Commit

Permalink
netfilter: flowtable: fix excessive hw offload attempts after failure
Browse files Browse the repository at this point in the history
If a flow cannot be offloaded, the code currently repeatedly tries again as
quickly as possible, which can significantly increase system load.
Fix this by limiting flow timeout update and hardware offload retry to once
per second.

Fixes: c07531c ("netfilter: flowtable: Remove redundant hw refresh bit")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
nbd168 authored and ummakynes committed May 16, 2022
1 parent f3f19f9 commit 396ef64
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/netfilter/nf_flow_table_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,10 @@ void flow_offload_refresh(struct nf_flowtable *flow_table,
u32 timeout;

timeout = nf_flowtable_time_stamp + flow_offload_get_timeout(flow);
if (READ_ONCE(flow->timeout) != timeout)
if (timeout - READ_ONCE(flow->timeout) > HZ)
WRITE_ONCE(flow->timeout, timeout);
else
return;

if (likely(!nf_flowtable_hw_offload(flow_table)))
return;
Expand Down

0 comments on commit 396ef64

Please sign in to comment.