From patchwork Fri Jun 2 16:38:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Soheil Hassas Yeganeh X-Patchwork-Id: 770504 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wfVJq1GmHz9ryv for ; Sat, 3 Jun 2017 02:38:35 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZjcIcBHd"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751154AbdFBQic (ORCPT ); Fri, 2 Jun 2017 12:38:32 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:34316 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750813AbdFBQib (ORCPT ); Fri, 2 Jun 2017 12:38:31 -0400 Received: by mail-qt0-f194.google.com with SMTP id o21so1982198qtb.1 for ; Fri, 02 Jun 2017 09:38:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=hqBgCHlZyXUGkDnrLNXcg8JeJzP6Wrb7uM0TkpRcTHY=; b=ZjcIcBHd+oDdxyNX5kbSSN/P8BBpj7zIrasC48YIbQmArJHZVxgDOZQcX6D2hLNqVG M9aqBaob0hI19the5aBmOrAOF15z0wOtK8Dx+3BbnYRMJq12ZboRrwk3ArVqo7SIYMR/ NyT7ML9bNQN0D2FCNEcH+mTup6uEu5ionwK4Me+7KmIWuQKzdixxRjMhPQrcuEGZceHo WDLkFjrfcPdFxO859bT1ZHUz71cx9cOp9C4KpK2CHd5Hkys0ZITUOD2atsZag3XHDKhW sCN203tAiiYmNS8lyeiBZhO0mRfGv6/C0j6S9imjQ6N+uPRRY2tj9cgintW6fk/O3ov1 1V+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=hqBgCHlZyXUGkDnrLNXcg8JeJzP6Wrb7uM0TkpRcTHY=; b=EryTn7vCmBOEzq0vPTJsD4iq5PgEITym5SOGdOyVHbKdYayKpb1bSctsHLRkX2sA1R srAhjkRnnZBUBwUGnlQ5u3RpDaagje0fQ15nmndFpPYXpvaXNwaXMDGpprbEZzLhyzCG eYAYa/iQXORa6D8hySQWIvC2fcKwWizCwASt4XcdP8anprLHb75+FYxM66LpNBTbIkVG odV5ToSgtpTSxwIbLb/Jcl+ryehofqqVgsusPwUgOeismx96ExXVENFGiiKIgk1fw+Wm w+pzxgc3jtRw0Od6qKv+FiWL8V8hdZWewQJdFv/iP9Ml7rS2BAj2cKjUaeKsBEG8G74n B2bQ== X-Gm-Message-State: AODbwcAXITZ66dPPNZxOjTQVZap+w86ZXFp4buhGw/+Aek8y9xFgclpG aY883KBAUsOi33Nghg0= X-Received: by 10.200.35.230 with SMTP id r35mr9773422qtr.167.1496421510686; Fri, 02 Jun 2017 09:38:30 -0700 (PDT) Received: from z.nyc.corp.google.com ([172.26.104.94]) by smtp.gmail.com with ESMTPSA id t20sm15298353qtb.22.2017.06.02.09.38.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 02 Jun 2017 09:38:30 -0700 (PDT) From: Soheil Hassas Yeganeh To: davem@davemloft.net, netdev@vger.kernel.org Cc: chrubis@suse.cz, Soheil Hassas Yeganeh , Eric Dumazet , Willem de Bruijn Subject: [PATCH net] sock: reset sk_err when the error queue is empty Date: Fri, 2 Jun 2017 12:38:22 -0400 Message-Id: <20170602163822.67543-1-soheil.kdev@gmail.com> X-Mailer: git-send-email 2.13.0.506.g27d5fe0cd-goog Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Soheil Hassas Yeganeh 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) Reported-by: Cyril Hrubis Test-by: Cyril Hrubis Signed-off-by: Soheil Hassas Yeganeh Signed-off-by: Eric Dumazet Signed-off-by: Willem de Bruijn --- net/core/skbuff.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 346d3e85dfbc..b1be7c01efe2 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -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)