From patchwork Tue Feb 13 14:00:10 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: 128241 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4286669ljc; Tue, 13 Feb 2018 06:05:38 -0800 (PST) X-Google-Smtp-Source: AH8x224WgGdAPVbaS3NQaTMTukFv9f9AhdzEqlVYANnOAxBHso/v8IjnvBIe1J3gM6H6WA3jA4DJ X-Received: by 10.237.37.196 with SMTP id y4mr2193143qtc.182.1518530738141; Tue, 13 Feb 2018 06:05:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518530738; cv=none; d=google.com; s=arc-20160816; b=SnrvQ/VIWmcGlGAkBnq2bXcK7ubdbTKM1JznDU0xYvreaQkqCdoyeBSsaziAqlBcp7 sN593t9hyAxubqxDD3aeuMvuriUaPvh6MyxuM/MH3rhtw3QYDcCBvQro+zF4hd1QcE5v YLeQQHcKZbcXavqqRgmOqjMCtU7oBlKXcLe7qzLu1aBJXrhqia67so9V0lrKAcLTttRo BA3AnCPP2kLv7ykM8KZMA+OaQ4DS4D8inBj1jZWQkJNKMHwSAeDLF9W4FxjPTUgoXHUN 8+zZxN7QZvtKIHJnyh+/LNYIHfsWLulOGhCpgb1Gglaf0eNwUf+dlmJ45tlgDEdDHC4J mOdg== 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=JGSbF3jEmtAEpZDu31FHb5ixhzjUTIFekR+c1wyHPEw=; b=Zx/ACREUXNg+9MnvbzmlVs4AWKEk4UizK8SrS3eKk1O+LfL05MGISVWXc6gsU2Cjbh IOTMNuEe2i02t//3IfrqWwHjw/x/NxtlOsT7WoIijvjbU0UwQtco6P1J+SPZt/PpaYT7 AvjmMwk0bkhQ5CQLaTay7lzVgP7xOYQ9+XDqfuAJSaD5WtxRvPdMcDPVoFcjgAwSIpr3 vqDDbYMfxJUMuUZWj1IV4FJ2BVchMXaewi82HtrDm8/MGiMfvbJLbqxl/gjJD6DkDVlr 2JTrZTdrmv7RgoLLLjsdhcqfAFqKAptu3pIZjbe6sO85KgKYO++5H9lhNw80k0bCmM1j Q1Mg== 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 x4si5125533qkl.113.2018.02.13.06.05.37; Tue, 13 Feb 2018 06:05: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 CAF9660855; Tue, 13 Feb 2018 14:05:37 +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 1A724616F9; Tue, 13 Feb 2018 14:00:47 +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 C938D60928; Tue, 13 Feb 2018 14:00:26 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id 5AF9B60C5E for ; Tue, 13 Feb 2018 14:00:19 +0000 (UTC) Received: from mxback20j.mail.yandex.net (mxback20j.mail.yandex.net [IPv6:2a02:6b8:0:1619::114]) by forward101o.mail.yandex.net (Yandex) with ESMTP id D49DD1341F97 for ; Tue, 13 Feb 2018 17:00:17 +0300 (MSK) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [2a02:6b8:0:1a2d::25]) by mxback20j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id IXBW65Z65s-0HI0WMQg; Tue, 13 Feb 2018 17:00:17 +0300 Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 6Ss5leStGE-0HFe50Ig; Tue, 13 Feb 2018 17:00:17 +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: Tue, 13 Feb 2018 17:00:10 +0300 Message-Id: <1518530410-18574-8-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518530410-18574-1-git-send-email-odpbot@yandex.ru> References: <1518530410-18574-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 472 Subject: [lng-odp] [PATCH v2 7/7] validation: packet: add IP multicast tests 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 Ethernet/IP multi- and broadcasts. Signed-off-by: Petri Savolainen --- /** Email created from pull request 472 (psavol:master-parser-validation) ** https://github.com/Linaro/odp/pull/472 ** Patch: https://github.com/Linaro/odp/pull/472.patch ** Base sha: 41b3fa2cd994a7ef68290a07dcde5564e4640847 ** Merge commit sha: 38d924655e8119f902e986011a477e1ad9094ab6 **/ test/common/test_packet_parser.h | 56 ++++++++++++++++++ test/validation/api/packet/packet.c | 111 +++++++++++++++++++++++++++++++++++- 2 files changed, 166 insertions(+), 1 deletion(-) diff --git a/test/common/test_packet_parser.h b/test/common/test_packet_parser.h index b7d02113e..d0a0582ab 100644 --- a/test/common/test_packet_parser.h +++ b/test/common/test_packet_parser.h @@ -333,6 +333,62 @@ static const uint8_t test_packet_ipv6_ipsec_esp[] = { 0x88, 0x37, 0x65, 0xab, 0x0d, 0xe9, 0x95, 0x3b }; +static const uint8_t test_packet_mcast_eth_ipv4_udp[] = { + 0x03, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x02, 0x00, + 0x00, 0x03, 0x04, 0x05, 0x08, 0x00, 0x45, 0x00, + 0x00, 0x63, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11, + 0xC8, 0xDB, 0xC0, 0xA8, 0x00, 0x01, 0xEF, 0x01, + 0x02, 0x03, 0x04, 0xD2, 0x16, 0x2E, 0x00, 0x4F, + 0x25, 0x61, 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_bcast_eth_ipv4_udp[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x02, 0x00, + 0x00, 0x03, 0x04, 0x05, 0x08, 0x00, 0x45, 0x00, + 0x00, 0x63, 0x00, 0x01, 0x00, 0x00, 0x40, 0x11, + 0xB9, 0xE0, 0xC0, 0xA8, 0x00, 0x01, 0xFF, 0xFF, + 0xFF, 0xFF, 0x04, 0xD2, 0x16, 0x2E, 0x00, 0x4F, + 0x16, 0x66, 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_mcast_eth_ipv6_udp[] = { + 0x33, 0x33, 0x01, 0x02, 0x03, 0x04, 0x02, 0x00, + 0x00, 0x03, 0x04, 0x05, 0x86, 0xDD, 0x60, 0x00, + 0x00, 0x00, 0x00, 0x4F, 0x11, 0x40, 0xFE, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0xFF, 0xFE, 0x03, 0x04, 0x05, 0xFF, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x04, 0xD2, + 0x16, 0x2E, 0x00, 0x4F, 0xD6, 0x79, 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 ccfe6e512..db3a47cf8 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -65,7 +65,10 @@ static uint32_t parse_test_pkt_len[] = { sizeof(test_packet_ipv4_ipsec_ah), sizeof(test_packet_ipv4_ipsec_esp), sizeof(test_packet_ipv6_ipsec_ah), - sizeof(test_packet_ipv6_ipsec_esp) + 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) }; #define packet_compare_offset(pkt1, off1, pkt2, off2, len) \ @@ -3051,6 +3054,109 @@ static void parse_eth_ipv6_ipsec_esp(void) odp_packet_free_multi(pkt, num_pkt); } +/* Ethernet mcast/IPv4 mcast/UDP */ +static void parse_mcast_eth_ipv4_udp(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_mcast_eth_ipv4_udp, + sizeof(test_packet_mcast_eth_ipv4_udp)); + + 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_eth_mcast(pkt[i])); + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_ip_mcast(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_eth_bcast(pkt[i])); + CU_ASSERT(!odp_packet_has_ip_bcast(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet bcast/IPv4 bcast/UDP */ +static void parse_bcast_eth_ipv4_udp(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_bcast_eth_ipv4_udp, + sizeof(test_packet_bcast_eth_ipv4_udp)); + + 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_eth_bcast(pkt[i])); + /* API specifies that Ethernet broadcast is also multicast */ + CU_ASSERT(odp_packet_has_eth_mcast(pkt[i])); + CU_ASSERT(odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(odp_packet_has_ip_bcast(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_ip_mcast(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet mcast/IPv6 mcast/UDP */ +static void parse_mcast_eth_ipv6_udp(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_mcast_eth_ipv6_udp, + sizeof(test_packet_mcast_eth_ipv6_udp)); + + 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_eth_mcast(pkt[i])); + CU_ASSERT(odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(odp_packet_has_ip_mcast(pkt[i])); + CU_ASSERT(odp_packet_has_udp(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_eth_bcast(pkt[i])); + CU_ASSERT(!odp_packet_has_ip_bcast(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), @@ -3102,6 +3208,9 @@ odp_testinfo_t packet_parse_suite[] = { ODP_TEST_INFO(parse_eth_ipv4_ipsec_esp), ODP_TEST_INFO(parse_eth_ipv6_ipsec_ah), ODP_TEST_INFO(parse_eth_ipv6_ipsec_esp), + 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_NULL, };