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 A5427A0A0E for ; Tue, 27 Apr 2021 15:58:28 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8DC874126A; Tue, 27 Apr 2021 15:58:28 +0200 (CEST) Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by mails.dpdk.org (Postfix) with ESMTP id 8CD90406A3 for ; Tue, 27 Apr 2021 15:58:24 +0200 (CEST) Received: by mail-wm1-f49.google.com with SMTP id n3-20020a05600c4f83b02901425630b2c2so1097491wmq.1 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=hYiCTwyK4fiZVhmVNi9smzbYDSlrWR9KoGVmw4Czr03LQs/plI9uNeoEpfd5uf1SVR iaQ12JLtBtm59bUl+2FngBUvFNgP2NFWAwhVMSoZ+zgTc1mCTifNGKnxKenjIJjNbOuU CDySJ+ufKu+dmrQMkM8ncrGLqRLkpO+Jg2oFS3oyu8E/Mt2VnsXYBytrXDnm92f9Np3E NmhDtWUsSDOcTGvqQai/RVQDdfbJhi9/Z2vPNuWOoBg5d7jp2wgw447St7kn/OVkLv5q 4wAu6WPPz/uuLw/AXDQe0V4oPhi2arpA87Vwph6D/8Zqrsy7EmRXUs5jE/q1W6u5NKqo n5Ow== X-Gm-Message-State: AOAM531Lcq0mq4QMHFnp8gNnPRbX3v1LTfUVXCaTp/SFJfLBYcbHTXDS LXiparumozsd3qFfADomiqZTJ7PpH0+RtQ== 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-stable] [PATCH 2/4] net/tap: fix Rx cksum flags on TCP packets X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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