get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/95082/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 95082,
    "url": "http://patchwork.dpdk.org/api/patches/95082/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20210630135158.8108-4-olivier.matz@6wind.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20210630135158.8108-4-olivier.matz@6wind.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210630135158.8108-4-olivier.matz@6wind.com",
    "date": "2021-06-30T13:51:57",
    "name": "[v2,3/4] net: introduce functions to verify L4 checksums",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "f10a593185c49ff41fb3c386c11b93be1cd2aa51",
    "submitter": {
        "id": 8,
        "url": "http://patchwork.dpdk.org/api/people/8/?format=api",
        "name": "Olivier Matz",
        "email": "olivier.matz@6wind.com"
    },
    "delegate": {
        "id": 3961,
        "url": "http://patchwork.dpdk.org/api/users/3961/?format=api",
        "username": "arybchenko",
        "first_name": "Andrew",
        "last_name": "Rybchenko",
        "email": "andrew.rybchenko@oktetlabs.ru"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20210630135158.8108-4-olivier.matz@6wind.com/mbox/",
    "series": [
        {
            "id": 17552,
            "url": "http://patchwork.dpdk.org/api/series/17552/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=17552",
            "date": "2021-06-30T13:51:54",
            "name": "net/tap: fix Rx cksum",
            "version": 2,
            "mbox": "http://patchwork.dpdk.org/series/17552/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/95082/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/95082/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "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])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 85CA3A0A0F;\n\tWed, 30 Jun 2021 15:52:49 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 7ADBF41287;\n\tWed, 30 Jun 2021 15:52:34 +0200 (CEST)",
            "from mail-wm1-f41.google.com (mail-wm1-f41.google.com\n [209.85.128.41]) by mails.dpdk.org (Postfix) with ESMTP id 3576D41273\n for <dev@dpdk.org>; Wed, 30 Jun 2021 15:52:30 +0200 (CEST)",
            "by mail-wm1-f41.google.com with SMTP id\n l18-20020a1ced120000b029014c1adff1edso4480926wmh.4\n for <dev@dpdk.org>; Wed, 30 Jun 2021 06:52:30 -0700 (PDT)",
            "from gojira.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com.\n [62.23.145.78])\n by smtp.gmail.com with ESMTPSA id g15sm193026wrs.50.2021.06.30.06.52.28\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 30 Jun 2021 06:52:29 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind.com; s=google;\n h=from:to:cc:subject:date:message-id:in-reply-to:references\n :mime-version:content-transfer-encoding;\n bh=Ql9Y5sCUS8yUDG08ePU8Cvv++0Z5mr4+Fp+MgcBb1dI=;\n b=T8jJS14lV0tEsZQ1if6TBnmlTPyv11lJhGpnGgi81/FnJWFXf+/iQoO1FiKEptElqG\n J2GU2mth396490DqlsMDsth45PwwJgmG0mdoBbnOI2UmFYZiEhRc6mMSukJMpVy27BjO\n 5sC+1C9CXBC9YYAB82aYSxC9kpQjSu8vDSqIxxjPktXT/vuhg8XN75GV2DJ242QImVt3\n Lg9zegTDD6sBHfYaez+bRJfb6ib0xm5plB+MKHfCxY9LZQPnAUDfPDMq0hof+MTHytIi\n E1wmOwghHWc4raTZA4Wr4CYkQwoM5O2FMzttZvjWOROjhcZiFOEivZdSRFZk80wHfbQR\n iLDQ==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20161025;\n h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n :references:mime-version:content-transfer-encoding;\n bh=Ql9Y5sCUS8yUDG08ePU8Cvv++0Z5mr4+Fp+MgcBb1dI=;\n b=qskINcosGxECDZ0Eap6mUUTsjATSvKsARhHjQdej+BWX42F+GHTMp8KREcR/6n1eed\n D42VwP2e/bO/MopHbniPTUBFXyQqaTeSNCMf4a4LxhdLQu7kQs0aePl2EtsftmvCc/iV\n i9c0NDsKD1M2VQX5almvQ6HdObKweRfKHFp4pGLQJHNZNhrlAf1xAXhOhLrvznQKMVdI\n P2wRFzw5c/hmM2u/U6lZww6Yt2MhnMgGKy2Uf8KBF+B9NsBk70Tc5DFk6escjlW4Xn16\n hGFUtpSdv+S0GPLwSHR/XqH2Ai/7eYVxlDlXiQUS4xN0IoKQ1wA7hVi3zc07NaynBR9/\n mdpg==",
        "X-Gm-Message-State": "AOAM532eJBI5UqDnVY1iHdz6umqSpwePEjU5nJ6KY0ITXABqx+tV+2z9\n IyhySHxWus00oRxR2JnbJzQgi7MymAMiFA==",
        "X-Google-Smtp-Source": "\n ABdhPJxjV+cW+WZYc8NcahLy9RDkIsWmp99zRGIIpVdlIg+juq9NUJewgEfkX3zkqRrhXouNCBwFeQ==",
        "X-Received": "by 2002:a1c:f705:: with SMTP id v5mr4838478wmh.69.1625061149914;\n Wed, 30 Jun 2021 06:52:29 -0700 (PDT)",
        "From": "Olivier Matz <olivier.matz@6wind.com>",
        "To": "dev@dpdk.org",
        "Cc": "guohongzhi1@huawei.com, keith.wiles@intel.com, mb@smartsharesystems.com,\n 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>\n <20210630135158.8108-1-olivier.matz@6wind.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v2 3/4] net: introduce functions to verify L4\n checksums",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Since commit d5df2ae0428a (\"net: fix unneeded replacement of TCP\nchecksum 0\"), the functions rte_ipv4_udptcp_cksum() and\nrte_ipv6_udptcp_cksum() can return either 0x0000 or 0xffff when used to\nverify a packet containing a valid checksum.\n\nSince these functions should be used to calculate the checksum to set in\na packet, introduce 2 new helpers for checksum verification. They return\n0 if the checksum is valid in the packet.\n\nUse this new helper in net/tap driver.\n\nSigned-off-by: Olivier Matz <olivier.matz@6wind.com>\nAcked-by: Morten Brørup <mb@smartsharesystems.com>\n---\n drivers/net/tap/rte_eth_tap.c |   7 +-\n lib/net/rte_ip.h              | 127 +++++++++++++++++++++++++++-------\n 2 files changed, 107 insertions(+), 27 deletions(-)",
    "diff": "diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c\nindex 5429f611c1..2229eef059 100644\n--- a/drivers/net/tap/rte_eth_tap.c\n+++ b/drivers/net/tap/rte_eth_tap.c\n@@ -369,11 +369,12 @@ tap_verify_csum(struct rte_mbuf *mbuf)\n \t\t\t\t\treturn;\n \t\t\t\t}\n \t\t\t}\n-\t\t\tcksum = rte_ipv4_udptcp_cksum(l3_hdr, l4_hdr);\n+\t\t\tcksum_ok = !rte_ipv4_udptcp_cksum_verify(l3_hdr,\n+\t\t\t\t\t\t\t\t l4_hdr);\n \t\t} else { /* l3 == RTE_PTYPE_L3_IPV6, checked above */\n-\t\t\tcksum = rte_ipv6_udptcp_cksum(l3_hdr, l4_hdr);\n+\t\t\tcksum_ok = !rte_ipv6_udptcp_cksum_verify(l3_hdr,\n+\t\t\t\t\t\t\t\t l4_hdr);\n \t\t}\n-\t\tcksum_ok = (cksum == 0) || (cksum == 0xffff);\n \t\tmbuf->ol_flags |= cksum_ok ?\n \t\t\tPKT_RX_L4_CKSUM_GOOD : PKT_RX_L4_CKSUM_BAD;\n \t}\ndiff --git a/lib/net/rte_ip.h b/lib/net/rte_ip.h\nindex 4b728969c1..05948b69b7 100644\n--- a/lib/net/rte_ip.h\n+++ b/lib/net/rte_ip.h\n@@ -344,20 +344,10 @@ rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags)\n }\n \n /**\n- * Process the IPv4 UDP or TCP checksum.\n- *\n- * The IP and layer 4 checksum must be set to 0 in the packet by\n- * the caller.\n- *\n- * @param ipv4_hdr\n- *   The pointer to the contiguous IPv4 header.\n- * @param l4_hdr\n- *   The pointer to the beginning of the L4 header.\n- * @return\n- *   The complemented checksum to set in the IP packet.\n+ * @internal Calculate the non-complemented IPv4 L4 checksum\n  */\n static inline uint16_t\n-rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr)\n+__rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr)\n {\n \tuint32_t cksum;\n \tuint32_t l3_len, l4_len;\n@@ -374,16 +364,65 @@ rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr)\n \tcksum += rte_ipv4_phdr_cksum(ipv4_hdr, 0);\n \n \tcksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff);\n-\tcksum = (~cksum) & 0xffff;\n+\n+\treturn (uint16_t)cksum;\n+}\n+\n+/**\n+ * Process the IPv4 UDP or TCP checksum.\n+ *\n+ * The IP and layer 4 checksum must be set to 0 in the packet by\n+ * the caller.\n+ *\n+ * @param ipv4_hdr\n+ *   The pointer to the contiguous IPv4 header.\n+ * @param l4_hdr\n+ *   The pointer to the beginning of the L4 header.\n+ * @return\n+ *   The complemented checksum to set in the IP packet.\n+ */\n+static inline uint16_t\n+rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr)\n+{\n+\tuint16_t cksum = __rte_ipv4_udptcp_cksum(ipv4_hdr, l4_hdr);\n+\n+\tcksum = ~cksum;\n+\n \t/*\n-\t * Per RFC 768:If the computed checksum is zero for UDP,\n+\t * Per RFC 768: If the computed checksum is zero for UDP,\n \t * it is transmitted as all ones\n \t * (the equivalent in one's complement arithmetic).\n \t */\n \tif (cksum == 0 && ipv4_hdr->next_proto_id == IPPROTO_UDP)\n \t\tcksum = 0xffff;\n \n-\treturn (uint16_t)cksum;\n+\treturn cksum;\n+}\n+\n+/**\n+ * Validate the IPv4 UDP or TCP checksum.\n+ *\n+ * In case of UDP, the caller must first check if udp_hdr->dgram_cksum is 0\n+ * (i.e. no checksum).\n+ *\n+ * @param ipv4_hdr\n+ *   The pointer to the contiguous IPv4 header.\n+ * @param l4_hdr\n+ *   The pointer to the beginning of the L4 header.\n+ * @return\n+ *   Return 0 if the checksum is correct, else -1.\n+ */\n+__rte_experimental\n+static inline int\n+rte_ipv4_udptcp_cksum_verify(const struct rte_ipv4_hdr *ipv4_hdr,\n+\t\t\t     const void *l4_hdr)\n+{\n+\tuint16_t cksum = __rte_ipv4_udptcp_cksum(ipv4_hdr, l4_hdr);\n+\n+\tif (cksum != 0xffff)\n+\t\treturn -1;\n+\n+\treturn 0;\n }\n \n /**\n@@ -448,6 +487,25 @@ rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)\n \treturn __rte_raw_cksum_reduce(sum);\n }\n \n+/**\n+ * @internal Calculate the non-complemented IPv4 L4 checksum\n+ */\n+static inline uint16_t\n+__rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr)\n+{\n+\tuint32_t cksum;\n+\tuint32_t l4_len;\n+\n+\tl4_len = rte_be_to_cpu_16(ipv6_hdr->payload_len);\n+\n+\tcksum = rte_raw_cksum(l4_hdr, l4_len);\n+\tcksum += rte_ipv6_phdr_cksum(ipv6_hdr, 0);\n+\n+\tcksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff);\n+\n+\treturn (uint16_t)cksum;\n+}\n+\n /**\n  * Process the IPv6 UDP or TCP checksum.\n  *\n@@ -464,16 +522,10 @@ rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)\n static inline uint16_t\n rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr)\n {\n-\tuint32_t cksum;\n-\tuint32_t l4_len;\n+\tuint16_t cksum = __rte_ipv6_udptcp_cksum(ipv6_hdr, l4_hdr);\n \n-\tl4_len = rte_be_to_cpu_16(ipv6_hdr->payload_len);\n-\n-\tcksum = rte_raw_cksum(l4_hdr, l4_len);\n-\tcksum += rte_ipv6_phdr_cksum(ipv6_hdr, 0);\n+\tcksum = ~cksum;\n \n-\tcksum = ((cksum & 0xffff0000) >> 16) + (cksum & 0xffff);\n-\tcksum = (~cksum) & 0xffff;\n \t/*\n \t * Per RFC 768: If the computed checksum is zero for UDP,\n \t * it is transmitted as all ones\n@@ -482,7 +534,34 @@ rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr)\n \tif (cksum == 0 && ipv6_hdr->proto == IPPROTO_UDP)\n \t\tcksum = 0xffff;\n \n-\treturn (uint16_t)cksum;\n+\treturn cksum;\n+}\n+\n+/**\n+ * Validate the IPv6 UDP or TCP checksum.\n+ *\n+ * In case of UDP, the caller must first check if udp_hdr->dgram_cksum is 0:\n+ * this is either invalid or means no checksum in some situations. See 8.1\n+ * (Upper-Layer Checksums) in RFC 8200.\n+ *\n+ * @param ipv6_hdr\n+ *   The pointer to the contiguous IPv6 header.\n+ * @param l4_hdr\n+ *   The pointer to the beginning of the L4 header.\n+ * @return\n+ *   Return 0 if the checksum is correct, else -1.\n+ */\n+__rte_experimental\n+static inline int\n+rte_ipv6_udptcp_cksum_verify(const struct rte_ipv6_hdr *ipv6_hdr,\n+\t\t\t     const void *l4_hdr)\n+{\n+\tuint16_t cksum = __rte_ipv6_udptcp_cksum(ipv6_hdr, l4_hdr);\n+\n+\tif (cksum != 0xffff)\n+\t\treturn -1;\n+\n+\treturn 0;\n }\n \n /** IPv6 fragment extension header. */\n",
    "prefixes": [
        "v2",
        "3/4"
    ]
}