Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: conntrack: remove unneeded nf_ct_put

We can delay refcount increment until we reassign the existing entry to
the current skb.

A 0 refcount can't happen while the nf_conn object is still in the
hash table and parallel mutations are impossible because we hold the
bucket lock.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Florian Westphal and committed by
Pablo Neira Ayuso
ff73e747 bc924704

+3 -4
+3 -4
net/netfilter/nf_conntrack_core.c
··· 908 908 tstamp->start = ktime_get_real_ns(); 909 909 } 910 910 911 + /* caller must hold locks to prevent concurrent changes */ 911 912 static int __nf_ct_resolve_clash(struct sk_buff *skb, 912 913 struct nf_conntrack_tuple_hash *h) 913 914 { ··· 922 921 if (nf_ct_is_dying(ct)) 923 922 return NF_DROP; 924 923 925 - if (!atomic_inc_not_zero(&ct->ct_general.use)) 926 - return NF_DROP; 927 - 928 924 if (((ct->status & IPS_NAT_DONE_MASK) == 0) || 929 925 nf_ct_match(ct, loser_ct)) { 930 926 struct net *net = nf_ct_net(ct); 927 + 928 + nf_conntrack_get(&ct->ct_general); 931 929 932 930 nf_ct_acct_merge(ct, ctinfo, loser_ct); 933 931 nf_ct_add_to_dying_list(loser_ct); ··· 937 937 return NF_ACCEPT; 938 938 } 939 939 940 - nf_ct_put(ct); 941 940 return NF_DROP; 942 941 } 943 942