Re: [iproute PATCH] ip-address: Fix filtering by negated address flags

2018-11-15 Thread Phil Sutter
Hi Stephen, On Wed, Nov 14, 2018 at 11:29:03AM -0800, Stephen Hemminger wrote: [...] > I was thinking something like this which simplifies the logic. > > diff --git a/ip/ipaddress.c b/ip/ipaddress.c > index cd8cc76a3473..3f1510383071 100644 > --- a/ip/ipaddress.c > +++ b/ip/ipaddress.c > @@ -1212

Re: [iproute PATCH] ip-address: Fix filtering by negated address flags

2018-11-14 Thread Stephen Hemminger
On Wed, 14 Nov 2018 11:52:51 +0100 Phil Sutter wrote: > Hi Stephen, > > On Tue, Nov 13, 2018 at 02:47:59PM -0800, Stephen Hemminger wrote: > > On Tue, 13 Nov 2018 16:12:01 +0100 > > Phil Sutter wrote: > > > > > + if (arg[0] == '-') { > > > + inv = true; > > > + arg++; > > > +

Re: [iproute PATCH] ip-address: Fix filtering by negated address flags

2018-11-14 Thread Phil Sutter
Hi Stephen, On Tue, Nov 13, 2018 at 02:47:59PM -0800, Stephen Hemminger wrote: > On Tue, 13 Nov 2018 16:12:01 +0100 > Phil Sutter wrote: > > > + if (arg[0] == '-') { > > + inv = true; > > + arg++; > > + } > The inverse logic needs to be moved into the loop handling filter

Re: [iproute PATCH] ip-address: Fix filtering by negated address flags

2018-11-13 Thread Stephen Hemminger
On Tue, 13 Nov 2018 16:12:01 +0100 Phil Sutter wrote: > + if (arg[0] == '-') { > + inv = true; > + arg++; > + } The inverse logic needs to be moved into the loop handling filter names. Otherwise, you get weirdness like "-dynamic" being accepted and not doing what

[iproute PATCH] ip-address: Fix filtering by negated address flags

2018-11-13 Thread Phil Sutter
When disabling a flag, one needs to AND with the inverse not the flag itself. Otherwise specifying for instance 'home -nodad' will effectively clear the flags variable. While being at it, simplify the code a bit by merging common parts of negated and non-negated case branches. Also allow for the "