Commit 2be825eb authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'socket-option-lockless'



Eric Dumazet says:

====================
net: more data-races fixes and lockless socket options

This is yet another round of data-races fixes,
and lockless socket options.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 06bc3668 eb44ad4e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -877,7 +877,7 @@ static int pppoe_sendmsg(struct socket *sock, struct msghdr *m,

	skb->dev = dev;

	skb->priority = sk->sk_priority;
	skb->priority = READ_ONCE(sk->sk_priority);
	skb->protocol = cpu_to_be16(ETH_P_PPP_SES);

	ph = skb_put(skb, total_len + sizeof(struct pppoe_hdr));
+1 −1
Original line number Diff line number Diff line
@@ -541,7 +541,7 @@ static inline struct sk_buff *bt_skb_sendmsg(struct sock *sk,
		return ERR_PTR(-EFAULT);
	}

	skb->priority = sk->sk_priority;
	skb->priority = READ_ONCE(sk->sk_priority);

	return skb;
}
+19 −7
Original line number Diff line number Diff line
@@ -2007,21 +2007,33 @@ static inline void sk_tx_queue_set(struct sock *sk, int tx_queue)
	/* sk_tx_queue_mapping accept only upto a 16-bit value */
	if (WARN_ON_ONCE((unsigned short)tx_queue >= USHRT_MAX))
		return;
	sk->sk_tx_queue_mapping = tx_queue;
	/* Paired with READ_ONCE() in sk_tx_queue_get() and
	 * other WRITE_ONCE() because socket lock might be not held.
	 */
	WRITE_ONCE(sk->sk_tx_queue_mapping, tx_queue);
}

#define NO_QUEUE_MAPPING	USHRT_MAX

static inline void sk_tx_queue_clear(struct sock *sk)
{
	sk->sk_tx_queue_mapping = NO_QUEUE_MAPPING;
	/* Paired with READ_ONCE() in sk_tx_queue_get() and
	 * other WRITE_ONCE() because socket lock might be not held.
	 */
	WRITE_ONCE(sk->sk_tx_queue_mapping, NO_QUEUE_MAPPING);
}

static inline int sk_tx_queue_get(const struct sock *sk)
{
	if (sk && sk->sk_tx_queue_mapping != NO_QUEUE_MAPPING)
		return sk->sk_tx_queue_mapping;
	if (sk) {
		/* Paired with WRITE_ONCE() in sk_tx_queue_clear()
		 * and sk_tx_queue_set().
		 */
		int val = READ_ONCE(sk->sk_tx_queue_mapping);

		if (val != NO_QUEUE_MAPPING)
			return val;
	}
	return -1;
}

@@ -2170,7 +2182,7 @@ static inline void __dst_negative_advice(struct sock *sk)
		if (ndst != dst) {
			rcu_assign_pointer(sk->sk_dst_cache, ndst);
			sk_tx_queue_clear(sk);
			sk->sk_dst_pending_confirm = 0;
			WRITE_ONCE(sk->sk_dst_pending_confirm, 0);
		}
	}
}
@@ -2187,7 +2199,7 @@ __sk_dst_set(struct sock *sk, struct dst_entry *dst)
	struct dst_entry *old_dst;

	sk_tx_queue_clear(sk);
	sk->sk_dst_pending_confirm = 0;
	WRITE_ONCE(sk->sk_dst_pending_confirm, 0);
	old_dst = rcu_dereference_protected(sk->sk_dst_cache,
					    lockdep_sock_is_held(sk));
	rcu_assign_pointer(sk->sk_dst_cache, dst);
@@ -2200,7 +2212,7 @@ sk_dst_set(struct sock *sk, struct dst_entry *dst)
	struct dst_entry *old_dst;

	sk_tx_queue_clear(sk);
	sk->sk_dst_pending_confirm = 0;
	WRITE_ONCE(sk->sk_dst_pending_confirm, 0);
	old_dst = xchg((__force struct dst_entry **)&sk->sk_dst_cache, dst);
	dst_release(old_dst);
}
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ TRACE_EVENT(mptcp_subflow_get_send,
		ssk = mptcp_subflow_tcp_sock(subflow);
		if (ssk && sk_fullsock(ssk)) {
			__entry->snd_wnd = tcp_sk(ssk)->snd_wnd;
			__entry->pace = ssk->sk_pacing_rate;
			__entry->pace = READ_ONCE(ssk->sk_pacing_rate);
		} else {
			__entry->snd_wnd = 0;
			__entry->pace = 0;
+1 −1
Original line number Diff line number Diff line
@@ -664,7 +664,7 @@ int aarp_send_ddp(struct net_device *dev, struct sk_buff *skb,

sendit:
	if (skb->sk)
		skb->priority = skb->sk->sk_priority;
		skb->priority = READ_ONCE(skb->sk->sk_priority);
	if (dev_queue_xmit(skb))
		goto drop;
sent:
Loading