batctl: Merge bugfixes from 2020.2
* fix endianness when reading radiotap header * Only remove batadv interface on hardif reduction Signed-off-by: Sven Eckelmann <sven@narfation.org>
This commit is contained in:
parent
719709a03e
commit
8dd6c08c2d
3 changed files with 88 additions and 1 deletions
|
@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
|
||||||
PKG_NAME:=batctl
|
PKG_NAME:=batctl
|
||||||
|
|
||||||
PKG_VERSION:=2018.1
|
PKG_VERSION:=2018.1
|
||||||
PKG_RELEASE:=2
|
PKG_RELEASE:=3
|
||||||
PKG_HASH:=27877d0da6916f88a6cecbbb3f3d23cc4558ef7c7294324bf4fd050ed606b553
|
PKG_HASH:=27877d0da6916f88a6cecbbb3f3d23cc4558ef7c7294324bf4fd050ed606b553
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
From: Marek Lindner <mareklindner@neomailbox.ch>
|
||||||
|
Date: Wed, 29 Apr 2020 12:09:44 +0200
|
||||||
|
Subject: batctl: fix endianness when reading radiotap header
|
||||||
|
|
||||||
|
All radiotap header fields are specified in little endian byte-order.
|
||||||
|
Header length conversion is necessary on some platforms.
|
||||||
|
|
||||||
|
Fixes: c6fcdb6dc9a9 ("batctl: add radiotap wifi packet decapsulation support")
|
||||||
|
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
|
||||||
|
Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||||
|
|
||||||
|
Origin: upstream, https://git.open-mesh.org/batctl.git/commit/440ae55a6ef96eb73ee628f9237915cf9fb26dee
|
||||||
|
|
||||||
|
diff --git a/tcpdump.c b/tcpdump.c
|
||||||
|
index dc4ccd37c3ddf8650cb79737defd923fe9f33c64..c41500e21eda0abc1f024a3265c23fc3a4802d17 100644
|
||||||
|
--- a/tcpdump.c
|
||||||
|
+++ b/tcpdump.c
|
||||||
|
@@ -29,6 +29,7 @@
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
+#include <endian.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <net/if_arp.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
@@ -1048,10 +1049,10 @@ static int monitor_header_length(unsigned char *packet_buff, ssize_t buff_len, i
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
radiotap_hdr = (struct radiotap_header*)packet_buff;
|
||||||
|
- if (buff_len <= radiotap_hdr->it_len)
|
||||||
|
+ if (buff_len <= le16toh(radiotap_hdr->it_len))
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
- return radiotap_hdr->it_len;
|
||||||
|
+ return le16toh(radiotap_hdr->it_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
|
@ -0,0 +1,49 @@
|
||||||
|
From: Sven Eckelmann <sven@narfation.org>
|
||||||
|
Date: Sat, 13 Jun 2020 17:59:34 +0200
|
||||||
|
Subject: batctl: Only remove batadv interface on hardif reduction
|
||||||
|
|
||||||
|
A deletion of a hardif from a batadv meshif will also get a success reply
|
||||||
|
from the kernel when the hardif was never part of the batadv meshif. If the
|
||||||
|
batadv meshif had no attached hardifs before the removal was started, then
|
||||||
|
users are then not expecting that the batadv meshif is removed at all.
|
||||||
|
|
||||||
|
Since the delete operation is not an atomic compare-and-swap operation,
|
||||||
|
just check first the number of attached interfaces and only start the
|
||||||
|
removal of the batadv meshif when the number attached hardifs was reduced.
|
||||||
|
|
||||||
|
Fixes: 25022e0b154d ("batctl: Use rtnl to add/remove interfaces")
|
||||||
|
Reported-by: Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
|
Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||||
|
|
||||||
|
Origin: upstream, https://git.open-mesh.org/batctl.git/commit/6d49a82cf58ee5ebd6235b6ddaca46febd42f876
|
||||||
|
|
||||||
|
diff --git a/interface.c b/interface.c
|
||||||
|
index 5951b471c6477e78ff557e97a7478ba774a0aa20..1ad36826fdb91a3e0254ed4dec758e7c383596e9 100644
|
||||||
|
--- a/interface.c
|
||||||
|
+++ b/interface.c
|
||||||
|
@@ -305,6 +305,7 @@ int interface(char *mesh_iface, int argc, char **argv)
|
||||||
|
int ret;
|
||||||
|
unsigned int ifindex;
|
||||||
|
unsigned int ifmaster;
|
||||||
|
+ unsigned int pre_cnt;
|
||||||
|
const char *long_op;
|
||||||
|
unsigned int cnt;
|
||||||
|
int rest_argc;
|
||||||
|
@@ -421,6 +422,8 @@ int interface(char *mesh_iface, int argc, char **argv)
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ pre_cnt = count_interfaces(mesh_iface);
|
||||||
|
+
|
||||||
|
for (i = 1; i < rest_argc; i++) {
|
||||||
|
ifindex = if_nametoindex(rest_argv[i]);
|
||||||
|
|
||||||
|
@@ -450,7 +453,7 @@ int interface(char *mesh_iface, int argc, char **argv)
|
||||||
|
/* check if there is no interface left and then destroy mesh_iface */
|
||||||
|
if (!manual_mode && rest_argv[0][0] == 'd') {
|
||||||
|
cnt = count_interfaces(mesh_iface);
|
||||||
|
- if (cnt == 0)
|
||||||
|
+ if (cnt == 0 && pre_cnt > 0)
|
||||||
|
destroy_interface(mesh_iface);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue