]> git.baikalelectronics.ru Git - kernel.git/commit
net: ipv4: fix RCU races on dst refcounts
authorEric Dumazet <edumazet@google.com>
Sun, 29 Jul 2012 23:20:37 +0000 (23:20 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 30 Jul 2012 21:53:22 +0000 (14:53 -0700)
commitfb567d86f7f1ad4612d6ce183a3cd50bcbec97ba
tree38e9748d38c415cc97b973fecb9279cd43f76393
parent166974ccf63be71f7b620400b170dad54f00ef13
net: ipv4: fix RCU races on dst refcounts

commit b7c2e4e3f9b7 (ipv4: Fix input route performance regression.)
added various fatal races with dst refcounts.

crashes happen on tcp workloads if routes are added/deleted at the same
time.

The dst_free() calls from free_fib_info_rcu() are clearly racy.

We need instead regular dst refcounting (dst_release()) and make
sure dst_release() is aware of RCU grace periods :

Add DST_RCU_FREE flag so that dst_release() respects an RCU grace period
before dst destruction for cached dst

Introduce a new inet_sk_rx_dst_set() helper, using atomic_inc_not_zero()
to make sure we dont increase a zero refcount (On a dst currently
waiting an rcu grace period before destruction)

rt_cache_route() must take a reference on the new cached route, and
release it if was not able to install it.

With this patch, my machines survive various benchmarks.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/dst.h
include/net/inet_sock.h
net/core/dst.c
net/decnet/dn_route.c
net/ipv4/fib_semantics.c
net/ipv4/route.c
net/ipv4/tcp_input.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_minisocks.c