Skip to content

Commit

Permalink
sock: reset sk_err when the error queue is empty
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
soheilhy authored and davem330 committed Jun 5, 2017
1 parent a7c0b8b commit 38b2579
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 38b2579

Please sign in to comment.