Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e47eb5df authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

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: default avatarFengguang Wu <fengguang.wu@intel.com>
Fixes: 97502231 ("udp: ipv4: must add synchronization in udp_sk_rx_dst_set()")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 50dc875f
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -1600,21 +1600,16 @@ 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;
	old = xchg(&sk->sk_rx_dst, dst);
	dst_release(old);
}
	spin_unlock(&sk->sk_dst_lock);
}

/*
 *	Multicasts and broadcasts go to each listener.