From patchwork Wed Feb 21 18:00:10 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: 129132 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp907499ljc; Wed, 21 Feb 2018 10:14:03 -0800 (PST) X-Google-Smtp-Source: AH8x224LBrqgfqyD5GfEI9kv1xFQ+Cnr8tDu8S0tM4kdmReygG0g09Aw/eBD4PpupKH25NYov1un X-Received: by 10.237.35.10 with SMTP id h10mr6767605qtc.147.1519236843242; Wed, 21 Feb 2018 10:14:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519236843; cv=none; d=google.com; s=arc-20160816; b=se2xoCDpFc2tLtNySWiyD2i/RP/jxqk9I/RJpb10/yOQid5P9em1X0FB5VVfJ6ECzm pANI4mzABOxPtKFTP77mFIkIhNfvOwPoKG9zgn3Ajh5fLf02VgIHmx+DICFtLGcTp3RH 0rRrnboZfUJjdbDbv8UIw9fQ/g/oDFl23ZqETeI54L8adtVdR8SZV32J0XluAvQtI4hn KZ5yk8BCZqmZ7Z1zE04M1CS6cqZMuAkAV9T/FavShFGI0+LQJjYFWXAINj/07rDIfJHq 0fBsjmvLyJiDoHISCDa49k1aEPF8ipUUc2e/iUvRSlT1QhVk4S8Khy0b9ltkwz5t4A/1 JxZg== 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=vP8tNXCJCDDNgaWNN+N3dUTpFKznsTefRZUh82yMCFI=; b=Q118zzF5ggZg4th08Qsb6jpU8w6nekBrauhcpwk6HrqlFzGGEFDB0ZjKd6SiYUDWUX UoAuOye0Hf1ozGzb9hR0gcjcQDR1IQPgipfTuEAZDV0VtMK67kk7xYBb32VOgMdCSdga TH7B8cjnZAIPn1Y7bUGD5ogYd8TjsO5D2JlrshnrmyBpT8GDAXsGgY0oLwgzOjaG+b41 Pa313G4hH6CPBVB9vaII0fZWAB58hhVGS4LAmH5CzSc17BkVBxA7oHReRtCi0SGuYRGd HGJgIRQLDuA6aRhMaeYpX6B7bCyyiHx7pc1nCDmBA9eyRIrwqf3DD6Aba/uKwovkYjVO 8z3g== 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 1si146170qtt.279.2018.02.21.10.14.02; Wed, 21 Feb 2018 10:14:03 -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 A3D77617C4; Wed, 21 Feb 2018 18:14:02 +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 657ED61806; Wed, 21 Feb 2018 18:04:22 +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 BA34161806; Wed, 21 Feb 2018 18:04:16 +0000 (UTC) Received: from forward104p.mail.yandex.net (forward104p.mail.yandex.net [77.88.28.107]) by lists.linaro.org (Postfix) with ESMTPS id 8DE8E617DA for ; Wed, 21 Feb 2018 18:02:42 +0000 (UTC) Received: from mxback7g.mail.yandex.net (mxback7g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:168]) by forward104p.mail.yandex.net (Yandex) with ESMTP id 8A17B18549C for ; Wed, 21 Feb 2018 21:02:41 +0300 (MSK) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:7]) by mxback7g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id wSkESaMJW1-2fdCsaBG; Wed, 21 Feb 2018 21:02:41 +0300 Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id pTqHAnOINC-2H94cXkP; Wed, 21 Feb 2018 21:02:18 +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:10 +0300 Message-Id: <1519236011-14987-15-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 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: 0b6ae2680a00027c3958ebcafbbcf92642a68f5e **/ 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 9caf94903..20bd1f88f 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;