From beadd143d5adde6e482bb088255f9bba7a8d850a Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 18 Feb 2016 13:21:45 +0100 Subject: [PATCH] ip: allow ip address show to list addresses with certain flags not being set Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1231898 Upstream Status: iproute2.git commit b5f39b2588a6b commit b5f39b2588a6b0312f11ac6d0fab9391b105b83c Author: Heiner Kallweit Date: Mon Dec 22 20:18:43 2014 +0100 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. Signed-off-by: Heiner Kallweit --- ip/ipaddress.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ip/ipaddress.c b/ip/ipaddress.c index 197f5ae..1e0728c 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -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"); @@ -1233,9 +1233,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; @@ -1251,6 +1257,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; -- 1.8.3.1