Setting ->family in @inet_prefix seems pointless:
inet_addr_match() does not consider it's value:
better is to force get_addr_rta() to use address
family from filter to ensure we get correct one.

Signed-off-by: Serhey Popovych <serhe.popov...@gmail.com>
---
 ip/ipmroute.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/ip/ipmroute.c b/ip/ipmroute.c
index 0450ea9..d568d00 100644
--- a/ip/ipmroute.c
+++ b/ip/ipmroute.c
@@ -96,18 +96,22 @@ int print_mroute(const struct sockaddr_nl *who, struct 
nlmsghdr *n, void *arg)
                return 0;
 
        if (tb[RTA_DST] && filter.mdst.bitlen > 0) {
-               inet_prefix dst = { .family = r->rtm_family };
+               struct rtattr *rta = tb[RTA_DST];
+               inet_prefix dst, *f_mdst = &filter.mdst;
 
-               memcpy(&dst.data, RTA_DATA(tb[RTA_DST]), 
RTA_PAYLOAD(tb[RTA_DST]));
-               if (inet_addr_match(&dst, &filter.mdst, filter.mdst.bitlen))
+               if (get_addr_rta(&dst, rta, f_mdst->family))
+                       return 0;
+               if (inet_addr_match(&dst, f_mdst, f_mdst->bitlen))
                        return 0;
        }
 
        if (tb[RTA_SRC] && filter.msrc.bitlen > 0) {
-               inet_prefix src = { .family = r->rtm_family };
+               struct rtattr *rta = tb[RTA_SRC];
+               inet_prefix src, *f_msrc = &filter.msrc;
 
-               memcpy(&src.data, RTA_DATA(tb[RTA_SRC]), 
RTA_PAYLOAD(tb[RTA_SRC]));
-               if (inet_addr_match(&src, &filter.msrc, filter.msrc.bitlen))
+               if (get_addr_rta(&src, rta, f_msrc->family))
+                       return 0;
+               if (inet_addr_match(&src, f_msrc, f_msrc->bitlen))
                        return 0;
        }
 
@@ -213,6 +217,8 @@ static int mroute_list(int argc, char **argv)
        } else
                filter.af = RTNL_FAMILY_IP6MR;
 
+       filter.msrc.family = filter.mdst.family = family;
+
        while (argc > 0) {
                if (matches(*argv, "table") == 0) {
                        __u32 tid;
-- 
1.7.10.4

Reply via email to