From patchwork Wed Feb 21 17: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: 129113 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp847576ljc; Wed, 21 Feb 2018 09:10:26 -0800 (PST) X-Google-Smtp-Source: AH8x2275OJao1PScbzU9BGZoV0jKQFMvJ1obMXWa353lD6L5S6G7EPms6OtOimlIA0HHiMZM3BXq X-Received: by 10.55.204.71 with SMTP id r68mr6256220qki.356.1519233026216; Wed, 21 Feb 2018 09:10:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519233026; cv=none; d=google.com; s=arc-20160816; b=za165G2ARVJCIVNlAmJg+uaH4ReiFFG3Is12Hu6uSlzGFkQBbYtsX6w9NJAPzc6zOP eubSO4SlE/bCM7zNkzn2o+pHk854J8yBk7EKgKbYZR9gjPVwnsf2nyt9ZMHj7+qjYnBe BJ6/IENOLgWCVqmX6tIFrLn0QCK50N51c7WhDmVdwPyu5cx0yhlxkrKfGvx0ceZ5cB6l nUrF4y1QqTZrQ3XBGnm35s6LlScnpYfU1Pq1sJutBCx7JdgOcpLf+Z4Pr/RX8/JVVsy6 2G/3NJUERgZsqqW0pn0I8Zvpc8eH0BeFFVuoEQ0KokR7j18p+CAgz6K0JRzdVtERpCTq PNfw== 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=N6awqiymuP3TLWyhEmzaKsCNWAXDQQact5gr/ttG96M=; b=MKuXG+gvwNOerqHCw8o+ikPiGyle57RcUiMky4gJnmkQQwhfy5JDAccn3CaZrqsEcN mQ4gBXYCqOpn2jCjpzIcWrSxz52OTzlZLNiAcaOGx47VyPgp4iMnMR7FPWEUC4vBhuuI NHfD4qL1CSorZMyqwCZAZmXwO2m6MAO1pmvG32Glo58zULb0h5/Ar/Sh3GI91DeChywD xcuj0jDwtQrKqXxu9jyJlBIhuqZoTKojg0lxjwt+noBEZZ7cMqTIj4L2Y90/suNMQTjK OFB58nw82yyvUYh9U/hXwqK9LMU1SZ76cYGCLFfU3kpPkv4PKCe9kiZ/teStTsia0ono Ev9A== 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 o64si8841874qkl.56.2018.02.21.09.10.25; Wed, 21 Feb 2018 09:10:26 -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 C669B617CA; Wed, 21 Feb 2018 17:10:25 +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 21871617E3; Wed, 21 Feb 2018 17: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 2E1D0617B4; Wed, 21 Feb 2018 17:01:09 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id BA10F617B4 for ; Wed, 21 Feb 2018 17:00:20 +0000 (UTC) Received: from mxback3o.mail.yandex.net (mxback3o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1d]) by forward101o.mail.yandex.net (Yandex) with ESMTP id B25791345676 for ; Wed, 21 Feb 2018 20:00:19 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback3o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id f0kdb16ekG-0JFiWoeI; Wed, 21 Feb 2018 20:00:19 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id yTStk9eEsG-0JuSw76i; Wed, 21 Feb 2018 20: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: Wed, 21 Feb 2018 20:00:06 +0300 Message-Id: <1519232408-28445-14-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519232408-28445-1-git-send-email-odpbot@yandex.ru> References: <1519232408-28445-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 494 Subject: [lng-odp] [PATCH API-NEXT v1 13/15] linux-gen: ipsec: support tfc_pad_len IPsec option 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 494 (lumag:ipsec-tfc-imp) ** https://github.com/Linaro/odp/pull/494 ** Patch: https://github.com/Linaro/odp/pull/494.patch ** Base sha: ea2afab619ae74108a03798bc358fdfcd29fdd88 ** Merge commit sha: 7bc900650676584bfb99c8a92c3d8812b458f172 **/ platform/linux-generic/odp_ipsec.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index 63c3bb49e..c0b9cd2a7 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -1061,7 +1061,8 @@ static int ipsec_out_esp(odp_packet_t *pkt, ipsec_sa_t *ipsec_sa, odp_crypto_packet_op_param_t *param, odp_ipsec_op_status_t *status, - uint32_t mtu) + uint32_t mtu, + const odp_ipsec_out_opt_t *opt) { _odp_esphdr_t esp; _odp_esptrl_t esptrl; @@ -1069,6 +1070,7 @@ static int ipsec_out_esp(odp_packet_t *pkt, uint32_t encrypt_len; uint16_t ip_data_len = state->ip_tot_len - state->ip_hdr_len; + uint16_t tfc_len = opt->flag.tfc_pad ? opt->tfc_pad_len : 0; uint32_t pad_block = ipsec_sa->esp_block_len; uint16_t ipsec_offset = state->ip_offset + state->ip_hdr_len; unsigned hdr_len; @@ -1079,7 +1081,7 @@ static int ipsec_out_esp(odp_packet_t *pkt, if (pad_block < 4) pad_block = 4; - encrypt_len = IPSEC_PAD_LEN(ip_data_len + _ODP_ESPTRL_LEN, + encrypt_len = IPSEC_PAD_LEN(ip_data_len + tfc_len + _ODP_ESPTRL_LEN, pad_block); hdr_len = _ODP_ESPHDR_LEN + ipsec_sa->esp_iv_len; @@ -1120,7 +1122,7 @@ static int ipsec_out_esp(odp_packet_t *pkt, param->aad_ptr = (uint8_t *)&state->esp.aad; memset(&esptrl, 0, sizeof(esptrl)); - esptrl.pad_len = encrypt_len - ip_data_len - _ODP_ESPTRL_LEN; + esptrl.pad_len = encrypt_len - ip_data_len - tfc_len - _ODP_ESPTRL_LEN; esptrl.next_header = state->ip_next_hdr; odp_packet_copy_from_mem(*pkt, state->ip_next_hdr_offset, 1, &proto); @@ -1165,6 +1167,8 @@ static int ipsec_out_esp(odp_packet_t *pkt, ipsec_offset + _ODP_ESPHDR_LEN, ipsec_sa->esp_iv_len, state->iv + ipsec_sa->salt_length); + _odp_packet_set_data(*pkt, esptrl_offset - esptrl.pad_len - tfc_len, + 0xa5, tfc_len); odp_packet_copy_from_mem(*pkt, esptrl_offset - esptrl.pad_len, esptrl.pad_len, ipsec_padding); @@ -1383,7 +1387,8 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, } if (ODP_IPSEC_ESP == ipsec_sa->proto) { - rc = ipsec_out_esp(&pkt, &state, ipsec_sa, ¶m, status, mtu); + rc = ipsec_out_esp(&pkt, &state, ipsec_sa, ¶m, status, mtu, + opt); } else if (ODP_IPSEC_AH == ipsec_sa->proto) { rc = ipsec_out_ah(&pkt, &state, ipsec_sa, ¶m, status, mtu); } else {