From: David Ahern <dsa@cumulusnetworks.com>
To: netdev@vger.kernel.org
Cc: stephen@networkplumber.org, David Ahern <dsa@cumulusnetworks.com>
Subject: [PATCH iproute2 4/6] ip route: Change type mask to bitmask
Date: Mon, 27 Jun 2016 11:50:59 -0700 [thread overview]
Message-ID: <1467053461-16147-5-git-send-email-dsa@cumulusnetworks.com> (raw)
In-Reply-To: <1467053461-16147-1-git-send-email-dsa@cumulusnetworks.com>
Allow option to select multiple route types to show or exlude
specific route types.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
ip/iproute.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/ip/iproute.c b/ip/iproute.c
index 8224d7ffa94b..aae693d17be8 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -113,7 +113,7 @@ static struct
int flushe;
int protocol, protocolmask;
int scope, scopemask;
- int type, typemask;
+ __u64 typemask;
int tos, tosmask;
int iif, iifmask;
int oif, oifmask;
@@ -178,7 +178,8 @@ static int filter_nlmsg(struct nlmsghdr *n, struct rtattr **tb, int host_len)
return 0;
if ((filter.scope^r->rtm_scope)&filter.scopemask)
return 0;
- if ((filter.type^r->rtm_type)&filter.typemask)
+
+ if (filter.typemask && !(filter.typemask & (1 << r->rtm_type)))
return 0;
if ((filter.tos^r->rtm_tos)&filter.tosmask)
return 0;
@@ -365,7 +366,8 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
if (n->nlmsg_type == RTM_DELROUTE)
fprintf(fp, "Deleted ");
- if ((r->rtm_type != RTN_UNICAST || show_details > 0) && !filter.type)
+ if ((r->rtm_type != RTN_UNICAST || show_details > 0) &&
+ (!filter.typemask || (filter.typemask & (1 << r->rtm_type))))
fprintf(fp, "%s ", rtnl_rtntype_n2a(r->rtm_type, b1, sizeof(b1)));
if (tb[RTA_DST]) {
@@ -1433,10 +1435,9 @@ static int iproute_list_flush_or_save(int argc, char **argv, int action)
int type;
NEXT_ARG();
- filter.typemask = -1;
if (rtnl_rtntype_a2n(&type, *argv))
invarg("node type value is invalid\n", *argv);
- filter.type = type;
+ filter.typemask = (1<<type);
} else if (strcmp(*argv, "dev") == 0 ||
strcmp(*argv, "oif") == 0) {
NEXT_ARG();
--
2.1.4
next prev parent reply other threads:[~2016-06-27 18:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-27 18:50 [PATCH v2 iproute2 0/6] Add support for vrf keyword David Ahern
2016-06-27 18:50 ` [PATCH iproute2 1/6] ip vrf: Add name_is_vrf David Ahern
2016-06-29 15:06 ` Stephen Hemminger
2016-06-29 16:57 ` David Ahern
2016-06-27 18:50 ` [PATCH v2 iproute2 2/6] ip link/addr: Add support for vrf keyword David Ahern
2016-06-27 18:50 ` [PATCH iproute2 3/6] ip neigh: Add support for keyword David Ahern
2016-06-27 18:50 ` David Ahern [this message]
2016-06-27 18:51 ` [PATCH iproute2 5/6] ip vrf: Add ipvrf_get_table David Ahern
2016-06-27 18:51 ` [PATCH iproute2 6/6] ip route: Add support for vrf keyword David Ahern
2016-06-29 15:07 ` [PATCH v2 iproute2 0/6] " Stephen Hemminger
2016-06-29 17:06 ` David Ahern
-- strict thread matches above, loose matches on Subject: below --
2016-06-14 20:59 [PATCH " David Ahern
2016-06-14 20:59 ` [PATCH iproute2 4/6] ip route: Change type mask to bitmask David Ahern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1467053461-16147-5-git-send-email-dsa@cumulusnetworks.com \
--to=dsa@cumulusnetworks.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).