Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5454742imm; Tue, 16 Oct 2018 10:28:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV62+D9OHp/jVwFg5YAU97Ux7/AoPgTxny/eLUtsb0GXW+NqLQkQadApqtB8Qtx+5/yykubnx X-Received: by 2002:a17:902:9693:: with SMTP id n19-v6mr10730414plp.20.1539710895870; Tue, 16 Oct 2018 10:28:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539710895; cv=none; d=google.com; s=arc-20160816; b=wQcYhibZtSHF0mzjl5vIEqB1nArdDihUtAEcV2750ewz3FKh9EY2iCthZMZidZ1RMq 8fxJtuPxon8XIqo1sUWJkkxUsx8Rk2vJ8azrlFtIWaM6r4oHuecweBbGS6lTDXecXCDi bkbav3mCnTlyH2utBgRkgBXbAKCZf1liSFqh3Mn0VEmVWSzBpFRIHZENXfKs4wEU7g8d p9eqvh1A0yM3XRoNvVvv0TVgweHsKus2lup2Bn60DAaBUzUALsOz/Ht4DjiNsxdSdV3s FiWDJLiNMNsDb13961OnwUs2Ay6MVOf8ipvsi9DjZ8GIqcSFXONuF/vJX7OXsZ9Q9eef Ln1g== 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:dkim-signature; bh=PLrybYPKB/mLZYVRk+lBVZd8jURai1wO6NioJBgq8T0=; b=lq73w8oANcz1uGBnWBvWJkvsyTKal0RbqT+k0+3UNIw7T3m6lEhgLDzzFYwVMo1PUi EJ74nvpbxBrkBi8r/WqmKbJTOU6pcgoznqou0Kxu+e+l+CUYa9dd+rMFlIt08GJHFFBq eKlP60HoZyF2NrIYks/eqPpJrcJS0YNkHEJokryE7sZvqp0QxwHqD9++o0j5W+KQoCZy pUMcGLXcrXtFjGxHwWcbXsh01bkuDcB06loycFaNJcwxgM4qWhSz8SVAbJ6K4P0JZ63x E/xXHJTaXK4QV3OIs8Yx9QIsanaU13c9Gv2UwlyT0amHm2iDLiJVZxy0jYXSATjPEzUD YKvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Jxl9eki9; 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 f7-v6si16540402pln.125.2018.10.16.10.27.59; Tue, 16 Oct 2018 10:28:15 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Jxl9eki9; 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 S1731946AbeJQBQq (ORCPT + 99 others); Tue, 16 Oct 2018 21:16:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:35498 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730396AbeJQBQp (ORCPT ); Tue, 16 Oct 2018 21:16:45 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2DA7420866; Tue, 16 Oct 2018 17:25:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539710719; bh=wosc0yvhzjfrKcJItTSpRsOnKIUAFLoqkhojnDQR5bU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jxl9eki9jieGKAjIYnLumR9rn5i+RrwRDJBJTDgUhWn9vMyVcJllNTwQ5BLhyllIl kxJ1D/VjzFbkFXnyz1/mnheA1idNRSVAvVmx1e2TAp1FZ/zZJq4TZeoqmAbmBXTaOH gozI0Zx9UTDU8M35z7Qgf08DlMbSpRyLInvVhLFk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" Subject: [PATCH 4.9 65/71] net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends Date: Tue, 16 Oct 2018 19:10:02 +0200 Message-Id: <20181016170542.658704337@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181016170539.315587743@linuxfoundation.org> References: <20181016170539.315587743@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.9-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 @@ -2954,6 +2954,7 @@ static inline unsigned char *skb_push_rc 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 @@ -2967,9 +2968,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 @@ -1578,6 +1578,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