From: Stephen Hemminger Date: Fri, 9 Mar 2018 02:02:19 +0000 (-0800) Subject: ipmroute: better error message if no kernel mroute X-Git-Tag: v4.17.0~60^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e06e9a6bac6a8e16ee6580635f891bd2dfd1a1b6;p=thirdparty%2Fiproute2.git ipmroute: better error message if no kernel mroute If kernel does not support the IP multicast address family, then it will report all routes (PF_UNSPEC). Give the user a better error message and abort the command. Signed-off-by: Stephen Hemminger Signed-off-by: David Ahern --- diff --git a/ip/ipmroute.c b/ip/ipmroute.c index 03087b6c4..59c5b7718 100644 --- a/ip/ipmroute.c +++ b/ip/ipmroute.c @@ -75,10 +75,11 @@ int print_mroute(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) fprintf(stderr, "BUG: wrong nlmsg len %d\n", len); return -1; } + if (r->rtm_type != RTN_MULTICAST) { - fprintf(stderr, "Not a multicast route (type: %s)\n", - rtnl_rtntype_n2a(r->rtm_type, b1, sizeof(b1))); - return 0; + fprintf(stderr, + "Non multicast route received, kernel does support IP multicast?\n"); + return -1; } parse_rtattr(tb, RTA_MAX, RTM_RTA(r), len);