Hi,
batctl has a "root" user check since the beginning of this tool. It even got a
TODO comment in 58525b8330e9 ("batctl: adjust vis.c coding style"):
/* TODO: remove this generic check here and move it into the individual functions */
This patchset is now trying to resolve this TODO.
* batctl: Move root privileges check in separate function
* batctl: Use geteuid for checks of root privileges
* batctl: Return type of error on netlink_get_info error
* batctl: Make root privileges check function specific
* batctl: Allow to retrieve interface stats as non-root
* batctl: Allow to read loglevel as normal user
* batctl: Allow to read gw_mode as normal user
* batctl: Allow to read sysfs settings as normal user
* batctl: Allow to read list of interfaces as normal user
"Return type of error on netlink_get_info error" may look a little bit odd in
this list. But it was required in my initial test to avoid that "originators"
and "gwl" try to start a debugfs access when the netlink function should have
returned a "-EPERM" (but did return a -EOPNOTSUPP).
Kind regards,
Sven
This commit restructures the compat code regarding cfg80211 to achieve
the following:
a) Allows to compile kernels < 3.16 with -Werror by replacing the
"#warning" with a runtime warning through pr_warn_once().
b) Allows to run < 3.16 kernels without warnings if no cfg80211 based
interface is used.
c) Migrates cfg80211 compat code from compat.h to compat cfg80211.h to
keep compat.h slim.
Signed-off-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
---
compat-include/net/cfg80211.h | 21 ++++++++++++++++++++-
compat.h | 21 ---------------------
2 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/compat-include/net/cfg80211.h b/compat-include/net/cfg80211.h
index 8dbbf0e..6e0eca3 100644
--- a/compat-include/net/cfg80211.h
+++ b/compat-include/net/cfg80211.h
@@ -4,9 +4,28 @@
#include <linux/version.h>
#include_next <net/cfg80211.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
+
+static inline int cfg80211_get_station(struct net_device *dev,
+ const u8 *mac_addr,
+ struct station_info *sinfo)
+{
+ pr_warn_once("cfg80211 based throughput metric is only supported with Linux 3.16+\n");
+ return -ENOENT;
+}
+
+/* The following define substitutes the expected_throughput field with a random
+ * one existing in the station_info struct. It can be random because due to the
+ * function above it will never be used. Only needed to make the code compile
+ */
+#define expected_throughput filled
+
+#endif /* < KERNEL_VERSION(3, 16, 0) */
+
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
-#if !IS_ENABLED(CONFIG_CFG80211)
+#if !IS_ENABLED(CONFIG_CFG80211) && \
+ LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
#define cfg80211_get_station(dev, mac_addr, sinfo) \
batadv_cfg80211_get_station(dev, mac_addr, sinfo)
diff --git a/compat.h b/compat.h
index 5397629..e43c413 100644
--- a/compat.h
+++ b/compat.h
@@ -130,27 +130,6 @@ static int __batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
#endif /* < KERNEL_VERSION(3, 10, 0) */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
-
-/* the expected behaviour of this function is to return 0 on success, therefore
- * it is possible to define it as 1 so that batman-adv thinks like something
- * went wrong. It will then decide what to do.
- */
-#define cfg80211_get_station(_a, _b, _c) (1)
-/* the following define substitute the expected_throughput field with a random
- * one existing in the station_info struct. It can be random because due to the
- * define above it will never be used. We need it only to make the code compile
- */
-#define expected_throughput filled
-
-#ifdef CONFIG_BATMAN_ADV_BATMAN_V
-
-#warning cfg80211 based throughput metric is only supported with Linux 3.15+
-
-#endif
-
-#endif /* < KERNEL_VERSION(3, 16, 0) */
-
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
/* wild hack for batadv_getlink_net only */
--
2.1.4
Hi,
here are just some random cleanups/fixes for things I've noticed while having
a look at https://www.open-mesh.org/issues/298.
batctl: tcpdump: Reset socket state on initialization error
batctl: tcpdump: Free resources on SIG(TERM|INT)
batctl: ping: Use sig_atomic_t variable to stop ping
batctl: Simplify standard error messages with perror
Kind regards,
Sven
Currently, batman-adv fails to build for 4.5 kernel headers provided by
Debian's make-kpkg. "make" complains with:
"include/net/sch_generic.h:413:2: error: implicit declaration of
function ‘G_TC_AT’ [-Werror=implicit-function-declaration]"
And:
"include/net/sch_generic.h:413:33: error: ‘AT_INGRESS’ undeclared (first
use in this function)"
The issue seems to be that make-kpkg creates two pkt_cls.h with the same
include guard but differing contents, "uapi/linux/pkt_cls.h" and
"linux/pkt_cls.h". The latter has its "#ifdef __KERNEL__" section
stripped and therefore misses the needed defines.
Depending on the include order, the batman-adv might fail.
This commit provides a workaround by ensuring that the full-blown
uapi variant is included first.
Eventually, the issue should be fixed in make-kpkg and this commit
reverted (no response from the make-kpkg Debian maintainer yet).
For future reference and updates:
* https://www.open-mesh.org/issues/322
Signed-off-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
---
compat.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/compat.h b/compat.h
index d61a30e..8e23911 100644
--- a/compat.h
+++ b/compat.h
@@ -164,4 +164,13 @@ static int __batadv_interface_kill_vid(struct net_device *dev, __be16 proto,\
#endif /* < KERNEL_VERSION(4, 3, 0) */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
+
+/* workaround for current issues with Debian's make-kpkg */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
+#include <uapi/linux/pkt_cls.h>
+#endif
+
+#endif /* < KERNEL_VERSION(4, 6, 0) */
+
#endif /* _NET_BATMAN_ADV_COMPAT_H_ */
--
2.1.4
On Donnerstag, 12. Januar 2017 20:27:34 CET Andrei Buciulea wrote:
[...]
> *> The tunnels can be successfully created in OpenWRT*I have created the
> tunnel and assigning the mesh devices an IP(192.168.100.5):
> The other one mesh device IP is: 192.168.100.4
>
> tun0 Link encap:UNSPEC HWaddr
> 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
> inet addr:192.168.100.5 P-t-P:192.168.100.5
> Mask:255.255.255.0
> UP POINTOPOINT NOARP MULTICAST MTU:1500 Metric:1
[...]
> If anyone has any idea why it does not work I would be very grateful.
Sorry, but I still don't get what are you doing with layer 3 tunnel stuff and
what batman-adv has to do with it (it is a layer 2 based protocol which
requires layer 2 interfaces).
Kind regards,
Sven