[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7f83992a-90e0-4f15-2be4-7348a6742e6c@gmail.com>
Date: Mon, 18 Dec 2017 23:02:07 +0200
From: Serhey Popovich <serhe.popovych@...il.com>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH iproute2 1/3] iplink: Improve index parameter handling
Stephen Hemminger wrote:
> On Mon, 18 Dec 2017 20:54:06 +0200
> Serhey Popovych <serhe.popovych@...il.com> wrote:
>
>> 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 iplink_req *req,
>> *name = *argv;
>> } else if (strcmp(*argv, "index") == 0) {
>> NEXT_ARG();
>> + if (*index)
>> + duparg("index", *argv);
>> *index = atoi(*argv);
>> - if (*index < 0)
>> + if (*index <= 0)
>
> 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. <= 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 <= 0 is not correct
(however possible). Kernel itself never chooses ifindex <= 0.
Having unsigned int > 0x7fffffff actually means index <= 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.
>
Download attachment "signature.asc" of type "application/pgp-signature" (491 bytes)
Powered by blists - more mailing lists