Subject: [PATCH iproute2-next 06/12] mroute: fix up family handling

From: David Ahern <[email-masked]>
Date: Wed, 19 Dec 2018 19:54:21 -0800

From: David Ahern <[email-masked]>

Only ipv4 and ipv6 have multicast routing. Set family
accordingly and just return for other cases.

Signed-off-by: David Ahern <[email-masked]>
---
 ip/ipmroute.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/ip/ipmroute.c b/ip/ipmroute.c
index de7a035f852f..b8f0bc49b92e 100644
--- a/ip/ipmroute.c
+++ b/ip/ipmroute.c
@@ -223,18 +223,20 @@ void ipmroute_reset_filter(int ifindex)
 static int mroute_list(int argc, char **argv)
 {
 	char *id = NULL;
-	int family;
+	int family = preferred_family;
 
 	ipmroute_reset_filter(0);
-	if (preferred_family == AF_UNSPEC)
-		family = AF_INET;
-	else
-		family = AF_INET6;
-	if (family == AF_INET) {
+	if (family == AF_INET || family == AF_UNSPEC) {
+		family = RTNL_FAMILY_IPMR;
 		filter.af = RTNL_FAMILY_IPMR;
 		filter.tb = RT_TABLE_DEFAULT;  /* for backward compatibility */
-	} else
+	} else if (family == AF_INET6) {
+		family = RTNL_FAMILY_IP6MR;
 		filter.af = RTNL_FAMILY_IP6MR;
+	} else {
+		/* family does not have multicast routing */
+		return 0;
+	}
 
 	filter.msrc.family = filter.mdst.family = family;
 
-- 
2.11.0