batctl: Merge bugfixes from 2019.3
* Prefer netlink hardif status retrieval over sysfs Signed-off-by: Sven Eckelmann <sven@narfation.org>
This commit is contained in:
parent
6ea9e9b093
commit
d65d6f1ea3
2 changed files with 91 additions and 1 deletions
|
@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
|
|||
PKG_NAME:=batctl
|
||||
|
||||
PKG_VERSION:=2019.2
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
PKG_HASH:=fb656208ff7d4cd8b1b422f60c9e6d8747302a347cbf6c199d7afa9b80f80ea3
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
From: Sven Eckelmann <sven@narfation.org>
|
||||
Date: Wed, 19 Jun 2019 09:37:50 +0200
|
||||
Subject: batctl: Prefer netlink hardif status retrieval over sysfs
|
||||
|
||||
The sysfs code in batman-adv was changed to print a deprecated warning when
|
||||
sysfs files are accessed. The `batctl if` call would therefore cause
|
||||
warnings like this in the kernel log:
|
||||
|
||||
batman_adv: [Deprecated]: batctl (pid 18540) Use of sysfs file "iface_status".
|
||||
Use batadv genl family instead
|
||||
|
||||
It is now appropriate to try the generic netlink BATADV_CMD_GET_HARDIF
|
||||
request first to get the status of the interface before falling back to
|
||||
sysfs.
|
||||
|
||||
Reported-by: Linus Lüssing <linus.luessing@c0d3.blue>
|
||||
Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||
|
||||
Origin: upstream, https://git.open-mesh.org/batctl.git/commit/
|
||||
|
||||
diff --git a/interface.c b/interface.c
|
||||
index 19e6670b45d1bd2dd65c8fbb47eb85361e8c4d26..c2bfc7402aece61be37a71730745c47ad56e2af4 100644
|
||||
--- a/interface.c
|
||||
+++ b/interface.c
|
||||
@@ -67,18 +67,18 @@ static int get_iface_status_netlink_parse(struct nl_msg *msg, void *arg)
|
||||
static char *get_iface_status_netlink(unsigned int meshif, unsigned int hardif,
|
||||
char *iface_status)
|
||||
{
|
||||
+ char *ret_status = NULL;
|
||||
struct nl_sock *sock;
|
||||
struct nl_msg *msg;
|
||||
int batadv_family;
|
||||
struct nl_cb *cb;
|
||||
int ret;
|
||||
|
||||
- strncpy(iface_status, "<error reading status>\n", IFACE_STATUS_LEN);
|
||||
- iface_status[IFACE_STATUS_LEN - 1] = '\0';
|
||||
+ iface_status[0] = '\0';
|
||||
|
||||
sock = nl_socket_alloc();
|
||||
if (!sock)
|
||||
- return iface_status;
|
||||
+ return NULL;
|
||||
|
||||
ret = genl_connect(sock);
|
||||
if (ret < 0)
|
||||
@@ -111,6 +111,9 @@ static char *get_iface_status_netlink(unsigned int meshif, unsigned int hardif,
|
||||
|
||||
nl_recvmsgs(sock, cb);
|
||||
|
||||
+ if (strlen(iface_status) > 0)
|
||||
+ ret_status = iface_status;
|
||||
+
|
||||
err_free_msg:
|
||||
nlmsg_free(msg);
|
||||
err_free_cb:
|
||||
@@ -118,7 +121,7 @@ static char *get_iface_status_netlink(unsigned int meshif, unsigned int hardif,
|
||||
err_free_sock:
|
||||
nl_socket_free(sock);
|
||||
|
||||
- return iface_status;
|
||||
+ return ret_status;
|
||||
}
|
||||
|
||||
static struct nla_policy link_policy[IFLA_MAX + 1] = {
|
||||
@@ -161,13 +164,17 @@ static int print_interfaces_rtnl_parse(struct nl_msg *msg, void *arg)
|
||||
if (master != print_arg->ifindex)
|
||||
goto err;
|
||||
|
||||
- snprintf(path_buff, sizeof(path_buff), SYS_IFACE_STATUS_FMT, ifname);
|
||||
- ret = read_file("", path_buff, USE_READ_BUFF | SILENCE_ERRORS, 0, 0, 0);
|
||||
- if (ret != EXIT_SUCCESS)
|
||||
- status = get_iface_status_netlink(master, ifm->ifi_index,
|
||||
- iface_status);
|
||||
- else
|
||||
- status = line_ptr;
|
||||
+ status = get_iface_status_netlink(master, ifm->ifi_index, iface_status);
|
||||
+ if (!status) {
|
||||
+ snprintf(path_buff, sizeof(path_buff), SYS_IFACE_STATUS_FMT,
|
||||
+ ifname);
|
||||
+ ret = read_file("", path_buff, USE_READ_BUFF | SILENCE_ERRORS,
|
||||
+ 0, 0, 0);
|
||||
+ if (ret != EXIT_SUCCESS)
|
||||
+ status = "<error reading status>\n";
|
||||
+ else
|
||||
+ status = line_ptr;
|
||||
+ }
|
||||
|
||||
printf("%s: %s", ifname, status);
|
||||
|
Loading…
Reference in a new issue