From patchwork Thu Aug 24 12:00:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 110893 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp5561852qge; Thu, 24 Aug 2017 05:04:30 -0700 (PDT) X-Received: by 10.55.76.17 with SMTP id z17mr7848366qka.8.1503576270715; Thu, 24 Aug 2017 05:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503576270; cv=none; d=google.com; s=arc-20160816; b=zJSwXSpM8nVdOlsHV2sW4W3Prnsdd0BmU0faD+X9jF4mg94a+fXtDhg2VNJJYCxTBe bxlzIODQ1cXcrHstrE6a5WZQEns4q+BHFf45C8Cf6KLZtD1tg2oqAJ+sPUrTX9w3RkKH x9XrLtnASVPfRViQSm86rC9v6YZUj2Zt9L7a7faT5sEhRWE5ldW7yYtzGbXhQvMzKJxj piBMCgxHXa5bmTIu8L1jXv7yNuJ7XYiphlAv2FIEWPQyg5I8WngaPA7UMd/UKkgHUKnI JU86dAHKawb8P0tmf9isv0f8rmSqEBrqsouUogcKk+aXIsueijLKL1YgxOQRbCMSmgwF PjOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=qbRLZDDSl3NIKcV6OcV+pj3riqGV6kPacWPXQUX0Wpg=; b=zvL+YR1oJvtRqL6GFTHrfJLvAEZulKjWL/OLgRU1OI+w+P5E74+N+j++MDsgHfvLqW xOVsrRU2FuX/SIC0eoHN9bHkJeiIbDBqqyoQQyYcnPKYdXJLHHpjyOZCmf6eFpCY972j 7ZyP6b6Q/DnWFemjGeIARwgsLXuGBuaSR/SyMMn99WX/XgN8fCQTjlg9YrfPBaVulCZP GZTbTp5NT4zr8MaPnGarSLdsgCKb4JB8O2fns3zwhvncokHH01tMfnrR2yh3pO1VEen8 baNEfSKQg73UY0mY1XGyyzSNnNC4dTcrr8HMn2ihBhMlxh9kYUQ+nn+P0Avz/uvEPvIA M/vA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id n192si439791qkn.515.2017.08.24.05.04.30; Thu, 24 Aug 2017 05:04:30 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 2D02F64479; Thu, 24 Aug 2017 12:04:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 0B9C062D19; Thu, 24 Aug 2017 12:01:50 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 1E70C60D7C; Thu, 24 Aug 2017 12:01:31 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id B300E62D19 for ; Thu, 24 Aug 2017 12:00:30 +0000 (UTC) Received: from mxback15j.mail.yandex.net (mxback15j.mail.yandex.net [IPv6:2a02:6b8:0:1619::91]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 237991345C52 for ; Thu, 24 Aug 2017 15:00:23 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback15j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id OBdzNLPNPH-0Mrq1Xxb; Thu, 24 Aug 2017 15:00:22 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 1AcxP7MKsj-0MwCdwp4; Thu, 24 Aug 2017 15:00:22 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 24 Aug 2017 15:00:06 +0300 Message-Id: <1503576008-15890-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503576008-15890-1-git-send-email-odpbot@yandex.ru> References: <1503576008-15890-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 132 Subject: [lng-odp] [PATCH v5 1/3] helper: chksum: calculate checksum in network byte order X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov All examples and usecases assumed network byte order for odph_chksum() return value. Instead of changing this convention, rather document that odph_chksum returns value in network byte order. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 132 (lumag:fix-checksum) ** https://github.com/Linaro/odp/pull/132 ** Patch: https://github.com/Linaro/odp/pull/132.patch ** Base sha: 8705e548f330d23173283fcca62f4afb835a6380 ** Merge commit sha: e256e0810a3feee8b1b91b8d61f21bdfdd339dff **/ helper/include/odp/helper/chksum.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/helper/include/odp/helper/chksum.h b/helper/include/odp/helper/chksum.h index 520e9275..2da0303e 100644 --- a/helper/include/odp/helper/chksum.h +++ b/helper/include/odp/helper/chksum.h @@ -40,16 +40,16 @@ typedef enum { * @param buffer calculate chksum for buffer * @param len buffer length * - * @return checksum value in host cpu order + * @return checksum value in network order */ static inline odp_u16sum_t odph_chksum(void *buffer, int len) { - uint16_t *buf = (uint16_t *)buffer; + odp_u16be_t *buf = (odp_u16be_t *)buffer; uint32_t sum = 0; uint16_t result; for (sum = 0; len > 1; len -= 2) - sum += *buf++; + sum += odp_be_to_cpu_16(*buf++); if (len == 1) sum += *(unsigned char *)buf; @@ -58,7 +58,7 @@ static inline odp_u16sum_t odph_chksum(void *buffer, int len) sum += (sum >> 16); result = ~sum; - return (__odp_force odp_u16sum_t) result; + return odp_cpu_to_be_16(result); } /** From patchwork Thu Aug 24 12:00:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 110892 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp5557824qge; Thu, 24 Aug 2017 05:02:00 -0700 (PDT) X-Received: by 10.237.54.6 with SMTP id e6mr8251864qtb.278.1503576120639; Thu, 24 Aug 2017 05:02:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503576120; cv=none; d=google.com; s=arc-20160816; b=msQ7lJPZKCJ2PeN7qG4Y8NlUPBAswmTofygjyB5MFBb0L4+8NZqMzB3LSZ7H6M09yQ 8gEHEYgjUdMm+CxWBOjYgkrXUhf3Y44dKlWTIjS3lXsEMPKvLsjQ9MKkaXkYzk7eA74w rluUGYGDnvRUmxTQKHdjHvecv3Fh0NIregjM70vF8NZq9rccmiL+CZPN3UWx+0UB/OGV 0j1r/9dcROEZqNCR9GlRpW3Sws2z7jQz6cgRkyNyHD6tbXtJckvvuVKa3O2+OvPFgMMl WJRNUvnLbiCvONv/gHWQxKW6RT5EWAYk/hT/wI5zHwdfgA4K8QukFgFnY1RfxUF9zcE3 ZkZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=2mJNiWkoC3VqNrpyNCIe7tZccX4mbctdLfmHTOqKEj0=; b=Hfz9URHdyfuaHfktVtH8K+HwQP08C0cM2dU9yYRwn4fRGelBwSKlwENPIEbnjoMUA5 2c5mL28G/31PalR56hmUB21iUNFiTYPffi6u3O6oHLXgWkEqVkPyVAUnA/hvRqHHG710 qt3e3UlMssIwwo712RZoWYTkDjRVbT6wYqkZZuBq9qzdZxwgCNEd4WJhuGjLpQ1kjSel 3NXAfcUcMvIrBAQeVze/Edi97ONwAFNl/mUQsfpJOCcSZHgTjwCPv4hsIIvWxsm+UBF+ vdDmoIbLkxjwHiHchwwczaI0WBhStKMTMAut+9m6Pa84oHWhkubVsZY6pykZJ00q91W0 Me0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g26si3781189qte.314.2017.08.24.05.02.00; Thu, 24 Aug 2017 05:02:00 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 10D1A644C6; Thu, 24 Aug 2017 12:02:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id E4B6364460; Thu, 24 Aug 2017 12:01:34 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B5168644A0; Thu, 24 Aug 2017 12:01:26 +0000 (UTC) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [37.140.190.182]) by lists.linaro.org (Postfix) with ESMTPS id 802E760D7C for ; Thu, 24 Aug 2017 12:00:25 +0000 (UTC) Received: from mxback6j.mail.yandex.net (mxback6j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10f]) by forward102o.mail.yandex.net (Yandex) with ESMTP id 0CE745A03F80 for ; Thu, 24 Aug 2017 15:00:24 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback6j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id RPysmkB9d7-0N2CO8su; Thu, 24 Aug 2017 15:00:23 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 1AcxP7MKsj-0Nw4XGG2; Thu, 24 Aug 2017 15:00:23 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 24 Aug 2017 15:00:07 +0300 Message-Id: <1503576008-15890-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503576008-15890-1-git-send-email-odpbot@yandex.ru> References: <1503576008-15890-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 132 Subject: [lng-odp] [PATCH v5 2/3] helper: ip: correct ipv4 header checksum calculation X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Current code for IPv4 header checksum calculation assumes that packet data is aligned on 2-byte boundary, that there are no optional headers, etc. Rewrite checksumming code to properly copy & process headers. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 132 (lumag:fix-checksum) ** https://github.com/Linaro/odp/pull/132 ** Patch: https://github.com/Linaro/odp/pull/132.patch ** Base sha: 8705e548f330d23173283fcca62f4afb835a6380 ** Merge commit sha: e256e0810a3feee8b1b91b8d61f21bdfdd339dff **/ helper/include/odp/helper/ip.h | 75 +++++++++++++++------- .../api/classification/odp_classification_common.c | 3 +- .../classification/odp_classification_test_pmr.c | 2 +- .../api/classification/odp_classification_tests.c | 9 +-- 4 files changed, 58 insertions(+), 31 deletions(-) diff --git a/helper/include/odp/helper/ip.h b/helper/include/odp/helper/ip.h index 91776fad..e0d5c3bf 100644 --- a/helper/include/odp/helper/ip.h +++ b/helper/include/odp/helper/ip.h @@ -74,6 +74,9 @@ extern "C" { /** @internal Returns true if IPv4 packet is a fragment */ #define ODPH_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff) +/** @internal Checksum offset in IPv4 header */ +#define ODPH_IPV4HDR_CSUM_OFFSET 10 + /** IPv4 header */ typedef struct ODP_PACKED { uint8_t ver_ihl; /**< Version / Header length */ @@ -92,6 +95,28 @@ typedef struct ODP_PACKED { ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, "ODPH_IPV4HDR_T__SIZE_ERROR"); +static inline int odph_ipv4_csum(odp_packet_t pkt, + uint32_t offset, + odph_ipv4hdr_t *ip, + odp_u16sum_t *chksum) +{ + int nleft = ODPH_IPV4HDR_IHL(ip->ver_ihl) * 4; + uint16_t buf[nleft / 2]; + int res; + + ip->chksum = 0; + memcpy(buf, ip, sizeof(*ip)); + res = odp_packet_copy_to_mem(pkt, offset + sizeof(*ip), + nleft - sizeof(*ip), + buf + sizeof(*ip) / 2); + if (odp_unlikely(res < 0)) + return res; + + *chksum = odph_chksum(buf, nleft); + + return 0; +} + /** * Check if IPv4 checksum is valid * @@ -102,11 +127,9 @@ ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, static inline int odph_ipv4_csum_valid(odp_packet_t pkt) { uint32_t offset; - odp_u16be_t res = 0; - uint16_t *w; - int nleft = sizeof(odph_ipv4hdr_t); + int res; odph_ipv4hdr_t ip; - odp_u16be_t chksum; + odp_u16sum_t chksum, cur_chksum; offset = odp_packet_l3_offset(pkt); if (offset == ODP_PACKET_OFFSET_INVALID) @@ -114,37 +137,45 @@ static inline int odph_ipv4_csum_valid(odp_packet_t pkt) odp_packet_copy_to_mem(pkt, offset, sizeof(odph_ipv4hdr_t), &ip); - w = (uint16_t *)(void *)&ip; chksum = ip.chksum; - ip.chksum = 0x0; - res = odph_chksum(w, nleft); - return (res == chksum) ? 1 : 0; + res = odph_ipv4_csum(pkt, offset, &ip, &cur_chksum); + if (odp_unlikely(res < 0)) + return 0; + + return (cur_chksum == chksum) ? 1 : 0; } /** * Calculate and fill in IPv4 checksum * - * @note when using this api to populate data destined for the wire - * odp_cpu_to_be_16() can be used to remove sparse warnings - * * @param pkt ODP packet * - * @return IPv4 checksum in host cpu order, or 0 on failure + * @retval 0 on success + * @retval <0 on failure */ -static inline odp_u16sum_t odph_ipv4_csum_update(odp_packet_t pkt) +static inline int odph_ipv4_csum_update(odp_packet_t pkt) { - uint16_t *w; - odph_ipv4hdr_t *ip; - int nleft = sizeof(odph_ipv4hdr_t); + uint32_t offset; + odph_ipv4hdr_t ip; + odp_u16sum_t chksum; + int res; - ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); - if (ip == NULL) - return 0; + offset = odp_packet_l3_offset(pkt); + if (offset == ODP_PACKET_OFFSET_INVALID) + return -1; + + res = odp_packet_copy_to_mem(pkt, offset, sizeof(ip), &ip); + if (odp_unlikely(res < 0)) + return res; + + res = odph_ipv4_csum(pkt, offset, &ip, &chksum); + if (odp_unlikely(res < 0)) + return res; - w = (uint16_t *)(void *)ip; - ip->chksum = odph_chksum(w, nleft); - return ip->chksum; + return odp_packet_copy_from_mem(pkt, + offset + ODPH_IPV4HDR_CSUM_OFFSET, + 2, &chksum); } /** IPv6 version */ diff --git a/test/common_plat/validation/api/classification/odp_classification_common.c b/test/common_plat/validation/api/classification/odp_classification_common.c index de8a9327..e4c49648 100644 --- a/test/common_plat/validation/api/classification/odp_classification_common.c +++ b/test/common_plat/validation/api/classification/odp_classification_common.c @@ -315,8 +315,7 @@ odp_packet_t create_packet(cls_packet_info_t pkt_info) ip->src_addr = odp_cpu_to_be_32(addr); ip->ver_ihl = ODPH_IPV4 << 4 | ODPH_IPV4HDR_IHL_MIN; ip->id = odp_cpu_to_be_16(seqno); - ip->chksum = 0; - ip->chksum = odph_ipv4_csum_update(pkt); + odph_ipv4_csum_update(pkt); ip->proto = next_hdr; ip->tot_len = odp_cpu_to_be_16(l3_len); ip->ttl = DEFAULT_TTL; diff --git a/test/common_plat/validation/api/classification/odp_classification_test_pmr.c b/test/common_plat/validation/api/classification/odp_classification_test_pmr.c index e6b496a1..0d846ffa 100644 --- a/test/common_plat/validation/api/classification/odp_classification_test_pmr.c +++ b/test/common_plat/validation/api/classification/odp_classification_test_pmr.c @@ -1678,7 +1678,7 @@ static void classification_test_pmr_term_daddr(void) odp_pktio_mac_addr(pktio, eth->dst.addr, ODPH_ETHADDR_LEN); ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); ip->dst_addr = odp_cpu_to_be_32(addr); - ip->chksum = odph_ipv4_csum_update(pkt); + odph_ipv4_csum_update(pkt); seqno = cls_pkt_get_seq(pkt); CU_ASSERT(seqno != TEST_SEQ_INVALID); diff --git a/test/common_plat/validation/api/classification/odp_classification_tests.c b/test/common_plat/validation/api/classification/odp_classification_tests.c index a0f73e39..202c84d0 100644 --- a/test/common_plat/validation/api/classification/odp_classification_tests.c +++ b/test/common_plat/validation/api/classification/odp_classification_tests.c @@ -237,8 +237,7 @@ void test_cls_pmr_chain(void) ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); parse_ipv4_string(CLS_PMR_CHAIN_SADDR, &addr, &mask); ip->src_addr = odp_cpu_to_be_32(addr); - ip->chksum = 0; - ip->chksum = odph_ipv4_csum_update(pkt); + odph_ipv4_csum_update(pkt); set_first_supported_pmr_port(pkt, CLS_PMR_CHAIN_PORT); @@ -260,8 +259,7 @@ void test_cls_pmr_chain(void) ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); parse_ipv4_string(CLS_PMR_CHAIN_SADDR, &addr, &mask); ip->src_addr = odp_cpu_to_be_32(addr); - ip->chksum = 0; - ip->chksum = odph_ipv4_csum_update(pkt); + odph_ipv4_csum_update(pkt); enqueue_pktio_interface(pkt, pktio_loop); pkt = receive_packet(&queue, ODP_TIME_SEC_IN_NS); @@ -668,8 +666,7 @@ void test_pktio_pmr_composite_cos(void) ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); parse_ipv4_string(CLS_PMR_SET_SADDR, &addr, &mask); ip->src_addr = odp_cpu_to_be_32(addr); - ip->chksum = 0; - ip->chksum = odph_ipv4_csum_update(pkt); + odph_ipv4_csum_update(pkt); set_first_supported_pmr_port(pkt, CLS_PMR_SET_PORT); enqueue_pktio_interface(pkt, pktio_loop); From patchwork Thu Aug 24 12:00:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 110897 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp5566666qge; Thu, 24 Aug 2017 05:07:44 -0700 (PDT) X-Received: by 10.55.109.134 with SMTP id i128mr8915731qkc.216.1503576464704; Thu, 24 Aug 2017 05:07:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503576464; cv=none; d=google.com; s=arc-20160816; b=TFiok4GHQV9XGv8KLA0uZtj8hJhMDAjELd/7OLGiwRopysZT9q1r6PYtmnGlRjo7nM Xev/J7MZOw3LeDff8tiCBn8mg/f9D/pZWElZ2nOMHKTZTUgF6l8/MQEpr2qZ7/JOd6J6 Pla6sJ4jjTclWFUGzm0rHTtdl6wLcPf7per1FvLGGy6mcYg/xu/4WFjVqjCHOuAwTQHF VeViLiIvjW9pnQ+QhjIKugP4j8vBzjBUq87b+uqlvl1ErcjqoL+yHX6D4jfqaNyVearA cQGfjk+dhqHd3HLlR/k8Y1Yi4DsjGEoVXBgcYi86jDXwS4y0v2r+pLb8wKUSZzBbbpmc sATg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=48lvi7zSMvW1mu6FzP0LTQFUO37gcqAt0DdFHnIYcyw=; b=ujHc64HASIe/pxDeXYTrYP7YPB2lKrgBSxLMfXnv0RyWwbNIyd/WshEvLQdJyKHFP7 wlNq4F1he9JdlppyY22qlo8WmnMnqJZAjfZPahttbf6cypxZunAONncufxszmGACjECl Gd48bMg0vRoDGFkB+zGx/gP8aBqIMn6S/68O/ySOiAcv1SyEojBt5ngzzDgbdTbmDuOv ZpmIjkwuCprBY9+HjQSzQIVgB0vnPpJiLiPjAi4XBB8Mxt6TKKcoKBmHW2XaK7cTnNUj ktwKHxz6X9zFsxLs1XkTEuIX8VRhwH152Xv1COc7/lyRJixtYdAe8oadaL1OvTAlV0jJ lCIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f67si3948703qkf.521.2017.08.24.05.07.44; Thu, 24 Aug 2017 05:07:44 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 5A03A64490; Thu, 24 Aug 2017 12:07:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 4FE06644C6; Thu, 24 Aug 2017 12:02:02 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 386C264464; Thu, 24 Aug 2017 12:01:34 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id 4AC6E6445C for ; Thu, 24 Aug 2017 12:00:31 +0000 (UTC) Received: from mxback8o.mail.yandex.net (mxback8o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::22]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 7754D1341474 for ; Thu, 24 Aug 2017 15:00:24 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback8o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id an0A0pzbGD-0OJmtndj; Thu, 24 Aug 2017 15:00:24 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 1AcxP7MKsj-0OwWFLvO; Thu, 24 Aug 2017 15:00:24 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 24 Aug 2017 15:00:08 +0300 Message-Id: <1503576008-15890-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503576008-15890-1-git-send-email-odpbot@yandex.ru> References: <1503576008-15890-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 132 Subject: [lng-odp] [PATCH v5 3/3] helper: chksum: verify odph_ipv4_chksum_*() functions X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 132 (lumag:fix-checksum) ** https://github.com/Linaro/odp/pull/132 ** Patch: https://github.com/Linaro/odp/pull/132.patch ** Base sha: 8705e548f330d23173283fcca62f4afb835a6380 ** Merge commit sha: e256e0810a3feee8b1b91b8d61f21bdfdd339dff **/ helper/test/chksum.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/helper/test/chksum.c b/helper/test/chksum.c index 1beae47f..4a957c32 100644 --- a/helper/test/chksum.c +++ b/helper/test/chksum.c @@ -108,9 +108,17 @@ int main(int argc ODPH_UNUSED, char *argv[] ODPH_UNUSED) ODPH_IPV4HDR_LEN); ip->proto = ODPH_IPPROTO_UDP; ip->id = odp_cpu_to_be_16(1); - ip->chksum = 0; odp_packet_has_ipv4_set(test_packet, 1); - odph_ipv4_csum_update(test_packet); + if (odph_ipv4_csum_update(test_packet) < 0) + status = -1; + + if (!odph_ipv4_csum_valid(test_packet)) + status = -1; + + printf("IP chksum = 0x%x\n", odp_be_to_cpu_16(ip->chksum)); + + if (odp_be_to_cpu_16(ip->chksum) != 0x3965) + status = -1; /* udp */ odp_packet_l4_offset_set(test_packet, ODPH_ETHHDR_LEN