From patchwork Mon Nov 13 14:00:22 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: 118777 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1851241qgn; Mon, 13 Nov 2017 06:20:21 -0800 (PST) X-Google-Smtp-Source: AGs4zMZfsA8I73U0RYkECkfI7NXk4ypS2gZt1Geuadcs4qss9a//RvJ1gUdun2faGcjueDYnVwKE X-Received: by 10.55.157.133 with SMTP id g127mr13491737qke.280.1510582820935; Mon, 13 Nov 2017 06:20:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510582820; cv=none; d=google.com; s=arc-20160816; b=qeMyalXPhNFaq36lPYPLuuf1nVnpkg/DyxiETXeTMrIuXOOMJtbYBgGEMpLBkTXx4f psjeIBtlw2OZ7U/u3G+G/0KgUcg3TLc5d686hgybWERZIQ1+58VMIPSYFst9f5FTkEqm 2bYN+UiskNL2ojPZdS9oGwLO/YljbGDIJPoJ14sQ4THj9W0i66h4TmEIEh0TCiJSG1NT OpXSGyWnKT8S4C+VTx5Rna4bwxLhJvfY/mxd7+ETlJTbMn4RLun7r9HsdYP0eQZsD8PY 70vVuQM6gXFcxndCTk3TRLSb87muSflk5jjVeJeZz2YB/VWYlWwVot4vQor6kUku2u+4 TtPw== 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=4JPs8D0Jog5lAgmfvHlwn3tFKoQWCGbaCqkCxQ5k758=; b=CD/xpP4ozNmgX4/5zXcReAGBWBcNLG/kyJvBriQd3bZs5CDDFLuik05aInpzY6d2z6 SNVzyoRXMyxlUWQsJF5c4e3ZM60kb5CwNNiCBwgnuy6xo0T5pe6z8xzxlV9FG+Nlps43 gruLs5LC9aPab9Cdn/ENKZQ0DBp1O4TCJnWvzQp4OxXOwfyiMyT+i2yjKrV6jhOu1ycD ELLr+fT9hk1lzofmQOGXl42spygi4/cucGLotERLA6aeOqaUYTt/Ruk9c7v3OAI9j34r ejxlT1p7R5JgiIPZC3SDi3VNDCyCn0w3hkgS/23/HwtnSxWfc+Bg086ogJtEH86c671l hdgQ== 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 j94si731504qkh.331.2017.11.13.06.20.20; Mon, 13 Nov 2017 06:20:20 -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 863B060991; Mon, 13 Nov 2017 14:20:20 +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,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 4C3EC61203; Mon, 13 Nov 2017 14:03:06 +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 BE0CF61039; Mon, 13 Nov 2017 14:01:45 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id 4E06460F70 for ; Mon, 13 Nov 2017 14:00:36 +0000 (UTC) Received: from mxback2j.mail.yandex.net (mxback2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10b]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 4A6AE5602D14 for ; Mon, 13 Nov 2017 17:00:35 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback2j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id aHqgF3Z2tI-0ZFmt0S9; Mon, 13 Nov 2017 17:00:35 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 955rfAmciQ-0YkqMvD9; Mon, 13 Nov 2017 17:00:34 +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, 13 Nov 2017 17:00:22 +0300 Message-Id: <1510581630-13993-9-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510581630-13993-1-git-send-email-odpbot@yandex.ru> References: <1510581630-13993-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 243 Subject: [lng-odp] [PATCH API-NEXT v16 8/16] linux-gen: ipsec: support replay window checks 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 243 (lumag:ipsec-packet-impl-3) ** https://github.com/Linaro/odp/pull/243 ** Patch: https://github.com/Linaro/odp/pull/243.patch ** Base sha: a908a4dead95321e84d6a8a23de060051dcd8969 ** Merge commit sha: 845914564f2d99792452ac22a524279f44496a1d **/ platform/linux-generic/odp_ipsec.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index dc6359d6e..1f9d410db 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -42,6 +42,8 @@ int odp_ipsec_capability(odp_ipsec_capability_t *capa) capa->max_num_sa = ODP_CONFIG_IPSEC_SAS; + capa->max_antireplay_ws = IPSEC_ANTIREPLAY_WS; + rc = odp_crypto_capability(&crypto_capa); if (rc < 0) return rc; @@ -402,6 +404,12 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt, ip->frag_offset = 0; ip->ttl = 0; + aad.spi = ah.spi; + aad.seq_no = ah.seq_no; + + param.aad.ptr = (uint8_t *)&aad; + param.aad.length = sizeof(aad); + param.auth_range.offset = ip_offset; param.auth_range.length = odp_be_to_cpu_16(ip->tot_len); param.hash_result_offset = ipsec_offset + _ODP_AHHDR_LEN; @@ -412,6 +420,11 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt, goto out; } + if (_odp_ipsec_sa_replay_precheck(ipsec_sa, + odp_be_to_cpu_32(aad.seq_no), + status) < 0) + goto out; + if (_odp_ipsec_sa_stats_precheck(ipsec_sa, status) < 0) goto out; @@ -450,6 +463,11 @@ static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt, if (_odp_ipsec_sa_stats_update(ipsec_sa, stats_length, status) < 0) goto out; + if (_odp_ipsec_sa_replay_update(ipsec_sa, + odp_be_to_cpu_32(aad.seq_no), + status) < 0) + goto out; + ip_offset = odp_packet_l3_offset(pkt); ip = odp_packet_l3_ptr(pkt, NULL); ip_hdr_len = ipv4_hdr_len(ip); @@ -809,6 +827,12 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, ah.next_header = ip->proto; ip->proto = _ODP_IPPROTO_AH; + aad.spi = ah.spi; + aad.seq_no = ah.seq_no; + + param.aad.ptr = (uint8_t *)&aad; + param.aad.length = sizeof(aad); + odp_packet_copy_from_mem(pkt, ipsec_offset, _ODP_AHHDR_LEN, &ah);