From patchwork Mon Nov 13 02:00:11 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: 118702 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1269481qgn; Sun, 12 Nov 2017 18:07:00 -0800 (PST) X-Google-Smtp-Source: AGs4zMYa0OZpUD0pDCIiShqj8XG2AK6yHYydlYLVUvsVtJ/0PBISWHH2npFqrQqkNfBgVbDBMZct X-Received: by 10.200.55.75 with SMTP id p11mr12002715qtb.298.1510538820601; Sun, 12 Nov 2017 18:07:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510538820; cv=none; d=google.com; s=arc-20160816; b=qdlIC6ZCVDRAJ0j7WeiwBeIdTnvs9Xe3B6vOtg7W6VPpXoy82qvGu2tSrr100Z5oyo ke5fBrYycikXmI3XL55nj5ed5UE9KJQeyPviC4Qb66qOZx+3l4Fd8vAr0toKY3mpusPB zHEicB1ivnpZZDYZpYHtkLoUVaZerug4HSflGXt0ccoXCg5V41KKO6a0fuC4PY9ZWQdG O/JqAsgmafzG1mzG+9P1qcqgaih+DxYjzr6oXf4fctSF7khgcXCwEO6A/wnPb294hTkG arrlHr8esYISNjd4PmchaB99cnU/stkokWgPuCmsnG01UqrotB6p9L/MpeEOu2aDmvzS J6CA== 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=7zt7w/gko13F7TVh4KOoXmIN6SvYnFy29iMupOwCW2I=; b=JJm95adHhWQ6/ztTj9fn2vdfqzvj8GyKNYsBu77GR11+HG0oo8DHSRJ/+fzqcG/tiO SujpdxMQTtDt11OjwD3za1xsI7fTSnOYRrj+LfdlhJUdmymqO0NR1YoPcVtAQj7A/hW1 VKXkiTrVZBeUtnNMJKe31BtpHD6TahjkLDXZy/c1XjbiPwNMv76KVJH4QSci4xur/PTp b2YPpB4gqxpJaIJMwkRx5nUkbXYt6ii7Z55n41oTGzD2cufINbpc9thlkUWhgWpa3tnT 1sprwPJmQjEH+qenaiED9ILcwlK10Mt1XXIXdLCDDud/+DEM3O5xjo5zQ0K9QCdf5Ioh hphQ== 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 i11si3398317qtc.23.2017.11.12.18.07.00; Sun, 12 Nov 2017 18:07: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 4755E60CD2; Mon, 13 Nov 2017 02:07: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,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 871B060D77; Mon, 13 Nov 2017 02:02: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 8267560D3C; Mon, 13 Nov 2017 02:02:16 +0000 (UTC) Received: from forward15o.cmail.yandex.net (forward15o.cmail.yandex.net [37.9.109.212]) by lists.linaro.org (Postfix) with ESMTPS id 6042560C16 for ; Mon, 13 Nov 2017 02:00:26 +0000 (UTC) Received: from mxback1g.mail.yandex.net (mxback1g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:162]) by forward15o.cmail.yandex.net (Yandex) with ESMTP id EB4602AD25 for ; Mon, 13 Nov 2017 05:00:23 +0300 (MSK) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [2a02:6b8:0:1a2d::27]) by mxback1g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id SwSbxsfyS9-0NmqDwT9; Mon, 13 Nov 2017 05:00:23 +0300 Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id uZeq9OjDfk-0NvuXCCi; Mon, 13 Nov 2017 05:00:23 +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 05:00:11 +0300 Message-Id: <1510538419-566-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510538419-566-1-git-send-email-odpbot@yandex.ru> References: <1510538419-566-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 243 Subject: [lng-odp] [PATCH API-NEXT v15 6/14] 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: 44a6636daa5f976c8aac76116e80e0c764352072 **/ 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);