Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/76199/?format=api
https://patches.dpdk.org/api/patches/76199/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20200901094755.561661-1-michael.pfeiffer@tu-ilmenau.de/", "project": { "id": 1, "url": "https://patches.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": "<20200901094755.561661-1-michael.pfeiffer@tu-ilmenau.de>", "list_archive_url": "https://inbox.dpdk.org/dev/20200901094755.561661-1-michael.pfeiffer@tu-ilmenau.de", "date": "2020-09-01T09:47:55", "name": "[v2] net: calculate checksums for packets with IPv4 options", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "6f234b8642773b45ccb0304f1e5b92d12fce5a8d", "submitter": { "id": 1506, "url": "https://patches.dpdk.org/api/people/1506/?format=api", "name": "Michael Pfeiffer", "email": "michael.pfeiffer@tu-ilmenau.de" }, "delegate": { "id": 1, "url": "https://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "https://patches.dpdk.org/project/dpdk/patch/20200901094755.561661-1-michael.pfeiffer@tu-ilmenau.de/mbox/", "series": [ { "id": 11869, "url": "https://patches.dpdk.org/api/series/11869/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=11869", "date": "2020-09-01T09:47:55", "name": "[v2] net: calculate checksums for packets with IPv4 options", "version": 2, "mbox": "https://patches.dpdk.org/series/11869/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/76199/comments/", "check": "success", "checks": "https://patches.dpdk.org/api/patches/76199/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 01E05A04AC;\n\tTue, 1 Sep 2020 11:48:07 +0200 (CEST)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id D66881BE9D;\n\tTue, 1 Sep 2020 11:48:06 +0200 (CEST)", "from smail.rz.tu-ilmenau.de (smail.rz.tu-ilmenau.de [141.24.186.67])\n by dpdk.org (Postfix) with ESMTP id 6CDB85B30\n for <dev@dpdk.org>; Tue, 1 Sep 2020 11:48:05 +0200 (CEST)", "from localhost.localdomain (unknown [91.137.63.238])\n (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n (No client certificate requested)\n by smail.rz.tu-ilmenau.de (Postfix) with ESMTPSA id E33CF580076;\n Tue, 1 Sep 2020 11:48:04 +0200 (CEST)" ], "From": "Michael Pfeiffer <michael.pfeiffer@tu-ilmenau.de>", "To": "Olivier Matz <olivier.matz@6wind.com>", "Cc": "Andrew Rybchenko <arybchenko@solarflare.com>, dev@dpdk.org,\n Michael Pfeiffer <michael.pfeiffer@tu-ilmenau.de>", "Date": "Tue, 1 Sep 2020 11:47:55 +0200", "Message-Id": "<20200901094755.561661-1-michael.pfeiffer@tu-ilmenau.de>", "X-Mailer": "git-send-email 2.28.0", "In-Reply-To": "<20200821113210.307175-1-michael.pfeiffer@tu-ilmenau.de>", "References": "<20200821113210.307175-1-michael.pfeiffer@tu-ilmenau.de>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH v2] net: calculate checksums for packets with\n\tIPv4 options", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "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": "Currently, rte_ipv4_cksum() and rte_ipv4_udptcp_cksum() assume all IPv4\nheaders have sizeof(struct rte_ipv4_hdr) bytes. This is not true for\nthose (rare) packets with IPv4 options. Thus, both IPv4 and TCP/UDP\nchecksums are calculated wrong.\n\nThis patch fixes the issue by using the actual IPv4 header length from\nthe packet's IHL field.\n\nSigned-off-by: Michael Pfeiffer <michael.pfeiffer@tu-ilmenau.de>\n---\nv2:\n* Use actual header length for sanity check as well.\n* Introduce ip_hdr_len variable to increase readability.\n\n lib/librte_net/rte_ip.h | 21 +++++++++++++--------\n 1 file changed, 13 insertions(+), 8 deletions(-)", "diff": "diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h\nindex fcd1eb342..bb55ebb6f 100644\n--- a/lib/librte_net/rte_ip.h\n+++ b/lib/librte_net/rte_ip.h\n@@ -269,7 +269,7 @@ static inline uint16_t\n rte_ipv4_cksum(const struct rte_ipv4_hdr *ipv4_hdr)\n {\n \tuint16_t cksum;\n-\tcksum = rte_raw_cksum(ipv4_hdr, sizeof(struct rte_ipv4_hdr));\n+\tcksum = rte_raw_cksum(ipv4_hdr, (ipv4_hdr->version_ihl & 0xf) * 4);\n \treturn (uint16_t)~cksum;\n }\n \n@@ -302,6 +302,9 @@ rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags)\n \t\tuint16_t len; /* L4 length. */\n \t} psd_hdr;\n \n+\tuint32_t l3_len;\n+\tuint8_t ip_hdr_len;\n+\n \tpsd_hdr.src_addr = ipv4_hdr->src_addr;\n \tpsd_hdr.dst_addr = ipv4_hdr->dst_addr;\n \tpsd_hdr.zero = 0;\n@@ -309,9 +312,9 @@ rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags)\n \tif (ol_flags & PKT_TX_TCP_SEG) {\n \t\tpsd_hdr.len = 0;\n \t} else {\n-\t\tpsd_hdr.len = rte_cpu_to_be_16(\n-\t\t\t(uint16_t)(rte_be_to_cpu_16(ipv4_hdr->total_length)\n-\t\t\t\t- sizeof(struct rte_ipv4_hdr)));\n+\t\tl3_len = rte_be_to_cpu_16(ipv4_hdr->total_length);\n+\t\tip_hdr_len = (ipv4_hdr->version_ihl & 0xf) * 4;\n+\t\tpsd_hdr.len = rte_cpu_to_be_16((uint16_t)(l3_len - ip_hdr_len));\n \t}\n \treturn rte_raw_cksum(&psd_hdr, sizeof(psd_hdr));\n }\n@@ -319,8 +322,8 @@ rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags)\n /**\n * Process the IPv4 UDP or TCP checksum.\n *\n- * The IPv4 header should not contains options. The IP and layer 4\n- * checksum must be set to 0 in the packet by the caller.\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@@ -334,12 +337,14 @@ 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+\tuint8_t ip_hdr_len;\n \n+\tip_hdr_len = (ipv4_hdr->version_ihl & 0xf) * 4;\n \tl3_len = rte_be_to_cpu_16(ipv4_hdr->total_length);\n-\tif (l3_len < sizeof(struct rte_ipv4_hdr))\n+\tif (l3_len < ip_hdr_len)\n \t\treturn 0;\n \n-\tl4_len = l3_len - sizeof(struct rte_ipv4_hdr);\n+\tl4_len = l3_len - ip_hdr_len;\n \n \tcksum = rte_raw_cksum(l4_hdr, l4_len);\n \tcksum += rte_ipv4_phdr_cksum(ipv4_hdr, 0);\n", "prefixes": [ "v2" ] }{ "id": 76199, "url": "