Skip to content

Commit 38b2579

Browse files
soheilhydavem330
authored andcommitted
sock: reset sk_err when the error queue is empty
Prior to f5f9930 (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: f5f9930 (sock: do not set sk_err in sock_dequeue_err_skb) Reported-by: Cyril Hrubis <[email protected]> Tested-by: Cyril Hrubis <[email protected]> Signed-off-by: Soheil Hassas Yeganeh <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: Willem de Bruijn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a7c0b8b commit 38b2579

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/core/skbuff.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3754,8 +3754,11 @@ struct sk_buff *sock_dequeue_err_skb(struct sock *sk)
37543754

37553755
spin_lock_irqsave(&q->lock, flags);
37563756
skb = __skb_dequeue(q);
3757-
if (skb && (skb_next = skb_peek(q)))
3757+
if (skb && (skb_next = skb_peek(q))) {
37583758
icmp_next = is_icmp_err_skb(skb_next);
3759+
if (icmp_next)
3760+
sk->sk_err = SKB_EXT_ERR(skb_next)->ee.ee_origin;
3761+
}
37593762
spin_unlock_irqrestore(&q->lock, flags);
37603763

37613764
if (is_icmp_err_skb(skb) && !icmp_next)

0 commit comments

Comments
 (0)