diff options
author | Martin Josefsson <gandalf@wlug.westbo.se> | 2006-11-28 20:35:12 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-03 00:31:14 -0500 |
commit | be00c8e48993368663e2714bd1e7c886b7736406 (patch) | |
tree | e846325f0ae13b20b78fa711759b09600c8646df /net | |
parent | 824621eddd2087b0e6f0b2e0da91e8d77e4919bf (diff) |
[NETFILTER]: nf_conntrack: reduce timer updates in __nf_ct_refresh_acct()
Only update the conntrack timer if there's been at least HZ jiffies since
the last update. Reduces the number of del_timer/add_timer cycles from one
per packet to one per connection per second (plus once for each state change
of a connection)
Should handle timer wraparounds and connection timeout changes.
Signed-off-by: Martin Josefsson <gandalf@wlug.westbo.se>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/netfilter/nf_conntrack_core.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index 355b330c214e..3e7c0a90003a 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
@@ -864,9 +864,14 @@ void __nf_ct_refresh_acct(struct nf_conn *ct, | |||
864 | ct->timeout.expires = extra_jiffies; | 864 | ct->timeout.expires = extra_jiffies; |
865 | event = IPCT_REFRESH; | 865 | event = IPCT_REFRESH; |
866 | } else { | 866 | } else { |
867 | /* Need del_timer for race avoidance (may already be dying). */ | 867 | unsigned long newtime = jiffies + extra_jiffies; |
868 | if (del_timer(&ct->timeout)) { | 868 | |
869 | ct->timeout.expires = jiffies + extra_jiffies; | 869 | /* Only update the timeout if the new timeout is at least |
870 | HZ jiffies from the old timeout. Need del_timer for race | ||
871 | avoidance (may already be dying). */ | ||
872 | if (newtime - ct->timeout.expires >= HZ | ||
873 | && del_timer(&ct->timeout)) { | ||
874 | ct->timeout.expires = newtime; | ||
870 | add_timer(&ct->timeout); | 875 | add_timer(&ct->timeout); |
871 | event = IPCT_REFRESH; | 876 | event = IPCT_REFRESH; |
872 | } | 877 | } |