From patchwork Fri Feb 16 12:00:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 128551 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp483350ljc; Fri, 16 Feb 2018 04:01:38 -0800 (PST) X-Google-Smtp-Source: AH8x224Raq+7p096U4U5oA2rQwlf2l6m6qZML3kq3TYCUqGQLHOu1/U1RUGR77WaHYRo662Hne5s X-Received: by 10.55.49.74 with SMTP id x71mr9564587qkx.133.1518782498470; Fri, 16 Feb 2018 04:01:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518782498; cv=none; d=google.com; s=arc-20160816; b=aDZ1wbCQ8XxtAMCR3BOpaAnDnv9sjfGb65Qy+W5z98FMX5x70z06FKa5MDzgcV76ed jvKXHhPrDj9wEUdb6I6NVDkhH5Bk9Zo6wJxdDn6+y3VHTpGq8mgMskVE5a7MKkIKI5q9 h7+kfTib2LpejLLg9kYNjzbmQz4xn0jMRz/sBg/itHBe2pv0UQIKs6npBKpNEjvREZB/ A+Tx9wk5RqhCdoKaG33/15qHxtaIzjrkusBQMlP45vIR3hLDBjyHHSV65mbGYWhQb57U fwqThSMSUhkLDqJsW74kN4ufiefl6+mSAi4g4IYLFh4PrgBlGopQps9qHsc/i3OjClYL RNHw== 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=kozzLIc6vfbJEDevZiWE4V46j5I0s2r2rpZjLE5smSc=; b=brjAZQpN3atHQSLgHZ9eBv/Fiukd3SdcW0VvE6M24S5Vmmc+JLxeK4rd7dbqEXVi9c icsqcF80LiHO97L4Luk/jWR6xPrYePYTR2akB2Mek/tKkfxk5v9syk5KFvi+RQbhWGbi n3LYXED8h2YvzSWbFL8niQsF6kfvXgTcKrpFbVs7ekdt+XJW8CPZ1h2MGkiR880+xYwF H9vSGaMLZIcBMvvR7RpfGz6BPdeRpw2ZDMKnu8uBjLCAE9mdTC+/Vi+IAhKqTmrW4Egl JbC0xPr85AWG2naVy+hF76O/lq6vklxsSpM6X2X4Q5mpTBj67YKAfoA14YTZyHlP2DyW oYcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id 33si3743178qtg.473.2018.02.16.04.01.37; Fri, 16 Feb 2018 04:01:38 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 F3EF46174D; Fri, 16 Feb 2018 12:01:36 +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=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 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 225A8608C1; Fri, 16 Feb 2018 12:01:25 +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 D84946150B; Fri, 16 Feb 2018 12:01:13 +0000 (UTC) Received: from forward101j.mail.yandex.net (forward101j.mail.yandex.net [5.45.198.241]) by lists.linaro.org (Postfix) with ESMTPS id B10286171D for ; Fri, 16 Feb 2018 12:00:11 +0000 (UTC) Received: from mxback10g.mail.yandex.net (mxback10g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:171]) by forward101j.mail.yandex.net (Yandex) with ESMTP id 518BA1242919 for ; Fri, 16 Feb 2018 15:00:10 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback10g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id wvKwyEguuw-0A4qlhXL; Fri, 16 Feb 2018 15:00:10 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id FzrxHp0zbR-09vOLrKv; Fri, 16 Feb 2018 15:00:09 +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, 16 Feb 2018 15:00:07 +0300 Message-Id: <1518782408-24067-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518782408-24067-1-git-send-email-odpbot@yandex.ru> References: <1518782408-24067-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 487 Subject: [lng-odp] [PATCH v1 1/2] validation: packet: add IPv4 fragments 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: Petri Savolainen Added test cases for IPv4/UDP fragments. Signed-off-by: Petri Savolainen --- /** Email created from pull request 487 (psavol:master-parser-validation-2) ** https://github.com/Linaro/odp/pull/487 ** Patch: https://github.com/Linaro/odp/pull/487.patch ** Base sha: ea529e1c3312459b6722c8a175d7f03ad0251a0a ** Merge commit sha: eaabe19cc054a6abb16e8ea22cc256106e47a7c5 **/ test/common/test_packet_parser.h | 35 +++++++++++++++++++ test/validation/api/packet/packet.c | 70 ++++++++++++++++++++++++++++++++++++- 2 files changed, 104 insertions(+), 1 deletion(-) diff --git a/test/common/test_packet_parser.h b/test/common/test_packet_parser.h index d0a0582ab..fd1b40abf 100644 --- a/test/common/test_packet_parser.h +++ b/test/common/test_packet_parser.h @@ -389,6 +389,41 @@ static const uint8_t test_packet_mcast_eth_ipv6_udp[] = { 0x79, 0x74, 0x65, 0x73, 0x2E }; +static const uint8_t test_packet_ipv4_udp_first_frag[] = { + 0x02, 0x00, 0x00, 0x04, 0x05, 0x06, 0x02, 0x00, + 0x00, 0x01, 0x02, 0x03, 0x08, 0x00, 0x45, 0x00, + 0x00, 0x63, 0x00, 0x01, 0x20, 0x00, 0x40, 0x11, + 0xD9, 0x35, 0xC0, 0xA8, 0x00, 0x01, 0xC0, 0xA8, + 0x00, 0x02, 0x04, 0xD2, 0x16, 0x2E, 0x01, 0x17, + 0x54, 0xF3, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, + 0x73, 0x20, 0x6D, 0x79, 0x20, 0x64, 0x75, 0x6D, + 0x6D, 0x79, 0x20, 0x70, 0x61, 0x79, 0x6C, 0x6F, + 0x61, 0x64, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6E, + 0x67, 0x2E, 0x20, 0x54, 0x68, 0x65, 0x20, 0x6C, + 0x65, 0x6E, 0x67, 0x74, 0x68, 0x20, 0x6F, 0x66, + 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x73, 0x74, + 0x72, 0x69, 0x6E, 0x67, 0x20, 0x69, 0x73, 0x20, + 0x37, 0x31, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, + 0x2E +}; + +static const uint8_t test_packet_ipv4_udp_last_frag[] = { + 0x02, 0x00, 0x00, 0x04, 0x05, 0x06, 0x02, 0x00, + 0x00, 0x01, 0x02, 0x03, 0x08, 0x00, 0x45, 0x00, + 0x00, 0x5B, 0x00, 0x01, 0x00, 0x0A, 0x40, 0x11, + 0xF9, 0x33, 0xC0, 0xA8, 0x00, 0x01, 0xC0, 0xA8, + 0x00, 0x02, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, + 0x73, 0x20, 0x6D, 0x79, 0x20, 0x64, 0x75, 0x6D, + 0x6D, 0x79, 0x20, 0x70, 0x61, 0x79, 0x6C, 0x6F, + 0x61, 0x64, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6E, + 0x67, 0x2E, 0x20, 0x54, 0x68, 0x65, 0x20, 0x6C, + 0x65, 0x6E, 0x67, 0x74, 0x68, 0x20, 0x6F, 0x66, + 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x73, 0x74, + 0x72, 0x69, 0x6E, 0x67, 0x20, 0x69, 0x73, 0x20, + 0x37, 0x31, 0x20, 0x62, 0x79, 0x74, 0x65, 0x73, + 0x2E +}; + #ifdef __cplusplus } #endif diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index db3a47cf8..71bf1d861 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -68,7 +68,9 @@ static uint32_t parse_test_pkt_len[] = { sizeof(test_packet_ipv6_ipsec_esp), sizeof(test_packet_mcast_eth_ipv4_udp), sizeof(test_packet_bcast_eth_ipv4_udp), - sizeof(test_packet_mcast_eth_ipv6_udp) + sizeof(test_packet_mcast_eth_ipv6_udp), + sizeof(test_packet_ipv4_udp_first_frag), + sizeof(test_packet_ipv4_udp_last_frag) }; #define packet_compare_offset(pkt1, off1, pkt2, off2, len) \ @@ -3157,6 +3159,70 @@ static void parse_mcast_eth_ipv6_udp(void) odp_packet_free_multi(pkt, num_pkt); } +/* Ethernet/IPv4/UDP first fragment */ +static void parse_eth_ipv4_udp_first_frag(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_ipv4_udp_first_frag, + sizeof(test_packet_ipv4_udp_first_frag)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + parse.chksums.all_chksum = 0; + + CU_ASSERT(odp_packet_parse(pkt[0], 0, &parse) == 0); + CU_ASSERT(odp_packet_parse_multi(&pkt[1], parse_test.offset_zero, + num_pkt - 1, &parse) == (num_pkt - 1)); + + for (i = 0; i < num_pkt; i++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_ipfrag(pkt[i])); + CU_ASSERT(odp_packet_has_udp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipopt(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet/IPv4/UDP last fragment */ +static void parse_eth_ipv4_udp_last_frag(void) +{ + odp_packet_parse_param_t parse; + int i; + int num_pkt = PARSE_TEST_NUM_PKT; + odp_packet_t pkt[num_pkt]; + + parse_test_alloc(pkt, test_packet_ipv4_udp_last_frag, + sizeof(test_packet_ipv4_udp_last_frag)); + + parse.proto = ODP_PROTO_ETH; + parse.last_layer = ODP_PROTO_LAYER_L4; + parse.chksums.all_chksum = 0; + + CU_ASSERT(odp_packet_parse(pkt[0], 0, &parse) == 0); + CU_ASSERT(odp_packet_parse_multi(&pkt[1], parse_test.offset_zero, + num_pkt - 1, &parse) == (num_pkt - 1)); + + for (i = 0; i < num_pkt; i++) { + CU_ASSERT(odp_packet_has_eth(pkt[i])); + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_ipfrag(pkt[i])); + CU_ASSERT(odp_packet_has_udp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipopt(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + odp_testinfo_t packet_suite[] = { ODP_TEST_INFO(packet_test_alloc_free), ODP_TEST_INFO(packet_test_alloc_free_multi), @@ -3211,6 +3277,8 @@ odp_testinfo_t packet_parse_suite[] = { ODP_TEST_INFO(parse_mcast_eth_ipv4_udp), ODP_TEST_INFO(parse_bcast_eth_ipv4_udp), ODP_TEST_INFO(parse_mcast_eth_ipv6_udp), + ODP_TEST_INFO(parse_eth_ipv4_udp_first_frag), + ODP_TEST_INFO(parse_eth_ipv4_udp_last_frag), ODP_TEST_INFO_NULL, };