netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mazhar Rana <ranamazharp@gmail.com>
To: netdev@vger.kernel.org, stephen@networkplumber.org
Cc: Mazhar Rana <ranamazharp@gmail.com>
Subject: [PATCH iproute2] mroute: "ip mroute show" not working when "to" and/or "from" is given
Date: Thu, 11 Jun 2015 21:37:36 +0530	[thread overview]
Message-ID: <1434038856-18054-1-git-send-email-ranamazharp@gmail.com> (raw)

The command "ip mroute show" is not showing routes when "to" and/or "from"
filter is applied.

root@mazhar:~# ip mroute show
(10.202.30.101, 235.1.2.3)       Iif: eth0       Oifs: eth1

But When I applied filter, it does not show anything.

root@mazhar:~# ip mroute show 235.1.2.3 from 10.202.30.101
root@mazhar:~#

Signed-off-by: Mazhar Rana <ranamazharp@gmail.com>
---
 ip/ipmroute.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/ip/ipmroute.c b/ip/ipmroute.c
index 125a13f..fffa9e2 100644
--- a/ip/ipmroute.c
+++ b/ip/ipmroute.c
@@ -97,15 +97,25 @@ int print_mroute(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 	if (filter.af && filter.af != r->rtm_family)
 		return 0;
 
-	if (tb[RTA_DST] &&
-	    filter.mdst.bitlen > 0 &&
-	    inet_addr_match(RTA_DATA(tb[RTA_DST]), &filter.mdst, filter.mdst.bitlen))
-		return 0;
+	if (tb[RTA_DST] && filter.mdst.bitlen > 0) {
+		inet_prefix dst;
+
+		memset(&dst, 0, sizeof(dst));
+		dst.family = r->rtm_family;
+		memcpy(&dst.data, RTA_DATA(tb[RTA_DST]), RTA_PAYLOAD(tb[RTA_DST]));
+		if (inet_addr_match(&dst, &filter.mdst, filter.mdst.bitlen))
+			return 0;
+	}
 
-	if (tb[RTA_SRC] &&
-	    filter.msrc.bitlen > 0 &&
-	    inet_addr_match(RTA_DATA(tb[RTA_SRC]), &filter.msrc, filter.msrc.bitlen))
-		return 0;
+	if (tb[RTA_SRC] && filter.msrc.bitlen > 0) {
+		inet_prefix src;
+
+		memset(&src, 0, sizeof(src));
+		src.family = r->rtm_family;
+		memcpy(&src.data, RTA_DATA(tb[RTA_SRC]), RTA_PAYLOAD(tb[RTA_SRC]));
+		if (inet_addr_match(&src, &filter.msrc, filter.msrc.bitlen))
+			return 0;
+	}
 
 	family = r->rtm_family == RTNL_FAMILY_IPMR ? AF_INET : AF_INET6;
 
-- 
1.9.1

             reply	other threads:[~2015-06-11 16:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-11 16:07 Mazhar Rana [this message]
2015-06-25 12:47 ` [PATCH iproute2] mroute: "ip mroute show" not working when "to" and/or "from" is given Stephen Hemminger

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=1434038856-18054-1-git-send-email-ranamazharp@gmail.com \
    --to=ranamazharp@gmail.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).