Skip to content

Commit e47eb5d

Browse files
edumazetdavem330
authored andcommitted
udp: ipv4: do not use sk_dst_lock from softirq context
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>
1 parent 50dc875 commit e47eb5d

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

‎net/ipv4/udp.c‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,20 +1600,15 @@ static void flush_stack(struct sock **stack, unsigned int count,
16001600
}
16011601

16021602
/* For TCP sockets, sk_rx_dst is protected by socket lock
1603-
* For UDP, we use sk_dst_lock to guard against concurrent changes.
1603+
* For UDP, we use xchg() to guard against concurrent changes.
16041604
*/
16051605
static void udp_sk_rx_dst_set(struct sock *sk, struct dst_entry *dst)
16061606
{
16071607
struct dst_entry *old;
16081608

1609-
spin_lock(&sk->sk_dst_lock);
1610-
old = sk->sk_rx_dst;
1611-
if (likely(old != dst)) {
1612-
dst_hold(dst);
1613-
sk->sk_rx_dst = dst;
1614-
dst_release(old);
1615-
}
1616-
spin_unlock(&sk->sk_dst_lock);
1609+
dst_hold(dst);
1610+
old = xchg(&sk->sk_rx_dst, dst);
1611+
dst_release(old);
16171612
}
16181613

16191614
/*

0 commit comments

Comments
 (0)