All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <sthemmin@microsoft.com>,
	Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH iproute2-next 3/3] ipmroute: better error message if no kernel mroute
Date: Thu,  8 Mar 2018 18:02:19 -0800	[thread overview]
Message-ID: <20180309020219.6417-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20180309020219.6417-1-stephen@networkplumber.org>

From: Stephen Hemminger <sthemmin@microsoft.com>

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 <stephen@networkplumber.org>
---
 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

  parent reply	other threads:[~2018-03-09  2:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-09  2:02 [PATCH iproute2-next 0/3] ip: multicast commands JSON Stephen Hemminger
2018-03-09  2:02 ` [PATCH iproute2-next 1/3] ipmaddr: json and color support Stephen Hemminger
2018-03-09  2:02 ` [PATCH iproute2-next 2/3] ipmroute: convert to output JSON Stephen Hemminger
2018-03-09  2:02 ` Stephen Hemminger [this message]
2018-03-12  1:57 ` [PATCH iproute2-next 0/3] ip: multicast commands JSON David Ahern

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=20180309020219.6417-4-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=netdev@vger.kernel.org \
    --cc=sthemmin@microsoft.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.