Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4538061imm; Mon, 17 Sep 2018 16:06:16 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaSBmQ0XGRXj7WtTj8AF6S0b5rNTp35B9TjIJ1rUch7lOfHArya0wTLQwEfm21Aeebqb8Fs X-Received: by 2002:a63:24c4:: with SMTP id k187-v6mr25459390pgk.162.1537225576476; Mon, 17 Sep 2018 16:06:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537225576; cv=none; d=google.com; s=arc-20160816; b=A0D1lQucCOR/ONofhCsydpvpztjcHic94AosySgezohgjCfy0TA3qalooLHvRrgn4K 6KDefYlhZq+IffE0lF+9AQLR9CV/J1z6vgMQAFOJmqC/LdQtBzEWxZyvEyqgfIcztXWn RAHXqzDW8r59JjCqpm8JYaI//cnEONHEhyWOsYGkrqmL/zwcnfkqrx0XgzIt+6gUpvBw tVkbs6FG0wFB7RWop7K8jCNzsf4ZZUaShpLZ3wUOo4MP6ZnLOyAKF72rEt5d4aaujbbu uf3gOiSHUZAnxMX20FQAHI/uYFa60a4N/Gk/014eW2fMH2+eLFxvB2kk+kYqes5AudG4 Xs9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=l0fBAannK9Lj44tFU6ia/xUFU5hmV41Psm9oKcqNfJs=; b=gdSD4p9hJTzRbZlM1yZ0i/xHvCGk0kq34+I4oxTlwGXRfrByiWTHlU5zL89bgT+au6 W3ht7TCIoJArYurOxgCj0aeF5wS/NbGOjrijcvcWQyvGnwTlMgoplcYiirAGUEpwqQx9 YI3cqZszSb+B2QEta1rmAMu2P1xjEUKKCXGcNeMDO1HO+q2bbGBsgo5DNxxveMxS3jnP hlCcEiLz7+e72yYSrlLyEpsUmrulfxE0uxgzQyEFwaElVbqITp4JZIyky2nHpSybgr2w +5jK+i2uigh40ZDRBV7oqtiX5AG3ec/G2XEKNoXLE9jN48e6Eha1XPyR1aTnnB3gzPU7 pIww== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j21-v6si16581286pgl.8.2018.09.17.16.06.00; Mon, 17 Sep 2018 16:06:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731173AbeIREfX (ORCPT + 99 others); Tue, 18 Sep 2018 00:35:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49392 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730202AbeIREfW (ORCPT ); Tue, 18 Sep 2018 00:35:22 -0400 Received: from localhost (li1825-44.members.linode.com [172.104.248.44]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 83314C49; Mon, 17 Sep 2018 23:05:52 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" Subject: [PATCH 4.14 115/126] net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends Date: Tue, 18 Sep 2018 00:42:43 +0200 Message-Id: <20180917211711.524851913@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180917211703.481236999@linuxfoundation.org> References: <20180917211703.481236999@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet After working on IP defragmentation lately, I found that some large packets defeat CHECKSUM_COMPLETE optimization because of NIC adding zero paddings on the last (small) fragment. While removing the padding with pskb_trim_rcsum(), we set skb->ip_summed to CHECKSUM_NONE, forcing a full csum validation, even if all prior fragments had CHECKSUM_COMPLETE set. We can instead compute the checksum of the part we are trimming, usually smaller than the part we keep. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller (cherry picked from commit 88078d98d1bb085d72af8437707279e203524fa5) Signed-off-by: Greg Kroah-Hartman --- include/linux/skbuff.h | 5 ++--- net/core/skbuff.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -3135,6 +3135,7 @@ static inline void *skb_push_rcsum(struc return skb->data; } +int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len); /** * pskb_trim_rcsum - trim received skb and update checksum * @skb: buffer to trim @@ -3148,9 +3149,7 @@ static inline int pskb_trim_rcsum(struct { if (likely(len >= skb->len)) return 0; - if (skb->ip_summed == CHECKSUM_COMPLETE) - skb->ip_summed = CHECKSUM_NONE; - return __pskb_trim(skb, len); + return pskb_trim_rcsum_slow(skb, len); } static inline int __skb_trim_rcsum(struct sk_buff *skb, unsigned int len) --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -1839,6 +1839,20 @@ done: } EXPORT_SYMBOL(___pskb_trim); +/* Note : use pskb_trim_rcsum() instead of calling this directly + */ +int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len) +{ + if (skb->ip_summed == CHECKSUM_COMPLETE) { + int delta = skb->len - len; + + skb->csum = csum_sub(skb->csum, + skb_checksum(skb, len, delta, 0)); + } + return __pskb_trim(skb, len); +} +EXPORT_SYMBOL(pskb_trim_rcsum_slow); + /** * __pskb_pull_tail - advance tail of skb header * @skb: buffer to reallocate