Return-Path: Received: from mail-pl0-f67.google.com ([209.85.160.67]:45435 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750783AbeCICCb (ORCPT ); Thu, 8 Mar 2018 21:02:31 -0500 Received: by mail-pl0-f67.google.com with SMTP id v9-v6so4401961plp.12 for ; Thu, 08 Mar 2018 18:02:31 -0800 (PST) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger , Stephen Hemminger Subject: [PATCH iproute2-next 3/3] ipmroute: better error message if no kernel mroute Date: Thu, 8 Mar 2018 18:02:19 -0800 Message-Id: <20180309020219.6417-4-stephen@networkplumber.org> In-Reply-To: <20180309020219.6417-1-stephen@networkplumber.org> References: <20180309020219.6417-1-stephen@networkplumber.org> Sender: netdev-owner@vger.kernel.org List-ID: From: Stephen Hemminger 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 --- ip/ipmroute.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ip/ipmroute.c b/ip/ipmroute.c index 83548caf4946..a4a8fb2bbe1f 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); -- 2.16.1