From patchwork Tue Apr 19 08:41:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cao, Min" X-Patchwork-Id: 12107 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 5ED212E81; Tue, 19 Apr 2016 10:41:15 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id D12DD2935 for ; Tue, 19 Apr 2016 10:41:13 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP; 19 Apr 2016 01:41:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,506,1455004800"; d="scan'208";a="87821929" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga004.fm.intel.com with ESMTP; 19 Apr 2016 01:41:12 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 19 Apr 2016 01:41:11 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.229]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.136]) with mapi id 14.03.0248.002; Tue, 19 Apr 2016 16:41:09 +0800 From: "Cao, Min" To: "De Lara Guarch, Pablo" , "dev@dpdk.org" CC: "Doherty, Declan" , "De Lara Guarch, Pablo" Thread-Topic: [dpdk-dev] [PATCH] l2fwd-crypto: fix supported key size check Thread-Index: AQHRlKLCRmT3N1DOxEKvul4mWbSFzZ+RBLvw Date: Tue, 19 Apr 2016 08:41:09 +0000 Message-ID: References: <1460455443-11130-1-git-send-email-pablo.de.lara.guarch@intel.com> In-Reply-To: <1460455443-11130-1-git-send-email-pablo.de.lara.guarch@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] l2fwd-crypto: fix supported key size check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Tested-by: Min Cao - Tested Commit: b3b9719f18ee83773c6ed7adda300c5ac63c37e9 - OS: Fedora20 3.11.10-301.fc20.x86_64 - GCC: gcc (GCC) 4.8.3 - CPU: Intel(R) Xeon(R) CPU E5-2658 v3 @ 2.20GHz - NIC: Niantic - Default x86_64-native-linuxapp-gcc configuration - Prerequisites: - Total 1 cases, 1 passed, 0 failed - test case 1: l2fwd-crypto with 64 bytes auth_key Total 1 cases, 1 passed, 0 failed -----Original Message----- From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Pablo de Lara Sent: Tuesday, April 12, 2016 6:04 PM To: dev@dpdk.org Cc: Doherty, Declan; De Lara Guarch, Pablo Subject: [dpdk-dev] [PATCH] l2fwd-crypto: fix supported key size check When initializing crypto devices within the app, the provided key sizes are checked against the supported sizes from the crypto device capabilities. When the supported sizes are not a range, but a single value, the check may become an infinite loop (when size is not supported). Fixes: a061e50a0d97 ("examples/l2fwd-crypto: fix ambiguous input key size") Signed-off-by: Pablo de Lara --- examples/l2fwd-crypto/main.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index d4e2d8d..e273f2f 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -1486,6 +1486,15 @@ check_supported_size(uint16_t length, uint16_t min, uint16_t max, { uint16_t supp_size; + /* Single value */ + if (increment == 0) { + if (length == min) + return 0; + else + return -1; + } + + /* Range of values */ for (supp_size = min; supp_size <= max; supp_size += increment) { if (length == supp_size) return 0; -- 2.5.5