On Sat, Jul 8, 2017 at 12:39 AM, Stephen Hemminger <step...@networkplumber.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;