From mboxrd@z Thu Jan 1 00:00:00 1970 From: Serhey Popovich Subject: Re: [PATCH iproute2 1/3] iplink: Improve index parameter handling Date: Mon, 18 Dec 2017 23:02:07 +0200 Message-ID: <7f83992a-90e0-4f15-2be4-7348a6742e6c@gmail.com> References: <1513623248-7689-1-git-send-email-serhe.popovych@gmail.com> <1513623248-7689-2-git-send-email-serhe.popovych@gmail.com> <20171218112359.1ef8db23@xeon-e3> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="vjiMNw4DX4VEcfJ2xsbNWBp62P2w54wCj" Cc: netdev@vger.kernel.org To: Stephen Hemminger Return-path: Received: from mail-wm0-f66.google.com ([74.125.82.66]:37656 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932558AbdLRVCP (ORCPT ); Mon, 18 Dec 2017 16:02:15 -0500 Received: by mail-wm0-f66.google.com with SMTP id f140so320631wmd.2 for ; Mon, 18 Dec 2017 13:02:14 -0800 (PST) In-Reply-To: <20171218112359.1ef8db23@xeon-e3> Sender: netdev-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --vjiMNw4DX4VEcfJ2xsbNWBp62P2w54wCj Content-Type: multipart/mixed; boundary="FMubvb5J5rnDsj7ElhJXO1Nb83aAIOKeN"; protected-headers="v1" From: Serhey Popovich To: Stephen Hemminger Cc: netdev@vger.kernel.org Message-ID: <7f83992a-90e0-4f15-2be4-7348a6742e6c@gmail.com> Subject: Re: [PATCH iproute2 1/3] iplink: Improve index parameter handling References: <1513623248-7689-1-git-send-email-serhe.popovych@gmail.com> <1513623248-7689-2-git-send-email-serhe.popovych@gmail.com> <20171218112359.1ef8db23@xeon-e3> In-Reply-To: <20171218112359.1ef8db23@xeon-e3> --FMubvb5J5rnDsj7ElhJXO1Nb83aAIOKeN Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Stephen Hemminger wrote: > On Mon, 18 Dec 2017 20:54:06 +0200 > Serhey Popovych wrote: >=20 >> diff --git a/ip/iplink.c b/ip/iplink.c >> index 1e685cc..4f9c169 100644 >> --- a/ip/iplink.c >> +++ b/ip/iplink.c >> @@ -586,8 +586,10 @@ int iplink_parse(int argc, char **argv, struct ip= link_req *req, >> *name =3D *argv; >> } else if (strcmp(*argv, "index") =3D=3D 0) { >> NEXT_ARG(); >> + if (*index) >> + duparg("index", *argv); >> *index =3D atoi(*argv); >> - if (*index < 0) >> + if (*index <=3D 0) >=20 > Why not use strtoul instead of atoi? Do not see reason for strtoul() instead atoi(): 1) main arg: indexes in kernel represented as "int", which is signed. <=3D 0 values are reserved for various special purposes (see net/core/fib_rules.c on how device matching implemented). Configuring network device manually with index <=3D 0 is not correct= (however possible). Kernel itself never chooses ifindex <=3D 0. Having unsigned int > 0x7fffffff actually means index <=3D 0. 2) this is not single place in iproute2 where it is used: not going to remove last user. 3) make changes clear and transparent for review. Thanks. >=20 --FMubvb5J5rnDsj7ElhJXO1Nb83aAIOKeN-- --vjiMNw4DX4VEcfJ2xsbNWBp62P2w54wCj Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQEcBAEBAgAGBQJaOCzTAAoJEBTawMmQ61bBz34IAMrkEyP40j2SZH0hR8eLsLLM tb/hCvBwZeE4tDdwLK+kVo7hLtmY6X6kIMWtEmNrVhheV+ISSb99Ofx6v/LKm3DR OjcrvXPY2C2mzRZAnfve/6U5Tw8BOcSIwv4WYVEG5G6V2y4DJBZ9nsm/+gHcq61n +ouJJjDvSRrwsiZw4Pka9vWS+qb59ScVUqGJP67bGVOwQKCXcSPpxt7/eaxL2XvQ 8UPik1LCvm/0Vj48qbokZFeNSdfWN9Y/Abq/gCPZ9CZ10yEuQuHTB+HCehmoKmmU T14BD6V9E0hu2+p3htacOEz9eslmH00jOmZYg8UDs9HTBkVjPyn/pDLPYrBxdXg= =a3Fa -----END PGP SIGNATURE----- --vjiMNw4DX4VEcfJ2xsbNWBp62P2w54wCj--