From patchwork Wed Feb 21 17:00:07 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: 129115 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp849292ljc; Wed, 21 Feb 2018 09:12:02 -0800 (PST) X-Google-Smtp-Source: AH8x2269LUnbguvZqqNA2L11lBsdeBaKQ9zOEIsrtsHUw/8kc9zv1+b7ASoxzVTIIKMFsWb79HGV X-Received: by 10.55.54.73 with SMTP id d70mr6355697qka.260.1519233121873; Wed, 21 Feb 2018 09:12:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519233121; cv=none; d=google.com; s=arc-20160816; b=WLFWSpfCY3l+r+ltnMBGdBm26GBmEnk3H0MMhO+JEL8/rqfWH22H0AJAh9iByMlBRd KZ13t7urPRwbhnN6GHoiwxrv484Nl+CcFLF9NkJ8xVs+50M/guwa6I4mwhDw5Q8D8ANF exL7wDchcL7LB8cfKAZXnu/GOyCjzjk8SV7DgX40/jXPOFiiiSM5qX6zoM7x0OgFDnnp xjudg9IXMopWBlPygSk9E3DV2w4rkoLhl117OwA+96vkr1PWeNN100GQtJ561/wkUNFN +kG3i4pVjNnyE857sRPlvEEgL34gOMqxCR5ZVv6NjN+iGKHRTMZVfnRDuaGrFaRs2Itc vuIQ== 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=RvsuTi9VetJ5I2Pbi+gEBZc/7x8g/7annaks9X/m51Q=; b=KXzEG8jz5f/eOOi5Pw5kPOvrJEJ1ue2fWgYY3M1j3gcF1NwSlok3tYCBugWywm3xCt LfpkoddcWfSkfWmZTp/aGM19Pwg5AdGmq7wNqibr9gYc6DdyFU78ok1FwVq4gkCSUu72 9A9BREgaMYlHLQiwCunqoNNspNnFt2AbZTJ+JoFS4vfJfJbSakaO2PZrEEw4ldQauEit gauIqx/AqLs5uacjALYwHRfCGOJHTaQfGwW9W4g64ORTmgpplriIcr/CORs6LtnViuAf pHRGpAF2oCwkstbpKf0hExNjB1xURwhWrjM/H47LpubK782XBcIMcvIdqHCA7yvw4brH BRSA== 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 f94si168593qtb.284.2018.02.21.09.12.01; Wed, 21 Feb 2018 09:12:01 -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 82AB76107F; Wed, 21 Feb 2018 17:12:01 +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 E2548617F7; Wed, 21 Feb 2018 17:01:31 +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 6EFD5617B2; Wed, 21 Feb 2018 17:01:15 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id 684716179D for ; Wed, 21 Feb 2018 17:00:21 +0000 (UTC) Received: from mxback17j.mail.yandex.net (mxback17j.mail.yandex.net [IPv6:2a02:6b8:0:1619::93]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 5920A134566A for ; Wed, 21 Feb 2018 20:00:20 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback17j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id EMUNrFVGAW-0KG4F2KB; Wed, 21 Feb 2018 20:00:20 +0300 Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id yTStk9eEsG-0JueJPb4; 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:07 +0300 Message-Id: <1519232408-28445-15-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 14/15] linux-gen: ipsec: support TFC dummy packet generation 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 | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index c0b9cd2a7..a9680ba0e 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -949,8 +949,10 @@ static int ipsec_out_tunnel_ipv4(odp_packet_t *pkt, state->ip_hdr_len = _ODP_IPV4HDR_LEN; if (state->is_ipv4) state->ip_next_hdr = _ODP_IPPROTO_IPIP; - else + else if (state->is_ipv6) state->ip_next_hdr = _ODP_IPPROTO_IPV6; + else + state->ip_next_hdr = _ODP_IPPROTO_NO_NEXT; state->ip_next_hdr_offset = state->ip_offset + _ODP_IPV4HDR_PROTO_OFFSET; @@ -1008,8 +1010,10 @@ static int ipsec_out_tunnel_ipv6(odp_packet_t *pkt, state->ip_hdr_len = _ODP_IPV6HDR_LEN; if (state->is_ipv4) state->ip_next_hdr = _ODP_IPPROTO_IPIP; - else + else if (state->is_ipv6) state->ip_next_hdr = _ODP_IPPROTO_IPV6; + else + state->ip_next_hdr = _ODP_IPPROTO_NO_NEXT; state->ip_next_hdr_offset = state->ip_offset + _ODP_IPV6HDR_NHDR_OFFSET; state->is_ipv4 = 0; @@ -1330,8 +1334,17 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, state.ip_offset = odp_packet_l3_offset(pkt); ODP_ASSERT(ODP_PACKET_OFFSET_INVALID != state.ip_offset); - state.ip = odp_packet_l3_ptr(pkt, NULL); - ODP_ASSERT(NULL != state.ip); + if (opt->flag.tfc_dummy) { + state.ip = NULL; + state.is_ipv4 = 0; + state.is_ipv6 = 0; + } else { + state.ip = odp_packet_l3_ptr(pkt, NULL); + ODP_ASSERT(NULL != state.ip); + + state.is_ipv4 = (((uint8_t *)state.ip)[0] >> 4) == 0x4; + state.is_ipv6 = (((uint8_t *)state.ip)[0] >> 4) == 0x6; + } ipsec_sa = _odp_ipsec_sa_use(sa); ODP_ASSERT(NULL != ipsec_sa); @@ -1347,9 +1360,6 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, /* Initialize parameters block */ memset(¶m, 0, sizeof(param)); - state.is_ipv4 = (((uint8_t *)state.ip)[0] >> 4) == 0x4; - state.is_ipv6 = (((uint8_t *)state.ip)[0] >> 4) == 0x6; - if (ODP_IPSEC_MODE_TRANSPORT == ipsec_sa->mode) { if (state.is_ipv4) rc = ipsec_parse_ipv4(&state, pkt); @@ -1365,7 +1375,12 @@ static ipsec_sa_t *ipsec_out_single(odp_packet_t pkt, rc = ipsec_out_tunnel_parse_ipv4(&state, ipsec_sa); else if (state.is_ipv6) rc = ipsec_out_tunnel_parse_ipv6(&state, ipsec_sa); - else + else if (opt->flag.tfc_dummy) { + state.out_tunnel.ip_tos = 0; + state.out_tunnel.ip_df = 0; + state.out_tunnel.ip_flabel = 0; + rc = 0; + } else rc = -1; if (rc < 0) { status->error.alg = 1;