From patchwork Wed Jul 21 21:56:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 484342 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, 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 D6DEFC6377B for ; Wed, 21 Jul 2021 23:56:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B0A5161177 for ; Wed, 21 Jul 2021 23:56:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229928AbhGUXPq (ORCPT ); Wed, 21 Jul 2021 19:15:46 -0400 Received: from mout.gmx.net ([212.227.17.20]:38103 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229974AbhGUXPh (ORCPT ); Wed, 21 Jul 2021 19:15:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1626911767; bh=MTzoNI+4/t77AVtRX7F3dHidZZBtCwdh6utBGbbuUCM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=h1ixPFzUldtN6+MF1sX2ojNNcTYmbrtAtZu9qs3VOOvnt09Ry2+x0B5b9zWk97w2p /QVMTNgzHKUe3ytPAePdyF7kzV3zN3p0KmKZIUqvNXx1VtZkzqisbw7WMH3W2ODmvP w24kuQBEOESKReg/UcQrmVBH4XPffruJUfxHVI54= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([149.172.237.67]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M6ll8-1m1M8T2p1a-008KqK; Wed, 21 Jul 2021 23:56:51 +0200 From: Lino Sanfilippo To: woojung.huh@microchip.com, olteanv@gmail.com Cc: UNGLinuxDriver@microchip.com, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lino Sanfilippo Subject: [PATCH v2 2/2] net: dsa: tag_ksz: dont let the hardware process the layer 4 checksum Date: Wed, 21 Jul 2021 23:56:42 +0200 Message-Id: <20210721215642.19866-3-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210721215642.19866-1-LinoSanfilippo@gmx.de> References: <20210721215642.19866-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:VrYRZ8zYIkA/EmJQWzaTUwoWNymemMyGpBXSXegQD3tN4gQv8hr SKV/Rfr0ylf4Afz6WxOvFNJ47HRx9YkCa8eomMPWnuPnE5rXCHl+wgYia4nV/RQI3kHRbpz JnYxqysjd8rwUEKc9obqdFK4cE/cxP91xjQpGMQz4lTk/87hb2SlbVbS5hRJHKvLZRBZ7AS 6Oz0bYceci9NqZ0ricBrg== X-UI-Out-Filterresults: notjunk:1; V03:K0:wttdpPwfjc8=:9y0l/U1MEUh58h4FCgqWsc uF2bw17XQlk+iIv91j6pCdIOf0hGu9AnwCR9tbVsGLQu2q0RXiHsvFhqNZPviXoWm45LXevJU b7ZGFelk9YvtIcXNUdfI0nzv4BqLToOdxFkrQi4TVI58PaVerNqmCbCdw03qv/Naq8ZTf9wiN ikCEPUZzF5+tNWaz2pA7Z2jjIEb5TAhgU9E7eWAlBOuetS8t1rt+mFkL0jxEZZp8iRFJg5HjE NIhoHX7tL5uErrNGsFgmBovQqVKl2p9oi1mLWWZvtNOV09u4W2Pdw1uUS9qqr3cboDd6uhcsY DZgW6MbDNjqYA9mkijp8RjyTMlPl68k4OuWYbeDK9aRtAw/60VTbASBbtl8w4b8b2XHH2L6YN CH/nGO3hTyyrLH4RM4tDScHRxoerfHnHZFT/BJ5gsc+Iq9xRAM7wMM4HF2PrKDtPIURCQSW3y ZplH9ssJNrFIeZz0IOSXdH5q0uCzBbZZzgpvPkl8J8ISZO1agSDxCLtv7Bxdf/uIFPByp0fHR gtq/1VjJQjxyRwBqol8O6oyAkmqmnvswziMCu9jWLyNhhtkeUHgkH0hasQR9OkZJcdg9NeNK3 Xo4x/mT0JDe2vBIkuNBB4JkQHw6TMecKOoDbgT7XjeqnIjAPDViWFV+7eLDgWRhDjoDDTT6eq KUuyeIVstbWZ+Z3YXVx2PtrpDhjy/ilVbIgNhvu3hCXKN6ucfUWrdsjgCeGDIxsUmqGDnNhfd oxKyt3Kbzqx/IsRricuvNPi/RUeria5uy0T6DfodVPedz1OHt/hotI6XZYFzss86tiWNiRbG/ elo+CySMsr7FPtAYPn6d8GykpNvgc/a6XBMFmb3BAjhCWNV4+gX/wkGvSdXmwjAnrMf/6PMqS oa07bBUeFQbu2rjffphWGo3zR34sIqHx1aRL42q+IaL1CloO+l34PduUy42TzC1JPNTlZJiIW PUIS3De+AOfmKC06A48bML4wwITualUq9RCu2/XkVwwtczwthelYtexI3aD1JQGLwUVlef5c2 hV0ztaXXpYyF+9UjiZfEbpccelkz0zjHqVKygo91NTJVLQ7xMLCvYgaFfkWhpEAJDfpTlPwVm xqjnc/C36rpqP2lnu9uUdq5bkizW8PXsYoS1c5+CSMWVoRW7O6I9oSg3A== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.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 considered as being part of the daa and thus errorneously included into the checksum calculation. To avoid this, always calculate the layer 4 checksum in software. Signed-off-by: Lino Sanfilippo Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli --- 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 53565f48934c..a201ccf2435d 100644 --- a/net/dsa/tag_ksz.c +++ b/net/dsa/tag_ksz.c @@ -53,6 +53,9 @@ static struct sk_buff *ksz8795_xmit(struct sk_buff *skb, struct net_device *dev) u8 *tag; u8 *addr; + 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); @@ -114,6 +117,9 @@ static struct sk_buff *ksz9477_xmit(struct sk_buff *skb, u8 *addr; u16 val; + 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); @@ -164,6 +170,9 @@ static struct sk_buff *ksz9893_xmit(struct sk_buff *skb, u8 *addr; u8 *tag; + 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);