From patchwork Wed Feb 21 18:00:09 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: 129130 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp904366ljc; Wed, 21 Feb 2018 10:10:35 -0800 (PST) X-Google-Smtp-Source: AH8x227fuvJpiVegvs6LyJY8DPNnotxLNfp0h+rzh87NFq6wCWF//5tGDKEzjGFeLGder1mInZDP X-Received: by 10.55.178.196 with SMTP id b187mr909339qkf.276.1519236634636; Wed, 21 Feb 2018 10:10:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519236634; cv=none; d=google.com; s=arc-20160816; b=Jnj75t8lukABUeNWnIhQND/gfKIt/AUuyoa/4euc87a37+GVkGYxRnPoaTDGuz98ou RnPr2lqnBzspukA2W3wtANLx4rrNh7lU9/2wSMOXFJe73f9tD8XosWHSMD9MiclfX0v/ OliYYjAfleZvgqtJXumXHC9FHcux0EAdBb3NSojFFGu2t+DE+JVxy+tGgJsVq5psq7MX rxkFZBdAkRQDPFczSLxhTsSFtzBiZ0SjiF69C7JKaHWQ/YGs2K0SZ1pkjSwL6XvfTFqB 1XvAGuKeffzObUTvTubY8fufcFX04eDqW1+W/zclRJfJgutQF2ASVCwaPrPAHksST08R B18g== 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=t8U/B/nVqdLCJ1U0Zc0w2he1vfnOprhKM/Y5JMK+K4Q=; b=ujFSs+C7TLIkUHlNulRdRNNDWuruL7Ist0gElVemuRxhn+6xgR0hKTGc1shkWTs4f1 p2glfb8UNe6ushMZi+x2u9a3B5UgGzKZMVUH01Mxe8RWaynae4bXfZ2jAtIfHkMmNOSS Wx+UuGwFSDr/C4lgir1RHsIEQ5E9pd8lZiAldkDs8M9K/rWJpoNl6Ku5e7Z12SUYyh/u HRaMyiYeP9e4H1D4ITd1Cy4B1IjFjHe+b0VFR4Ng4mPjdcU1DB+iXCk2Edk2jm65Lzvl BkTaSD9eG0E6uJKZIU8CrBEkr9/G7wbTVuNQEb3db3FIIjVWxDz/gFPkx47F/VPIby1N PlaA== 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 n13si1633151qki.173.2018.02.21.10.10.33; Wed, 21 Feb 2018 10:10:34 -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 6150B607BE; Wed, 21 Feb 2018 18:10:33 +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 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 C8781617BE; Wed, 21 Feb 2018 18:04:04 +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 D4C75617D2; Wed, 21 Feb 2018 18:03:51 +0000 (UTC) Received: from forward103o.mail.yandex.net (forward103o.mail.yandex.net [37.140.190.177]) by lists.linaro.org (Postfix) with ESMTPS id 91771617BE for ; Wed, 21 Feb 2018 18:02:20 +0000 (UTC) Received: from mxback9g.mail.yandex.net (mxback9g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:170]) by forward103o.mail.yandex.net (Yandex) with ESMTP id E316658821A1 for ; Wed, 21 Feb 2018 21:02:17 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback9g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id zdPGsVPtbz-2HVm6HST; Wed, 21 Feb 2018 21:02:17 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id pTqHAnOINC-2B9iAIkP; Wed, 21 Feb 2018 21:02:11 +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 21:00:09 +0300 Message-Id: <1519236011-14987-14-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519236011-14987-1-git-send-email-odpbot@yandex.ru> References: <1519236011-14987-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 494 Subject: [lng-odp] [PATCH API-NEXT v2 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: 0b6ae2680a00027c3958ebcafbbcf92642a68f5e **/ 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 37226cede..9caf94903 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); @@ -1385,7 +1389,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 {