From patchwork Wed Jul 14 19:17:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 12377725 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MIME_BASE64_TEXT,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30449C1B08C for ; Wed, 14 Jul 2021 19:18:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 156BE613C8 for ; Wed, 14 Jul 2021 19:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240149AbhGNTVR (ORCPT ); Wed, 14 Jul 2021 15:21:17 -0400 Received: from mout.gmx.net ([212.227.15.18]:48889 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230185AbhGNTVM (ORCPT ); Wed, 14 Jul 2021 15:21:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1626290287; bh=0Vu294fMLWIi7gFkQR70Ggc20BScAncxP5pTxianCVo=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=QLHTr+1KaDMeaIooUyH6iPx6kKaUUXbvZ9290LCAN0rZWfYJnObH8KTsPxpEjKkw1 OGUdDUTTSMQp4VVPCE7PWIUb0ks82jg2X8zMzzENm7rVOpix9fZ3ku87j2852FVqVx 5CLlvdV4ypEd/PzBlmzJqCYMSIckFgbzHOzYCwGY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([149.172.237.67]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MWRRZ-1lejeW1jWF-00XvkV; Wed, 14 Jul 2021 21:18:07 +0200 From: Lino Sanfilippo To: woojung.huh@microchip.com Cc: UNGLinuxDriver@microchip.com, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lino Sanfilippo Subject: [PATCH 2/2] net: dsa: tag_ksz: dont let the hardware process the layer 4 checksum Date: Wed, 14 Jul 2021 21:17:23 +0200 Message-Id: <20210714191723.31294-3-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210714191723.31294-1-LinoSanfilippo@gmx.de> References: <20210714191723.31294-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:JCoB5BM+Bai/xCSzcnAL1DpJwVTKmW5Z3yW1PB+KpAG290y0d/2 nsDriOHoXw8vLXrLGyqKwZJX7CpsFKZUIY41S1ydmFF1CIAhg6tHUqFFE340YBg+uftBTgY ilN55HxyelA7ZZAiPyykc0Zq5XQkPD2lRi2ozjqtUaBk3rJb1vAAUqkwTZGkJ4TWZLzU0dH lzwcvFsCy6S9gv5qFnQ7w== X-UI-Out-Filterresults: notjunk:1;V03:K0:Dy0uXD9Ok10=:D3rSzTC6gEaoRX4EfHM7xC RJonplED3trLlh7qeMMCKBIEF9MdfWCe/divPw1ewAwaTbj4ZqazDXG5qJaLX29o27zXeWhvy 8wFFHRsBpWN6jcMJF/FNFsaw7lNWT7kYRnvh1AY2fRGU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org If the checksum calculation is offloaded to the network device (e.g due to NETIF_F_HW_CSUM inherited from the DSA master device), the calculated layer 4 checksum is incorrect. This is since the DSA tag which is placed after the layer 4 data is seen as a part of the data portion and thus errorneously included into the checksum calculation. To avoid this, always calculate the layer 4 checksum in software. Signed-off-by: Lino Sanfilippo --- net/dsa/tag_ksz.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c index 364f509d7cd7..d59f0e7019e2 100644 --- a/net/dsa/tag_ksz.c +++ b/net/dsa/tag_ksz.c @@ -56,6 +56,9 @@ static struct sk_buff *ksz8795_xmit(struct sk_buff *skb, struct net_device *dev) if (skb_linearize(skb)) return NULL; + if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb)) + return NULL; + /* Tag encoding */ tag = skb_put(skb, KSZ_INGRESS_TAG_LEN); addr = skb_mac_header(skb); @@ -120,6 +123,9 @@ static struct sk_buff *ksz9477_xmit(struct sk_buff *skb, if (skb_linearize(skb)) return NULL; + if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb)) + return NULL; + /* Tag encoding */ tag = skb_put(skb, KSZ9477_INGRESS_TAG_LEN); addr = skb_mac_header(skb); @@ -173,6 +179,9 @@ static struct sk_buff *ksz9893_xmit(struct sk_buff *skb, if (skb_linearize(skb)) return NULL; + if (skb->ip_summed == CHECKSUM_PARTIAL && skb_checksum_help(skb)) + return NULL; + /* Tag encoding */ tag = skb_put(skb, KSZ_INGRESS_TAG_LEN); addr = skb_mac_header(skb);