From patchwork Wed Jun 30 13:51:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 95080 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 084C7A0A0F; Wed, 30 Jun 2021 15:52:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 11AF54127A; Wed, 30 Jun 2021 15:52:32 +0200 (CEST) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mails.dpdk.org (Postfix) with ESMTP id 6D5BC41221 for ; Wed, 30 Jun 2021 15:52:28 +0200 (CEST) Received: by mail-wr1-f46.google.com with SMTP id j2so3711617wrs.12 for ; Wed, 30 Jun 2021 06:52:28 -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=r0c+JEWF44KsZ3Jo9Za0B/o6DO1SFW7AcGoN6uYcS6w=; b=DLkhOzdhV+mOhBsg5zcG1ZFbGdE+9a5jYTa6fBh5DX6WQ6QTeYZiLZiImT1QYjqbRC JgflF46gzNkA99ehlSrrjeEBgs6abUte7JtgV58LpFIC7Kw2TtQWQ1qztDCwY7mM0X0Z acLqjOxOxL5y1Njf6mzf/R0sKk6RfmLGUKzrEuHqtpUQ08bBv6Zyw9kwgB+xhOmOiO7T V+LfonsogPkS5WSKZ+2ryIx11e1GB3cBBf+ADFg3UyIfJL5qgkPXy/7LpBsiHmm1osOi a3n1s2AQW+VnYPQVhMelm1aNuIW0lSR6sdYp7gqqa2iCr3bC/YnqA8pGbb6knat6lgop jdcw== 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=r0c+JEWF44KsZ3Jo9Za0B/o6DO1SFW7AcGoN6uYcS6w=; b=Cbj9GZhL1QFaKe+0YMsxsdRA//+cdh1nn50bTY9lsNxGmp2qkYj0fJjqyAO0F+xW/B yb5WDhy0Z7FWsmhjOzBBlBmgYfZML7K13xbnv8lrylVtuFnZI9XK2e3LGivVep4QhfSJ uqNXjl+2kfqhjYXVkhBJsgPCnffTBexXXhULmizVgniDiS8YvTpFtsvupSzgpcnZS/w3 tzdcZ79zU4r7CvPjtV7ZZJEB1XxhW2WTNxN0SJVcZGh5i3y3G6xd0ubxGUwb98k9iWRe wPs/5d+tWSecjquAewQa8PUvFdp3YRgj1m4y3QN5WhTGpGxCh8tpoRWXP+EYj24l3AkY fUXw== X-Gm-Message-State: AOAM533/R+51s7WKJpGtlYWktVulhW/FjZXNljLdIp2ESZVolh0nkp8u MozkKfXTUpvfJDYey9GPnBivQzQvQXo2Pw== X-Google-Smtp-Source: ABdhPJxgB+xAgNUE3Uq/1GcRcc+UtQY2vSMfpXFvQ8hGdQq9FklD3RJiJRJ3ptLZmFEhuxab9Hm4Yg== X-Received: by 2002:a5d:6b82:: with SMTP id n2mr38760387wrx.206.1625061148173; Wed, 30 Jun 2021 06:52:28 -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 g15sm193026wrs.50.2021.06.30.06.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 06:52:27 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: guohongzhi1@huawei.com, keith.wiles@intel.com, mb@smartsharesystems.com, thomas@monjalon.net, ferruh.yigit@intel.com, andrew.rybchenko@oktetlabs.ru, stable@dpdk.org Date: Wed, 30 Jun 2021 15:51:55 +0200 Message-Id: <20210630135158.8108-2-olivier.matz@6wind.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210630135158.8108-1-olivier.matz@6wind.com> References: <20210427135755.927-1-olivier.matz@6wind.com> <20210630135158.8108-1-olivier.matz@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 1/4] net/tap: fix Rx cksum flags on IP options 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" When packet type is IPV4_EXT, the checksum is always marked as good in the mbuf offload flags. Since we know the header lengths, we can easily call rte_ipv4_udptcp_cksum() in this case too. Fixes: 8ae3023387e9 ("net/tap: add Rx/Tx checksum offload support") Cc: stable@dpdk.org Signed-off-by: Olivier Matz --- drivers/net/tap/rte_eth_tap.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 5735988e7c..5513cfd2d7 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -342,7 +342,11 @@ tap_verify_csum(struct rte_mbuf *mbuf) rte_pktmbuf_data_len(mbuf)) return; } else { - /* IPv6 extensions are not supported */ + /* - RTE_PTYPE_L3_IPV4_EXT_UNKNOWN cannot happen because + * mbuf->packet_type is filled by rte_net_get_ptype() which + * never returns this value. + * - IPv6 extensions are not supported. + */ return; } if (l4 == RTE_PTYPE_L4_UDP || l4 == RTE_PTYPE_L4_TCP) { @@ -350,7 +354,7 @@ tap_verify_csum(struct rte_mbuf *mbuf) /* Don't verify checksum for multi-segment packets. */ if (mbuf->nb_segs > 1) return; - if (l3 == RTE_PTYPE_L3_IPV4) { + if (l3 == RTE_PTYPE_L3_IPV4 || l3 == RTE_PTYPE_L3_IPV4_EXT) { if (l4 == RTE_PTYPE_L4_UDP) { udp_hdr = (struct rte_udp_hdr *)l4_hdr; if (udp_hdr->dgram_cksum == 0) { @@ -364,7 +368,7 @@ tap_verify_csum(struct rte_mbuf *mbuf) } } cksum = ~rte_ipv4_udptcp_cksum(l3_hdr, l4_hdr); - } else if (l3 == RTE_PTYPE_L3_IPV6) { + } else { /* l3 == RTE_PTYPE_L3_IPV6, checked above */ cksum = ~rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr); } mbuf->ol_flags |= cksum ? From patchwork Wed Jun 30 13:51:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 95081 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id E1317A0A0F; Wed, 30 Jun 2021 15:52:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 511BA41282; Wed, 30 Jun 2021 15:52:33 +0200 (CEST) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mails.dpdk.org (Postfix) with ESMTP id 0B88C41221 for ; Wed, 30 Jun 2021 15:52:29 +0200 (CEST) Received: by mail-wr1-f46.google.com with SMTP id v5so3773475wrt.3 for ; Wed, 30 Jun 2021 06:52:29 -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=o4SckZWNiSvzj3qHRROP/H8Lco3apigtHUeYza48pXg=; b=TEBQzUD36jvvVkmXs4QCkNvfiBAJSJ5zElTyMXCmWglVfuKjCuwntkK4u71qhxtVE9 Q9qJQqQPK/ZguyJ0azBhqUC4TsZbkg5jrEA6xlXfwIZYxTDVC8FHHQTwUOrGkUAQ76qi II2fDF62YfaouP7AMYxjv8Vf474jefl4y/Ro0W3J3Rt4mEL9PdhB5GqUeNVO/TLuJUtj R47/tL/qOh04Qyk4hYDQeZzIM0ete3thjcglVRE97lDhz8uuGH7nmt9P7pBhgB0/Wg04 W+N8QhFqAJRVd2kyoon5q5TpZPqVAlTSlNmkT3XqINHStgmt8RVWBtfzpLvl50YviG+U 2x+A== 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=o4SckZWNiSvzj3qHRROP/H8Lco3apigtHUeYza48pXg=; b=ejZdXyaAioDTGA35g2Dt91I9ZXB1/toYI1znhSbuagQpB2lBd4QcaKB4agmrghT5gF WdY4f/KATSQ36900TaXhnjkwzS+QzOZFk7wAXKf5173jvrducGbv3Vnss6i+CHOhNKRo F+4GtZPNmUNzaMCo5p+EQjFCfYpHdo2iIvFgh5prTDc1YvKwJAhpzS/5/HOsyUfYGGoq M+vlkJnfnkqIwos08EiGjEmh5ps7CK1uHWq3CBzyyZ7yDxp0cXoYN9mndykU1h9HoBvb oQHjn8v9r74zbTV5yMT/tPwEHB1VcTHNiiXodboFP5THmZq7ffFkjdOIYFwFjH7yOKnW QmFg== X-Gm-Message-State: AOAM531/ltwywfxjfGBxh0WGLL3rIG9TiPTGEH+2csUFbpo1QfEhR3r+ pl0e9Y6FWzHo4P2u7ij1QWxmajTDO3AfWg== X-Google-Smtp-Source: ABdhPJwvO0ceaT1Gwcfx1CktkNozvZ6zMAlUDokAskoESFBWJEYOu7M5ofJecmRKPvhAMnh6ogTJ1A== X-Received: by 2002:a5d:534d:: with SMTP id t13mr19746490wrv.171.1625061148887; Wed, 30 Jun 2021 06:52:28 -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 g15sm193026wrs.50.2021.06.30.06.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 06:52:28 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: guohongzhi1@huawei.com, keith.wiles@intel.com, mb@smartsharesystems.com, thomas@monjalon.net, ferruh.yigit@intel.com, andrew.rybchenko@oktetlabs.ru, stable@dpdk.org Date: Wed, 30 Jun 2021 15:51:56 +0200 Message-Id: <20210630135158.8108-3-olivier.matz@6wind.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210630135158.8108-1-olivier.matz@6wind.com> References: <20210427135755.927-1-olivier.matz@6wind.com> <20210630135158.8108-1-olivier.matz@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 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 Acked-by: Andrew Rybchenko --- 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 5513cfd2d7..5429f611c1 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -350,6 +350,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) @@ -367,13 +369,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; } } From patchwork Wed Jun 30 13:51:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 95082 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 85CA3A0A0F; Wed, 30 Jun 2021 15:52:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7ADBF41287; Wed, 30 Jun 2021 15:52:34 +0200 (CEST) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by mails.dpdk.org (Postfix) with ESMTP id 3576D41273 for ; Wed, 30 Jun 2021 15:52:30 +0200 (CEST) Received: by mail-wm1-f41.google.com with SMTP id l18-20020a1ced120000b029014c1adff1edso4480926wmh.4 for ; Wed, 30 Jun 2021 06:52:30 -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=Ql9Y5sCUS8yUDG08ePU8Cvv++0Z5mr4+Fp+MgcBb1dI=; b=T8jJS14lV0tEsZQ1if6TBnmlTPyv11lJhGpnGgi81/FnJWFXf+/iQoO1FiKEptElqG J2GU2mth396490DqlsMDsth45PwwJgmG0mdoBbnOI2UmFYZiEhRc6mMSukJMpVy27BjO 5sC+1C9CXBC9YYAB82aYSxC9kpQjSu8vDSqIxxjPktXT/vuhg8XN75GV2DJ242QImVt3 Lg9zegTDD6sBHfYaez+bRJfb6ib0xm5plB+MKHfCxY9LZQPnAUDfPDMq0hof+MTHytIi E1wmOwghHWc4raTZA4Wr4CYkQwoM5O2FMzttZvjWOROjhcZiFOEivZdSRFZk80wHfbQR iLDQ== 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=Ql9Y5sCUS8yUDG08ePU8Cvv++0Z5mr4+Fp+MgcBb1dI=; b=qskINcosGxECDZ0Eap6mUUTsjATSvKsARhHjQdej+BWX42F+GHTMp8KREcR/6n1eed D42VwP2e/bO/MopHbniPTUBFXyQqaTeSNCMf4a4LxhdLQu7kQs0aePl2EtsftmvCc/iV i9c0NDsKD1M2VQX5almvQ6HdObKweRfKHFp4pGLQJHNZNhrlAf1xAXhOhLrvznQKMVdI P2wRFzw5c/hmM2u/U6lZww6Yt2MhnMgGKy2Uf8KBF+B9NsBk70Tc5DFk6escjlW4Xn16 hGFUtpSdv+S0GPLwSHR/XqH2Ai/7eYVxlDlXiQUS4xN0IoKQ1wA7hVi3zc07NaynBR9/ mdpg== X-Gm-Message-State: AOAM532eJBI5UqDnVY1iHdz6umqSpwePEjU5nJ6KY0ITXABqx+tV+2z9 IyhySHxWus00oRxR2JnbJzQgi7MymAMiFA== X-Google-Smtp-Source: ABdhPJxjV+cW+WZYc8NcahLy9RDkIsWmp99zRGIIpVdlIg+juq9NUJewgEfkX3zkqRrhXouNCBwFeQ== X-Received: by 2002:a1c:f705:: with SMTP id v5mr4838478wmh.69.1625061149914; Wed, 30 Jun 2021 06:52:29 -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 g15sm193026wrs.50.2021.06.30.06.52.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 06:52:29 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: guohongzhi1@huawei.com, keith.wiles@intel.com, mb@smartsharesystems.com, thomas@monjalon.net, ferruh.yigit@intel.com, andrew.rybchenko@oktetlabs.ru Date: Wed, 30 Jun 2021 15:51:57 +0200 Message-Id: <20210630135158.8108-4-olivier.matz@6wind.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210630135158.8108-1-olivier.matz@6wind.com> References: <20210427135755.927-1-olivier.matz@6wind.com> <20210630135158.8108-1-olivier.matz@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 3/4] net: introduce functions to verify L4 checksums 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() and rte_ipv6_udptcp_cksum() can return either 0x0000 or 0xffff when used to verify a packet containing a valid checksum. Since these functions should be used to calculate the checksum to set in a packet, introduce 2 new helpers for checksum verification. They return 0 if the checksum is valid in the packet. Use this new helper in net/tap driver. Signed-off-by: Olivier Matz Acked-by: Morten Brørup --- drivers/net/tap/rte_eth_tap.c | 7 +- lib/net/rte_ip.h | 127 +++++++++++++++++++++++++++------- 2 files changed, 107 insertions(+), 27 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 5429f611c1..2229eef059 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -369,11 +369,12 @@ tap_verify_csum(struct rte_mbuf *mbuf) return; } } - cksum = rte_ipv4_udptcp_cksum(l3_hdr, l4_hdr); + cksum_ok = !rte_ipv4_udptcp_cksum_verify(l3_hdr, + l4_hdr); } else { /* l3 == RTE_PTYPE_L3_IPV6, checked above */ - cksum = rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr); + cksum_ok = !rte_ipv6_udptcp_cksum_verify(l3_hdr, + l4_hdr); } - cksum_ok = (cksum == 0) || (cksum == 0xffff); mbuf->ol_flags |= cksum_ok ? PKT_RX_L4_CKSUM_GOOD : PKT_RX_L4_CKSUM_BAD; } diff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h index 4b728969c1..05948b69b7 100644 --- a/lib/net/rte_ip.h +++ b/lib/net/rte_ip.h @@ -344,20 +344,10 @@ rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags) } /** - * Process the IPv4 UDP or TCP checksum. - * - * The IP and layer 4 checksum must be set to 0 in the packet by - * the caller. - * - * @param ipv4_hdr - * The pointer to the contiguous IPv4 header. - * @param l4_hdr - * The pointer to the beginning of the L4 header. - * @return - * The complemented checksum to set in the IP packet. + * @internal Calculate the non-complemented IPv4 L4 checksum */ static inline uint16_t -rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr) +__rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr) { uint32_t cksum; uint32_t l3_len, l4_len; @@ -374,16 +364,65 @@ rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr) cksum += rte_ipv4_phdr_cksum(ipv4_hdr, 0); cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff); - cksum = (~cksum) & 0xffff; + + return (uint16_t)cksum; +} + +/** + * Process the IPv4 UDP or TCP checksum. + * + * The IP and layer 4 checksum must be set to 0 in the packet by + * the caller. + * + * @param ipv4_hdr + * The pointer to the contiguous IPv4 header. + * @param l4_hdr + * The pointer to the beginning of the L4 header. + * @return + * The complemented checksum to set in the IP packet. + */ +static inline uint16_t +rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr) +{ + uint16_t cksum = __rte_ipv4_udptcp_cksum(ipv4_hdr, l4_hdr); + + cksum = ~cksum; + /* - * Per RFC 768:If the computed checksum is zero for UDP, + * Per RFC 768: If the computed checksum is zero for UDP, * it is transmitted as all ones * (the equivalent in one's complement arithmetic). */ if (cksum == 0 && ipv4_hdr->next_proto_id == IPPROTO_UDP) cksum = 0xffff; - return (uint16_t)cksum; + return cksum; +} + +/** + * Validate the IPv4 UDP or TCP checksum. + * + * In case of UDP, the caller must first check if udp_hdr->dgram_cksum is 0 + * (i.e. no checksum). + * + * @param ipv4_hdr + * The pointer to the contiguous IPv4 header. + * @param l4_hdr + * The pointer to the beginning of the L4 header. + * @return + * Return 0 if the checksum is correct, else -1. + */ +__rte_experimental +static inline int +rte_ipv4_udptcp_cksum_verify(const struct rte_ipv4_hdr *ipv4_hdr, + const void *l4_hdr) +{ + uint16_t cksum = __rte_ipv4_udptcp_cksum(ipv4_hdr, l4_hdr); + + if (cksum != 0xffff) + return -1; + + return 0; } /** @@ -448,6 +487,25 @@ rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags) return __rte_raw_cksum_reduce(sum); } +/** + * @internal Calculate the non-complemented IPv4 L4 checksum + */ +static inline uint16_t +__rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr) +{ + uint32_t cksum; + uint32_t l4_len; + + l4_len = rte_be_to_cpu_16(ipv6_hdr->payload_len); + + cksum = rte_raw_cksum(l4_hdr, l4_len); + cksum += rte_ipv6_phdr_cksum(ipv6_hdr, 0); + + cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff); + + return (uint16_t)cksum; +} + /** * Process the IPv6 UDP or TCP checksum. * @@ -464,16 +522,10 @@ rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags) static inline uint16_t rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr) { - uint32_t cksum; - uint32_t l4_len; + uint16_t cksum = __rte_ipv6_udptcp_cksum(ipv6_hdr, l4_hdr); - l4_len = rte_be_to_cpu_16(ipv6_hdr->payload_len); - - cksum = rte_raw_cksum(l4_hdr, l4_len); - cksum += rte_ipv6_phdr_cksum(ipv6_hdr, 0); + cksum = ~cksum; - cksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff); - cksum = (~cksum) & 0xffff; /* * Per RFC 768: If the computed checksum is zero for UDP, * it is transmitted as all ones @@ -482,7 +534,34 @@ rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr) if (cksum == 0 && ipv6_hdr->proto == IPPROTO_UDP) cksum = 0xffff; - return (uint16_t)cksum; + return cksum; +} + +/** + * Validate the IPv6 UDP or TCP checksum. + * + * In case of UDP, the caller must first check if udp_hdr->dgram_cksum is 0: + * this is either invalid or means no checksum in some situations. See 8.1 + * (Upper-Layer Checksums) in RFC 8200. + * + * @param ipv6_hdr + * The pointer to the contiguous IPv6 header. + * @param l4_hdr + * The pointer to the beginning of the L4 header. + * @return + * Return 0 if the checksum is correct, else -1. + */ +__rte_experimental +static inline int +rte_ipv6_udptcp_cksum_verify(const struct rte_ipv6_hdr *ipv6_hdr, + const void *l4_hdr) +{ + uint16_t cksum = __rte_ipv6_udptcp_cksum(ipv6_hdr, l4_hdr); + + if (cksum != 0xffff) + return -1; + + return 0; } /** IPv6 fragment extension header. */ From patchwork Wed Jun 30 13:51:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 95083 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4290DA0A0F; Wed, 30 Jun 2021 15:52:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A5D24128C; Wed, 30 Jun 2021 15:52:35 +0200 (CEST) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by mails.dpdk.org (Postfix) with ESMTP id DDBF741273 for ; Wed, 30 Jun 2021 15:52:30 +0200 (CEST) Received: by mail-wr1-f49.google.com with SMTP id j2so3711773wrs.12 for ; Wed, 30 Jun 2021 06:52:30 -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=evhZW9wftKtpez2phFWijAL4t1JEhsyyuM27rbpI6Ck=; b=G/qH4omHzIfextPgSE4P2xM/tQq3fcAq5LM/6cqWDgT2KYtJmpZqwSAfWP1o5c4b4d F1b+BEj5GZDKE6BzUeEaOkwkXQa0MzBHHf4Hh9yro7aPtKPvglazg9P+WX9KrjujtsSo lPUC3y0grE0AYkG+aP9rwVEDvTnpI/iFBOIyKB8/aRqyAVKr8fBXwk1w3ZYN39vSwg6M uM+va5gTEg71o9AeOwuFDpQfpSljsGKQnyfUo7yUnhHBwCddXwzRpWqwpjwK1ZuZzGbG wBamX9y6YYi2mS9zlugkZHaj/EtgyoHSC8GqQCBF5Fxc2kL5RfTs/LrRXChUMryT1qrv jIVw== 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=evhZW9wftKtpez2phFWijAL4t1JEhsyyuM27rbpI6Ck=; b=e1o1Pe40qoFhwdeIasajY/zRVgOITv2ljZ5chLOtZZuF9sx0Jj6Kj5nZXXOyStoDHR kUvSmmvotIWe1nKhd10yRwrlHQyQOw5bqVB55nR7yWOSYwIpxHuaVa1CDCgAlFJ7mzBJ WXYdkAjy+FzuH6UJZEa1gbyVhUZAnDCx8vVFatcqZA01L6937uSyWfd3V8Dn7Nk62ySm BRAXRw7OEZUT9VdMSTc8r1xvc44tlJgrrQBFzzDIk+QVtiwRuQYHoV3bYCeauW87WTb9 rTv5B9myW9VGreBHKqxAwo08KKl5xmTGQOV+tiK5MLg6JaNBJl9yGrrgQqYlOqz5WaZ4 uRQQ== X-Gm-Message-State: AOAM531riXUHyt1lDpvmaViE+c9VZRLoj3wPeAzcNBleLtdtkpseeMN/ i1w3o6vANWQXFHu96Qtdgf+OOC8JFehdqA== X-Google-Smtp-Source: ABdhPJxIW94nOCR6Zqqn5fdF9wDnD/uZrDjSasAbDVPueT77VP0HiMnr5eBYGIEEU9jGDovwL8BnkA== X-Received: by 2002:a5d:5742:: with SMTP id q2mr20152078wrw.256.1625061150621; Wed, 30 Jun 2021 06:52:30 -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 g15sm193026wrs.50.2021.06.30.06.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 06:52:30 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Cc: guohongzhi1@huawei.com, keith.wiles@intel.com, mb@smartsharesystems.com, thomas@monjalon.net, ferruh.yigit@intel.com, andrew.rybchenko@oktetlabs.ru Date: Wed, 30 Jun 2021 15:51:58 +0200 Message-Id: <20210630135158.8108-5-olivier.matz@6wind.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210630135158.8108-1-olivier.matz@6wind.com> References: <20210427135755.927-1-olivier.matz@6wind.com> <20210630135158.8108-1-olivier.matz@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 4/4] test/cksum: new test for L3/L4 checksum API 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" Add a simple unit test for checksum API. Signed-off-by: Olivier Matz --- MAINTAINERS | 1 + app/test/autotest_data.py | 6 + app/test/meson.build | 2 + app/test/test_cksum.c | 271 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 280 insertions(+) create mode 100644 app/test/test_cksum.c diff --git a/MAINTAINERS b/MAINTAINERS index 5877a16971..4347555ebc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1314,6 +1314,7 @@ Packet processing Network headers M: Olivier Matz F: lib/net/ +F: app/test/test_cksum.c Packet CRC M: Jasvinder Singh diff --git a/app/test/autotest_data.py b/app/test/autotest_data.py index 11f9c8640c..302d6374c1 100644 --- a/app/test/autotest_data.py +++ b/app/test/autotest_data.py @@ -567,6 +567,12 @@ "Func": default_autotest, "Report": None, }, + { + "Name": "Checksum autotest", + "Command": "cksum_autotest", + "Func": default_autotest, + "Report": None, + }, # #Please always keep all dump tests at the end and together! # diff --git a/app/test/meson.build b/app/test/meson.build index 0a5f425578..ef90b16f16 100644 --- a/app/test/meson.build +++ b/app/test/meson.build @@ -17,6 +17,7 @@ test_sources = files( 'test_bitmap.c', 'test_bpf.c', 'test_byteorder.c', + 'test_cksum.c', 'test_cmdline.c', 'test_cmdline_cirbuf.c', 'test_cmdline_etheraddr.c', @@ -188,6 +189,7 @@ fast_tests = [ ['atomic_autotest', false], ['bitops_autotest', true], ['byteorder_autotest', true], + ['cksum_autotest', true], ['cmdline_autotest', true], ['common_autotest', true], ['cpuflags_autotest', true], diff --git a/app/test/test_cksum.c b/app/test/test_cksum.c new file mode 100644 index 0000000000..cd983d7c01 --- /dev/null +++ b/app/test/test_cksum.c @@ -0,0 +1,271 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2021 6WIND S.A. + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include "test.h" + +#define MEMPOOL_CACHE_SIZE 0 +#define MBUF_DATA_SIZE 256 +#define NB_MBUF 128 + +/* + * Test L3/L4 checksum API. + */ + +#define GOTO_FAIL(str, ...) do { \ + printf("cksum test FAILED (l.%d): <" str ">\n", \ + __LINE__, ##__VA_ARGS__); \ + goto fail; \ + } while (0) + +/* generated in scapy with Ether()/IP()/TCP())) */ +static const char test_cksum_ipv4_tcp[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00, + 0x00, 0x28, 0x00, 0x01, 0x00, 0x00, 0x40, 0x06, + 0x7c, 0xcd, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, + 0x00, 0x01, 0x00, 0x14, 0x00, 0x50, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x02, + 0x20, 0x00, 0x91, 0x7c, 0x00, 0x00, + +}; + +/* generated in scapy with Ether()/IPv6()/TCP()) */ +static const char test_cksum_ipv6_tcp[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x60, 0x00, + 0x00, 0x00, 0x00, 0x14, 0x06, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x14, + 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x50, 0x02, 0x20, 0x00, 0x8f, 0x7d, + 0x00, 0x00, +}; + +/* generated in scapy with Ether()/IP()/UDP()/Raw('x')) */ +static const char test_cksum_ipv4_udp[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x45, 0x00, + 0x00, 0x1d, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11, + 0x7c, 0xcd, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, + 0x00, 0x01, 0x00, 0x35, 0x00, 0x35, 0x00, 0x09, + 0x89, 0x6f, 0x78, +}; + +/* generated in scapy with Ether()/IPv6()/UDP()/Raw('x')) */ +static const char test_cksum_ipv6_udp[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x86, 0xdd, 0x60, 0x00, + 0x00, 0x00, 0x00, 0x09, 0x11, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x35, + 0x00, 0x35, 0x00, 0x09, 0x87, 0x70, 0x78, +}; + +/* generated in scapy with Ether()/IP(options='\x00')/UDP()/Raw('x')) */ +static const char test_cksum_ipv4_opts_udp[] = { + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x46, 0x00, + 0x00, 0x21, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11, + 0x7b, 0xc9, 0x7f, 0x00, 0x00, 0x01, 0x7f, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x35, + 0x00, 0x35, 0x00, 0x09, 0x89, 0x6f, 0x78, +}; + +/* test l3/l4 checksum api */ +static int +test_l4_cksum(struct rte_mempool *pktmbuf_pool, const char *pktdata, size_t len) +{ + struct rte_net_hdr_lens hdr_lens; + struct rte_mbuf *m = NULL; + uint32_t packet_type; + uint16_t prev_cksum; + void *l3_hdr; + void *l4_hdr; + uint32_t l3; + uint32_t l4; + char *data; + + m = rte_pktmbuf_alloc(pktmbuf_pool); + if (m == NULL) + GOTO_FAIL("Cannot allocate mbuf"); + + data = rte_pktmbuf_append(m, len); + if (data == NULL) + GOTO_FAIL("Cannot append data"); + + memcpy(data, pktdata, len); + + packet_type = rte_net_get_ptype(m, &hdr_lens, RTE_PTYPE_ALL_MASK); + l3 = packet_type & RTE_PTYPE_L3_MASK; + l4 = packet_type & RTE_PTYPE_L4_MASK; + + l3_hdr = rte_pktmbuf_mtod_offset(m, void *, hdr_lens.l2_len); + l4_hdr = rte_pktmbuf_mtod_offset(m, void *, + hdr_lens.l2_len + hdr_lens.l3_len); + + if (l3 == RTE_PTYPE_L3_IPV4 || l3 == RTE_PTYPE_L3_IPV4_EXT) { + struct rte_ipv4_hdr *ip = l3_hdr; + + /* verify IPv4 checksum */ + if (rte_ipv4_cksum(l3_hdr) != 0) + GOTO_FAIL("invalid IPv4 checksum verification"); + + /* verify bad IPv4 checksum */ + ip->hdr_checksum++; + if (rte_ipv4_cksum(l3_hdr) == 0) + GOTO_FAIL("invalid IPv4 bad checksum verification"); + ip->hdr_checksum--; + + /* recalculate IPv4 checksum */ + prev_cksum = ip->hdr_checksum; + ip->hdr_checksum = 0; + ip->hdr_checksum = rte_ipv4_cksum(ip); + if (ip->hdr_checksum != prev_cksum) + GOTO_FAIL("invalid IPv4 checksum calculation"); + + /* verify L4 checksum */ + if (rte_ipv4_udptcp_cksum_verify(l3_hdr, l4_hdr) != 0) + GOTO_FAIL("invalid L4 checksum verification"); + + if (l4 == RTE_PTYPE_L4_TCP) { + struct rte_tcp_hdr *tcp = l4_hdr; + + /* verify bad TCP checksum */ + tcp->cksum++; + if (rte_ipv4_udptcp_cksum_verify(l3_hdr, l4_hdr) == 0) + GOTO_FAIL("invalid bad TCP checksum verification"); + tcp->cksum--; + + /* recalculate TCP checksum */ + prev_cksum = tcp->cksum; + tcp->cksum = 0; + tcp->cksum = rte_ipv4_udptcp_cksum(l3_hdr, l4_hdr); + if (tcp->cksum != prev_cksum) + GOTO_FAIL("invalid TCP checksum calculation"); + + } else if (l4 == RTE_PTYPE_L4_UDP) { + struct rte_udp_hdr *udp = l4_hdr; + + /* verify bad UDP checksum */ + udp->dgram_cksum++; + if (rte_ipv4_udptcp_cksum_verify(l3_hdr, l4_hdr) == 0) + GOTO_FAIL("invalid bad UDP checksum verification"); + udp->dgram_cksum--; + + /* recalculate UDP checksum */ + prev_cksum = udp->dgram_cksum; + udp->dgram_cksum = 0; + udp->dgram_cksum = rte_ipv4_udptcp_cksum(l3_hdr, + l4_hdr); + if (udp->dgram_cksum != prev_cksum) + GOTO_FAIL("invalid TCP checksum calculation"); + } + } else if (l3 == RTE_PTYPE_L3_IPV6 || l3 == RTE_PTYPE_L3_IPV6_EXT) { + if (rte_ipv6_udptcp_cksum_verify(l3_hdr, l4_hdr) != 0) + GOTO_FAIL("invalid L4 checksum verification"); + + if (l4 == RTE_PTYPE_L4_TCP) { + struct rte_tcp_hdr *tcp = l4_hdr; + + /* verify bad TCP checksum */ + tcp->cksum++; + if (rte_ipv6_udptcp_cksum_verify(l3_hdr, l4_hdr) == 0) + GOTO_FAIL("invalid bad TCP checksum verification"); + tcp->cksum--; + + /* recalculate TCP checksum */ + prev_cksum = tcp->cksum; + tcp->cksum = 0; + tcp->cksum = rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr); + if (tcp->cksum != prev_cksum) + GOTO_FAIL("invalid TCP checksum calculation"); + + } else if (l4 == RTE_PTYPE_L4_UDP) { + struct rte_udp_hdr *udp = l4_hdr; + + /* verify bad UDP checksum */ + udp->dgram_cksum++; + if (rte_ipv6_udptcp_cksum_verify(l3_hdr, l4_hdr) == 0) + GOTO_FAIL("invalid bad UDP checksum verification"); + udp->dgram_cksum--; + + /* recalculate UDP checksum */ + prev_cksum = udp->dgram_cksum; + udp->dgram_cksum = 0; + udp->dgram_cksum = rte_ipv6_udptcp_cksum(l3_hdr, + l4_hdr); + if (udp->dgram_cksum != prev_cksum) + GOTO_FAIL("invalid TCP checksum calculation"); + } + } + + rte_pktmbuf_free(m); + + return 0; + +fail: + if (m) + rte_pktmbuf_free(m); + + return -1; +} + +static int +test_cksum(void) +{ + struct rte_mempool *pktmbuf_pool = NULL; + + /* create pktmbuf pool if it does not exist */ + pktmbuf_pool = rte_pktmbuf_pool_create("test_cksum_mbuf_pool", + NB_MBUF, MEMPOOL_CACHE_SIZE, 0, MBUF_DATA_SIZE, + SOCKET_ID_ANY); + + if (pktmbuf_pool == NULL) + GOTO_FAIL("cannot allocate mbuf pool"); + + if (test_l4_cksum(pktmbuf_pool, test_cksum_ipv4_tcp, + sizeof(test_cksum_ipv4_tcp)) < 0) + GOTO_FAIL("checksum error on ipv4_tcp"); + + if (test_l4_cksum(pktmbuf_pool, test_cksum_ipv6_tcp, + sizeof(test_cksum_ipv6_tcp)) < 0) + GOTO_FAIL("checksum error on ipv6_tcp"); + + if (test_l4_cksum(pktmbuf_pool, test_cksum_ipv4_udp, + sizeof(test_cksum_ipv4_udp)) < 0) + GOTO_FAIL("checksum error on ipv4_udp"); + + if (test_l4_cksum(pktmbuf_pool, test_cksum_ipv6_udp, + sizeof(test_cksum_ipv6_udp)) < 0) + GOTO_FAIL("checksum error on ipv6_udp"); + + if (test_l4_cksum(pktmbuf_pool, test_cksum_ipv4_opts_udp, + sizeof(test_cksum_ipv4_opts_udp)) < 0) + GOTO_FAIL("checksum error on ipv4_opts_udp"); + + rte_mempool_free(pktmbuf_pool); + + return 0; + +fail: + rte_mempool_free(pktmbuf_pool); + + return -1; +} +#undef GOTO_FAIL + +REGISTER_TEST_COMMAND(cksum_autotest, test_cksum);