From patchwork Tue Oct 31 16:00:10 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: 117648 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4096833qgn; Tue, 31 Oct 2017 09:06:27 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Rf7X9LjLOvU0TeARP/igKyWqmxxApp/5P6mdD52yc9SuEVTuKSu0X+GoLcJNq8o2CTQOWL X-Received: by 10.237.34.169 with SMTP id p38mr3903239qtc.182.1509465987205; Tue, 31 Oct 2017 09:06:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509465987; cv=none; d=google.com; s=arc-20160816; b=EI+0zh2ufj87TDwJLIiCKeFiq1ki3htRIz7DohVdr9FXyKayRcceHmOUB0al/RIEqV NKr8G28ZczFG+eT6Dz7xA11WuYpiHTsodkyiO9PQUnAmZW3jKogwPCbEw/z1up5DKwcc ZHH+FHqkPPt1jza32sjLhZoCW2tf8zz7E6nChvnZuIVebl/EWe8ob1DcTk4C/B7r/qCO nNSWxlyiwXxNmQMG0fIEmYZep6k+ZzMWHo0If6Tk7mRMGWINeWcOTkdhvhdqKSu/ZtzZ V7DLoMblPw3KEkSzu1pbdXvAnFCgcu9uoxJkoBLywN3zBq2+Ht/HKJ4FI9g6huYnb9x0 muSw== 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=6a7IkABs5bbLXMKr4JyDPpYo4qIXFEDAbFxPAV7rzPY=; b=FZBBuCo/Hk50HFrnXnE1Vc0JrGbT8KhVM2aByu3ms+0dEKwNOIpFcg88NHnGk2Xg/H 1BWyzIYRMZWgjq1I1PUfY61C7G10uo3W6FDnSQznb5CDgaNsy7NL9q3pB0KRObRRj/Qz sAMnW/0iIMu0+JWdn0BoMT9fIbFBNHM3DaeBOtPMtJNGCqWxmXB3h9A/9hVHQuKPnXWR IfhYDCtu/uZzPIYsLi6Q2j+5LzrMz9J2/wJZFD5noQKcoiZe7aofQGTU9Cm3WrDoPnBd ex8+0yEw9cOGeHmogWjPOBONOm40aXG0P87aRYqQbyvUMaNF3JZXHx8GsCscg/dGNuxi 6XAQ== 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 i38si272050qtc.420.2017.10.31.09.06.26; Tue, 31 Oct 2017 09:06:27 -0700 (PDT) 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 A631B60B2F; Tue, 31 Oct 2017 16:06:26 +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_H3,RCVD_IN_MSPIKE_WL,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 97ED460C64; Tue, 31 Oct 2017 16:01:21 +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 2111260C2F; Tue, 31 Oct 2017 16:00:39 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id 0D01E60B3D for ; Tue, 31 Oct 2017 16:00:27 +0000 (UTC) Received: from mxback11g.mail.yandex.net (mxback11g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:90]) by forward100o.mail.yandex.net (Yandex) with ESMTP id 42C2F2A20BF6 for ; Tue, 31 Oct 2017 19:00:23 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback11g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id y16pVEHR8q-0NNWQR6J; Tue, 31 Oct 2017 19:00:23 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id fRI2MH6OIq-0Mo4JiM3; Tue, 31 Oct 2017 19:00:22 +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, 31 Oct 2017 19:00:10 +0300 Message-Id: <1509465617-2530-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1509465617-2530-1-git-send-email-odpbot@yandex.ru> References: <1509465617-2530-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 243 Subject: [lng-odp] [PATCH API-NEXT v4 6/13] 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: 825f75ed8644ef57c5648961e7982daf13cd9375 ** Merge commit sha: edc1f88ae0a1e8cae8a229f024181ded1f17de56 **/ 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 55b60162d..5bb8330cb 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); @@ -814,6 +832,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);