From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 03840A0A02; Tue, 27 Apr 2021 15:58:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6C6D641266; Tue, 27 Apr 2021 15:58:27 +0200 (CEST) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by mails.dpdk.org (Postfix) with ESMTP id 9159D41243 for ; Tue, 27 Apr 2021 15:58:24 +0200 (CEST) Received: by mail-wm1-f48.google.com with SMTP id i129so4926664wma.3 for ; Tue, 27 Apr 2021 06:58:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yWA5ktoUNnaZAuLRrsuiTyEQoYhVA/XUN6xF47YxwOY=; b=Rh84MnLqJWTCgM3WaftKrOxPzKMDEfYOEkd4wC98JfmVfZLpJ+CQqvRjAVxVn9pXnx kZijZRGy+xxhf/uFckqwa+lCwD7FG6KSkF4n48xb4+Ncw6pbvHrIP9n58T9DMbwxZqzL glHNJEZPgrOBxr3NlSm0XKLjn/9yPIiQokemXZ1Mlp5KUz/WHp0XVX7ekWsZ2nEKMcme gw5HZKOuReFlu2Rep3PjWI0wPzIlAyFIDl4AMPbdbqeIhjpTPgGCYXsMXjIIbDhKsEU0 fHryJWk6ihJcYi30EX6nTCXIwSk9jArtB4rvf9KGuKAFm0UaSZ+CAqMcfFjx78Ndy5Ly p50g== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=yWA5ktoUNnaZAuLRrsuiTyEQoYhVA/XUN6xF47YxwOY=; b=h6a9a9jzKgSAxFMGtHCPsOcbtMvg65CoWNfHe2evXfpED8+h26oYPBXqtYsmFZ8Z5P BdIokWL5pu/kyffYbwkDRAYi8q8nEIdVbCx6cFUfIDUFoMDUt/b8LsUOPeY4ZlvQD944 QmG7IotFMrh0Tf6YT9RF4WqXde5Jjwzq+m7TWTvKcQfqd4kOqevWc8O9F8zIDMG2Z+Oc hDUfwTJLmYkyqESNiKiOoqSiAMqHQSf4PXQ7ZoqCdbLKp2YS/M8ht5W/yp94fumeBEG/ 6zOfjijb6CEdzxYHW7aTfE2Rw9rTYG5nwGldNShbiw50PTZQlSdYbscxTigdriTZVqUF Hs6w== X-Gm-Message-State: AOAM533QseAFvC/LQEz610jUHQuxEyIhm5LWDIXB51y7AHJUz6ceQSal m37zAmV0v8dN+tZ/yLnTa4Q4R0p0nJnblA== X-Google-Smtp-Source: ABdhPJym2bUtTpsMOpXoANZVDpa/50qFMGr40yfqg43kcyxTz8m6rnZBTfmbSRlCKeluepGG6SJewQ== X-Received: by 2002:a05:600c:48a8:: with SMTP id j40mr7375054wmp.114.1619531904383; Tue, 27 Apr 2021 06:58:24 -0700 (PDT) Received: from gojira.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id h9sm21072213wmb.35.2021.04.27.06.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 06:58:24 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: Keith Wiles , Hongzhi Guo , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Thomas Monjalon , stable@dpdk.org Date: Tue, 27 Apr 2021 15:57:53 +0200 Message-Id: <20210427135755.927-3-olivier.matz@6wind.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427135755.927-1-olivier.matz@6wind.com> References: <20210427135755.927-1-olivier.matz@6wind.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 2/4] net/tap: fix Rx cksum flags on TCP packets X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Since commit d5df2ae0428a ("net: fix unneeded replacement of TCP checksum 0"), the functions rte_ipv4_udptcp_cksum() or rte_ipv6_udptcp_cksum() can return either 0x0000 or 0xffff when used to verify a packet containing a valid checksum. This new behavior broke the checksum verification in tap driver for TCP packets: these packets are marked with PKT_RX_L4_CKSUM_BAD. Fix this by checking the 2 possible values. A next commit will introduce a checksum verification helper to simplify this a bit. Fixes: d5df2ae0428a ("net: fix unneeded replacement of TCP checksum 0") Cc: stable@dpdk.org Signed-off-by: Olivier Matz --- drivers/net/tap/rte_eth_tap.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index e7b185a4b5..71282e8065 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -346,6 +346,8 @@ tap_verify_csum(struct rte_mbuf *mbuf) return; } if (l4 == RTE_PTYPE_L4_UDP || l4 == RTE_PTYPE_L4_TCP) { + int cksum_ok; + l4_hdr = rte_pktmbuf_mtod_offset(mbuf, void *, l2_len + l3_len); /* Don't verify checksum for multi-segment packets. */ if (mbuf->nb_segs > 1) @@ -363,13 +365,13 @@ tap_verify_csum(struct rte_mbuf *mbuf) return; } } - cksum = ~rte_ipv4_udptcp_cksum(l3_hdr, l4_hdr); + cksum = rte_ipv4_udptcp_cksum(l3_hdr, l4_hdr); } else { /* l3 == RTE_PTYPE_L3_IPV6, checked above */ - cksum = ~rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr); + cksum = rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr); } - mbuf->ol_flags |= cksum ? - PKT_RX_L4_CKSUM_BAD : - PKT_RX_L4_CKSUM_GOOD; + cksum_ok = (cksum == 0) || (cksum == 0xffff); + mbuf->ol_flags |= cksum_ok ? + PKT_RX_L4_CKSUM_GOOD : PKT_RX_L4_CKSUM_BAD; } } -- 2.29.2