From patchwork Tue Feb 13 14:00:08 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: 128239 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4284763ljc; Tue, 13 Feb 2018 06:03:50 -0800 (PST) X-Google-Smtp-Source: AH8x225+nkGp1itW/IkzqBG/eczkcZ6pk2SPqkp0YHJYNcOBX3TSHe8E96C+TJkuLCAjLHNoazA8 X-Received: by 10.200.24.152 with SMTP id s24mr2008064qtj.239.1518530630088; Tue, 13 Feb 2018 06:03:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518530630; cv=none; d=google.com; s=arc-20160816; b=xD5/yOFXXjF2rZFTdDmh4H43M00AQhgnvWNoOt6XjfH0/itjgBseqqGNbEmfnZyXNx WgkfOeXXmeFxcLrWPchsm8+bZKPaFwC7S17h+3vCgsYj3nDR27hKzAtSDdcRp1b6IITl 1IxuI3DDHRmPOos9utHxdZWKJF/CkF7UZcCp4KYAmvJFLeh9YPQbF1FA8S0uw2MMJ30K 13z47rSg72JQMnMeQyfdCLmt7HzC/dwiCGsx0RyuEMcQ45urtOaiacT3YkKfIaNpTaHc 7abhaEEEsoXQY9erM5WYlupfnFks9n0NwzfQR0wm9t/rB3vqKfASNM7y7azZU95nPeZQ 8Yaw== 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=3paAO+OXS3ZPEZk89KQMsSLkqe6BdRAX194Yo3h5ktM=; b=peC4HbWUwCR6r9rD5BnPDvLm+oIN8+Er4Hot08rdtK6ReON1nu7mU/o0eF1Vkjlz12 xecEeILETasgf2bg7BPAJzmiWWGESOEaUlP/XVKrd2SkTI8FpIor+7mO6lExGLx6aont BRfaxUapKq7z1Ql3ueAtued2ZB5nAt2+pKBev+T/6UHTLQVQmOUpDz/PXgh9JPwxI4Hc Aw350J/3eTrSXpFq4ZWwCG4h7g9S6nYiny0lDTNBP8oZzx8kj2Bzq2bAlCuF/WsGXtoF QbsixDncsBZFqJTugEfEwfpG+S+jY1NdY6P00tltcL/6+6vDsP2rfBCQXQdW1RMgIkzz 5l6A== 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 h48si1051244qta.136.2018.02.13.06.03.39; Tue, 13 Feb 2018 06:03:50 -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 30AA961724; Tue, 13 Feb 2018 14:03:39 +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 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 79AF561555; Tue, 13 Feb 2018 14:00:41 +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 69186608A2; Tue, 13 Feb 2018 14:00:25 +0000 (UTC) Received: from forward104p.mail.yandex.net (forward104p.mail.yandex.net [77.88.28.107]) by lists.linaro.org (Postfix) with ESMTPS id 06D0561510 for ; Tue, 13 Feb 2018 14:00:18 +0000 (UTC) Received: from mxback8j.mail.yandex.net (mxback8j.mail.yandex.net [IPv6:2a02:6b8:0:1619::111]) by forward104p.mail.yandex.net (Yandex) with ESMTP id 973B8184FDC for ; Tue, 13 Feb 2018 17:00:16 +0300 (MSK) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [2a02:6b8:0:1a2d::25]) by mxback8j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id bi9uRAMC59-0G6e5kDe; Tue, 13 Feb 2018 17:00:16 +0300 Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 6Ss5leStGE-0FF8qD4i; Tue, 13 Feb 2018 17:00:15 +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:08 +0300 Message-Id: <1518530410-18574-6-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 5/7] validation: packet: add IPSEC parse test 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 IPSEC. AH and ESP headers with both IP versions. 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 | 165 ++++++++++++++++++++++++++++++++++++ test/validation/api/packet/packet.c | 134 ++++++++++++++++++++++++++++- 2 files changed, 298 insertions(+), 1 deletion(-) diff --git a/test/common/test_packet_parser.h b/test/common/test_packet_parser.h index 22c7e6c57..b7d02113e 100644 --- a/test/common/test_packet_parser.h +++ b/test/common/test_packet_parser.h @@ -168,6 +168,171 @@ static const uint8_t test_packet_ipv4_sctp[] = { 0x79, 0x74, 0x65, 0x73, 0x2E }; +static const uint8_t test_packet_ipv4_ipsec_ah[] = { + /* ETH */ + 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, + 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x08, 0x00, + + /* IPv4 */ + 0x45, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x33, 0xab, 0xd9, 0xc0, 0xa8, 0x6f, 0x02, + 0xc0, 0xa8, 0xde, 0x02, + + /* AH */ + 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, + 0x00, 0x00, 0x00, 0x01, + 0x6c, 0x2e, 0xf7, 0x1f, 0x7c, 0x70, 0x39, 0xa3, + 0x4a, 0x77, 0x01, 0x47, 0x9e, 0x45, 0x73, 0x51, + + /* ICMP */ + 0x08, 0x00, 0xfb, 0x37, 0x12, 0x34, 0x00, 0x00, + 0xba, 0xbe, 0x01, 0x23, 0x45, 0x67, 0xca, 0xfe, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b +}; + +static const uint8_t test_packet_ipv4_ipsec_esp[] = { + /* ETH */ + 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, + 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x08, 0x00, + + /* IPv4 */ + 0x45, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x32, 0x19, 0x18, 0x0a, 0x00, 0x6f, 0x02, + 0x0a, 0x00, 0xde, 0x02, + + /* ESP */ + 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x01, + + /* IPv4 */ + 0x45, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x01, 0xac, 0x27, 0xc0, 0xa8, 0x6f, 0x02, + 0xc0, 0xa8, 0xde, 0x02, + + /* ICMP */ + 0x08, 0x00, 0xfb, 0x37, 0x12, 0x34, 0x00, 0x00, + 0xba, 0xbe, 0x01, 0x23, 0x45, 0x67, 0xca, 0xfe, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, + + /* ESP TRL */ + 0x01, 0x02, 0x02, 0x04, + + /* ICV */ + 0x73, 0x8d, 0xf6, 0x9a, 0x26, 0x06, 0x4d, 0xa1, + 0x88, 0x37, 0x65, 0xab, 0x0d, 0xe9, 0x95, 0x3b +}; + +static const uint8_t test_packet_ipv6_ipsec_ah[] = { + /* ETH */ + 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, + 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x86, 0xdd, + + /* IPv6 */ + 0x60, 0x00, 0x00, 0x00, 0x00, 0xbc, 0x33, 0x40, + 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x11, 0x43, 0xff, 0xfe, 0x4a, 0xd7, 0x0a, + 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, + + /* AH */ + 0x29, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, + 0x00, 0x00, 0x00, 0x01, + 0x62, 0x96, 0x2b, 0x40, 0x3e, 0x53, 0x76, 0x4a, + 0x4d, 0x7f, 0xf6, 0x22, 0x35, 0x3c, 0x74, 0xe2, + 0x00, 0x00, 0x00, 0x00, + + /* IPv6 */ + 0x60, 0x00, 0x00, 0x00, 0x00, 0x74, 0x00, 0x40, + 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x11, 0x43, 0xff, 0xfe, 0x4a, 0xd7, 0x0a, + 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, + + /* Hop-by-Hop */ + 0x3a, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, + + /* ICMP */ + 0x08, 0x00, 0xfb, 0x37, 0x12, 0x34, 0x00, 0x00, + 0xba, 0xbe, 0x01, 0x23, 0x45, 0x67, 0xca, 0xfe, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b +}; + +static const uint8_t test_packet_ipv6_ipsec_esp[] = { + /* ETH */ + 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, 0xf1, + 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0x86, 0xdd, + + /* IPv6 */ + 0x60, 0x00, 0x00, 0x00, 0x00, 0x9c, 0x32, 0x40, + 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x11, 0x43, 0xff, 0xfe, 0x4a, 0xd7, 0x0a, + 0x20, 0x01, 0x0d, 0xb8, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, + + /* ESP */ + 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x01, + + /* IPv4 */ + 0x45, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x01, 0xac, 0x27, 0xc0, 0xa8, 0x6f, 0x02, + 0xc0, 0xa8, 0xde, 0x02, + + /* ICMP */ + 0x08, 0x00, 0xfb, 0x37, 0x12, 0x34, 0x00, 0x00, + 0xba, 0xbe, 0x01, 0x23, 0x45, 0x67, 0xca, 0xfe, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + 0x58, 0x59, 0x5a, 0x5b, + + /* ESP TRL */ + 0x01, 0x02, 0x02, 0x04, + + /* ICV */ + 0x73, 0x8d, 0xf6, 0x9a, 0x26, 0x06, 0x4d, 0xa1, + 0x88, 0x37, 0x65, 0xab, 0x0d, 0xe9, 0x95, 0x3b +}; + #ifdef __cplusplus } #endif diff --git a/test/validation/api/packet/packet.c b/test/validation/api/packet/packet.c index ad5520408..ccfe6e512 100644 --- a/test/validation/api/packet/packet.c +++ b/test/validation/api/packet/packet.c @@ -61,7 +61,11 @@ static uint32_t parse_test_pkt_len[] = { sizeof(test_packet_ipv6_tcp), sizeof(test_packet_ipv6_udp), sizeof(test_packet_vlan_ipv6_udp), - sizeof(test_packet_ipv4_sctp) + sizeof(test_packet_ipv4_sctp), + sizeof(test_packet_ipv4_ipsec_ah), + sizeof(test_packet_ipv4_ipsec_esp), + sizeof(test_packet_ipv6_ipsec_ah), + sizeof(test_packet_ipv6_ipsec_esp) }; #define packet_compare_offset(pkt1, off1, pkt2, off2, len) \ @@ -2923,6 +2927,130 @@ static void parse_eth_ipv4_sctp(void) odp_packet_free_multi(pkt, num_pkt); } +/* Ethernet/IPv4/IPSEC AH*/ +static void parse_eth_ipv4_ipsec_ah(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_ipsec_ah, + sizeof(test_packet_ipv4_ipsec_ah)); + + 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_ipsec(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_udp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet/IPv4/IPSEC ESP*/ +static void parse_eth_ipv4_ipsec_esp(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_ipsec_esp, + sizeof(test_packet_ipv4_ipsec_esp)); + + 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_ipsec(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv6(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_udp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet/IPv6/IPSEC AH*/ +static void parse_eth_ipv6_ipsec_ah(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_ipv6_ipsec_ah, + sizeof(test_packet_ipv6_ipsec_ah)); + + 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_ipv6(pkt[i])); + CU_ASSERT(odp_packet_has_ipsec(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_udp(pkt[i])); + } + + odp_packet_free_multi(pkt, num_pkt); +} + +/* Ethernet/IPv6/IPSEC ESP*/ +static void parse_eth_ipv6_ipsec_esp(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_ipv6_ipsec_esp, + sizeof(test_packet_ipv6_ipsec_esp)); + + 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_ipv6(pkt[i])); + CU_ASSERT(odp_packet_has_ipsec(pkt[i])); + CU_ASSERT(!odp_packet_has_ipv4(pkt[i])); + CU_ASSERT(!odp_packet_has_tcp(pkt[i])); + CU_ASSERT(!odp_packet_has_udp(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), @@ -2970,6 +3098,10 @@ odp_testinfo_t packet_parse_suite[] = { ODP_TEST_INFO(parse_eth_ipv4_icmp), ODP_TEST_INFO(parse_eth_ipv6_icmp), ODP_TEST_INFO(parse_eth_ipv4_sctp), + ODP_TEST_INFO(parse_eth_ipv4_ipsec_ah), + 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_NULL, };