From patchwork Mon Feb 26 15:00:06 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: 129686 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp306213lja; Mon, 26 Feb 2018 07:11:01 -0800 (PST) X-Google-Smtp-Source: AG47ELtWDwMOa7C7DG2b5wuthYRv4PlEQSrcHbfStkbKrCSytrjje5BJJeYsjCws2cwn8oimlQMf X-Received: by 10.55.212.150 with SMTP id s22mr17803808qks.267.1519657860834; Mon, 26 Feb 2018 07:11:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519657860; cv=none; d=google.com; s=arc-20160816; b=udVRODZveZRPPe0JMxHOgEcLoZ3KHMkUTVfS2z49eS1BQ7eebQjUxDhfHYqUPm6PPh ddD/SqGwuLT+U3G+ochjjVRHX9krco2Adn1IrS3ztNQUusb+QmsmMD7TlBpEV0qspQ5w VFZcbfQm4rLipmpDKqP/L4u5SVGCl36DVNw6eT0IDSzXQuscbwGWD2VvWzM1voYDduuA H9/0vX5euT3tyInJcwY6HUboAjLS6SlX5GaCydnqrG8CyTxb3QYEZ+7l7AeICKVN1T3x D8Lwp2ao93Gkn/S7WumY6W5yOdiLrDPze8Y+/QHoiYFShOp4dgZsPyzw6gUimZA1mGAP zmZg== 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=C1vxG5jW2Hll4D6Vg83M700xRwry3+1DbEobs8wZv1w=; b=gXueEaF28qbZVB7MVwZjyn7K6g4vljvmjZlUj4DoChHpkFv42+pcNDfLBlOehjSVLu mFrvHs/kLKpj/MXXkgU5ULFzsszqy4a/zbuU3sZeUY01kTHJ+ZAB/Fqlh9HZpqfqkZop lVstg+d0tYU+Nnhq5uz/BEEf8Zk0Mku6rpBt74DKP55q7MchNfAzZZuLcykMDaJRgioq QWodoAZ7wJDnXvaJOVBMIKeVHkG6u7zfn9A/P3iL1GGyBFkfGOOUr56ST4u0Yekbf0Gw /F97vUgJUJsmVU++sZsnXaFPqmIb0gv07JIZcy9ODxgGaYw8d3bYtAZUvOdwq9JQxoGf vT/A== 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 p2si937938qte.193.2018.02.26.07.11.00; Mon, 26 Feb 2018 07:11:00 -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 1A20A60721; Mon, 26 Feb 2018 15:11: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=-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 2AC5B61806; Mon, 26 Feb 2018 15:01:49 +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 5BE01617AC; Mon, 26 Feb 2018 15:01:24 +0000 (UTC) Received: from forward103p.mail.yandex.net (forward103p.mail.yandex.net [77.88.28.106]) by lists.linaro.org (Postfix) with ESMTPS id 57203617AF for ; Mon, 26 Feb 2018 15:00:19 +0000 (UTC) Received: from mxback12j.mail.yandex.net (mxback12j.mail.yandex.net [IPv6:2a02:6b8:0:1619::87]) by forward103p.mail.yandex.net (Yandex) with ESMTP id 8AA1021851E6 for ; Mon, 26 Feb 2018 18:00:17 +0300 (MSK) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [2a02:6b8:0:1a2d::25]) by mxback12j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id p2zO19V5bc-0HCqf3gq; Mon, 26 Feb 2018 18:00:17 +0300 Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id kHvqsGsU0k-0GTGN11i; Mon, 26 Feb 2018 18:00:16 +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: Mon, 26 Feb 2018 18:00:06 +0300 Message-Id: <1519657209-30140-9-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519657209-30140-1-git-send-email-odpbot@yandex.ru> References: <1519657209-30140-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 502 Subject: [lng-odp] [PATCH API-NEXT v1 8/11] linux-gen: ipsec: separate ipv4/ipv6 flags 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 502 (lumag:ipsec-imp-upd) ** https://github.com/Linaro/odp/pull/502 ** Patch: https://github.com/Linaro/odp/pull/502.patch ** Base sha: c91eae61d19350dd19aacf18c1148c9491398c14 ** Merge commit sha: 8c909084626ccef140542645cd34549ce7f4bcde **/ platform/linux-generic/odp_ipsec.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index cfdfa9dc9..55beb382e 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -269,6 +269,7 @@ typedef struct { uint16_t ip_next_hdr_offset; uint8_t ip_next_hdr; unsigned is_ipv4 : 1; + unsigned is_ipv6 : 1; union { struct { uint32_t ip_flabel; @@ -669,10 +670,13 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt, * state.is_ipv4 = odp_packet_has_ipv4(pkt); */ state.is_ipv4 = (((uint8_t *)state.ip)[0] >> 4) == 0x4; + state.is_ipv6 = (((uint8_t *)state.ip)[0] >> 4) == 0x6; if (state.is_ipv4) rc = ipsec_parse_ipv4(&state, pkt); - else + else if (state.is_ipv6) rc = ipsec_parse_ipv6(&state, pkt); + else + rc = -1; if (rc < 0 || state.ip_tot_len + state.ip_offset > odp_packet_len(pkt)) { status->error.alg = 1; @@ -776,8 +780,10 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt, state.ip_tot_len -= state.ip_hdr_len + state.in.hdr_len; if (_ODP_IPPROTO_IPIP == state.ip_next_hdr) { state.is_ipv4 = 1; + state.is_ipv6 = 0; } else if (_ODP_IPPROTO_IPV6 == state.ip_next_hdr) { state.is_ipv4 = 0; + state.is_ipv6 = 1; } else { status->error.proto = 1; goto err; @@ -802,7 +808,7 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt, else ipv4hdr->ttl -= ipsec_sa->dec_ttl; _odp_ipv4_csum_update(pkt); - } else if (!state.is_ipv4 && odp_packet_len(pkt) > _ODP_IPV6HDR_LEN) { + } else if (state.is_ipv6 && odp_packet_len(pkt) > _ODP_IPV6HDR_LEN) { _odp_ipv6hdr_t *ipv6hdr = odp_packet_l3_ptr(pkt, NULL); if (ODP_IPSEC_MODE_TRANSPORT == ipsec_sa->mode) @@ -816,9 +822,9 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt, goto err; } - parse_param.proto = state.is_ipv4 ? - ODP_PROTO_IPV4 : - ODP_PROTO_IPV6; + parse_param.proto = state.is_ipv4 ? ODP_PROTO_IPV4 : + state.is_ipv6 ? ODP_PROTO_IPV6 : + ODP_PROTO_NONE; parse_param.last_layer = ipsec_config.inbound.parse_level; parse_param.chksums = ipsec_config.inbound.chksums; @@ -934,6 +940,7 @@ static int ipsec_out_tunnel_ipv4(odp_packet_t *pkt, _ODP_IPV4HDR_PROTO_OFFSET; state->is_ipv4 = 1; + state->is_ipv6 = 0; return 0; } @@ -990,6 +997,7 @@ static int ipsec_out_tunnel_ipv6(odp_packet_t *pkt, state->ip_next_hdr_offset = state->ip_offset + _ODP_IPV6HDR_NHDR_OFFSET; state->is_ipv4 = 0; + state->is_ipv6 = 1; return 0; } @@ -1320,20 +1328,25 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, memset(¶m, 0, sizeof(param)); state.is_ipv4 = (((uint8_t *)state.ip)[0] >> 4) == 0x4; + state.is_ipv6 = (((uint8_t *)state.ip)[0] >> 4) == 0x6; if (ODP_IPSEC_MODE_TRANSPORT == ipsec_sa->mode) { if (state.is_ipv4) rc = ipsec_parse_ipv4(&state, pkt); - else + else if (state.is_ipv6) rc = ipsec_parse_ipv6(&state, pkt); + else + rc = -1; if (state.ip_tot_len + state.ip_offset != odp_packet_len(pkt)) rc = -1; } else { if (state.is_ipv4) rc = ipsec_out_tunnel_parse_ipv4(&state, ipsec_sa); - else + else if (state.is_ipv6) rc = ipsec_out_tunnel_parse_ipv6(&state, ipsec_sa); + else + rc = -1; if (rc < 0) { status->error.alg = 1; goto err;