Merge pull request #451 from ecsv/batadv-2019.0

batman-adv: finish config batctl usage & drop unused compat code
This commit is contained in:
Simon Wunderlich 2019-03-07 16:56:37 +01:00 committed by GitHub
commit 571b0b5672
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 83 additions and 240 deletions

View file

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=batctl
PKG_VERSION:=2019.0
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_HASH:=997721096ff396644e8d697ea7651e9d38243faf317bcea2661d4139ff58b531
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
@ -101,6 +101,7 @@ config-n := \
fragmentation \
gateways \
gw_mode \
hop_penalty \
interface \
isolation_mark \
log \
@ -130,6 +131,7 @@ config-settings := \
distributed_arp_table \
fragmentation \
gw_mode \
hop_penalty \
interface \
isolation_mark \
loglevel \

View file

@ -0,0 +1,59 @@
From: Sven Eckelmann <sven@narfation.org>
Date: Fri, 22 Feb 2019 22:19:59 +0100
Subject: batctl: Add hop_penalty command
Signed-off-by: Sven Eckelmann <sven@narfation.org>
diff --git a/Makefile b/Makefile
index 4d8b7095a1e307f0dde7660a718e4ad9c6b11102..55105cc754f546891ba2fcaf57dc8b3ac4c22f71 100755
--- a/Makefile
+++ b/Makefile
@@ -63,6 +63,7 @@ $(eval $(call add_command,event,y))
$(eval $(call add_command,fragmentation,y))
$(eval $(call add_command,gateways,y))
$(eval $(call add_command,gw_mode,y))
+$(eval $(call add_command,hop_penalty,y))
$(eval $(call add_command,interface,y))
$(eval $(call add_command,isolation_mark,y))
$(eval $(call add_command,log,y))
diff --git a/hop_penalty.c b/hop_penalty.c
new file mode 100644
index 0000000000000000000000000000000000000000..6e6a06a661e2ffbb76793116fb214396523bbd8d
--- /dev/null
+++ b/hop_penalty.c
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (C) 2009-2019 B.A.T.M.A.N. contributors:
+ *
+ * Marek Lindner <mareklindner@neomailbox.ch>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA
+ *
+ * License-Filename: LICENSES/preferred/GPL-2.0
+ */
+
+#include <stddef.h>
+
+#include "main.h"
+#include "sys.h"
+
+static struct settings_data batctl_settings_hop_penalty = {
+ .sysfs_name = "hop_penalty",
+ .params = NULL,
+};
+
+COMMAND_NAMED(SUBCOMMAND, hop_penalty, "hp", handle_sys_setting,
+ COMMAND_FLAG_MESH_IFACE, &batctl_settings_hop_penalty,
+ "[penalty] \tdisplay or modify hop_penalty setting");

View file

@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=batman-adv
PKG_VERSION:=2019.0
PKG_RELEASE:=0
PKG_RELEASE:=2
PKG_HASH:=3e97d8a771cdbd7b2df42c52b88e071eaa58b5d28eb4e17a4b13b6698debbdc0
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz

View file

@ -40,11 +40,27 @@ bat_config()
[ -n "$distributed_arp_table" ] && batctl -m "$mesh" distributed_arp_table "$distributed_arp_table" 2>&-
[ -n "$fragmentation" ] && batctl -m "$mesh" fragmentation "$fragmentation"
[ -n "$gw_bandwidth" ] && echo $gw_bandwidth > /sys/class/net/$mesh/mesh/gw_bandwidth
[ -n "$gw_mode" ] && echo $gw_mode > /sys/class/net/$mesh/mesh/gw_mode
[ -n "$gw_sel_class" ] && echo $gw_sel_class > /sys/class/net/$mesh/mesh/gw_sel_class
[ -n "$hop_penalty" ] && echo $hop_penalty > /sys/class/net/$mesh/mesh/hop_penalty
case "$gw_mode" in
server)
if [ -n "$gw_bandwidth" ]; then
batctl -m "$mesh" gw_mode "server" "$gw_bandwidth"
else
batctl -m "$mesh" gw_mode "server"
fi
;;
client)
if [ -n "$gw_sel_class" ]; then
batctl -m "$mesh" gw_mode "client" "$gw_sel_class"
else
batctl -m "$mesh" gw_mode "client"
fi
;;
*)
batctl -m "$mesh" gw_mode "off"
;;
esac
[ -n "$hop_penalty" ] && batctl -m "$mesh" hop_penalty "$hop_penalty"
[ -n "$isolation_mark" ] && batctl -m "$mesh" isolation_mark "$isolation_mark"
[ -n "$multicast_mode" ] && batctl -m "$mesh" multicast_mode "$multicast_mode" 2>&-
[ -n "$network_coding" ] && batctl -m "$mesh" network_coding "$network_coding" 2>&-

View file

@ -1,33 +0,0 @@
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -19,7 +19,7 @@
#include "main.h"
#include <linux/atomic.h>
-#include <linux/build_bug.h>
+#include <linux/bug.h>
#include <linux/byteorder/generic.h>
#include <linux/crc32c.h>
#include <linux/errno.h>
--- a/net/batman-adv/tp_meter.c
+++ b/net/batman-adv/tp_meter.c
@@ -20,7 +20,7 @@
#include "main.h"
#include <linux/atomic.h>
-#include <linux/build_bug.h>
+#include <linux/bug.h>
#include <linux/byteorder/generic.h>
#include <linux/cache.h>
#include <linux/compiler.h>
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -21,7 +21,7 @@
#include <linux/atomic.h>
#include <linux/bitops.h>
-#include <linux/build_bug.h>
+#include <linux/bug.h>
#include <linux/byteorder/generic.h>
#include <linux/cache.h>
#include <linux/compiler.h>

View file

@ -36,11 +36,6 @@
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
/* for batadv_v_elp_get_throughput which would have used
* STATION_INFO_EXPECTED_THROUGHPUT in Linux 4.0.0
*/
#define NL80211_STA_INFO_EXPECTED_THROUGHPUT 28
/* wild hack for batadv_getlink_net only */
#define get_link_net get_xstats_size || 1 ? fallback_net : (struct net*)netdev->rtnl_link_ops->get_xstats_size
@ -109,113 +104,6 @@ batadv_ethtool_get_link_ksettings(struct net_device *dev,
#endif /* < KERNEL_VERSION(4, 6, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)
#ifdef netif_trans_update
#undef netif_trans_update
#endif
#define netif_trans_update batadv_netif_trans_update
static inline void batadv_netif_trans_update(struct net_device *dev)
{
dev->trans_start = jiffies;
}
#endif /* < KERNEL_VERSION(4, 7, 0) */
#include_next <linux/netlink.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)
#include_next <net/netlink.h>
static inline bool batadv_nla_need_padding_for_64bit(struct sk_buff *skb);
static inline int batadv_nla_align_64bit(struct sk_buff *skb, int padattr)
{
if (batadv_nla_need_padding_for_64bit(skb) &&
!nla_reserve(skb, padattr, 0))
return -EMSGSIZE;
return 0;
}
static inline struct nlattr *batadv__nla_reserve_64bit(struct sk_buff *skb,
int attrtype,
int attrlen, int padattr)
{
if (batadv_nla_need_padding_for_64bit(skb))
batadv_nla_align_64bit(skb, padattr);
return __nla_reserve(skb, attrtype, attrlen);
}
static inline void batadv__nla_put_64bit(struct sk_buff *skb, int attrtype,
int attrlen, const void *data,
int padattr)
{
struct nlattr *nla;
nla = batadv__nla_reserve_64bit(skb, attrtype, attrlen, padattr);
memcpy(nla_data(nla), data, attrlen);
}
static inline bool batadv_nla_need_padding_for_64bit(struct sk_buff *skb)
{
#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
/* The nlattr header is 4 bytes in size, that's why we test
* if the skb->data _is_ aligned. A NOP attribute, plus
* nlattr header for next attribute, will make nla_data()
* 8-byte aligned.
*/
if (IS_ALIGNED((unsigned long)skb_tail_pointer(skb), 8))
return true;
#endif
return false;
}
static inline int batadv_nla_total_size_64bit(int payload)
{
return NLA_ALIGN(nla_attr_size(payload))
#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
+ NLA_ALIGN(nla_attr_size(0))
#endif
;
}
static inline int batadv_nla_put_64bit(struct sk_buff *skb, int attrtype,
int attrlen, const void *data,
int padattr)
{
size_t len;
if (batadv_nla_need_padding_for_64bit(skb))
len = batadv_nla_total_size_64bit(attrlen);
else
len = nla_total_size(attrlen);
if (unlikely(skb_tailroom(skb) < len))
return -EMSGSIZE;
batadv__nla_put_64bit(skb, attrtype, attrlen, data, padattr);
return 0;
}
#ifdef nla_put_u64_64bit
#undef nla_put_u64_64bit
#endif
#define nla_put_u64_64bit(_skb, _attrtype, _value, _padattr) \
batadv_nla_put_u64_64bit(_skb, _attrtype, _value, _padattr)
static inline int batadv_nla_put_u64_64bit(struct sk_buff *skb, int attrtype,
u64 value, int padattr)
{
return batadv_nla_put_64bit(skb, attrtype, sizeof(u64), &value,
padattr);
}
#endif /* < KERNEL_VERSION(4, 7, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
@ -250,48 +138,6 @@ static inline int batadv_nla_put_u64_64bit(struct sk_buff *skb, int attrtype,
#endif /* < KERNEL_VERSION(4, 11, 9) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
static inline void *batadv_skb_put(struct sk_buff *skb, unsigned int len)
{
return (void *)skb_put(skb, len);
}
#ifdef skb_put
#undef skb_put
#endif
#define skb_put batadv_skb_put
static inline void *batadv_skb_put_zero(struct sk_buff *skb, unsigned int len)
{
void *tmp = skb_put(skb, len);
memset(tmp, 0, len);
return tmp;
}
#ifdef skb_put_zero
#undef skb_put_zero
#endif
#define skb_put_zero batadv_skb_put_zero
static inline void *batadv_skb_put_data(struct sk_buff *skb, const void *data,
unsigned int len)
{
void *tmp = skb_put(skb, len);
memcpy(tmp, data, len);
return tmp;
}
#ifdef skb_put_data
#undef skb_put_data
#endif
#define skb_put_data batadv_skb_put_data
#endif /* < KERNEL_VERSION(4, 13, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
@ -300,53 +146,6 @@ static inline void *batadv_skb_put_data(struct sk_buff *skb, const void *data,
#endif /* < KERNEL_VERSION(4, 15, 0) */
#ifndef from_timer
#define TIMER_DATA_TYPE unsigned long
#define TIMER_FUNC_TYPE void (*)(TIMER_DATA_TYPE)
static inline void timer_setup(struct timer_list *timer,
void (*callback)(struct timer_list *),
unsigned int flags)
{
__setup_timer(timer, (TIMER_FUNC_TYPE)callback,
(TIMER_DATA_TYPE)timer, flags);
}
#define from_timer(var, callback_timer, timer_fieldname) \
container_of(callback_timer, typeof(*var), timer_fieldname)
#endif /* !from_timer */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 16, 0)
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0)
#include <net/cfg80211.h>
/* cfg80211 fix: https://patchwork.kernel.org/patch/10449857/ */
static inline int batadv_cfg80211_get_station(struct net_device *dev,
const u8 *mac_addr,
struct station_info *sinfo)
{
memset(sinfo, 0, sizeof(*sinfo));
return cfg80211_get_station(dev, mac_addr, sinfo);
}
#define cfg80211_get_station(dev, mac_addr, sinfo) \
batadv_cfg80211_get_station(dev, mac_addr, sinfo)
#endif /* < KERNEL_VERSION(4, 18, 0) */
#ifdef __CHECK_POLL
typedef unsigned __bitwise __poll_t;
#else
typedef unsigned __poll_t;
#endif
#endif /* < KERNEL_VERSION(4, 16, 0) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)