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 C8A8EA0519; Mon, 22 Jun 2020 14:17:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DF9B71D6B8; Mon, 22 Jun 2020 14:17:27 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id F0A601D6B4 for ; Mon, 22 Jun 2020 14:17:25 +0200 (CEST) IronPort-SDR: /IEYU5mOvc8BsFgGmaUGsYJ3r6t6MAVvdYERPe/rXrp83H7ow5SlWVIU4VpwQkweirYn2OdIP8 BeRAJb+7/HXg== X-IronPort-AV: E=McAfee;i="6000,8403,9659"; a="124015401" X-IronPort-AV: E=Sophos;i="5.75,266,1589266800"; d="scan'208";a="124015401" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2020 05:17:24 -0700 IronPort-SDR: K4NJ+gCYlPnSKQJ1wEkmHGksSbWnMqkMxryrD4ElbNvtEb9mVrGZFKN3bJZDnEOwGbXsrOLG4q cojzu5FMyEJw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,266,1589266800"; d="scan'208";a="278735746" Received: from orsmsx101.amr.corp.intel.com ([10.22.225.128]) by orsmga006.jf.intel.com with ESMTP; 22 Jun 2020 05:17:24 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX101.amr.corp.intel.com (10.22.225.128) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 22 Jun 2020 05:17:24 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX607.amr.corp.intel.com (10.22.229.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 22 Jun 2020 05:17:23 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 22 Jun 2020 05:17:23 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.175) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 22 Jun 2020 05:17:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OZv4lgLqbgh50m3Ls6G5auzb6E+f6S+j6Y0tUrqa11aidyrcG07AXjjYfb34J+2+u/+c3QxZDt7kJ4HxNXg+LbzwKWy02UmfLUu4ylgAIa9u0z2p7jGPi/CoRYDi61PGMc0YMa0DqVG42S/7J62r8StZrm8kZkvEpj4gUs97T2HHxQesu1kCnRV5+KQ2K51TIWzH4MijRXC4Wa51dq+4NZpfOHH6LkMG6Yx0D3QFUNmVgH4Ju0wI0CUskP625iAKCJeqRnk76HOlFKsgUpQi0bi8mJoorhPY2y9QO3+33ywRnLQr+GeqqKvWw4pT7O0LgCoEMDU3RYnPrRQaj+xdPw== 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=OMNumYUgU6OIyjXKASD23BGI4FO4QOVfK+twHgtRK3A=; b=jCIwM0xCTBcbEknG5gzWiPorO61b0TOwlqftT3leDBuV1BBkOyzMg7G3/OC0ow0bC9onhiJ7VduKfH+4ehameOeNR/n9MYw3UbaFJKZmeqhD+emSHw0lROWRkU2c2V/5hWOvFE6vAftivsEn/Oh16nszAP7JjxJTjjNw52oD2FNPB7zi1KVtYFGe0KrVb8p9o7KHnN9w5SLAlJ+7uxZH6xr3uv7BN4p3DbfsaQqSUfQr8Rfo3Q0xGvQWVhg0BZCkqxwm2y18j4aGz0HEjhkBtpJNDY8KT7/iHdqlhDxe8rigNlPwEBiQwmy21ZRKe+Hj/Un9ixEoSSBft4VgFbOr1Q== 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=OMNumYUgU6OIyjXKASD23BGI4FO4QOVfK+twHgtRK3A=; b=qYjntffVXMCEEE8MiEWzdh/FuPXkz7uLT69BJaPX7gVnpjTb4QuakJ+BWCLRQ6zPKld+rYKtUUn+lbpWQrGl2WOvyoxXGBECHc9GhgGMqbTdB1TScwfeGWgMn4lFTahelo3K4/7veFc6BLdiPjYTZAfahum9GSG/vOTdSXjvLEU= Received: from BYAPR11MB3301.namprd11.prod.outlook.com (2603:10b6:a03:7f::26) by BY5PR11MB4103.namprd11.prod.outlook.com (2603:10b6:a03:18c::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.23; Mon, 22 Jun 2020 12:17:21 +0000 Received: from BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f160:29ab:b8f9:4189]) by BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f160:29ab:b8f9:4189%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 12:17:21 +0000 From: "Ananyev, Konstantin" To: Ibtisam Tariq , "Singh, Jasvinder" , "Dumitrescu, Cristian" , "Nicolau, Radu" , "akhil.goyal@nxp.com" CC: "dev@dpdk.org" , "Zhang, Roy Fan" Thread-Topic: [dpdk-dev] [PATCH v2 3/3] examples/ipsec-secgw: Remove the re-implementation of inet_pton Thread-Index: AQHWPWrz3mD4eeutFE2zNNU1bbRSSqjkoRYg Date: Mon, 22 Jun 2020 12:17:20 +0000 Message-ID: References: <20200608075836.3609-1-ibtisam.tariq@emumba.com> <20200608075836.3609-3-ibtisam.tariq@emumba.com> In-Reply-To: <20200608075836.3609-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: emumba.com; dkim=none (message not signed) header.d=none;emumba.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.151.184] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 175ef446-978b-4400-3a2e-08d816a636ab x-ms-traffictypediagnostic: BY5PR11MB4103: 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:632; x-forefront-prvs: 0442E569BC x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: m8DAX1vK+lN1GZGXqwg68woHEN2fqRF3ORpWWGy/Pi78/Q+wfoD1ZcdYc+raP5NqEQJe6VaTZ7uXfCpbbL4FOFHRpBRavf9i00IBEI3xpn4NFkdmNm5NHOdla5Facz8NImeLQEKq1n2C8QtnFmoHVVqv5b2BLvw0Uw4QVuDaxBW1fw7xf/J6PgeXB+KFC/xmoeg410pVnvLIGF+PAuiI3IMBwpRoiEvkIF3BEr91BWlXYXt2Nubs4sXqpkNLXa1E0IXjTGFnddhUVIJZlLHvfgpbGmhnOv/OVAjkivNrnT2L952rW+ISOETVCcxrHnxZYZl76i1HtLSE8IDtNvJaDj6tAetEmYtAOJ6FNFsLZAdg8OCctIbEmmX49TBvRLAfuZRJmC6/dEhc3mToISVWVw== 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:(4636009)(396003)(39860400002)(136003)(376002)(366004)(346002)(966005)(5660300002)(478600001)(4326008)(316002)(76116006)(55016002)(9686003)(110136005)(66946007)(186003)(54906003)(7696005)(66476007)(66556008)(64756008)(2906002)(66446008)(86362001)(33656002)(26005)(6506007)(83380400001)(8936002)(52536014)(107886003)(71200400001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: pLGU81uhp9oEnHkMd3CJk8E18VNcIG1PTHm3FxBpQiMBiBFtu7sZTRBoNFk/wrxYoIRZyHIx3UqmlwGDOML2PZtO8pi3/DgKRtpNgAQ58FlNhg8QerVOy0+HKGs5nB3LjTUEIvzLLNgNZ+V7/DCJpTY5E6X026wLCTY6lcz4wcjntzfgXdaXlcQLs/9qtQeN+TXCKfZxoaOpxPvxz0mnffoJJ1vttZQRZX4MOrLSiDq6xnt/JBh9UqvhnJhTUNNecbQEnC/InUqEpqLbLiA+u0GG6L+WER8d89ZJAzGu/vMksvXV++1lyAOg9rwnmkJWn0/tT9Qk3UAc914qkx9D9HTdi8eZYwrqnhjnaKc2zGT/o5Rk4SdiqxnL2d+kTy/jaJroU42vrcm/jjSamfIqwdeJGPsSXQUEgtBVZ9CZzodrRicT20IJ6/EtcuGQ19nIIXH+hKYqHPF0PepoqzQFUj87Le93Icnl5LlTLbeNLCXNN7K9bDeb/cjsvW3/NvyT Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 175ef446-978b-4400-3a2e-08d816a636ab X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jun 2020 12:17:20.8159 (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: MT6a56nCo1XnsYYeqJZaa3n6F86Xdk8Y6iQYyMTHpirNLE3Xxtukd1pfrADImk5fiygZDt8WTIa79bbMDNeyR0vS2FJWXJh9pyYvztbOnJ8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR11MB4103 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v2 3/3] examples/ipsec-secgw: Remove 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" >=20 > inet_pton4 and inet_pton6 was reimplemented. Replace implementation of > inet_pton4 and inet_pton6 with libc inet_pton function >=20 > Bugzilla ID: 365 > Fixes: 0d547ed03717 ("examples/ipsec-secgw: support configuration file") > Cc: roy.fan.zhang@intel.com >=20 > Reported-by: David Marchand > Signed-off-by: Ibtisam Tariq LGTM One thing to address - freebsd build is failing: http://mails.dpdk.org/archives/test-report/2020-June/134949.html Presumably extra include ( ?) is missing. > --- > v2: > * Fixed the name of variable, passed as input to inet_pton function. > * Add fixed id in commit body > --- > 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..58ef3de0a 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, ip_str, ipv4) !=3D 1) > 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, ip_str, ipv6) !=3D 1) > return -EINVAL; >=20 > return 0; > -- > 2.17.1