From patchwork Fri Aug 25 10:00:05 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: 110977 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp723476ybm; Fri, 25 Aug 2017 03:02:41 -0700 (PDT) X-Received: by 10.237.59.207 with SMTP id s15mr13454084qte.340.1503655361568; Fri, 25 Aug 2017 03:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503655361; cv=none; d=google.com; s=arc-20160816; b=S9K7BXnLFQ1LTr2RDnzW+EwQvuDoFuot7cGPrWGIdTtRydrbpCviiYBnl6XDvO/3rt 8hEH9T8m9QRq7+pnwaxbjLD++ku+RsrVGQcgkTEjYb+4koBvGai9hHZxfXiSHGie+/Rf 1W3kQ9nlezxbPKJ8Ucv+LMf1cPqK1JOb3OZPi0yvokmDyCfsD6rcLguTZkruuCU6wDLa s/2gn/1uxzs59qDdcQuyfAa0c8zzI1x96a3rQokZDcsqD32lzHCgv1fkoOQhsNW4+FjL G2wYdmEHwHMOudIjBIvQ2WoEFswX3nI601anUAZZ6qpp8EdB01YbsE+oaDnxBXsGey7U i5zQ== 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=Bksx4h8o/ky9tpWbJZjwXuiwcZWTjJTgd+wcd1sbP88=; b=ixAlbaaGVkM7T4rDeBGoKjSlN2z0uFRRx1ewi9dWFeHfqlt3B7Z3MJ+80BF96Vmpc2 oFiaucTVH/tiROb8SIEGd+SlZxAliaXasHYW1LbsVNwA0ffeDS+QrNLzCtuHjiHb2B9u BRY0mG5W+fGMiXdriPlXdAhZhZ3aRbYLE2NfaKwP5G49J+bHRoEd7SyWaNwDdGs4B5sS VwMwIXbg2uGXqy2kkNupLmYhbihd5jv4jpjUKKAt0SvWtbXz046KXEBRbi+SU0Gi9EjT 6sWFaQBqdBzKpO8e73u+n1yA8YuggUMwRIR1ar/PwBYFuAyqxiXyEccjQ1VrUbEMOVCw NWaA== 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 r70si5679655qki.51.2017.08.25.03.02.41; Fri, 25 Aug 2017 03:02:41 -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 3AD8465BFF; Fri, 25 Aug 2017 10:02:41 +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 A1CF465C07; Fri, 25 Aug 2017 10:00:51 +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 1310E65BF8; Fri, 25 Aug 2017 10:00:33 +0000 (UTC) Received: from forward101p.mail.yandex.net (forward101p.mail.yandex.net [77.88.28.101]) by lists.linaro.org (Postfix) with ESMTPS id CC0FA65BF4 for ; Fri, 25 Aug 2017 10:00:29 +0000 (UTC) Received: from mxback13g.mail.yandex.net (mxback13g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:92]) by forward101p.mail.yandex.net (Yandex) with ESMTP id A659A6A8357F for ; Fri, 25 Aug 2017 13:00:26 +0300 (MSK) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [2a02:6b8:0:801::ac]) by mxback13g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id FnFaxqyBAB-0QTWGU2B; Fri, 25 Aug 2017 13:00:26 +0300 Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id irVIP3ZZaC-0QriH6Qa; Fri, 25 Aug 2017 13:00:26 +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: Fri, 25 Aug 2017 13:00:05 +0300 Message-Id: <1503655207-26292-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503655207-26292-1-git-send-email-odpbot@yandex.ru> References: <1503655207-26292-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 132 Subject: [lng-odp] [PATCH v5 1/3] helper: chksum: odph_chksum returns value 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: 7ad532c561535935fe0e51774755fcd4c5bb7ebc **/ helper/include/odp/helper/chksum.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helper/include/odp/helper/chksum.h b/helper/include/odp/helper/chksum.h index 520e9275..1bf950c8 100644 --- a/helper/include/odp/helper/chksum.h +++ b/helper/include/odp/helper/chksum.h @@ -40,7 +40,7 @@ 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) { From patchwork Fri Aug 25 10: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: 110975 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp721625ybm; Fri, 25 Aug 2017 03:01:24 -0700 (PDT) X-Received: by 10.237.33.206 with SMTP id m14mr13044962qtc.9.1503655284607; Fri, 25 Aug 2017 03:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503655284; cv=none; d=google.com; s=arc-20160816; b=T8UMqg/BVj5LGuScOX1wgNGE9h1Esm3QvYEbVauvq7Mnu4Tu58EXb6yfnZs9yL3/gA VFJDVQcM/mhmIOTUp2qAsqXuq1A6F3LAZ4AMGlFGwiMOE7hrOGfWC0zewULq5lPOM80E q0sfrzQuUUZq7xC5sGeUk4N91lFfY3zNuQS00nHQ6bqcCFev13TZAks5D1xApqclxeJh F07t1XREwZeErJdp5dCN1ODTpaGWGK2zRrVpW+LCL581Lwbs8gkNFsdDvc7+jl8DgMRw Ufu6oTt7SxALsFlIye/+XDq02cTLrn4rKgmA2KOJO85JPzjCVZvCsVv/rkcwtXP5CCr3 vMpA== 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=a8D4M7uMkj5Bq/92d5zuDZZgAkmx12JqcpVrCq/X8F4=; b=UuAkuGTDTtDf7Cyx0PQ2njtV7jk6Hrq/0FffsX2Cr4/98wqOAk6pCoMrcpxk63S9XK 5wEmzK1+YywD0QXTQddD0jRpGmTpiig+6uLfoT0UG76+HjQqB3kc/gKmUMIgr/faQrc8 OHxzjYWdM22OW7vIkFoGRMHR+tu+2IS4NVC8qijY/UvMF5wKGp6nIKiZs+6WPvqsONFp 3xTOnui9k/cEox8TtjkCkqYbl+8XgRkIricuK/jNxpgOzjCTnHapluthOGEqhfoIZje9 4aaHPzCIYjkzp/JqkSQm9BJg9I8v5v17BqO14fWksIH4PRsGgxxUnvI54bpjZ4FdtaQh TBnA== 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 f3si5545718qtb.277.2017.08.25.03.01.24; Fri, 25 Aug 2017 03:01:24 -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 3A0B465BF4; Fri, 25 Aug 2017 10:01:24 +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 10F1E65BFB; Fri, 25 Aug 2017 10:00:39 +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 B7D8F65BFA; Fri, 25 Aug 2017 10:00:30 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id C163F65BF7 for ; Fri, 25 Aug 2017 10:00:28 +0000 (UTC) Received: from mxback13j.mail.yandex.net (mxback13j.mail.yandex.net [IPv6:2a02:6b8:0:1619::88]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 588BD13446BD for ; Fri, 25 Aug 2017 13:00:27 +0300 (MSK) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [2a02:6b8:0:801::ac]) by mxback13j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 9LJBtVTQV4-0RT4Tk99; Fri, 25 Aug 2017 13:00:27 +0300 Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id irVIP3ZZaC-0QrKsAQo; Fri, 25 Aug 2017 13:00:26 +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: Fri, 25 Aug 2017 13:00:06 +0300 Message-Id: <1503655207-26292-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503655207-26292-1-git-send-email-odpbot@yandex.ru> References: <1503655207-26292-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: 7ad532c561535935fe0e51774755fcd4c5bb7ebc **/ 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 0acf2cf7..5484a42b 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 @@ -1676,7 +1676,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 Fri Aug 25 10: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: 110976 Delivered-To: patch@linaro.org Received: by 10.37.128.210 with SMTP id c18csp722664ybm; Fri, 25 Aug 2017 03:02:09 -0700 (PDT) X-Received: by 10.200.9.108 with SMTP id z41mr11945581qth.234.1503655329552; Fri, 25 Aug 2017 03:02:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503655329; cv=none; d=google.com; s=arc-20160816; b=plf+dmF9/1Dh2HYgHgbULX4HwXFFF6jj3e4ASBjxZpzW1yjCDlu5wpvvuuSRpwiJ1j Ij7o+2HOlX9T9/OIKMIkRXGJby/4qjpIIz+SrJSHtlBzeu0v9OEpKRp11bDjnX20692b QMHZ/JCbMegbi/1DwR+oGY3TyP40V1wWrh0oAVPF4S2HR3gygsb1QTAeohWXALUD2MlW SBwYB5q9fchc5keqaMFtooNtHf39cx90clOMT2oQbCyq7XUa0xnssZyIE5EbFv8JzSwQ UzIK6Jktt32IzEnTQfHo8DwssYxk7BV4lWaS2ytdX7vRa1nazkEl/WMo0cIYuzRs5yq5 QNvA== 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=zrE3WXhsKNW8qEMgiNgx/4KzfLqJdrsRQU1/LkoYuDs=; b=LU7/nnZuvH0AydC7QDictZYUlwCYIkF37WvvcXYVg0BQRSCDa5aeinb3o+RHC88gkw 6LmbM+N69/AHbYYXQngETYXSh5HfO2iZ/+UXdTP05JlWrTCaNkAGbNuV8DM01Xq0KfxL hUWROBZt7wn2V8yKVPJjgXYG5lCsfUBDa+q0XFVDA7lDT70ZU01ZUjf69Ndni+cH48zq x2FBV+9scDgxhoBS+j+7XTG2MTfOL5z4piSN70rrtYU2K79HgyNqb5P2YjZLetUbQIUE RtOpHZI0vim7GxoylaAz+clLPyRMBpQvRVjTWoX35qbk5qrWWt3+px2AaC8QURA8iBjA 5kow== 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 i65si5606371qkc.431.2017.08.25.03.02.09; Fri, 25 Aug 2017 03:02:09 -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 2864865C08; Fri, 25 Aug 2017 10:02:09 +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, 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 711E065C01; Fri, 25 Aug 2017 10:00:46 +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 3CE8C65BFA; Fri, 25 Aug 2017 10:00:32 +0000 (UTC) Received: from forward105p.mail.yandex.net (forward105p.mail.yandex.net [77.88.28.108]) by lists.linaro.org (Postfix) with ESMTPS id 132A065BF7 for ; Fri, 25 Aug 2017 10:00:31 +0000 (UTC) Received: from mxback16j.mail.yandex.net (mxback16j.mail.yandex.net [IPv6:2a02:6b8:0:1619::92]) by forward105p.mail.yandex.net (Yandex) with ESMTP id 34FF040820DC for ; Fri, 25 Aug 2017 13:00:28 +0300 (MSK) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [2a02:6b8:0:801::ac]) by mxback16j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id IuL1u7P8rS-0S688bA4; Fri, 25 Aug 2017 13:00:28 +0300 Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id irVIP3ZZaC-0RrWEnZE; Fri, 25 Aug 2017 13:00:27 +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: Fri, 25 Aug 2017 13:00:07 +0300 Message-Id: <1503655207-26292-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503655207-26292-1-git-send-email-odpbot@yandex.ru> References: <1503655207-26292-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: 7ad532c561535935fe0e51774755fcd4c5bb7ebc **/ 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