From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00081.outbound.protection.outlook.com [40.107.0.81]) by dpdk.org (Postfix) with ESMTP id 66C551B91E for ; Thu, 21 Jun 2018 15:49:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hikwpdfV/EWMGsv14eSipSFcHF3VjTgaFNJtgrwjoj4=; b=Q6CEGoHmm+WOnCvgH3M9Y5NspZdOz6hrWZLks/O3dmWC08G61YzRX0Jy1U41QUKeSsU04xNhenb3+gkddkK/zMfwKuuYlTZmDXC72Gr1iCNtFD0zoL2iDIktidc9GuU/M3FlxCqTm97LLjE9Mq1RMXBE0OrtRPoi8wjlrcGT5lo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=akhil.goyal@nxp.com; Received: from [10.232.134.144] (14.142.187.166) by VI1PR04MB1390.eurprd04.prod.outlook.com (2a01:111:e400:5348::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.16; Thu, 21 Jun 2018 13:49:02 +0000 To: Konstantin Ananyev , dev@dpdk.org Cc: radu.nicolau@intel.com References: <1528208163-31560-1-git-send-email-konstantin.ananyev@intel.com> <1528208163-31560-2-git-send-email-konstantin.ananyev@intel.com> From: Akhil Goyal Message-ID: <36d2a552-e043-7451-ed66-70d13f0f6fe6@nxp.com> Date: Thu, 21 Jun 2018 19:18:45 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <1528208163-31560-2-git-send-email-konstantin.ananyev@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [14.142.187.166] X-ClientProxiedBy: BMXPR01CA0007.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:d::17) To VI1PR04MB1390.eurprd04.prod.outlook.com (2a01:111:e400:5348::21) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c4d3553b-9bc5-4b6c-7b71-08d5d77dbff3 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(5600026)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB1390; X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB1390; 3:AbHyYEBJLSHht45cWnTQRi06t4J5Cq8Hc4VWXxRIZ8jhs1FPwnKGzvPg1EFAxUqPohg+A2/Uw9uyucPlWwjw7U5Xjm3MnbpkZxVGkWIhMLMpZGPXkSnc5o/n2TCoipeTbPBsrtziXULB6BPopANuGmXF1sK+6U3gylcQG6azOUYRCDhh98LBw1tmDfJ3Q8LUknqSwEwKW4R0M51BxN620UEBqv6ws6pkzzkvndRQGBvsTlXIJd/Py+mxZlDjECaL; 25:X7Z6jI9R3N/nVG+YeNDUnOFjhR/hgdvcG6vivE+7EVLPaEQByO0qQExL7hXAbGmk8+LMb+HzDONezuRM32JsVHz3EQGD2chWAFZ6ExhsasbaPjaTa+xuDvXJVhFX0aS+uUUQjvnnP2juCOBvGVSDWhp/5Ozq0uEmo5CvktKwGTGEO7Samo4vGbHZBZhE3kHolIw2534RjQ09Mc3SJ8RMxrXe4QHZNXHQiw80LmpNUq5xSTX3dzg6fHvNXVtORMjQyZTEq+9NJAj565IInZQGebMeWzvbMH7YXVy2mKYk8gbV7LRrDtfV/ms1nLSo3EZQKLa3HrYX9V4itW0avLJJGg==; 31:iWIsvhv9X68e+5/ZOgNc1aqu+WleFkDDKmd+2NgDcSR17kO+ll27KqRMmyV9rS7NtiFDza5j/JNqmTAUA1KgOqKCmCzxwtRy9CgMDeMQ3tJ5MYpCulZ46WT8eY3X7ukxgK2p/dRiY8CZTOSv9LzOMtEE4gpVaFiV0PzfjEo5J7PyAGz6vVhHHbj4ADcV+o06sIbJySyLXVH7H/ovD9ZMUOF63JF85m/DjUD5zvW/byY= X-MS-TrafficTypeDiagnostic: VI1PR04MB1390: X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB1390; 20:njDA1n7P4tf1EmI75q7hRkD61UfohN6Pf9oyQc56G7we143iMUS/VYJK/IeQiOZI0tApKQMjHWn7yrw05wXLMt9vaRTx3kHvauT+Nqx1iFcvTQ4x3RT7SPo8sRpiGe4Md/s/DqKTOW9/phEBFskiChCU72iZjkAnvBWVkfHoCKf2F63cSjmIUpIc4RDydmvX6U+vrmC74hzWM5TnS68+jd0tymd9HBsxK5p8bOHLnBmCTpphrC/BkKvAV1j+ugUG5YhBxZECKG3++/LVYmkJn3MY2i9ddW/zksacV977W6BJI92LHffDf1frLmfwhzKGu6riVNeX0neZzb+3MMkRIh6sz8f6w1M8iQj2M+bytVWlGBpipWv1aSdJbiDBdTps+VpLIjcxrFlKHkXqgw61hZM0hh97QSFEeDttinWsNlGcOrAK8LG/OfCn1UVrx2TzNDsZ83byonZFN3RR/ipDaAVCyrEAlSf5YN7mqW6V4N0aSI4pt0bRG/UqaVQ5egAr; 4:hzOz+vCXzMc2yrhnK2lNpS+1zDB1AwgxwNKC1XXmjOkwkKIcaxzTh4qZWlk/Brxy/sjTsRYJTYi84jfJwBP6UnYVPNTHyQH39FMKaxe5B5vHTrPDVaTheX0+P24cQ+X07Iw5JnOX7pQaBd8TJyZZS78u+m1sDAyOo/10oF7/Xfy6PIIyFdljndgMeQ1nl/M0KUs98/ahXFi9KpFLesTJXe7Q/EF/zB0oFQrvng2j3qekmRyWXzVJtM8rV8rdOGo8EQinMq7SCk9ZS6zz5yq6GfMVaP3xPib0clR40bs6ybVmWsCKxHhYUG2T+qUtXscY X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231254)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123560045)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:VI1PR04MB1390; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB1390; X-Forefront-PRVS: 07106EF9B9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6049001)(39860400002)(376002)(346002)(39380400002)(366004)(396003)(189003)(199004)(476003)(316002)(386003)(53546011)(97736004)(64126003)(486006)(65806001)(65956001)(47776003)(186003)(66066001)(3260700006)(6666003)(55236004)(68736007)(478600001)(25786009)(76176011)(50466002)(956004)(86362001)(2616005)(446003)(11346002)(2486003)(16576012)(23676004)(52116002)(52146003)(77096007)(44832011)(16526019)(58126008)(26005)(67846002)(8936002)(81156014)(229853002)(36756003)(5660300001)(31696002)(81166006)(31686004)(106356001)(4326008)(53936002)(6246003)(105586002)(6486002)(230700001)(7736002)(6116002)(3846002)(305945005)(65826007)(2906002)(8676002)(5009440100003)(110426005); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB1390; H:[10.232.134.144]; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtWSTFQUjA0TUIxMzkwOzIzOnVLa28vRm9WZkx6RDBLWlhheis5Q3ZLdFJk?= =?utf-8?B?VGs4a2x2bTRxRHhXandjUFFhSnRxSTloYXBWUkNsaTJHdVpjNnkydHFKY1lz?= =?utf-8?B?VVNEL0RBdWhGcEJVaUlZWXJUNkkwZVMyT25XSGhBRFRHNU5jZlZuQjBrbUpB?= =?ut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MFQQdyYB/6/kh+KSdoOYIKsIJYNkTbo5fLmd2gs41znbhNoAaXhkcrQXIkxepFWbHZW7LS1n30zS9CNxnDAH7l1AuyjF96YkhZqaHN8w=; 24:SSvBXLHthIJeWTHJ4V8YS/kcwGwczxL/Al4i5RcYZG9heSHbthTX1V7C/zLiwqhI4PoD8b4qD0hpMeMuASCIXlo0bDgvvkb4XxLWJBvpF7U= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB1390; 7:6vaFwN1urK3wlI5a8kivjcz0VuypWQYmRTgeOMVSFwYKPMyLVizAc3OcJWlpGrrjUDIFI0Q3ktS3JHnn5thYiahNprcVvchzeR/YO2+Id5G+f5CAph+deQl7ZMjs1zkemjIadXs/8KbhAbWPiLauMiATZwfGwQnVF/oq/9QXOawJFZ2FnUii/S1iUKQ9w0Z52EQGYpOZ/5RzqNlHfb7BAsv8AgQ0Tqnr6KBQL+gCAnXFEwbAVH9STHTvLttNp+Ff X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2018 13:49:02.6295 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c4d3553b-9bc5-4b6c-7b71-08d5d77dbff3 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB1390 Subject: Re: [dpdk-dev] [PATCH 2/2] examples/ipsec-secgw: fix portmask option parsing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jun 2018 13:49:05 -0000 Hi Konstantin, On 6/5/2018 7:46 PM, Konstantin Ananyev wrote: > parse_portmask() returns both portmask value and possible error code > as 32-bit integer. That causes some confusion for callers. > Split error code and portmask value into two distinct variables. > Also allows to run the app with unprotected_port_mask == 0. This would also allow cryptodev_mask == 0 to work well which should not be the case. > > Fixes: d299106e8e31 ("examples/ipsec-secgw: add IPsec sample application") > > Signed-off-by: Konstantin Ananyev > --- > examples/ipsec-secgw/ipsec-secgw.c | 29 +++++++++++++++-------------- > 1 file changed, 15 insertions(+), 14 deletions(-) > > diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c > index fafb41161..5d7071657 100644 > --- a/examples/ipsec-secgw/ipsec-secgw.c > +++ b/examples/ipsec-secgw/ipsec-secgw.c > @@ -972,20 +972,19 @@ print_usage(const char *prgname) > } > > static int32_t > -parse_portmask(const char *portmask) > +parse_portmask(const char *portmask, uint32_t *pmv) > { > - char *end = NULL; > + char *end; > unsigned long pm; > > /* parse hexadecimal string */ > + errno = 0; > pm = strtoul(portmask, &end, 16); > - if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0')) > + if (errno != 0 || *end != '\0' || pm > UINT32_MAX) > return -1; > > - if ((pm == 0) && errno) > - return -1; > - > - return pm; > + *pmv = pm; > + return 0; > } > > static int32_t > @@ -1063,6 +1062,7 @@ parse_args(int32_t argc, char **argv) > int32_t opt, ret; > char **argvopt; > int32_t option_index; > + uint32_t v; > char *prgname = argv[0]; > int32_t f_present = 0; > > @@ -1073,8 +1073,8 @@ parse_args(int32_t argc, char **argv) > > switch (opt) { > case 'p': > - enabled_port_mask = parse_portmask(optarg); > - if (enabled_port_mask == 0) { > + ret = parse_portmask(optarg, &enabled_port_mask); > + if (ret < 0 || enabled_port_mask == 0) { > printf("invalid portmask\n"); > print_usage(prgname); > return -1; > @@ -1085,8 +1085,8 @@ parse_args(int32_t argc, char **argv) > promiscuous_on = 1; > break; > case 'u': > - unprotected_port_mask = parse_portmask(optarg); > - if (unprotected_port_mask == 0) { > + ret = parse_portmask(optarg, &unprotected_port_mask); > + if (ret < 0) { > printf("invalid unprotected portmask\n"); > print_usage(prgname); > return -1; > @@ -1147,15 +1147,16 @@ parse_args(int32_t argc, char **argv) > single_sa_idx); > break; > case CMD_LINE_OPT_CRYPTODEV_MASK_NUM: > - ret = parse_portmask(optarg); > + ret = parse_portmask(optarg, &v); I think there is no need for v, enabled_cryptodev_mask can be used instead. > if (ret == -1) { enabled_cryptodev_mask should not be 0 and should be checked here. -Akhil > - printf("Invalid argument[portmask]\n"); > + printf("Invalid argument[%s]\n", > + CMD_LINE_OPT_CRYPTODEV_MASK); > print_usage(prgname); > return -1; > } > > /* else */ > - enabled_cryptodev_mask = ret; > + enabled_cryptodev_mask = v; > break; > default: > print_usage(prgname);