[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKD1Yr1tPL3_30jLJA-E4h05X2A85d=UOLmsGo+atWMResK7cA@mail.gmail.com>
Date: Sat, 8 Jul 2017 15:08:12 +0900
From: Lorenzo Colitti <lorenzo@...gle.com>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH iproute2] ip: change flag names to an array
On Sat, Jul 8, 2017 at 12:39 AM, Stephen Hemminger
<stephen@...workplumber.org> wrote:
> For the most of the address flags, use a table of bit values rather
> than open coding every value. This allows for easier inevitable
> expansion of flags.
Thanks for doing this.
> +static unsigned int get_ifa_flag_mask(const char *name)
> +{
> + unsigned int i;
> +
> + for (i = 0; i < ARRAY_SIZE(ifa_flag_names); i++) {
> + if (!strcmp(name, ifa_flag_names[i]))
> + return 1u << i;
> + }
> + return 0;
> +}
It looks like the user can specify things such as "-deprecated".
Perhaps that sort of thing can be handled by this function too?
Instead of returning an unsigned int, this function could be void and
take a flag value and a mask as output parameters. If the flag name
starts with "-" it would set the value to 0, and if it doesn't it
would set the value to 1.
Otherwise, some of the -<flag> parameters will either need to be
special cased or cease to be supported. Specifically, I see this one:
> - } else if (strcmp(*argv, "-tentative") == 0) {
> - filter.flags &= ~IFA_F_TENTATIVE;
> - filter.flagmask |= IFA_F_TENTATIVE;
this one:
> - } else if (strcmp(*argv, "-deprecated") == 0) {
> - filter.flags &= ~IFA_F_DEPRECATED;
> - filter.flagmask |= IFA_F_DEPRECATED;
and this one:
> - } else if (strcmp(*argv, "-dadfailed") == 0) {
> - filter.flags &= ~IFA_F_DADFAILED;
> - filter.flagmask |= IFA_F_DADFAILED;
Powered by blists - more mailing lists