Skip to contentSkip to conversation

sock: reset sk_err when the error queue is empty

PATCH In review Soheil Hassas Yeganeh 2 participants 2 messages Jun 2, 2017 – Jun 5, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sock: reset sk_err when the error queue is empty

From: Soheil Hassas Yeganeh <[email protected]>

Prior to f5f99309fa74 (sock: do not set sk_err in sock_dequeue_err_skb), sk_err was reset to the error of the skb on the head of the error queue.

Applications, most notably ping, are relying on this behavior to reset sk_err for ICMP packets.

Set sk_err to the ICMP error when there is an ICMP packet at the head of the error queue.

Fixes f5f99309fa74 (sock: do not set sk_err in sock_dequeue_err_skb)
---
 net/core/skbuff.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/core/skbuff.c +4 -1
index 346d3e85dfbc..b1be7c01efe2 100644
@@ -3754,8 +3754,11 @@ struct sk_buff *sock_dequeue_err_skb(struct sock *sk)
 
 	spin_lock_irqsave(&q->lock, flags);
 	skb = __skb_dequeue(q);
-	if (skb && (skb_next = skb_peek(q)))
+	if (skb && (skb_next = skb_peek(q))) {
 		icmp_next = is_icmp_err_skb(skb_next);
+		if (icmp_next)
+			sk->sk_err = SKB_EXT_ERR(skb_next)->ee.ee_origin;
+	}
 	spin_unlock_irqrestore(&q->lock, flags);
 
 	if (is_icmp_err_skb(skb) && !icmp_next)
Signature · 1 line
2.13.0.506.g27d5fe0cd-goog
maintainer
#1 lore raw

From: Soheil Hassas Yeganeh <[email protected]>
Date: Fri, 2 Jun 2017 12:38:22 -0400

Quoted 12 lines

From: Soheil Hassas Yeganeh <[email protected]>

Prior to f5f99309fa74 (sock: do not set sk_err in sock_dequeue_err_skb), sk_err was reset to the error of the skb on the head of the error queue.

Applications, most notably ping, are relying on this behavior to reset sk_err for ICMP packets.

Set sk_err to the ICMP error when there is an ICMP packet at the head of the error queue.

Quoted 6 lines
Fixes f5f99309fa74 (sock: do not set sk_err in sock_dequeue_err_skb)

Applied and queued up for -stable, thank you.