From patchwork Tue Oct 24 20:00:10 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: 116994 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp65498qgn; Tue, 24 Oct 2017 13:01:30 -0700 (PDT) X-Google-Smtp-Source: ABhQp+To5n2hLoz9DPp36qAfsz4pk3qPLADjQ3YH6pkWbPBYsv2PoU6naFkIKsCX7GbOscX04cRU X-Received: by 10.55.120.194 with SMTP id t185mr24872951qkc.202.1508875289951; Tue, 24 Oct 2017 13:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508875289; cv=none; d=google.com; s=arc-20160816; b=Ijdtf+nx+lc0oczT4bonD2BcOvMT0BN2x0jpl5htaeKV9B0dtbwj4XNvEoDm/HP6Fq ZorD18A7KFKpxi4cxXu3a59X9muJBSEIbDXVlnh4FXhin/lD9PIelVceQb3aFjNtUCkT rrzLIqqZK1IJ71jre+yoQ3stJlo+M4Ahv9w4FZwg9ZbbRdeq6RfAYX4ULNTJTPU4UVxf Y0zpP4wftYgRjq9wiH2XB7qkmlS2DAyS06v7FNea6vzPYlGgYFF0Fw294Mde46hoWoJQ /PWACWhBtsGWxvrVyjZkAmfyC2gQVZVpdJimu/yunP2C6cp/HY2l8pfhjDI6AmtXL1uY O8iw== 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=OcaEXrJxhfFVn7GMH3OFZhZ9tV3JbT2e3X/BGFnfpcY=; b=JFAvHNydbRUp2naQITkWinMnJ+GoC86qZyddLPKTlinnfdGXzHub1osxGk8q+fO0vC iwEfZPg2Deg5TMORKiZ/C9Yiq2CHIkPJCL/nePArcFRCrkfAFLhwpsfv+fgZ1mQ7gxNY 1IFQxCvFH2Ylurl0vV2uB4uFITDhRC4Gw90oAJGW0Hwrw0+lkgpyIMnVudntNT0+coQi 6VRux4G3v70HMf53LDgH4BtwLZ8iflaZWEy2z4lFMtiZeWeV98v6W+1GYoW7kK3NzPKU X4svML6DWrWXbLVD+wxA9uRsD90yaCyivZptbWpoTXB0B5dEaZSCZ544bGdp/KxTIeXe pN9w== 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 q56si935175qta.21.2017.10.24.13.01.29; Tue, 24 Oct 2017 13:01:29 -0700 (PDT) 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 7CCA062919; Tue, 24 Oct 2017 20:01:29 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 35FB062922; Tue, 24 Oct 2017 20:01:00 +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 9D31B628C0; Tue, 24 Oct 2017 20:00: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 D16D96204E for ; Tue, 24 Oct 2017 20:00:49 +0000 (UTC) Received: from mxback2j.mail.yandex.net (mxback2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10b]) by forward103o.mail.yandex.net (Yandex) with ESMTP id 6FA2D58862BE for ; Tue, 24 Oct 2017 23:00:48 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback2j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id xNR8jmybvQ-0m7W5Xep; Tue, 24 Oct 2017 23:00:48 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ISLUajEG9T-0kGe9TS1; Tue, 24 Oct 2017 23:00:47 +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: Tue, 24 Oct 2017 23:00:10 +0300 Message-Id: <1508875212-29753-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508875212-29753-1-git-send-email-odpbot@yandex.ru> References: <1508875212-29753-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 256 Subject: [lng-odp] [PATCH API-NEXT v2 1/3] api: ipsec: rework ODP_IPSEC_SA_DISABLE into packet error 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 According to the discussion on mailing list, most of implementations will not be able to support odp_ipsec_sa_disable() status event directly. Instead they will submit a dummy packet to that SA. Then after receiving this packet after odp_ipsec_result() will detect this packet and will report it as a packet with odp_ipsec_error_t->sa_disabled bit set. Signed-off-by: Dmitry Eremin-Solenikov Cc: Nikhil Agarwal Cc: Balasubramanian Manoharan --- /** Email created from pull request 256 (lumag:ipsec_sa_disable_v2) ** https://github.com/Linaro/odp/pull/256 ** Patch: https://github.com/Linaro/odp/pull/256.patch ** Base sha: 825f75ed8644ef57c5648961e7982daf13cd9375 ** Merge commit sha: cc282d667b3abb92a45a0f287d68f16850481ba8 **/ include/odp/api/spec/ipsec.h | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h index 26e852fca..ea0ead1ce 100644 --- a/include/odp/api/spec/ipsec.h +++ b/include/odp/api/spec/ipsec.h @@ -843,10 +843,12 @@ odp_ipsec_sa_t odp_ipsec_sa_create(const odp_ipsec_sa_param_t *param); * * When in synchronous operation mode, the call will return when it's possible * to destroy the SA. In asynchronous mode, the same is indicated by an - * ODP_EVENT_IPSEC_STATUS event sent to the queue specified for the SA. The - * status event is guaranteed to be the last event for the SA, i.e. all - * in-progress operations have completed and resulting events (including status - * events) have been enqueued before it. + * artificial packet event sent to the queue specified for the SA having + * sa_disabled error bit set in the odp_ipsec_packet_result_t returned by + * odp_ipsec_result(). The packet is guaranteed to be the last event for + * the SA, i.e. all in-progress operations have completed and resulting events + * (including status events) have been enqueued before it. No packets will come + * from SA after this one. * * @param sa IPSEC SA to be disabled * @@ -914,6 +916,12 @@ typedef struct odp_ipsec_error_t { /** Hard lifetime expired: packets */ uint32_t hard_exp_packets : 1; + + /** + * SA is disabled, all packets are processed, it is + * safe to destroy it now. + */ + uint32_t sa_disabled : 1; }; /** All error bits @@ -927,7 +935,13 @@ typedef struct odp_ipsec_error_t { } odp_ipsec_error_t; -/** IPSEC warnings */ +/** + * IPSEC warnings + * + * For outbound SAs in ODP_IPSEC_OP_MODE_INLINE mode warnings can be reported + * only as status events. In all other cases warnings are reported either as + * a part of IPsec packet result metadata. + */ typedef struct odp_ipsec_warn_t { /** IPSEC warnings */ union { @@ -1133,15 +1147,6 @@ typedef struct odp_ipsec_packet_result_t { * IPSEC status ID */ typedef enum odp_ipsec_status_id_t { - /** Response to SA disable command - * - * Following status event (odp_ipsec_status_t) fields have valid - * content, other fields must be ignored: - * - sa: The SA that was requested to be disabled - * - result: Operation result - */ - ODP_IPSEC_STATUS_SA_DISABLE = 0, - /** Warning from inline IPSEC processing * * Following status event (odp_ipsec_status_t) fields have valid @@ -1152,7 +1157,7 @@ typedef enum odp_ipsec_status_id_t { * This status event is generated only for outbound SAs in * ODP_IPSEC_OP_MODE_INLINE mode. */ - ODP_IPSEC_STATUS_WARN + ODP_IPSEC_STATUS_WARN = 0 } odp_ipsec_status_id_t; @@ -1166,13 +1171,6 @@ typedef struct odp_ipsec_status_t { /** IPSEC SA that was target of the operation */ odp_ipsec_sa_t sa; - /** Result of the operation - * - * 0: Success - * <0: Failure - */ - int result; - /** Warnings of an ODP_IPSEC_STATUS_WARN status event */ odp_ipsec_warn_t warn; @@ -1469,8 +1467,6 @@ int odp_ipsec_result(odp_ipsec_packet_result_t *result, odp_packet_t packet); * * @retval 0 On success * @retval <0 On failure - * - * @see odp_ipsec_sa_disable() */ int odp_ipsec_status(odp_ipsec_status_t *status, odp_event_t event); From patchwork Tue Oct 24 20: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: 116995 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp66331qgn; Tue, 24 Oct 2017 13:02:08 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SP8pVRkUK5VbQcv0aw7+B6282J+GYf9/hOe5KpoAFD8+hUokSdndubu7sjny5s4SV8/kHX X-Received: by 10.200.7.75 with SMTP id k11mr25224255qth.122.1508875328443; Tue, 24 Oct 2017 13:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508875328; cv=none; d=google.com; s=arc-20160816; b=wWiwIcedfKagGMYX48MjL5gtatrn0bIvvtr+QZdepZRbPa4K0QDF/qULLFQ1hOGRbi 2ljoZN5KOcbv6bZeUKl+/0gsokoNgFfbHtWeh0NYLwF+sSbT4RmXpmq6rjyFjtamJlWW hAXZ7FpVPR0lhVtf3jQBmr/HASPNZ2eVCCKNcDv1hnrA81klqXXTGAg5jTohI1WViMYF 27feBdULDEW8kfhrzKczylnuW9t4+DrBVR0FM2YkCrkWQaZx4pC7Mw6QcyLdSvQNaiXb 4vQymCAx6LcspBJ75D1oPrA15UPUBZ460Ghig//m5AI7EOhRKEWmzGWBkZerlK5OxraD zXmw== 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=tdCa4KkeAQeJccnhQJrcoSg1HHKQbLQd5uVL9BWQmh4=; b=f/2KzBKHObACFjmqRHjyw5zA0tXPoTzObZ20w1E/LborbEnBKJTmRgRQRSCDii5S6M OnJT4BdDmt+viYAs8mdbN8fnV3+UVcvqiAMl/NxvNh416ak7+N1SrM4hmQMEIJ3bx/Zq txJMsLSRMsbpeHOa+jT6CwSTk0/DK/Y43Ohm5XsBYx1Py/qLevp+eID7OwpqbOqTNylM Qzrf4X4t0J1zovtZOuHUs80BXdXTDsId9RzFLtmuZgYVk6xJtcyESr2Dw67owDu6EmCm daSNXZx/vRcM2B6syXG8yjyhCMEiEEvDNajN7i7vOA+i5xS/ZGZEwUgYP+yJkjf1hIyZ wOkw== 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 m24si906022qta.192.2017.10.24.13.02.08; Tue, 24 Oct 2017 13:02:08 -0700 (PDT) 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 18AA362937; Tue, 24 Oct 2017 20:02:08 +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=-5.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, 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 8D94A62934; Tue, 24 Oct 2017 20:01:03 +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 A449262922; Tue, 24 Oct 2017 20:00:53 +0000 (UTC) Received: from forward102o.mail.yandex.net (forward102o.mail.yandex.net [37.140.190.182]) by lists.linaro.org (Postfix) with ESMTPS id 0F02F6227A for ; Tue, 24 Oct 2017 20:00:51 +0000 (UTC) Received: from mxback19j.mail.yandex.net (mxback19j.mail.yandex.net [IPv6:2a02:6b8:0:1619::95]) by forward102o.mail.yandex.net (Yandex) with ESMTP id 58B565A057E7 for ; Tue, 24 Oct 2017 23:00:49 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback19j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 7yoy2j5Kpd-0nheQhq9; Tue, 24 Oct 2017 23:00:49 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ISLUajEG9T-0mGGZ1jV; Tue, 24 Oct 2017 23:00:48 +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: Tue, 24 Oct 2017 23:00:11 +0300 Message-Id: <1508875212-29753-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508875212-29753-1-git-send-email-odpbot@yandex.ru> References: <1508875212-29753-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 256 Subject: [lng-odp] [PATCH API-NEXT v2 2/3] validation: ipsec: adapt to odp_ipsec_sa_disable() change 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 256 (lumag:ipsec_sa_disable_v2) ** https://github.com/Linaro/odp/pull/256 ** Patch: https://github.com/Linaro/odp/pull/256.patch ** Base sha: 825f75ed8644ef57c5648961e7982daf13cd9375 ** Merge commit sha: cc282d667b3abb92a45a0f287d68f16850481ba8 **/ test/validation/api/ipsec/ipsec.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/test/validation/api/ipsec/ipsec.c b/test/validation/api/ipsec/ipsec.c index a8fdf2b14..ea385d2ae 100644 --- a/test/validation/api/ipsec/ipsec.c +++ b/test/validation/api/ipsec/ipsec.c @@ -315,7 +315,9 @@ void ipsec_sa_param_fill(odp_ipsec_sa_param_t *param, void ipsec_sa_destroy(odp_ipsec_sa_t sa) { odp_event_t event; - odp_ipsec_status_t status; + odp_packet_t packet; + odp_ipsec_packet_result_t result; + odp_event_subtype_t subtype; CU_ASSERT_EQUAL(ODP_IPSEC_OK, odp_ipsec_sa_disable(sa)); @@ -324,14 +326,18 @@ void ipsec_sa_destroy(odp_ipsec_sa_t sa) event = odp_queue_deq(suite_context.queue); } while (event == ODP_EVENT_INVALID); - CU_ASSERT_EQUAL(ODP_EVENT_IPSEC_STATUS, odp_event_type(event)); + CU_ASSERT_EQUAL(ODP_EVENT_PACKET, + odp_event_types(event, &subtype)); + CU_ASSERT_EQUAL(ODP_EVENT_PACKET_IPSEC, + subtype); - CU_ASSERT_EQUAL(ODP_IPSEC_OK, odp_ipsec_status(&status, event)); + packet = odp_ipsec_packet_from_event(event); - CU_ASSERT_EQUAL(ODP_IPSEC_STATUS_SA_DISABLE, status.id); - CU_ASSERT_EQUAL(sa, status.sa); - CU_ASSERT_EQUAL(0, status.result); - CU_ASSERT_EQUAL(0, status.warn.all); + CU_ASSERT_EQUAL(0, odp_ipsec_result(&result, packet)); + + CU_ASSERT_EQUAL(sa, result.sa); + CU_ASSERT_EQUAL(1, result.status.error.sa_disabled); + CU_ASSERT_EQUAL(0, result.status.warn.all); odp_event_free(event); } From patchwork Tue Oct 24 20:00:12 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: 116996 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp67259qgn; Tue, 24 Oct 2017 13:02:50 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Q4/GkhylkXU9UMk033Vwpz+6EjC36UHCKf5G00MTAVGaLab/0WjPFrzNucXh7qYtveOCFl X-Received: by 10.200.48.37 with SMTP id f34mr27621772qte.228.1508875370633; Tue, 24 Oct 2017 13:02:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508875370; cv=none; d=google.com; s=arc-20160816; b=jzwIX+rPYQMUkSf7gTTY9rOHEBagpo9TJqm7yQLBuFLWYY818ja2EkbtIGzHXezJye rMJ78xy9BJEa5fn2WMJxI0+My5BLvGq4zopMY/v96a1CQK85+l4pRQJgXKtCUq65lMLD ZL176Xg2SIreYn848AtcGC4QgsXDab6hcxR+tLTp4gP1FlK/B7ANtI6W0kSuvBY41N// 0X1BaZ+aW2yG6P8uXoMRaWqEgDJemOKGuDoF6JJlOIq1Omb8rikULDRgO6C2L5DdNpcP +43Lq1lnG9tRlI02cbnM38K9udbQUwFypwH8uGO0XigwAKbOV010107E9uh6dGgEyy4G g5YQ== 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=w/vqs3q5BiGxZxgiyZxfI8dfwZSymTrS19jgmprYZR0=; b=K6QaXJrP1oUjlRNwpkZvouB11GzQZlpV+h+Mjq6kyQuF0OMtnlsJR2oWY0xmWJZmKy GowjeDt/qXG5dhyweUhs/SsaxSqJ9dXqUtv7WfP1X/qnpt0mGsULlWrZktjEq4z3gTSn Mm2zmyUpW48t3K3paABR5NQOGieuiUMLf8VsWpjSobLzAKLjX2MVNZEGByYcHzhCB20E 75lbynigE5MXEP+yfEnqRKQuWEaX+iuxUaLGQ+qFMOSIKEvXHqqD5tNjlRwDFsap6NOh xXqdICbFb7jdg8ppApZCwdte8NgpAUKNoailOkiC/jv0+GfiWSjgYTp6vYcinlP+eaL8 5ehg== 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 q71si878663qkh.341.2017.10.24.13.02.50; Tue, 24 Oct 2017 13:02:50 -0700 (PDT) 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 4BF0262949; Tue, 24 Oct 2017 20:02:50 +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 D989262940; Tue, 24 Oct 2017 20:01:08 +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 406B062919; Tue, 24 Oct 2017 20:00:59 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id C8FDE6204E for ; Tue, 24 Oct 2017 20:00:51 +0000 (UTC) Received: from mxback8g.mail.yandex.net (mxback8g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:169]) by forward106p.mail.yandex.net (Yandex) with ESMTP id 45C422D84278 for ; Tue, 24 Oct 2017 23:00:50 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback8g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id KFrmPpFQcw-0ormLQah; Tue, 24 Oct 2017 23:00:50 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ISLUajEG9T-0nGOqQE5; Tue, 24 Oct 2017 23:00:49 +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: Tue, 24 Oct 2017 23:00:12 +0300 Message-Id: <1508875212-29753-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508875212-29753-1-git-send-email-odpbot@yandex.ru> References: <1508875212-29753-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 256 Subject: [lng-odp] [PATCH API-NEXT v2 3/3] linux-gen: implement odp_ipsec_sa_disable() changes 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 256 (lumag:ipsec_sa_disable_v2) ** https://github.com/Linaro/odp/pull/256 ** Patch: https://github.com/Linaro/odp/pull/256.patch ** Base sha: 825f75ed8644ef57c5648961e7982daf13cd9375 ** Merge commit sha: cc282d667b3abb92a45a0f287d68f16850481ba8 **/ .../linux-generic/include/odp_ipsec_internal.h | 20 +++++++- platform/linux-generic/odp_ipsec.c | 18 ++++---- platform/linux-generic/odp_ipsec_events.c | 54 +++++++++++++++++++++- platform/linux-generic/odp_ipsec_sad.c | 16 ++----- 4 files changed, 84 insertions(+), 24 deletions(-) diff --git a/platform/linux-generic/include/odp_ipsec_internal.h b/platform/linux-generic/include/odp_ipsec_internal.h index 1340ca7bd..09a7ac126 100644 --- a/platform/linux-generic/include/odp_ipsec_internal.h +++ b/platform/linux-generic/include/odp_ipsec_internal.h @@ -74,9 +74,20 @@ void _odp_ipsec_status_free(ipsec_status_t status); int _odp_ipsec_status_send(odp_queue_t queue, odp_ipsec_status_id_t id, odp_ipsec_sa_t sa, - int result, odp_ipsec_warn_t warn); +/** + * @internal Send SA_DISABLED event + * + * Sends the packet notifying application that SA finished all processing and + * is now disabled. + * + * @param queue destination queue + * @param sa SA respective to the operation + */ +int _odp_ipsec_sa_disabled_send(odp_queue_t queue, + odp_ipsec_sa_t sa); + #define IPSEC_MAX_IV_LEN 32 /**< Maximum IV length in bytes */ #define IPSEC_MAX_SALT_LEN 4 /**< Maximum salt length in bytes */ @@ -191,6 +202,13 @@ int _odp_ipsec_sa_update_stats(ipsec_sa_t *ipsec_sa, uint32_t len, int _odp_ipsec_try_inline(odp_packet_t pkt); /** + * Return IPsec result instance connected to the IPsec packet + * + * @param packet packet of ODP_EVENT_PACKET_IPSEC subtype + */ +odp_ipsec_packet_result_t *_odp_ipsec_pkt_result(odp_packet_t packet); + +/** * @} */ diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c index e57736c2a..e9bf88c17 100644 --- a/platform/linux-generic/odp_ipsec.c +++ b/platform/linux-generic/odp_ipsec.c @@ -93,7 +93,7 @@ int odp_ipsec_config(const odp_ipsec_config_t *config) return 0; } -static odp_ipsec_packet_result_t *ipsec_pkt_result(odp_packet_t packet) +odp_ipsec_packet_result_t *_odp_ipsec_pkt_result(odp_packet_t packet) { ODP_ASSERT(ODP_EVENT_PACKET_IPSEC == odp_event_subtype(odp_packet_to_event(packet))); @@ -902,7 +902,7 @@ int odp_ipsec_in(const odp_packet_t pkt_in[], int num_in, _odp_buffer_event_subtype_set(packet_to_buffer(pkt), ODP_EVENT_PACKET_IPSEC); - result = ipsec_pkt_result(pkt); + result = _odp_ipsec_pkt_result(pkt); memset(result, 0, sizeof(*result)); result->status = status; if (NULL != ipsec_sa) @@ -966,7 +966,7 @@ int odp_ipsec_out(const odp_packet_t pkt_in[], int num_in, _odp_buffer_event_subtype_set(packet_to_buffer(pkt), ODP_EVENT_PACKET_IPSEC); - result = ipsec_pkt_result(pkt); + result = _odp_ipsec_pkt_result(pkt); memset(result, 0, sizeof(*result)); result->status = status; result->sa = ipsec_sa->ipsec_sa_hdl; @@ -1014,7 +1014,7 @@ int odp_ipsec_in_enq(const odp_packet_t pkt_in[], int num_in, _odp_buffer_event_subtype_set(packet_to_buffer(pkt), ODP_EVENT_PACKET_IPSEC); - result = ipsec_pkt_result(pkt); + result = _odp_ipsec_pkt_result(pkt); memset(result, 0, sizeof(*result)); result->status = status; if (NULL != ipsec_sa) { @@ -1075,7 +1075,7 @@ int odp_ipsec_out_enq(const odp_packet_t pkt_in[], int num_in, _odp_buffer_event_subtype_set(packet_to_buffer(pkt), ODP_EVENT_PACKET_IPSEC); - result = ipsec_pkt_result(pkt); + result = _odp_ipsec_pkt_result(pkt); memset(result, 0, sizeof(*result)); result->status = status; result->sa = ipsec_sa->ipsec_sa_hdl; @@ -1115,7 +1115,7 @@ int _odp_ipsec_try_inline(odp_packet_t pkt) _odp_buffer_event_subtype_set(packet_to_buffer(pkt), ODP_EVENT_PACKET_IPSEC); - result = ipsec_pkt_result(pkt); + result = _odp_ipsec_pkt_result(pkt); memset(result, 0, sizeof(*result)); result->status = status; result->sa = ipsec_sa->ipsec_sa_hdl; @@ -1192,7 +1192,7 @@ int odp_ipsec_out_inline(const odp_packet_t pkt_in[], int num_in, _odp_buffer_event_subtype_set(packet_to_buffer(pkt), ODP_EVENT_PACKET_IPSEC); - result = ipsec_pkt_result(pkt); + result = _odp_ipsec_pkt_result(pkt); memset(result, 0, sizeof(*result)); result->sa = ipsec_sa->ipsec_sa_hdl; result->status = status; @@ -1217,7 +1217,7 @@ int odp_ipsec_out_inline(const odp_packet_t pkt_in[], int num_in, buf = packet_to_buffer(pkt); _odp_buffer_event_subtype_set(buf, ODP_EVENT_PACKET_IPSEC); - result = ipsec_pkt_result(pkt); + result = _odp_ipsec_pkt_result(pkt); memset(result, 0, sizeof(*result)); result->sa = ipsec_sa->ipsec_sa_hdl; result->status = status; @@ -1246,7 +1246,7 @@ int odp_ipsec_result(odp_ipsec_packet_result_t *result, odp_packet_t packet) ODP_ASSERT(result != NULL); - res = ipsec_pkt_result(packet); + res = _odp_ipsec_pkt_result(packet); /* FIXME: maybe postprocess here, setting alg error in case of crypto * error instead of processing packet fully in ipsec_in/out_single */ diff --git a/platform/linux-generic/odp_ipsec_events.c b/platform/linux-generic/odp_ipsec_events.c index 3a7ebd6e8..3a3a9f5f5 100644 --- a/platform/linux-generic/odp_ipsec_events.c +++ b/platform/linux-generic/odp_ipsec_events.c @@ -6,6 +6,8 @@ #include "config.h" +#include + #include #include @@ -13,6 +15,8 @@ #include #include #include +#include +#include #include typedef struct { @@ -23,6 +27,7 @@ typedef struct { } ipsec_status_hdr_t; static odp_pool_t ipsec_status_pool = ODP_POOL_INVALID; +static odp_pool_t ipsec_sa_disabled_pool = ODP_POOL_INVALID; #define IPSEC_EVENTS_POOL_BUF_COUNT 1024 @@ -43,8 +48,24 @@ int _odp_ipsec_events_init_global(void) goto err_status; } + odp_pool_param_init(¶m); + + param.pkt.seg_len = 16; + param.pkt.len = 16; + param.pkt.num = ODP_CONFIG_IPSEC_SAS; + param.type = ODP_POOL_PACKET; + + ipsec_sa_disabled_pool = odp_pool_create("ipsec_sa_disabled_pool", + ¶m); + if (ODP_POOL_INVALID == ipsec_sa_disabled_pool) { + ODP_ERR("Error: sa_disabled pool create failed.\n"); + goto err_sa_disabled; + } + return 0; +err_sa_disabled: + odp_pool_destroy(ipsec_status_pool); err_status: return -1; } @@ -54,6 +75,12 @@ int _odp_ipsec_events_term_global(void) int ret = 0; int rc = 0; + ret = odp_pool_destroy(ipsec_sa_disabled_pool); + if (ret < 0) { + ODP_ERR("sa_disabled pool destroy failed"); + rc = -1; + } + ret = odp_pool_destroy(ipsec_status_pool); if (ret < 0) { ODP_ERR("status pool destroy failed"); @@ -112,7 +139,6 @@ void _odp_ipsec_status_free(ipsec_status_t status) int _odp_ipsec_status_send(odp_queue_t queue, odp_ipsec_status_id_t id, odp_ipsec_sa_t sa, - int result, odp_ipsec_warn_t warn) { ipsec_status_t ipsec_ev = odp_ipsec_status_alloc(); @@ -125,7 +151,6 @@ int _odp_ipsec_status_send(odp_queue_t queue, status_hdr->status.id = id; status_hdr->status.sa = sa; - status_hdr->status.result = result; status_hdr->status.warn = warn; if (odp_queue_enq(queue, ipsec_status_to_event(ipsec_ev))) { @@ -154,3 +179,28 @@ int odp_ipsec_status(odp_ipsec_status_t *status, odp_event_t event) return 0; } + +int _odp_ipsec_sa_disabled_send(odp_queue_t queue, + odp_ipsec_sa_t sa) +{ + odp_packet_t packet; + odp_ipsec_packet_result_t *result; + + ODP_ASSERT(ODP_POOL_INVALID != ipsec_sa_disabled_pool); + packet = odp_packet_alloc(ipsec_sa_disabled_pool, 0); + ODP_ASSERT(ODP_PACKET_INVALID != packet); + + _odp_buffer_event_subtype_set(packet_to_buffer(packet), + ODP_EVENT_PACKET_IPSEC); + result = _odp_ipsec_pkt_result(packet); + memset(result, 0, sizeof(*result)); + result->status.error.sa_disabled = 1; + result->sa = sa; + + if (odp_queue_enq(queue, odp_ipsec_packet_to_event(packet))) { + odp_packet_free(packet); + return -1; + } + + return 0; +} diff --git a/platform/linux-generic/odp_ipsec_sad.c b/platform/linux-generic/odp_ipsec_sad.c index f0b5b9e4a..a1eff8849 100644 --- a/platform/linux-generic/odp_ipsec_sad.c +++ b/platform/linux-generic/odp_ipsec_sad.c @@ -171,7 +171,6 @@ void _odp_ipsec_sa_unuse(ipsec_sa_t *ipsec_sa) { odp_queue_t queue; odp_ipsec_sa_t sa; - odp_ipsec_warn_t warn = { .all = 0 }; ODP_ASSERT(NULL != ipsec_sa); @@ -179,9 +178,7 @@ void _odp_ipsec_sa_unuse(ipsec_sa_t *ipsec_sa) sa = ipsec_sa->ipsec_sa_hdl; if (ipsec_sa_unlock(ipsec_sa) && ODP_QUEUE_INVALID != queue) - _odp_ipsec_status_send(queue, - ODP_IPSEC_STATUS_SA_DISABLE, - sa, 0, warn); + _odp_ipsec_sa_disabled_send(queue, sa); } void odp_ipsec_sa_param_init(odp_ipsec_sa_param_t *param) @@ -370,17 +367,12 @@ int odp_ipsec_sa_disable(odp_ipsec_sa_t sa) } if (ODP_QUEUE_INVALID != ipsec_sa->queue) { - odp_ipsec_warn_t warn = { .all = 0 }; - /* - * If there were not active state when we disabled SA, - * send the event. + * If there was no active state when we disabled SA, send the + * event. Otherwise it will be sent by _odp_ipsec_sa_unuse(). */ if (0 == state) - _odp_ipsec_status_send(ipsec_sa->queue, - ODP_IPSEC_STATUS_SA_DISABLE, - ipsec_sa->ipsec_sa_hdl, - 0, warn); + _odp_ipsec_sa_disabled_send(ipsec_sa->queue, sa); return 0; }