]> asedeno.scripts.mit.edu Git - linux.git/commit
netfilter: nf_conncount: merge lookup and add functions
authorFlorian Westphal <fw@strlen.de>
Fri, 28 Dec 2018 00:24:46 +0000 (01:24 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Sat, 29 Dec 2018 01:45:20 +0000 (02:45 +0100)
commitdf4a902509766897f7371fdfa4c3bf8bc321b55d
treed1c36526cc52fceae52d46a0eb5b5a3c7ffbf2de
parente8cfb372b38a1b8979aa7f7631fb5e7b11c3793c
netfilter: nf_conncount: merge lookup and add functions

'lookup' is always followed by 'add'.
Merge both and make the list-walk part of nf_conncount_add().

This also avoids one unneeded unlock/re-lock pair.

Extra care needs to be taken in count_tree, as we only hold rcu
read lock, i.e. we can only insert to an existing tree node after
acquiring its lock and making sure it has a nonzero count.

As a zero count should be rare, just fall back to insert_tree()
(which acquires tree lock).

This issue and its solution were pointed out by Shawn Bohrer
during patch review.

Reviewed-by: Shawn Bohrer <sbohrer@cloudflare.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/net/netfilter/nf_conntrack_count.h
net/netfilter/nf_conncount.c
net/netfilter/nft_connlimit.c