Skip to content

netfilter: get rid of per-object conntrack timers

Florian Westphal netfilter-devel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest7 patches 8 repliesIn review
  2. v16 patches 8 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7netfilter: don't rely on DYING bit to detect when destroy event was sentinclude/net/netfilter/nf_conntrack_ecache.h net/netfilter/nf_conntrack_ecache.c+26 -131 reply
2/7netfilter: conntrack: get rid of conntrack timerinclude/net/netfilter/nf_conntrack.h net/netfilter/nf_conntrack_core.c net/netfilter/nf_conntrack_netlink.c +2 more+74 -631 reply
3/7netfilter: evict stale entries on netlink dumpsnet/netfilter/nf_conntrack_netlink.c+24 -11 reply
4/7netfilter: conntrack: add gc worker to remove timed-out entriesnet/netfilter/nf_conntrack_core.c+78 -04 replies
5/7netfilter: conntrack: resched gc again if eviction rate is highnet/netfilter/nf_conntrack_core.c+6 -00 replies
6/7netfilter: remove __nf_ct_kill_acct helperinclude/net/netfilter/nf_conntrack.h net/netfilter/nf_conntrack_core.c+8 -170 replies
7/7netfilter: restart search if moved to other chainnet/netfilter/nf_conntrack_core.c+7 -01 reply

Reviews trailers per patch

4 of 7 patches have a Reviewed-by or Acked-by.

PatchEric Dumazet
1/7A-b
2/7A-b
3/7A-b
4/7
5/7
6/7
7/7A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH nf-next v2 0/7] netfilter: get rid of per-object conntrack timers

During NFWS 2016 it was mentioned that per-conntrack timers have two drawbacks:
- the 5-day default established timeout is very large and brings extra constraints for the timer subsystem.
- most distros enable timer stats so timer struct eats 80 bytes in each conntrack object.

This series replaces the per-object struct timer with a u32 jiffie stamp and one global delayed work queue for conntrack eviction. Size of nf_conn struct is reduced to 256 bytes on x86_64.

Eviction is performed from the packet path when doing table lookup, for cases where we have idle periods the work queue is used.

No changes since v1, except addition of a comment in #3 and a one-line change (replace cond_reschd w. cond_resched_rcu_qs).

Patch #7 was not part of v1.

Tested with following script, conntrackd running in 'relible event mode' and httpterm running on other host:

-----------------------------------------------------------

random_resize() {
        while true; do
                RND=$RANDOM%256000
                RND=$((RND+8192))
                sysctl net.netfilter.nf_conntrack_buckets=$RND
                sleep $((RANDOM % 120))
        done
}

random_flush() {
while true; do
sleep $((RANDOM % 120))
conntrack -F
done
}

random_startstop() {
while true; do
sleep $((RANDOM % 120))
pkill -STOP conntrackd
sleep $((RANDOM % 10))
pkill -CONT conntrackd
done
}

http-client -u 1000 -t 3 -F 192.168.10.50 -G 192.168.10.17:8001 & http-client -u 1000 -t 3 -F 192.168.10.51 -G 192.168.10.17:8001 & http-client -u 1000 -t 3 -F 192.168.10.52 -G 192.168.10.17:8001 &

random_resize &
random_flush &
random_startstop &

wait
-----------------------------------------------------------

 include/net/netfilter/nf_conntrack.h        |   36 +++--
 include/net/netfilter/nf_conntrack_ecache.h |   17 +-
 net/netfilter/nf_conntrack_core.c           |  194 +++++++++++++++++++++-------
 net/netfilter/nf_conntrack_ecache.c         |   22 ++-
 net/netfilter/nf_conntrack_netlink.c        |   39 ++++-
 net/netfilter/nf_conntrack_pptp.c           |    3 
 net/netfilter/nf_nat_core.c                 |    6 
 7 files changed, 223 insertions(+), 94 deletions(-)