ip: allow ip address show to list addresses with certain flags not being set
Subsystems (2)
PATCH 1/1 ip: allow ip address show to list addresses with certain flags not being set
Sometimes it's needed to have "ip address show" list only addresses with certain flags not being set, e.g. in network scripts. As an example one might want to exclude addresses in "tentative" or "deprecated" state.
Support listing addresses with flags tentative, deprecated, dadfailed not being set by prefixing the respective flag with a minus.
--- ip/ipaddress.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
ip/ipaddress.c +10 -1
@@ -80,7 +80,7 @@ static void usage(void)fprintf (stderr,"SCOPE-ID := [ host | link | global | NUMBER ]\n" );fprintf (stderr,"FLAG-LIST := [ FLAG-LIST ] FLAG\n" );fprintf (stderr,"FLAG := [ permanent | dynamic | secondary | primary |\n" ); -fprintf (stderr," tentative | deprecated | dadfailed | temporary |\n" ); +fprintf (stderr," [-]tentative | [-]deprecated | [-]dadfailed | temporary |\n" );fprintf (stderr," CONFFLAG-LIST ]\n" );fprintf (stderr,"CONFFLAG-LIST := [ CONFFLAG-LIST ] CONFFLAG\n" );fprintf (stderr,"CONFFLAG := [ home | nodad | mngtmpaddr | noprefixroute ]\n" );
@@ -1261,9 +1261,15 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action) }else if (strcmp (*argv,"tentative" ) ==0 ) { filter.flags |=IFA_F_TENTATIVE ; filter.flagmask |=IFA_F_TENTATIVE ; + }else if (strcmp (*argv,"-tentative" ) ==0 ) { + filter.flags &= ~IFA_F_TENTATIVE ; + filter.flagmask |=IFA_F_TENTATIVE ; }else if (strcmp (*argv,"deprecated" ) ==0 ) { filter.flags |=IFA_F_DEPRECATED ; filter.flagmask |=IFA_F_DEPRECATED ; + }else if (strcmp (*argv,"-deprecated" ) ==0 ) { + filter.flags &= ~IFA_F_DEPRECATED ; + filter.flagmask |=IFA_F_DEPRECATED ; }else if (strcmp (*argv,"home" ) ==0 ) { filter.flags |=IFA_F_HOMEADDRESS ; filter.flagmask |=IFA_F_HOMEADDRESS ;
@@ -1279,6 +1285,9 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action) }else if (strcmp (*argv,"dadfailed" ) ==0 ) { filter.flags |=IFA_F_DADFAILED ; filter.flagmask |=IFA_F_DADFAILED ; + }else if (strcmp (*argv,"-dadfailed" ) ==0 ) { + filter.flags &= ~IFA_F_DADFAILED ; + filter.flagmask |=IFA_F_DADFAILED ; }else if (strcmp (*argv,"label" ) ==0 ) {NEXT_ARG (); filter.label = *argv;
Signature · 1 line
2.2.1
Stephen Hemminger
AppliedQuoted 9 lines · On Mon, 22 Dec 2014 20:18:43 +0100 Heiner Kallweit <[email protected]> wrote:
Sometimes it's needed to have "ip address show" list only addresses with certain flags not being set, e.g. in network scripts. As an example one might want to exclude addresses in "tentative" or "deprecated" state.
Support listing addresses with flags tentative, deprecated, dadfailed not being set by prefixing the respective flag with a minus.
Signed-off-by Heiner Kallweit <[email protected]>
Applied, but please send another patch to update manual page.
Am 24.12.2014 um 21:16 schrieb Stephen Hemminger:
Quoted 8 lines
Quoted 5 lines · On Mon, 22 Dec 2014 20:18:43 +0100 Heiner Kallweit <[email protected]> wrote:
Sometimes it's needed to have "ip address show" list only addresses with certain flags not being set, e.g. in network scripts. As an example one might want to exclude addresses in "tentative" or "deprecated" state.
Quoted 7 lines
Quoted 4 lines
Support listing addresses with flags tentative, deprecated, dadfailed not being set by prefixing the respective flag with a minus.
Signed-off-by Heiner Kallweit <[email protected]>Applied, but please send another patch to update manual page.
OK, man patch update follows ..
Heiner