From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id F286DA00C2; Fri, 24 Apr 2020 13:51:29 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5E4211C1CD; Fri, 24 Apr 2020 13:51:28 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 4C6281C1CB for ; Fri, 24 Apr 2020 13:51:26 +0200 (CEST) IronPort-SDR: 6IbzdO0XOLennbM4IZ0CyJxXYplqPygoMV+iCQ+WdUdzTqTI3uNAFTPwLenIQ3wgnwdlLEfrxK /qtuSbliImbw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2020 04:51:25 -0700 IronPort-SDR: l42z0MihK8gqJ2qwbzzzkpozJU6MFWUO0rz/EsaHn/NN6lTVczt8Fyessf8Bu4APBOLQd6XVvQ djSDznHOdSFQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,311,1583222400"; d="scan'208";a="248048524" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga008.fm.intel.com with ESMTP; 24 Apr 2020 04:51:24 -0700 Received: from fmsmsx121.amr.corp.intel.com (10.18.125.36) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 24 Apr 2020 04:51:07 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx121.amr.corp.intel.com (10.18.125.36) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 24 Apr 2020 04:51:08 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.102) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 24 Apr 2020 04:50:20 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aghlTSHmH8gaXG0CaxulkCAtoIEIHIzGLodAjlTCEWbeUt8chvP43IXEhUBr8Jw/xgemv5Sb9K6wCK68M8AWE7ngCZg+sGU7CdVe/cfJkX3/nbvSSp3nTmVees7L50MVKvfRNufM9de2PgU5/jBFzzwVLpHXptb/Gtv8//0EJm56Z4iGOUrmBq1dtYyWEcH0N+RQWugVLbUmW5zE4+KuEAl94ColLSkiAs1Hkz+hnh0NapsRNlvyRjDeZN+x+O+JSW8xehfTB1/JYLVTLI1e4cXXNIRwG/b5N1U0ZY6Dcp12+FyuHqGNyIqIsHPGEsUbtnC3xh1xuC9PbpwUkkpuYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kUJlvVOERHCOFrLEfEmMMpp3UEG/GiHv/VSaPOTtjps=; b=Mw4qqTRfspSEiFneBiJtRsvg4/LtDQLMr4Bz2Lcn/gRI5JJCmuDYMmkEr0fYeyuSlZY2Zc0iCa4N0/l/jzr2OEsISF9w6HVrv8JUSCYvCdULIl5TDIUUGbQ6sbdmVXIdt7scSlg7k9U842ggV+sBXcGvML+uPgFJKTWVQOxcrOuR6K1+5E5uMYjweIrmr+NivsglU1Bv1k7aSU1s0xa76qpUpgzP9ygL9URAlCD6F9fLAW3NVaWN8NY7sy7xqdtXfZ8SUcMvNnUP6zrsJDtU4TLGD4g3bJyGD7LYi4LwRB84s8ZwiMQgR+uxRMIUKe9dI9txkhlvVjIOJI7t6WBOCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kUJlvVOERHCOFrLEfEmMMpp3UEG/GiHv/VSaPOTtjps=; b=efH+04UArmMv8uZc3Y+2lreZCZY3G7A4CxfwH4nG3NrK3q6RzSrZgcpPxhG+60WOudqcQXrB48SIyUf/5PDBoFbQ6f7ZCKXCRkBhMYN9vNspBZm1L5sJOE8lGILXPZceesxDZ++LW32COW9S+5bYtap06fh+tKBN/tfADMR0/Ps= Received: from BYAPR11MB3301.namprd11.prod.outlook.com (2603:10b6:a03:7f::26) by BYAPR11MB3654.namprd11.prod.outlook.com (2603:10b6:a03:b2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.13; Fri, 24 Apr 2020 11:49:49 +0000 Received: from BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f8cb:58cd:e958:fff4]) by BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f8cb:58cd:e958:fff4%6]) with mapi id 15.20.2937.020; Fri, 24 Apr 2020 11:49:49 +0000 From: "Ananyev, Konstantin" To: Ibtisam Tariq , "Dumitrescu, Cristian" , "Singh, Jasvinder" , "Nicolau, Radu" , "akhil.goyal@nxp.com" CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 3/3] examples/ipsec-secgw/parser.c: Removing the re-implementation of inet_pton Thread-Index: AQHWGKXZx5EfE1DuoU6EJsGKryAeg6iIKv4g Date: Fri, 24 Apr 2020 11:49:49 +0000 Message-ID: References: <20200422125745.19744-1-ibtisam.tariq@emumba.com> <20200422125745.19744-3-ibtisam.tariq@emumba.com> In-Reply-To: <20200422125745.19744-3-ibtisam.tariq@emumba.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.2.0.6 authentication-results: spf=none (sender IP is ) smtp.mailfrom=konstantin.ananyev@intel.com; x-originating-ip: [192.198.151.170] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: ddb5b5f7-b847-429e-5e36-08d7e84597fb x-ms-traffictypediagnostic: BYAPR11MB3654: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6430; x-forefront-prvs: 03838E948C x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB3301.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(376002)(39860400002)(396003)(136003)(366004)(346002)(8936002)(4326008)(76116006)(33656002)(5660300002)(66476007)(64756008)(66946007)(66556008)(6506007)(2906002)(66446008)(26005)(186003)(478600001)(7696005)(71200400001)(55016002)(110136005)(52536014)(81156014)(86362001)(316002)(9686003); DIR:OUT; SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Oki9GZwqIUHKVMTqXojc0M0e7U0V2L/B+0vbfMMY2V8Ydx//mQhGGt+e7+dUXAh/R1OrKC/yFtGmQls05Yhz/8VMe7F17romBNfnhAhYHRywQUZ8pJ/7Tv5n9Xj2Peduj/N7E5jq3VFPJlDYrRltcPWCgI9vatSiS4cMvuw4BhmprVCA6iBbqviCbRiNlv7EWBY72hFJpiEdPP8Y5uCIEZjoTRb9W9WZIiCTw0w5tkUOEbyNQ61dknuQunYTkwIps4W9ItgAajmyHNvdsJfJDnmqP1JNq458Xfh+Vk8KkXqgLtj0aoIU8BvSo+dT2Gtsr9W1O0gL2dQ3QnJGVvQcl+6PUfVecJlSrVTMAy9PrexQDouaUJK7juZIe2eJDNDVosZRoc7SQsDKcleLaO00JtBX9I1rTeQ80yCgmIAKuuhaX4lWvH+93chGmfr19hop x-ms-exchange-antispam-messagedata: GzH9F9FMVXIwTp7f9VOxkrYBlXG/hk3kqfd9klnUu9/MypzfkkwR3NjhbvTp940MSn9um4WPol+pNo7KKa2q3iFGQ2tHLhTRt7VTx7yB77snCtmQ4DesaxOBd1LNKzM0Y66CrxuWrt5zphXkBXxNaA== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: ddb5b5f7-b847-429e-5e36-08d7e84597fb X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Apr 2020 11:49:49.5175 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ovFhm8kr3kK1WwY4No4HerbjxCbk+poPCLeih0/SCPBNZM6EgKLRi7UGxH1QmqlXYKHVaGQNlOEK/mLsPPXUjYIE1z7PTKR7yNPvZVR+7Bo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3654 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 3/3] examples/ipsec-secgw/parser.c: Removing the re-implementation of inet_pton 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > inet_pton4 and inet_pton6 was reimplemented. Replacing implementation of > inet_pton4 and inet_pton6 with libc inet_pton function > Bugzilla ID: 365 NACK After that patch ispec-secgw wouldn't even start. Next time before submitting a patch - spend some time to test it first. =20 > Cc: dev@dpdk.org >=20 > Reported-by: David Marchand > Signed-off-by: Ibtisam Tariq > --- > examples/ipsec-secgw/parser.c | 171 +--------------------------------- > 1 file changed, 3 insertions(+), 168 deletions(-) >=20 > diff --git a/examples/ipsec-secgw/parser.c b/examples/ipsec-secgw/parser.= c > index 65eb7e9e2..b9cb7409a 100644 > --- a/examples/ipsec-secgw/parser.c > +++ b/examples/ipsec-secgw/parser.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include >=20 > #include "ipsec.h" > #include "parser.h" > @@ -39,172 +40,6 @@ parse_tokenize_string(char *string, char *tokens[], u= int32_t *n_tokens) > return 0; > } >=20 > -#define INADDRSZ 4 > -#define IN6ADDRSZ 16 > - > -/* int > - * inet_pton4(src, dst) > - * like inet_aton() but without all the hexadecimal and shorthand. > - * return: > - * 1 if `src' is a valid dotted quad, else 0. > - * notice: > - * does not touch `dst' unless it's returning 1. > - * author: > - * Paul Vixie, 1996. > - */ > -static int > -inet_pton4(const char *src, unsigned char *dst) > -{ > - static const char digits[] =3D "0123456789"; > - int saw_digit, octets, ch; > - unsigned char tmp[INADDRSZ], *tp; > - > - saw_digit =3D 0; > - octets =3D 0; > - *(tp =3D tmp) =3D 0; > - while ((ch =3D *src++) !=3D '\0') { > - const char *pch; > - > - pch =3D strchr(digits, ch); > - if (pch !=3D NULL) { > - unsigned int new =3D *tp * 10 + (pch - digits); > - > - if (new > 255) > - return 0; > - if (!saw_digit) { > - if (++octets > 4) > - return 0; > - saw_digit =3D 1; > - } > - *tp =3D (unsigned char)new; > - } else if (ch =3D=3D '.' && saw_digit) { > - if (octets =3D=3D 4) > - return 0; > - *++tp =3D 0; > - saw_digit =3D 0; > - } else > - return 0; > - } > - if (octets < 4) > - return 0; > - > - memcpy(dst, tmp, INADDRSZ); > - return 1; > -} > - > -/* int > - * inet_pton6(src, dst) > - * convert presentation level address to network order binary form. > - * return: > - * 1 if `src' is a valid [RFC1884 2.2] address, else 0. > - * notice: > - * (1) does not touch `dst' unless it's returning 1. > - * (2) :: in a full address is silently ignored. > - * credit: > - * inspired by Mark Andrews. > - * author: > - * Paul Vixie, 1996. > - */ > -static int > -inet_pton6(const char *src, unsigned char *dst) > -{ > - static const char xdigits_l[] =3D "0123456789abcdef", > - xdigits_u[] =3D "0123456789ABCDEF"; > - unsigned char tmp[IN6ADDRSZ], *tp =3D 0, *endp =3D 0, *colonp =3D 0; > - const char *xdigits =3D 0, *curtok =3D 0; > - int ch =3D 0, saw_xdigit =3D 0, count_xdigit =3D 0; > - unsigned int val =3D 0; > - unsigned dbloct_count =3D 0; > - > - memset((tp =3D tmp), '\0', IN6ADDRSZ); > - endp =3D tp + IN6ADDRSZ; > - colonp =3D NULL; > - /* Leading :: requires some special handling. */ > - if (*src =3D=3D ':') > - if (*++src !=3D ':') > - return 0; > - curtok =3D src; > - saw_xdigit =3D count_xdigit =3D 0; > - val =3D 0; > - > - while ((ch =3D *src++) !=3D '\0') { > - const char *pch; > - > - pch =3D strchr((xdigits =3D xdigits_l), ch); > - if (pch =3D=3D NULL) > - pch =3D strchr((xdigits =3D xdigits_u), ch); > - if (pch !=3D NULL) { > - if (count_xdigit >=3D 4) > - return 0; > - val <<=3D 4; > - val |=3D (pch - xdigits); > - if (val > 0xffff) > - return 0; > - saw_xdigit =3D 1; > - count_xdigit++; > - continue; > - } > - if (ch =3D=3D ':') { > - curtok =3D src; > - if (!saw_xdigit) { > - if (colonp) > - return 0; > - colonp =3D tp; > - continue; > - } else if (*src =3D=3D '\0') { > - return 0; > - } > - if (tp + sizeof(int16_t) > endp) > - return 0; > - *tp++ =3D (unsigned char) ((val >> 8) & 0xff); > - *tp++ =3D (unsigned char) (val & 0xff); > - saw_xdigit =3D 0; > - count_xdigit =3D 0; > - val =3D 0; > - dbloct_count++; > - continue; > - } > - if (ch =3D=3D '.' && ((tp + INADDRSZ) <=3D endp) && > - inet_pton4(curtok, tp) > 0) { > - tp +=3D INADDRSZ; > - saw_xdigit =3D 0; > - dbloct_count +=3D 2; > - break; /* '\0' was seen by inet_pton4(). */ > - } > - return 0; > - } > - if (saw_xdigit) { > - if (tp + sizeof(int16_t) > endp) > - return 0; > - *tp++ =3D (unsigned char) ((val >> 8) & 0xff); > - *tp++ =3D (unsigned char) (val & 0xff); > - dbloct_count++; > - } > - if (colonp !=3D NULL) { > - /* if we already have 8 double octets, having a colon > - * means error */ > - if (dbloct_count =3D=3D 8) > - return 0; > - > - /* > - * Since some memmove()'s erroneously fail to handle > - * overlapping regions, we'll do the shift by hand. > - */ > - const int n =3D tp - colonp; > - int i; > - > - for (i =3D 1; i <=3D n; i++) { > - endp[-i] =3D colonp[n - i]; > - colonp[n - i] =3D 0; > - } > - tp =3D endp; > - } > - if (tp !=3D endp) > - return 0; > - memcpy(dst, tmp, IN6ADDRSZ); > - return 1; > -} > - > int > parse_ipv4_addr(const char *token, struct in_addr *ipv4, uint32_t *mask) > { > @@ -229,7 +64,7 @@ parse_ipv4_addr(const char *token, struct in_addr *ipv= 4, uint32_t *mask) > if (strlen(ip_str) >=3D INET_ADDRSTRLEN) > return -EINVAL; >=20 > - if (inet_pton4(ip_str, (unsigned char *)ipv4) !=3D 1) > + if (inet_pton(AF_INET, token, ipv4) !=3D 1) It should be ip_str, not token. Same for ipv6. > return -EINVAL; >=20 > return 0; > @@ -260,7 +95,7 @@ parse_ipv6_addr(const char *token, struct in6_addr *ip= v6, uint32_t *mask) > if (strlen(ip_str) >=3D INET6_ADDRSTRLEN) > return -EINVAL; >=20 > - if (inet_pton6(ip_str, (unsigned char *)ipv6) !=3D 1) > + if (inet_pton(AF_INET6, token, ipv6) !=3D 1) > return -EINVAL; >=20 > return 0; > -- > 2.17.1