* [PATCH] udp: ipv4: do not use sk_dst_lock from softirq context
@ 2013-12-15 18:53 Eric Dumazet
2013-12-17 19:51 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2013-12-15 18:53 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Fengguang Wu
From: Eric Dumazet <edumazet@google.com>
Using sk_dst_lock from softirq context is not supported right now.
Instead of adding BH protection everywhere,
udp_sk_rx_dst_set() can instead use xchg(), as suggested
by David.
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Fixes: 975022310233 ("udp: ipv4: must add synchronization in udp_sk_rx_dst_set()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/ipv4/udp.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 62c19fdd102d..f140048334ce 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1600,20 +1600,15 @@ static void flush_stack(struct sock **stack, unsigned int count,
}
/* For TCP sockets, sk_rx_dst is protected by socket lock
- * For UDP, we use sk_dst_lock to guard against concurrent changes.
+ * For UDP, we use xchg() to guard against concurrent changes.
*/
static void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
{
struct dst_entry *old;
- spin_lock(&sk->sk_dst_lock);
- old = sk->sk_rx_dst;
- if (likely(old != dst)) {
- dst_hold(dst);
- sk->sk_rx_dst = dst;
- dst_release(old);
- }
- spin_unlock(&sk->sk_dst_lock);
+ dst_hold(dst);
+ old = xchg(&sk->sk_rx_dst, dst);
+ dst_release(old);
}
/*
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] udp: ipv4: do not use sk_dst_lock from softirq context
2013-12-15 18:53 [PATCH] udp: ipv4: do not use sk_dst_lock from softirq context Eric Dumazet
@ 2013-12-17 19:51 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-12-17 19:51 UTC (permalink / raw)
To: eric.dumazet; +Cc: netdev, fengguang.wu
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Sun, 15 Dec 2013 10:53:46 -0800
> From: Eric Dumazet <edumazet@google.com>
>
> Using sk_dst_lock from softirq context is not supported right now.
>
> Instead of adding BH protection everywhere,
> udp_sk_rx_dst_set() can instead use xchg(), as suggested
> by David.
>
> Reported-by: Fengguang Wu <fengguang.wu@intel.com>
> Fixes: 975022310233 ("udp: ipv4: must add synchronization in udp_sk_rx_dst_set()")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Applied, thanks Eric.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-12-17 19:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-15 18:53 [PATCH] udp: ipv4: do not use sk_dst_lock from softirq context Eric Dumazet
2013-12-17 19:51 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).