Skip to content

Commit

Permalink
udp: ipv4: do not use sk_dst_lock from softirq context
Browse files Browse the repository at this point in the history
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: 9750223 ("udp: ipv4: must add synchronization in udp_sk_rx_dst_set()")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Dec 17, 2013
1 parent 50dc875 commit e47eb5d
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions net/ipv4/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down

0 comments on commit e47eb5d

Please sign in to comment.