public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCH 3/9] batctl: Return type of error on netlink_get_info error
Date: Sun, 22 Jan 2017 13:21:07 +0100	[thread overview]
Message-ID: <20170122122113.29588-3-sven@narfation.org> (raw)
In-Reply-To: <3266034.EiLA6asg3G@sven-edge>

It can happen that netlink_get_info will not return an algo string. This
usually happens because BATADV_CMD_GET_MESH_INFO is not implemented in the
kernel modules. But it is also possible that this happens because the user
didn't have the correct rights to retrieve this type of information.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 netlink.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/netlink.c b/netlink.c
index 9580aa3..7fb1ee1 100644
--- a/netlink.c
+++ b/netlink.c
@@ -1177,11 +1177,12 @@ int netlink_print_originators(char *mesh_iface, char *orig_iface,
 	}
 
 	/* only parse routing algorithm name */
+	last_err = -EINVAL;
 	info_header = netlink_get_info(ifindex, BATADV_CMD_GET_ORIGINATORS, NULL);
 	free(info_header);
 
 	if (strlen(algo_name_buf) == 0)
-		return -EOPNOTSUPP;
+		return last_err;
 
 	if (!strcmp("BATMAN_IV", algo_name_buf))
 		header = "   Originator        last-seen (#/255) Nexthop           [outgoingIF]\n";
@@ -1244,11 +1245,12 @@ int netlink_print_gateways(char *mesh_iface, char *orig_iface, int read_opts,
 	}
 
 	/* only parse routing algorithm name */
+	last_err = -EINVAL;
 	info_header = netlink_get_info(ifindex, BATADV_CMD_GET_ORIGINATORS, NULL);
 	free(info_header);
 
 	if (strlen(algo_name_buf) == 0)
-		return -EOPNOTSUPP;
+		return last_err;
 
 	if (!strcmp("BATMAN_IV", algo_name_buf))
 		header = "  Router            ( TQ) Next Hop          [outgoingIf]  Bandwidth\n";
-- 
2.11.0


  parent reply	other threads:[~2017-01-22 12:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-22 12:20 [B.A.T.M.A.N.] [PATCH 0/9] batctl: relax root privileges check Sven Eckelmann
2017-01-22 12:21 ` [B.A.T.M.A.N.] [PATCH 1/9] batctl: Move root privileges check in separate function Sven Eckelmann
2017-01-22 12:21 ` [B.A.T.M.A.N.] [PATCH 2/9] batctl: Use geteuid for checks of root privileges Sven Eckelmann
2017-01-22 12:21 ` Sven Eckelmann [this message]
2017-01-22 12:21 ` [B.A.T.M.A.N.] [PATCH 4/9] batctl: Make root privileges check function specific Sven Eckelmann
2017-01-22 12:21 ` [B.A.T.M.A.N.] [PATCH 5/9] batctl: Allow to retrieve interface stats as non-root Sven Eckelmann
2017-01-22 12:21 ` [B.A.T.M.A.N.] [PATCH 6/9] batctl: Allow to read loglevel as normal user Sven Eckelmann
2017-01-22 12:21 ` [B.A.T.M.A.N.] [PATCH 7/9] batctl: Allow to read gw_mode " Sven Eckelmann
2017-01-22 12:21 ` [B.A.T.M.A.N.] [PATCH 8/9] batctl: Allow to read sysfs settings " Sven Eckelmann
2017-01-22 12:21 ` [B.A.T.M.A.N.] [PATCH 9/9] batctl: Allow to read list of interfaces " Sven Eckelmann
2017-01-24 12:49 ` [B.A.T.M.A.N.] [PATCH 0/9] batctl: relax root privileges check Simon Wunderlich

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=20170122122113.29588-3-sven@narfation.org \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox