From patchwork Sun Nov 12 23:00:03 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: 118673 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1153522qgn; Sun, 12 Nov 2017 15:04:56 -0800 (PST) X-Google-Smtp-Source: AGs4zMY5ksJrX3OyX29viwTkAT9YFQ83Z5vGorgRaDlFL09mkUKQAg1KxHlUeMiI3IX6MD/NQZXV X-Received: by 10.200.2.160 with SMTP id p32mr11230754qtg.307.1510527896086; Sun, 12 Nov 2017 15:04:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510527896; cv=none; d=google.com; s=arc-20160816; b=cMp39sCS4sHQT4jm29ksIGfbDBBdCc0giKfLSFL5NxrLGYF4MckPs2LdKz5wAjQoHF NBnbG6NYnijOYCbpkDOvcOKurzoyIm27qCOVqoPsWj7tG1xalwvexI9HuaDIeazLPmiO PYk5Ak4CuNrQZwu12rf8gYdxuCFXcfI7PGPoyszXdg2PazJAObtIgy/tjugb0VzyiWHM OVCpHVmpMkfNyW7csNfxmuQ3+75CxRHwu93/Fp05oXhyF2Jt/Sw1nUFybUA1YIiTW7SY 1Wrc1lUtosh1BUIKhRyBZzx1KhSeqMXrJIa/VB534PAxnJpZWdY8ErUO2+v78ghRscjr v8EA== 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=kUROPnMjttMQG6hUoaQgQz88kMRF+DJreh3oAkOtQuw=; b=hspjnm2Ncjxa3vWmjCrg2fH/nhW1pRTpiljUsUiQk/sKi23J0fu3aIxVwGFGoODS2/ 9XpJe+dfJcUE30dY85Ya9mfAlwIUx3me5SjZwSDkGVptSUAD69w9ydoxqvBe6tKZUmMZ qEMezz2SzrKf+WRppOVx74hwKHYq9LeFh2KcJe5nlqab5iLHaQv8oNAEOIVyRS6ZA/By Orp69zLP0dVmbtNtyt7sAx22q7qiyG8nMPjk8xdMvNg3fy9mkR04irm/z6Mizt72vS23 Qy8gE6pTUOMVS56M5/yUWiEzTR/aS55mMsVbUIg0nJisYMlHBe+c+Znl21O1M5xKOJiT D38A== 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 n64si555708qkf.181.2017.11.12.15.04.55; Sun, 12 Nov 2017 15:04:56 -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 AAEBA60A81; Sun, 12 Nov 2017 23:04:55 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 24CBF60BD7; Sun, 12 Nov 2017 23:00:53 +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 F023460A57; Sun, 12 Nov 2017 23:00:25 +0000 (UTC) Received: from forward103o.mail.yandex.net (forward103o.mail.yandex.net [37.140.190.177]) by lists.linaro.org (Postfix) with ESMTPS id 0500760654 for ; Sun, 12 Nov 2017 23:00:21 +0000 (UTC) Received: from mxback19j.mail.yandex.net (mxback19j.mail.yandex.net [IPv6:2a02:6b8:0:1619::95]) by forward103o.mail.yandex.net (Yandex) with ESMTP id E4FBE588E32C for ; Mon, 13 Nov 2017 02:00:19 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback19j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id iJGWFDFBFG-0JbiOg1l; Mon, 13 Nov 2017 02:00:19 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 3gEL078gGO-0JjmlZQL; Mon, 13 Nov 2017 02:00:19 +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 02:00:03 +0300 Message-Id: <1510527615-30536-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510527615-30536-1-git-send-email-odpbot@yandex.ru> References: <1510527615-30536-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 243 Subject: [lng-odp] [PATCH API-NEXT v13 6/18] 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: 7261a0ce35cc31342937cb57dcc287aea0c59ede **/ 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 8810d73be..ef6a60249 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);