[PATCH 0/8] pull request for net-next: batman-adv 2017-05-24

2018-05-24 Thread Simon Wunderlich
Hi David,

here is a our feature/cleanup pull request of batman-adv to go into net-next.

Please pull or let me know of any problem!

Thank you,
  Simon

The following changes since commit 60cc43fc888428bb2f18f08997432d426a243338:

  Linux 4.17-rc1 (2018-04-15 18:24:20 -0700)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batadv-next-for-davem-20180524

for you to fetch changes up to 18cfb44cf1845d11d50f4733e039acb8b377c8eb:

  batman-adv: enable B.A.T.M.A.N. V compilation by default (2018-05-14 09:31:17 
+0200)


This feature/cleanup patchset includes the following patches:

 - bump version strings, by Simon Wunderlich

 - Disable batman-adv debugfs by default, by Sven Eckelmann

 - Improve handling mesh nodes with multicast optimizations disabled,
   by Linus Luessing

 - Avoid bool in structs, by Sven Eckelmann

 - Allocate less memory when debugfs is disabled, by Sven Eckelmann

 - Fix batadv_interface_tx return data type, by Luc Van Oostenryck

 - improve link speed handling for virtual interfaces, by Marek Lindner

 - Enable BATMAN V algorithm by default, by Marek Lindner


Linus Lüssing (1):
  batman-adv: Avoid old nodes disabling multicast optimizations completely

Luc Van Oostenryck (1):
  batman-adv: fix batadv_interface_tx()'s return type

Marek Lindner (2):
  batman-adv: disable ethtool link speed detection when auto negotiation off
  batman-adv: enable B.A.T.M.A.N. V compilation by default

Simon Wunderlich (1):
  batman-adv: Start new development cycle

Sven Eckelmann (3):
  batman-adv: Disable CONFIG_BATMAN_ADV_DEBUGFS by default
  batman-adv: Avoid bool in structures
  batman-adv: Remove unused dentry without DEBUGFS

 net/batman-adv/Kconfig  |  6 +++---
 net/batman-adv/bat_v_elp.c  | 15 ++-
 net/batman-adv/main.h   |  2 +-
 net/batman-adv/multicast.c  | 29 ++---
 net/batman-adv/soft-interface.c |  5 ++---
 net/batman-adv/types.h  | 23 +--
 6 files changed, 39 insertions(+), 41 deletions(-)


[PATCH 1/8] batman-adv: Start new development cycle

2018-05-24 Thread Simon Wunderlich
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/main.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 057a28a9fe88..8da3c9336111 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -25,7 +25,7 @@
 #define BATADV_DRIVER_DEVICE "batman-adv"
 
 #ifndef BATADV_SOURCE_VERSION
-#define BATADV_SOURCE_VERSION "2018.1"
+#define BATADV_SOURCE_VERSION "2018.2"
 #endif
 
 /* B.A.T.M.A.N. parameters */
-- 
2.11.0



[PATCH 2/8] batman-adv: Disable CONFIG_BATMAN_ADV_DEBUGFS by default

2018-05-24 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

All tools which were known to the batman-adv development team are
supporting the batman-adv netlink interface since a while. Also debugfs is
not supported for batman-adv interfaces in any non-default netns. Thus
disabling CONFIG_BATMAN_ADV_DEBUGFS by default should not cause problems on
most systems. It is still possible to enable it in case it is still
required in a specific setup.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/Kconfig b/net/batman-adv/Kconfig
index e4e2e02b7380..bee034a95208 100644
--- a/net/batman-adv/Kconfig
+++ b/net/batman-adv/Kconfig
@@ -94,13 +94,13 @@ config BATMAN_ADV_DEBUGFS
bool "batman-adv debugfs entries"
depends on BATMAN_ADV
depends on DEBUG_FS
-   default y
+   default n
help
  Enable this to export routing related debug tables via debugfs.
  The information for each soft-interface and used hard-interface can be
  found under batman_adv/
 
- If unsure, say Y.
+ If unsure, say N.
 
 config BATMAN_ADV_DEBUG
bool "B.A.T.M.A.N. debugging"
-- 
2.11.0



[PATCH 5/8] batman-adv: Remove unused dentry without DEBUGFS

2018-05-24 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The debug_dir variable in the main structures is only accessed when
CONFIG_BATMAN_ADV_DEBUGFS is enabled. It can be dropped to potentially save
some bytes of memory.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/types.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 3b3fc146b30d..360357f83f20 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -215,10 +215,12 @@ struct batadv_hard_iface {
struct batadv_hard_iface_bat_v bat_v;
 #endif
 
+#ifdef CONFIG_BATMAN_ADV_DEBUGFS
/**
 * @debug_dir: dentry for nc subdir in batman-adv directory in debugfs
 */
struct dentry *debug_dir;
+#endif
 
/**
 * @neigh_list: list of unique single hop neighbors via this interface
@@ -1242,10 +1244,12 @@ struct batadv_priv_nc {
/** @work: work queue callback item for cleanup */
struct delayed_work work;
 
+#ifdef CONFIG_BATMAN_ADV_DEBUGFS
/**
 * @debug_dir: dentry for nc subdir in batman-adv directory in debugfs
 */
struct dentry *debug_dir;
+#endif
 
/**
 * @min_tq: only consider neighbors for encoding if neigh_tq > min_tq
@@ -1598,8 +1602,10 @@ struct batadv_priv {
/** @mesh_obj: kobject for sysfs mesh subdirectory */
struct kobject *mesh_obj;
 
+#ifdef CONFIG_BATMAN_ADV_DEBUGFS
/** @debug_dir: dentry for debugfs batman-adv subdirectory */
struct dentry *debug_dir;
+#endif
 
/** @forw_bat_list: list of aggregated OGMs that will be forwarded */
struct hlist_head forw_bat_list;
-- 
2.11.0



[PATCH 7/8] batman-adv: disable ethtool link speed detection when auto negotiation off

2018-05-24 Thread Simon Wunderlich
From: Marek Lindner <mareklind...@neomailbox.ch>

Virtual interface drivers such as tun / tap interfaces, VLAN, etc tend
to initialize the interface throughput with some value for the sake of
having a throughput number to export via ethtool. This exported
throughput leaves batman-adv to conclude the interface throughput is
genuine (reflecting reality), thus no measurements are necessary.

Based on the observation that those interface types also tend to set
the link auto-negotiation to 'off', batman-adv shall check this
setting to differentiate between genuine link throughput information
and placeholders installed by virtual interfaces.

The "default throughput" setting exported via sysfs still allows to
configure the batman-adv throughput for the interface, thus disabling
the measurements.

Signed-off-by: Marek Lindner <mareklind...@neomailbox.ch>
Acked-by: Antonio Quartulli <a...@unstable.cc>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_v_elp.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index 28687493599f..71c20c1d4002 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -127,7 +127,20 @@ static u32 batadv_v_elp_get_throughput(struct 
batadv_hardif_neigh_node *neigh)
rtnl_lock();
ret = __ethtool_get_link_ksettings(hard_iface->net_dev, _settings);
rtnl_unlock();
-   if (ret == 0) {
+
+   /* Virtual interface drivers such as tun / tap interfaces, VLAN, etc
+* tend to initialize the interface throughput with some value for the
+* sake of having a throughput number to export via ethtool. This
+* exported throughput leaves batman-adv to conclude the interface
+* throughput is genuine (reflecting reality), thus no measurements
+* are necessary.
+*
+* Based on the observation that those interface types also tend to set
+* the link auto-negotiation to 'off', batman-adv shall check this
+* setting to differentiate between genuine link throughput information
+* and placeholders installed by virtual interfaces.
+*/
+   if (ret == 0 && link_settings.base.autoneg == AUTONEG_ENABLE) {
/* link characteristics might change over time */
if (link_settings.base.duplex == DUPLEX_FULL)
hard_iface->bat_v.flags |= BATADV_FULL_DUPLEX;
-- 
2.11.0



[PATCH 6/8] batman-adv: fix batadv_interface_tx()'s return type

2018-05-24 Thread Simon Wunderlich
From: Luc Van Oostenryck <luc.vanoostenr...@gmail.com>

The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
which is a typedef for an enum type, but the implementation in this
driver returns an 'int'.

Fix this by returning 'netdev_tx_t' in this driver too.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenr...@gmail.com>
[s...@narfation.org: fixed alignment]
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/soft-interface.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 67065e35de51..1485263a348b 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -188,8 +188,8 @@ static void batadv_interface_set_rx_mode(struct net_device 
*dev)
 {
 }
 
-static int batadv_interface_tx(struct sk_buff *skb,
-  struct net_device *soft_iface)
+static netdev_tx_t batadv_interface_tx(struct sk_buff *skb,
+  struct net_device *soft_iface)
 {
struct ethhdr *ethhdr;
struct batadv_priv *bat_priv = netdev_priv(soft_iface);
-- 
2.11.0



[PATCH 4/8] batman-adv: Avoid bool in structures

2018-05-24 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

Using the bool type for structure member is considered inappropriate [1]
for the kernel. Its size is not well defined (but usually 1 byte but maybe
also 4 byte).

[1] https://lkml.org/lkml/2017/11/21/384

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/types.h | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 0174f79e955a..3b3fc146b30d 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1160,13 +1160,13 @@ struct batadv_priv_dat {
  */
 struct batadv_mcast_querier_state {
/** @exists: whether a querier exists in the mesh */
-   bool exists;
+   unsigned char exists:1;
 
/**
 * @shadowing: if a querier exists, whether it is potentially shadowing
 *  multicast listeners (i.e. querier is behind our own bridge segment)
 */
-   bool shadowing;
+   unsigned char shadowing:1;
 };
 
 /**
@@ -1207,10 +1207,10 @@ struct batadv_priv_mcast {
u8 flags;
 
/** @enabled: whether the multicast tvlv is currently enabled */
-   bool enabled;
+   unsigned char enabled:1;
 
/** @bridged: whether the soft interface has a bridge on top */
-   bool bridged;
+   unsigned char bridged:1;
 
/**
 * @num_want_all_unsnoopables: number of nodes wanting unsnoopable IP
@@ -1389,7 +1389,7 @@ struct batadv_tp_vars {
atomic_t dup_acks;
 
/** @fast_recovery: true if in Fast Recovery mode */
-   bool fast_recovery;
+   unsigned char fast_recovery:1;
 
/** @recover: last sent seqno when entering Fast Recovery */
u32 recover;
@@ -2046,10 +2046,10 @@ struct batadv_skb_cb {
 * @decoded: Marks a skb as decoded, which is checked when searching for
 *  coding opportunities in network-coding.c
 */
-   bool decoded;
+   unsigned char decoded:1;
 
/** @num_bcasts: Counter for broadcast packet retransmissions */
-   unsigned int num_bcasts;
+   unsigned char num_bcasts;
 };
 
 /**
-- 
2.11.0



[PATCH 8/8] batman-adv: enable B.A.T.M.A.N. V compilation by default

2018-05-24 Thread Simon Wunderlich
From: Marek Lindner <mareklind...@neomailbox.ch>

Signed-off-by: Marek Lindner <mareklind...@neomailbox.ch>
Acked-by: Antonio Quartulli <a...@unstable.cc>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/Kconfig b/net/batman-adv/Kconfig
index bee034a95208..de8034d80623 100644
--- a/net/batman-adv/Kconfig
+++ b/net/batman-adv/Kconfig
@@ -35,7 +35,7 @@ config BATMAN_ADV
 config BATMAN_ADV_BATMAN_V
bool "B.A.T.M.A.N. V protocol (experimental)"
depends on BATMAN_ADV && !(CFG80211=m && BATMAN_ADV=y)
-   default n
+   default y
help
  This option enables the B.A.T.M.A.N. V protocol, the successor
  of the currently used B.A.T.M.A.N. IV protocol. The main
-- 
2.11.0



[PATCH 3/8] batman-adv: Avoid old nodes disabling multicast optimizations completely

2018-05-24 Thread Simon Wunderlich
From: Linus Lüssing <linus.luess...@c0d3.blue>

Instead of disabling multicast optimizations mesh-wide once a node with
no multicast optimizations capabilities joins the mesh, do the
following:

Just insert such nodes into the WANT_ALL_IPV4/IPV6 lists. This is
sufficient to avoid multicast packet loss to such unsupportive nodes.

Signed-off-by: Linus Lüssing <linus.luess...@c0d3.blue>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/multicast.c  | 29 ++---
 net/batman-adv/soft-interface.c |  1 -
 net/batman-adv/types.h  |  3 ---
 3 files changed, 6 insertions(+), 27 deletions(-)

diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index a11d3d89f012..36fd7b06c7cc 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -815,9 +815,6 @@ static int batadv_mcast_forw_mode_check(struct batadv_priv 
*bat_priv,
if (!atomic_read(_priv->multicast_mode))
return -EINVAL;
 
-   if (atomic_read(_priv->mcast.num_disabled))
-   return -EINVAL;
-
switch (ntohs(ethhdr->h_proto)) {
case ETH_P_IP:
return batadv_mcast_forw_mode_check_ipv4(bat_priv, skb,
@@ -1183,33 +1180,23 @@ static void batadv_mcast_tvlv_ogm_handler(struct 
batadv_priv *bat_priv,
 {
bool orig_mcast_enabled = !(flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND);
u8 mcast_flags = BATADV_NO_FLAGS;
-   bool orig_initialized;
 
if (orig_mcast_enabled && tvlv_value &&
tvlv_value_len >= sizeof(mcast_flags))
mcast_flags = *(u8 *)tvlv_value;
 
+   if (!orig_mcast_enabled) {
+   mcast_flags |= BATADV_MCAST_WANT_ALL_IPV4;
+   mcast_flags |= BATADV_MCAST_WANT_ALL_IPV6;
+   }
+
spin_lock_bh(>mcast_handler_lock);
-   orig_initialized = test_bit(BATADV_ORIG_CAPA_HAS_MCAST,
-   >capa_initialized);
 
-   /* If mcast support is turned on decrease the disabled mcast node
-* counter only if we had increased it for this node before. If this
-* is a completely new orig_node no need to decrease the counter.
-*/
if (orig_mcast_enabled &&
!test_bit(BATADV_ORIG_CAPA_HAS_MCAST, >capabilities)) {
-   if (orig_initialized)
-   atomic_dec(_priv->mcast.num_disabled);
set_bit(BATADV_ORIG_CAPA_HAS_MCAST, >capabilities);
-   /* If mcast support is being switched off or if this is an initial
-* OGM without mcast support then increase the disabled mcast
-* node counter.
-*/
} else if (!orig_mcast_enabled &&
-  (test_bit(BATADV_ORIG_CAPA_HAS_MCAST, >capabilities) ||
-   !orig_initialized)) {
-   atomic_inc(_priv->mcast.num_disabled);
+  test_bit(BATADV_ORIG_CAPA_HAS_MCAST, >capabilities)) {
clear_bit(BATADV_ORIG_CAPA_HAS_MCAST, >capabilities);
}
 
@@ -1595,10 +1582,6 @@ void batadv_mcast_purge_orig(struct batadv_orig_node 
*orig)
 
spin_lock_bh(>mcast_handler_lock);
 
-   if (!test_bit(BATADV_ORIG_CAPA_HAS_MCAST, >capabilities) &&
-   test_bit(BATADV_ORIG_CAPA_HAS_MCAST, >capa_initialized))
-   atomic_dec(_priv->mcast.num_disabled);
-
batadv_mcast_want_unsnoop_update(bat_priv, orig, BATADV_NO_FLAGS);
batadv_mcast_want_ipv4_update(bat_priv, orig, BATADV_NO_FLAGS);
batadv_mcast_want_ipv6_update(bat_priv, orig, BATADV_NO_FLAGS);
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index edeffcb9f3a2..67065e35de51 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -796,7 +796,6 @@ static int batadv_softif_init_late(struct net_device *dev)
bat_priv->mcast.querier_ipv6.shadowing = false;
bat_priv->mcast.flags = BATADV_NO_FLAGS;
atomic_set(_priv->multicast_mode, 1);
-   atomic_set(_priv->mcast.num_disabled, 0);
atomic_set(_priv->mcast.num_want_all_unsnoopables, 0);
atomic_set(_priv->mcast.num_want_all_ipv4, 0);
atomic_set(_priv->mcast.num_want_all_ipv6, 0);
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 476b052ad982..0174f79e955a 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1212,9 +1212,6 @@ struct batadv_priv_mcast {
/** @bridged: whether the soft interface has a bridge on top */
bool bridged;
 
-   /** @num_disabled: number of nodes that have no mcast tvlv */
-   atomic_t num_disabled;
-
/**
 * @num_want_all_unsnoopables: number of nodes wanting unsnoopable IP
 *  traffic
-- 
2.11.0



[PATCH 3/4] batman-adv: Fix TT sync flags for intermediate TT responses

2018-05-24 Thread Simon Wunderlich
From: Linus Lüssing <linus.luess...@c0d3.blue>

The previous TT sync fix so far only fixed TT responses issued by the
target node directly. So far, TT responses issued by intermediate nodes
still lead to the wrong flags being added, leading to CRC mismatches.

This behaviour was observed at Freifunk Hannover in a 800 nodes setup
where a considerable amount of nodes were still infected with 'WI'
TT flags even with (most) nodes having the previous TT sync fix applied.

I was able to reproduce the issue with intermediate TT responses in a
four node test setup and this patch fixes this issue by ensuring to
use the per originator instead of the summarized, OR'd ones.

Fixes: e9c00136a475 ("batman-adv: fix tt_global_entries flags update")
Reported-by: Leonardo Mörlein <m...@irrelefant.net>
Signed-off-by: Linus Lüssing <linus.luess...@c0d3.blue>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/translation-table.c | 61 +++---
 1 file changed, 51 insertions(+), 10 deletions(-)

diff --git a/net/batman-adv/translation-table.c 
b/net/batman-adv/translation-table.c
index 7fa3a0a0524a..23f9c212ab1e 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1538,6 +1538,8 @@ batadv_tt_global_orig_entry_find(const struct 
batadv_tt_global_entry *entry,
  *  handled by a given originator
  * @entry: the TT global entry to check
  * @orig_node: the originator to search in the list
+ * @flags: a pointer to store TT flags for the given @entry received
+ *  from @orig_node
  *
  * find out if an orig_node is already in the list of a tt_global_entry.
  *
@@ -1545,7 +1547,8 @@ batadv_tt_global_orig_entry_find(const struct 
batadv_tt_global_entry *entry,
  */
 static bool
 batadv_tt_global_entry_has_orig(const struct batadv_tt_global_entry *entry,
-   const struct batadv_orig_node *orig_node)
+   const struct batadv_orig_node *orig_node,
+   u8 *flags)
 {
struct batadv_tt_orig_list_entry *orig_entry;
bool found = false;
@@ -1553,6 +1556,10 @@ batadv_tt_global_entry_has_orig(const struct 
batadv_tt_global_entry *entry,
orig_entry = batadv_tt_global_orig_entry_find(entry, orig_node);
if (orig_entry) {
found = true;
+
+   if (flags)
+   *flags = orig_entry->flags;
+
batadv_tt_orig_list_entry_put(orig_entry);
}
 
@@ -1731,7 +1738,7 @@ static bool batadv_tt_global_add(struct batadv_priv 
*bat_priv,
if (!(common->flags & BATADV_TT_CLIENT_TEMP))
goto out;
if (batadv_tt_global_entry_has_orig(tt_global_entry,
-   orig_node))
+   orig_node, NULL))
goto out_remove;
batadv_tt_global_del_orig_list(tt_global_entry);
goto add_orig_entry;
@@ -2880,23 +2887,46 @@ batadv_tt_req_node_new(struct batadv_priv *bat_priv,
 }
 
 /**
- * batadv_tt_local_valid() - verify that given tt entry is a valid one
+ * batadv_tt_local_valid() - verify local tt entry and get flags
  * @entry_ptr: to be checked local tt entry
  * @data_ptr: not used but definition required to satisfy the callback 
prototype
+ * @flags: a pointer to store TT flags for this client to
+ *
+ * Checks the validity of the given local TT entry. If it is, then the provided
+ * flags pointer is updated.
  *
  * Return: true if the entry is a valid, false otherwise.
  */
-static bool batadv_tt_local_valid(const void *entry_ptr, const void *data_ptr)
+static bool batadv_tt_local_valid(const void *entry_ptr,
+ const void *data_ptr,
+ u8 *flags)
 {
const struct batadv_tt_common_entry *tt_common_entry = entry_ptr;
 
if (tt_common_entry->flags & BATADV_TT_CLIENT_NEW)
return false;
+
+   if (flags)
+   *flags = tt_common_entry->flags;
+
return true;
 }
 
+/**
+ * batadv_tt_global_valid() - verify global tt entry and get flags
+ * @entry_ptr: to be checked global tt entry
+ * @data_ptr: an orig_node object (may be NULL)
+ * @flags: a pointer to store TT flags for this client to
+ *
+ * Checks the validity of the given global TT entry. If it is, then the 
provided
+ * flags pointer is updated either with the common (summed) TT flags if 
data_ptr
+ * is NULL or the specific, per originator TT flags otherwise.
+ *
+ * Return: true if the entry is a valid, false otherwise.
+ */
 static bool batadv_tt_global_valid(const void *entry_ptr,
-  const void *data_ptr)
+  const 

[PATCH 2/4] batman-adv: Avoid race in TT TVLV allocator helper

2018-05-24 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The functions batadv_tt_prepare_tvlv_local_data and
batadv_tt_prepare_tvlv_global_data are responsible for preparing a buffer
which can be used to store the TVLV container for TT and add the VLAN
information to it.

This will be done in three phases:

1. count the number of VLANs and their entries
2. allocate the buffer using the counters from the previous step and limits
   from the caller (parameter tt_len)
3. insert the VLAN information to the buffer

The step 1 and 3 operate on a list which contains the VLANs. The access to
these lists must be protected with an appropriate lock or otherwise they
might operate on on different entries. This could for example happen when
another context is adding VLAN entries to this list.

This could lead to a buffer overflow in these functions when enough entries
were added between step 1 and 3 to the VLAN lists that the buffer room for
the entries (*tt_change) is smaller then the now required extra buffer for
new VLAN entries.

Fixes: 7ea7b4a14275 ("batman-adv: make the TT CRC logic VLAN specific")
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Acked-by: Antonio Quartulli <a...@unstable.cc>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/translation-table.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/batman-adv/translation-table.c 
b/net/batman-adv/translation-table.c
index 0225616d5771..7fa3a0a0524a 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -862,7 +862,7 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node 
*orig_node,
struct batadv_orig_node_vlan *vlan;
u8 *tt_change_ptr;
 
-   rcu_read_lock();
+   spin_lock_bh(_node->vlan_list_lock);
hlist_for_each_entry_rcu(vlan, _node->vlan_list, list) {
num_vlan++;
num_entries += atomic_read(>tt.num_entries);
@@ -900,7 +900,7 @@ batadv_tt_prepare_tvlv_global_data(struct batadv_orig_node 
*orig_node,
*tt_change = (struct batadv_tvlv_tt_change *)tt_change_ptr;
 
 out:
-   rcu_read_unlock();
+   spin_unlock_bh(_node->vlan_list_lock);
return tvlv_len;
 }
 
@@ -936,7 +936,7 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv 
*bat_priv,
u8 *tt_change_ptr;
int change_offset;
 
-   rcu_read_lock();
+   spin_lock_bh(_priv->softif_vlan_list_lock);
hlist_for_each_entry_rcu(vlan, _priv->softif_vlan_list, list) {
num_vlan++;
num_entries += atomic_read(>tt.num_entries);
@@ -974,7 +974,7 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv 
*bat_priv,
*tt_change = (struct batadv_tvlv_tt_change *)tt_change_ptr;
 
 out:
-   rcu_read_unlock();
+   spin_unlock_bh(_priv->softif_vlan_list_lock);
return tvlv_len;
 }
 
-- 
2.11.0



[PATCH 1/4] batman-adv: don't pass a NULL hard_iface to batadv_hardif_put

2018-05-24 Thread Simon Wunderlich
From: Colin Ian King <colin.k...@canonical.com>

In the case where hard_iface is NULL, the error path may pass a null
pointer to batadv_hardif_put causing a null pointer dereference error.
Avoid this by only calling the function if  hard_iface not null.

Detected by CoverityScan, CID#1466456 ("Explicit null dereferenced")

Fixes: 53dd9a68ba68 ("batman-adv: add multicast flags netlink support")
Signed-off-by: Colin Ian King <colin.k...@canonical.com>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/multicast.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index a11d3d89f012..a35f597e8c8b 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -1536,7 +1536,7 @@ batadv_mcast_netlink_get_primary(struct netlink_callback 
*cb,
 
if (!ret && primary_if)
*primary_if = hard_iface;
-   else
+   else if (hard_iface)
batadv_hardif_put(hard_iface);
 
return ret;
-- 
2.11.0



[PATCH 0/4] pull request for net: batman-adv 2018-05-24

2018-05-24 Thread Simon Wunderlich
Hi David,

here are a couple of bugfixes which we would like to have integrated into net.

Please pull or let me know of any problem!

Thank you,
  Simon

The following changes since commit 60cc43fc888428bb2f18f08997432d426a243338:

  Linux 4.17-rc1 (2018-04-15 18:24:20 -0700)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batadv-net-for-davem-20180524

for you to fetch changes up to 16116dac23396e73c0197b102e4833a4b205:

  batman-adv: prevent TT request storms by not sending inconsistent TT TLVLs 
(2018-05-12 18:53:08 +0200)


Here are some batman-adv bugfixes:

 - prevent hardif_put call with NULL parameter, by Colin Ian King

 - Avoid race in Translation Table allocator, by Sven Eckelmann

 - Fix Translation Table sync flags for intermediate Responses,
   by Linus Luessing

 - prevent sending inconsistent Translation Table TVLVs,
   by Marek Lindner


Colin Ian King (1):
  batman-adv: don't pass a NULL hard_iface to batadv_hardif_put

Linus Lüssing (1):
  batman-adv: Fix TT sync flags for intermediate TT responses

Marek Lindner (1):
  batman-adv: prevent TT request storms by not sending inconsistent TT TLVLs

Sven Eckelmann (1):
  batman-adv: Avoid race in TT TVLV allocator helper

 net/batman-adv/multicast.c |  2 +-
 net/batman-adv/translation-table.c | 84 ++
 2 files changed, 68 insertions(+), 18 deletions(-)


[PATCH 4/4] batman-adv: prevent TT request storms by not sending inconsistent TT TLVLs

2018-05-24 Thread Simon Wunderlich
From: Marek Lindner <mareklind...@neomailbox.ch>

A translation table TVLV changset sent with an OGM consists
of a number of headers (one per VLAN) plus the changeset
itself (addition and/or deletion of entries).

The per-VLAN headers are used by OGM recipients for consistency
checks. Said consistency check might determine that a full
translation table request is needed to restore consistency. If
the TT sender adds per-VLAN headers of empty VLANs into the OGM,
recipients are led to believe to have reached an inconsistent
state and thus request a full table update. The full table does
not contain empty VLANs (due to missing entries) the cycle
restarts when the next OGM is issued.

Consequently, when the translation table TVLV headers are
composed, empty VLANs are to be excluded.

Fixes: 21a57f6e7a3b ("batman-adv: make the TT CRC logic VLAN specific")
Signed-off-by: Marek Lindner <mareklind...@neomailbox.ch>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/translation-table.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/net/batman-adv/translation-table.c 
b/net/batman-adv/translation-table.c
index 23f9c212ab1e..3986551397ca 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -931,15 +931,20 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv 
*bat_priv,
struct batadv_tvlv_tt_vlan_data *tt_vlan;
struct batadv_softif_vlan *vlan;
u16 num_vlan = 0;
-   u16 num_entries = 0;
+   u16 vlan_entries = 0;
+   u16 total_entries = 0;
u16 tvlv_len;
u8 *tt_change_ptr;
int change_offset;
 
spin_lock_bh(_priv->softif_vlan_list_lock);
hlist_for_each_entry_rcu(vlan, _priv->softif_vlan_list, list) {
+   vlan_entries = atomic_read(>tt.num_entries);
+   if (vlan_entries < 1)
+   continue;
+
num_vlan++;
-   num_entries += atomic_read(>tt.num_entries);
+   total_entries += vlan_entries;
}
 
change_offset = sizeof(**tt_data);
@@ -947,7 +952,7 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv 
*bat_priv,
 
/* if tt_len is negative, allocate the space needed by the full table */
if (*tt_len < 0)
-   *tt_len = batadv_tt_len(num_entries);
+   *tt_len = batadv_tt_len(total_entries);
 
tvlv_len = *tt_len;
tvlv_len += change_offset;
@@ -964,6 +969,10 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv 
*bat_priv,
 
tt_vlan = (struct batadv_tvlv_tt_vlan_data *)(*tt_data + 1);
hlist_for_each_entry_rcu(vlan, _priv->softif_vlan_list, list) {
+   vlan_entries = atomic_read(>tt.num_entries);
+   if (vlan_entries < 1)
+   continue;
+
tt_vlan->vid = htons(vlan->vid);
tt_vlan->crc = htonl(vlan->tt.crc);
 
-- 
2.11.0



Re: [PATCH][next] batman-adv: don't pass a NULL hard_iface to batadv_hardif_put

2018-03-26 Thread Simon Wunderlich
Hi,

this looks good. David, would you pick this patch directly? Otherwise, I can 
send a pull request, but right now we would only have this single patch for 
net-next.

Acked-by: Simon Wunderlich <s...@simonwunderlich.de>
Acked-by: Sven Eckelmann <s...@narfation.org>

(just discussed with Sven offline)

Thank you,
 Simon

On Friday, March 23, 2018 10:53:50 PM CEST Colin King wrote:
> From: Colin Ian King <colin.k...@canonical.com>
> 
> In the case where hard_iface is NULL, the error path may pass a null
> pointer to batadv_hardif_put causing a null pointer dereference error.
> Avoid this by only calling the function if  hard_iface not null.
> 
> Detected by CoverityScan, CID#1466456 ("Explicit null dereferenced")
> 
> Fixes: 53dd9a68ba68 ("batman-adv: add multicast flags netlink support")
> Signed-off-by: Colin Ian King <colin.k...@canonical.com>
> ---
>  net/batman-adv/multicast.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
> index de3a055f7dd8..bd0ea374d043 100644
> --- a/net/batman-adv/multicast.c
> +++ b/net/batman-adv/multicast.c
> @@ -1536,7 +1536,7 @@ batadv_mcast_netlink_get_primary(struct
> netlink_callback *cb,
> 
>   if (!ret && primary_if)
>   *primary_if = hard_iface;
> - else
> + else if (hard_iface)
>   batadv_hardif_put(hard_iface);
> 
>   return ret;



signature.asc
Description: This is a digitally signed message part.


[PATCH 2/2] batman-adv: fix packet loss for broadcasted DHCP packets to a server

2018-03-26 Thread Simon Wunderlich
From: Linus Lüssing <linus.luess...@c0d3.blue>

DHCP connectivity issues can currently occur if the following conditions
are met:

1) A DHCP packet from a client to a server
2) This packet has a multicast destination
3) This destination has a matching entry in the translation table
   (FF:FF:FF:FF:FF:FF for IPv4, 33:33:00:01:00:02/33:33:00:01:00:03
for IPv6)
4) The orig-node determined by TT for the multicast destination
   does not match the orig-node determined by best-gateway-selection

In this case the DHCP packet will be dropped.

The "gateway-out-of-range" check is supposed to only be applied to
unicasted DHCP packets to a specific DHCP server.

In that case dropping the the unicasted frame forces the client to
retry via a broadcasted one, but now directed to the new best
gateway.

A DHCP packet with broadcast/multicast destination is already ensured to
always be delivered to the best gateway. Dropping a multicasted
DHCP packet here will only prevent completing DHCP as there is no
other fallback.

So far, it seems the unicast check was implicitly performed by
expecting the batadv_transtable_search() to return NULL for multicast
destinations. However, a multicast address could have always ended up in
the translation table and in fact is now common.

To fix this potential loss of a DHCP client-to-server packet to a
multicast address this patch adds an explicit multicast destination
check to reliably bail out of the gateway-out-of-range check for such
destinations.

The issue and fix were tested in the following three node setup:

- Line topology, A-B-C
- A: gateway client, DHCP client
- B: gateway server, hop-penalty increased: 30->60, DHCP server
- C: gateway server, code modifications to announce FF:FF:FF:FF:FF:FF

Without this patch, A would never transmit its DHCP Discover packet
due to an always "out-of-range" condition. With this patch,
a full DHCP handshake between A and B was possible again.

Fixes: be7af5cf9cae ("batman-adv: refactoring gateway handling code")
Signed-off-by: Linus Lüssing <linus.luess...@c0d3.blue>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/gateway_client.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 37fe9a644f22..808d2dd4a839 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -746,7 +746,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
 {
struct batadv_neigh_node *neigh_curr = NULL;
struct batadv_neigh_node *neigh_old = NULL;
-   struct batadv_orig_node *orig_dst_node;
+   struct batadv_orig_node *orig_dst_node = NULL;
struct batadv_gw_node *gw_node = NULL;
struct batadv_gw_node *curr_gw = NULL;
struct batadv_neigh_ifinfo *curr_ifinfo, *old_ifinfo;
@@ -757,6 +757,9 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
 
vid = batadv_get_vid(skb, 0);
 
+   if (is_multicast_ether_addr(ethhdr->h_dest))
+   goto out;
+
orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
 ethhdr->h_dest, vid);
if (!orig_dst_node)
-- 
2.11.0



[PATCH 0/2] pull request for net: batman-adv 2018-03-26

2018-03-26 Thread Simon Wunderlich
Hi David,

here are two late bugfixes for batman-adv which we would like to have in net
if still possible.

Please pull or let me know of any problem!

Thank you,
  Simon

The following changes since commit fc04fdb2c8a894283259f5621d31d75610701091:

  batman-adv: Fix skbuff rcsum on packet reroute (2018-03-18 13:20:32 +0100)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batadv-net-for-davem-20180326

for you to fetch changes up to a752c0a4524889cdc0765925258fd1fd72344100:

  batman-adv: fix packet loss for broadcasted DHCP packets to a server 
(2018-03-24 10:25:49 +0100)


Here are some batman-adv bugfixes:

 - fix multicast-via-unicast transmissions for AP isolation and gateway
   extension, by Linus Luessing (2 patches)


Linus Lüssing (2):
  batman-adv: fix multicast-via-unicast transmission with AP isolation
  batman-adv: fix packet loss for broadcasted DHCP packets to a server

 net/batman-adv/gateway_client.c | 5 -
 net/batman-adv/multicast.c  | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)


[PATCH 1/2] batman-adv: fix multicast-via-unicast transmission with AP isolation

2018-03-26 Thread Simon Wunderlich
From: Linus Lüssing <linus.luess...@c0d3.blue>

For multicast frames AP isolation is only supposed to be checked on
the receiving nodes and never on the originating one.

Furthermore, the isolation or wifi flag bits should only be intepreted
as such for unicast and never multicast TT entries.

By injecting flags to the multicast TT entry claimed by a single
target node it was verified in tests that this multicast address
becomes unreachable, leading to packet loss.

Omitting the "src" parameter to the batadv_transtable_search() call
successfully skipped the AP isolation check and made the target
reachable again.

Fixes: 1d8ab8d3c176 ("batman-adv: Modified forwarding behaviour for multicast 
packets")
Signed-off-by: Linus Lüssing <linus.luess...@c0d3.blue>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/multicast.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index d70640135e3a..ee56af5c43e0 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -814,8 +814,8 @@ static struct batadv_orig_node *
 batadv_mcast_forw_tt_node_get(struct batadv_priv *bat_priv,
  struct ethhdr *ethhdr)
 {
-   return batadv_transtable_search(bat_priv, ethhdr->h_source,
-   ethhdr->h_dest, BATADV_NO_FLAGS);
+   return batadv_transtable_search(bat_priv, NULL, ethhdr->h_dest,
+   BATADV_NO_FLAGS);
 }
 
 /**
-- 
2.11.0



[PATCH 2/3] batman-adv: add DAT cache netlink support

2018-03-19 Thread Simon Wunderlich
From: Linus Lüssing <linus.luess...@c0d3.blue>

Dump the list of DAT cache entries via the netlink socket.

Signed-off-by: Linus Lüssing <linus.luess...@c0d3.blue>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 include/uapi/linux/batman_adv.h|  20 +
 net/batman-adv/distributed-arp-table.c | 152 +
 net/batman-adv/distributed-arp-table.h |   8 ++
 net/batman-adv/netlink.c   |  76 ++---
 4 files changed, 223 insertions(+), 33 deletions(-)

diff --git a/include/uapi/linux/batman_adv.h b/include/uapi/linux/batman_adv.h
index 56ae28934070..95ab5dbd09fa 100644
--- a/include/uapi/linux/batman_adv.h
+++ b/include/uapi/linux/batman_adv.h
@@ -272,6 +272,21 @@ enum batadv_nl_attrs {
 */
BATADV_ATTR_BLA_CRC,
 
+   /**
+* @BATADV_ATTR_DAT_CACHE_IP4ADDRESS: Client IPv4 address
+*/
+   BATADV_ATTR_DAT_CACHE_IP4ADDRESS,
+
+   /**
+* @BATADV_ATTR_DAT_CACHE_HWADDRESS: Client MAC address
+*/
+   BATADV_ATTR_DAT_CACHE_HWADDRESS,
+
+   /**
+* @BATADV_ATTR_DAT_CACHE_VID: VLAN ID
+*/
+   BATADV_ATTR_DAT_CACHE_VID,
+
/* add attributes above here, update the policy in netlink.c */
 
/**
@@ -361,6 +376,11 @@ enum batadv_nl_commands {
 */
BATADV_CMD_GET_BLA_BACKBONE,
 
+   /**
+* @BATADV_CMD_GET_DAT_CACHE: Query list of DAT cache entries
+*/
+   BATADV_CMD_GET_DAT_CACHE,
+
/* add new commands above here */
 
/**
diff --git a/net/batman-adv/distributed-arp-table.c 
b/net/batman-adv/distributed-arp-table.c
index 4469dcc1558f..75dda9454ccf 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -43,13 +44,19 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 
 #include "bridge_loop_avoidance.h"
 #include "hard-interface.h"
 #include "hash.h"
 #include "log.h"
+#include "netlink.h"
 #include "originator.h"
 #include "send.h"
+#include "soft-interface.h"
 #include "translation-table.h"
 #include "tvlv.h"
 
@@ -852,6 +859,151 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, 
void *offset)
 #endif
 
 /**
+ * batadv_dat_cache_dump_entry() - dump one entry of the DAT cache table to a
+ *  netlink socket
+ * @msg: buffer for the message
+ * @portid: netlink port
+ * @seq: Sequence number of netlink message
+ * @dat_entry: entry to dump
+ *
+ * Return: 0 or error code.
+ */
+static int
+batadv_dat_cache_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
+   struct batadv_dat_entry *dat_entry)
+{
+   int msecs;
+   void *hdr;
+
+   hdr = genlmsg_put(msg, portid, seq, _netlink_family,
+ NLM_F_MULTI, BATADV_CMD_GET_DAT_CACHE);
+   if (!hdr)
+   return -ENOBUFS;
+
+   msecs = jiffies_to_msecs(jiffies - dat_entry->last_update);
+
+   if (nla_put_in_addr(msg, BATADV_ATTR_DAT_CACHE_IP4ADDRESS,
+   dat_entry->ip) ||
+   nla_put(msg, BATADV_ATTR_DAT_CACHE_HWADDRESS, ETH_ALEN,
+   dat_entry->mac_addr) ||
+   nla_put_u16(msg, BATADV_ATTR_DAT_CACHE_VID, dat_entry->vid) ||
+   nla_put_u32(msg, BATADV_ATTR_LAST_SEEN_MSECS, msecs)) {
+   genlmsg_cancel(msg, hdr);
+   return -EMSGSIZE;
+   }
+
+   genlmsg_end(msg, hdr);
+   return 0;
+}
+
+/**
+ * batadv_dat_cache_dump_bucket() - dump one bucket of the DAT cache table to
+ *  a netlink socket
+ * @msg: buffer for the message
+ * @portid: netlink port
+ * @seq: Sequence number of netlink message
+ * @head: bucket to dump
+ * @idx_skip: How many entries to skip
+ *
+ * Return: 0 or error code.
+ */
+static int
+batadv_dat_cache_dump_bucket(struct sk_buff *msg, u32 portid, u32 seq,
+struct hlist_head *head, int *idx_skip)
+{
+   struct batadv_dat_entry *dat_entry;
+   int idx = 0;
+
+   rcu_read_lock();
+   hlist_for_each_entry_rcu(dat_entry, head, hash_entry) {
+   if (idx < *idx_skip)
+   goto skip;
+
+   if (batadv_dat_cache_dump_entry(msg, portid, seq,
+   dat_entry)) {
+   rcu_read_unlock();
+   *idx_skip = idx;
+
+   return -EMSGSIZE;
+   }
+
+skip:
+   idx++;
+   }
+   rcu_read_unlock();
+
+   return 0;
+}
+
+/**
+ * batadv_dat_cache_dump() - dump DAT cache table to a netlink socket
+ * @msg: buffer for the message
+ * @cb: callback structure containing arguments
+ *
+ * Return: message lengt

[PATCH 1/3] batman-adv: Avoid redundant multicast TT entries

2018-03-19 Thread Simon Wunderlich
From: Linus Lüssing <linus.luess...@c0d3.blue>

If a node signals that it wants all traffic for a specific protocol
family then there is no need to announce individual multicast addresses
via TT.

Signed-off-by: Linus Lüssing <linus.luess...@c0d3.blue>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/multicast.c | 56 ++
 1 file changed, 52 insertions(+), 4 deletions(-)

diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index 6eaffe50335a..c7a1305ca7e7 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -102,7 +102,36 @@ static struct net_device *batadv_mcast_get_bridge(struct 
net_device *soft_iface)
 }
 
 /**
+ * batadv_mcast_addr_is_ipv4() - check if multicast MAC is IPv4
+ * @addr: the MAC address to check
+ *
+ * Return: True, if MAC address is one reserved for IPv4 multicast, false
+ * otherwise.
+ */
+static bool batadv_mcast_addr_is_ipv4(const u8 *addr)
+{
+   static const u8 prefix[] = {0x01, 0x00, 0x5E};
+
+   return memcmp(prefix, addr, sizeof(prefix)) == 0;
+}
+
+/**
+ * batadv_mcast_addr_is_ipv6() - check if multicast MAC is IPv6
+ * @addr: the MAC address to check
+ *
+ * Return: True, if MAC address is one reserved for IPv6 multicast, false
+ * otherwise.
+ */
+static bool batadv_mcast_addr_is_ipv6(const u8 *addr)
+{
+   static const u8 prefix[] = {0x33, 0x33};
+
+   return memcmp(prefix, addr, sizeof(prefix)) == 0;
+}
+
+/**
  * batadv_mcast_mla_softif_get() - get softif multicast listeners
+ * @bat_priv: the bat priv with all the soft interface information
  * @dev: the device to collect multicast addresses from
  * @mcast_list: a list to put found addresses into
  *
@@ -119,9 +148,12 @@ static struct net_device *batadv_mcast_get_bridge(struct 
net_device *soft_iface)
  * Return: -ENOMEM on memory allocation error or the number of
  * items added to the mcast_list otherwise.
  */
-static int batadv_mcast_mla_softif_get(struct net_device *dev,
+static int batadv_mcast_mla_softif_get(struct batadv_priv *bat_priv,
+  struct net_device *dev,
   struct hlist_head *mcast_list)
 {
+   bool all_ipv4 = bat_priv->mcast.flags & BATADV_MCAST_WANT_ALL_IPV4;
+   bool all_ipv6 = bat_priv->mcast.flags & BATADV_MCAST_WANT_ALL_IPV6;
struct net_device *bridge = batadv_mcast_get_bridge(dev);
struct netdev_hw_addr *mc_list_entry;
struct batadv_hw_addr *new;
@@ -129,6 +161,12 @@ static int batadv_mcast_mla_softif_get(struct net_device 
*dev,
 
netif_addr_lock_bh(bridge ? bridge : dev);
netdev_for_each_mc_addr(mc_list_entry, bridge ? bridge : dev) {
+   if (all_ipv4 && batadv_mcast_addr_is_ipv4(mc_list_entry->addr))
+   continue;
+
+   if (all_ipv6 && batadv_mcast_addr_is_ipv6(mc_list_entry->addr))
+   continue;
+
new = kmalloc(sizeof(*new), GFP_ATOMIC);
if (!new) {
ret = -ENOMEM;
@@ -193,6 +231,7 @@ static void batadv_mcast_mla_br_addr_cpy(char *dst, const 
struct br_ip *src)
 
 /**
  * batadv_mcast_mla_bridge_get() - get bridged-in multicast listeners
+ * @bat_priv: the bat priv with all the soft interface information
  * @dev: a bridge slave whose bridge to collect multicast addresses from
  * @mcast_list: a list to put found addresses into
  *
@@ -204,10 +243,13 @@ static void batadv_mcast_mla_br_addr_cpy(char *dst, const 
struct br_ip *src)
  * Return: -ENOMEM on memory allocation error or the number of
  * items added to the mcast_list otherwise.
  */
-static int batadv_mcast_mla_bridge_get(struct net_device *dev,
+static int batadv_mcast_mla_bridge_get(struct batadv_priv *bat_priv,
+  struct net_device *dev,
   struct hlist_head *mcast_list)
 {
struct list_head bridge_mcast_list = LIST_HEAD_INIT(bridge_mcast_list);
+   bool all_ipv4 = bat_priv->mcast.flags & BATADV_MCAST_WANT_ALL_IPV4;
+   bool all_ipv6 = bat_priv->mcast.flags & BATADV_MCAST_WANT_ALL_IPV6;
struct br_ip_list *br_ip_entry, *tmp;
struct batadv_hw_addr *new;
u8 mcast_addr[ETH_ALEN];
@@ -221,6 +263,12 @@ static int batadv_mcast_mla_bridge_get(struct net_device 
*dev,
goto out;
 
list_for_each_entry(br_ip_entry, _mcast_list, list) {
+   if (all_ipv4 && br_ip_entry->addr.proto == htons(ETH_P_IP))
+   continue;
+
+   if (all_ipv6 && br_ip_entry->addr.proto == htons(ETH_P_IPV6))
+   continue;
+
batadv_mcast_mla_br_addr_cpy(mcast_addr, _ip_entry->addr);
if (batadv_mcast_mla_is_duplicate(mcast_addr, mcast_l

[PATCH 0/3] pull request for net-next: batman-adv 2018-03-19

2018-03-19 Thread Simon Wunderlich
Hi David,

here is another late feature/cleanup pull request of batman-adv to go into 
net-next.

Please pull or let me know of any problem!

Thank you,
  Simon

The following changes since commit a163dc22d515d17844435c8217ff66193d35b3fa:

  batman-adv: always assume 2-byte packet alignment (2018-02-27 13:02:54 +0100)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batadv-next-for-davem-20180319

for you to fetch changes up to 53dd9a68ba683986ec90497586f94b941bb748a0:

  batman-adv: add multicast flags netlink support (2018-03-14 10:15:34 +0100)


This feature/cleanup patchset includes the following patches:

 - avoid redundant multicast TT entries, by Linus Luessing

 - add netlink support for distributed arp table cache and multicast flags,
   by Linus Luessing (2 patches)


Linus Lüssing (3):
  batman-adv: Avoid redundant multicast TT entries
  batman-adv: add DAT cache netlink support
  batman-adv: add multicast flags netlink support

 include/uapi/linux/batman_adv.h|  82 +
 net/batman-adv/distributed-arp-table.c | 152 +
 net/batman-adv/distributed-arp-table.h |   8 +
 net/batman-adv/multicast.c | 293 -
 net/batman-adv/multicast.h |  18 ++
 net/batman-adv/netlink.c   |  88 ++
 6 files changed, 604 insertions(+), 37 deletions(-)


[PATCH 3/3] batman-adv: add multicast flags netlink support

2018-03-19 Thread Simon Wunderlich
From: Linus Lüssing <linus.luess...@c0d3.blue>

Dump the list of multicast flags entries via the netlink socket.

Signed-off-by: Linus Lüssing <linus.luess...@c0d3.blue>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 include/uapi/linux/batman_adv.h |  62 +++
 net/batman-adv/multicast.c  | 237 
 net/batman-adv/multicast.h  |  18 +++
 net/batman-adv/netlink.c|  12 ++
 4 files changed, 329 insertions(+)

diff --git a/include/uapi/linux/batman_adv.h b/include/uapi/linux/batman_adv.h
index 95ab5dbd09fa..324a0e1143e7 100644
--- a/include/uapi/linux/batman_adv.h
+++ b/include/uapi/linux/batman_adv.h
@@ -92,6 +92,53 @@ enum batadv_tt_client_flags {
 };
 
 /**
+ * enum batadv_mcast_flags_priv - Private, own multicast flags
+ *
+ * These are internal, multicast related flags. Currently they describe certain
+ * multicast related attributes of the segment this originator bridges into the
+ * mesh.
+ *
+ * Those attributes are used to determine the public multicast flags this
+ * originator is going to announce via TT.
+ *
+ * For netlink, if BATADV_MCAST_FLAGS_BRIDGED is unset then all querier
+ * related flags are undefined.
+ */
+enum batadv_mcast_flags_priv {
+   /**
+* @BATADV_MCAST_FLAGS_BRIDGED: There is a bridge on top of the mesh
+* interface.
+*/
+   BATADV_MCAST_FLAGS_BRIDGED  = (1 << 0),
+
+   /**
+* @BATADV_MCAST_FLAGS_QUERIER_IPV4_EXISTS: Whether an IGMP querier
+* exists in the mesh
+*/
+   BATADV_MCAST_FLAGS_QUERIER_IPV4_EXISTS  = (1 << 1),
+
+   /**
+* @BATADV_MCAST_FLAGS_QUERIER_IPV6_EXISTS: Whether an MLD querier
+* exists in the mesh
+*/
+   BATADV_MCAST_FLAGS_QUERIER_IPV6_EXISTS  = (1 << 2),
+
+   /**
+* @BATADV_MCAST_FLAGS_QUERIER_IPV4_SHADOWING: If an IGMP querier
+* exists, whether it is potentially shadowing multicast listeners
+* (i.e. querier is behind our own bridge segment)
+*/
+   BATADV_MCAST_FLAGS_QUERIER_IPV4_SHADOWING   = (1 << 3),
+
+   /**
+* @BATADV_MCAST_FLAGS_QUERIER_IPV6_SHADOWING: If an MLD querier
+* exists, whether it is potentially shadowing multicast listeners
+* (i.e. querier is behind our own bridge segment)
+*/
+   BATADV_MCAST_FLAGS_QUERIER_IPV6_SHADOWING   = (1 << 4),
+};
+
+/**
  * enum batadv_nl_attrs - batman-adv netlink attributes
  */
 enum batadv_nl_attrs {
@@ -287,6 +334,16 @@ enum batadv_nl_attrs {
 */
BATADV_ATTR_DAT_CACHE_VID,
 
+   /**
+* @BATADV_ATTR_MCAST_FLAGS: Per originator multicast flags
+*/
+   BATADV_ATTR_MCAST_FLAGS,
+
+   /**
+* @BATADV_ATTR_MCAST_FLAGS_PRIV: Private, own multicast flags
+*/
+   BATADV_ATTR_MCAST_FLAGS_PRIV,
+
/* add attributes above here, update the policy in netlink.c */
 
/**
@@ -381,6 +438,11 @@ enum batadv_nl_commands {
 */
BATADV_CMD_GET_DAT_CACHE,
 
+   /**
+* @BATADV_CMD_GET_MCAST_FLAGS: Query list of multicast flags
+*/
+   BATADV_CMD_GET_MCAST_FLAGS,
+
/* add new commands above here */
 
/**
diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index c7a1305ca7e7..5615b6abea6f 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -52,14 +53,20 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
+#include 
 
 #include "hard-interface.h"
 #include "hash.h"
 #include "log.h"
+#include "netlink.h"
+#include "soft-interface.h"
 #include "translation-table.h"
 #include "tvlv.h"
 
@@ -1334,6 +1341,236 @@ int batadv_mcast_flags_seq_print_text(struct seq_file 
*seq, void *offset)
 #endif
 
 /**
+ * batadv_mcast_mesh_info_put() - put multicast info into a netlink message
+ * @msg: buffer for the message
+ * @bat_priv: the bat priv with all the soft interface information
+ *
+ * Return: 0 or error code.
+ */
+int batadv_mcast_mesh_info_put(struct sk_buff *msg,
+  struct batadv_priv *bat_priv)
+{
+   u32 flags = bat_priv->mcast.flags;
+   u32 flags_priv = BATADV_NO_FLAGS;
+
+   if (bat_priv->mcast.bridged) {
+   flags_priv |= BATADV_MCAST_FLAGS_BRIDGED;
+
+   if (bat_priv->mcast.querier_ipv4.exists)
+   flags_priv |= BATADV_MCAST_FLAGS_QUERIER_IPV4_EXISTS;
+   if (bat_priv->mcast.querier_ipv6.exists)
+   flags_priv |= BATADV_MCAST_FLAGS_QUERIER_IPV6_EXISTS;
+   if (bat_priv->mcast.querier_ipv4.s

[PATCH 5/5] batman-adv: Fix skbuff rcsum on packet reroute

2018-03-19 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

batadv_check_unicast_ttvn may redirect a packet to itself or another
originator. This involves rewriting the ttvn and the destination address in
the batadv unicast header. These field were not yet pulled (with skb rcsum
update) and thus any change to them also requires a change in the receive
checksum.

Reported-by: Matthias Schiffer <mschif...@universe-factory.net>
Fixes: a73105b8d4c7 ("batman-adv: improved client announcement mechanism")
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/routing.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 6a9242658c8d..e61dc1293bb5 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -759,6 +759,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
 /**
  * batadv_reroute_unicast_packet() - update the unicast header for re-routing
  * @bat_priv: the bat priv with all the soft interface information
+ * @skb: unicast packet to process
  * @unicast_packet: the unicast header to be updated
  * @dst_addr: the payload destination
  * @vid: VLAN identifier
@@ -770,7 +771,7 @@ static int batadv_route_unicast_packet(struct sk_buff *skb,
  * Return: true if the packet header has been updated, false otherwise
  */
 static bool
-batadv_reroute_unicast_packet(struct batadv_priv *bat_priv,
+batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, struct sk_buff 
*skb,
  struct batadv_unicast_packet *unicast_packet,
  u8 *dst_addr, unsigned short vid)
 {
@@ -799,8 +800,10 @@ batadv_reroute_unicast_packet(struct batadv_priv *bat_priv,
}
 
/* update the packet header */
+   skb_postpull_rcsum(skb, unicast_packet, sizeof(*unicast_packet));
ether_addr_copy(unicast_packet->dest, orig_addr);
unicast_packet->ttvn = orig_ttvn;
+   skb_postpush_rcsum(skb, unicast_packet, sizeof(*unicast_packet));
 
ret = true;
 out:
@@ -841,7 +844,7 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv 
*bat_priv,
 * the packet to
 */
if (batadv_tt_local_client_is_roaming(bat_priv, ethhdr->h_dest, vid)) {
-   if (batadv_reroute_unicast_packet(bat_priv, unicast_packet,
+   if (batadv_reroute_unicast_packet(bat_priv, skb, unicast_packet,
  ethhdr->h_dest, vid))
batadv_dbg_ratelimited(BATADV_DBG_TT,
   bat_priv,
@@ -887,7 +890,7 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv 
*bat_priv,
 * destination can possibly be updated and forwarded towards the new
 * target host
 */
-   if (batadv_reroute_unicast_packet(bat_priv, unicast_packet,
+   if (batadv_reroute_unicast_packet(bat_priv, skb, unicast_packet,
  ethhdr->h_dest, vid)) {
batadv_dbg_ratelimited(BATADV_DBG_TT, bat_priv,
   "Rerouting unicast packet to %pM 
(dst=%pM): TTVN mismatch old_ttvn=%u new_ttvn=%u\n",
@@ -910,12 +913,14 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv 
*bat_priv,
if (!primary_if)
return false;
 
+   /* update the packet header */
+   skb_postpull_rcsum(skb, unicast_packet, sizeof(*unicast_packet));
ether_addr_copy(unicast_packet->dest, primary_if->net_dev->dev_addr);
+   unicast_packet->ttvn = curr_ttvn;
+   skb_postpush_rcsum(skb, unicast_packet, sizeof(*unicast_packet));
 
batadv_hardif_put(primary_if);
 
-   unicast_packet->ttvn = curr_ttvn;
-
return true;
 }
 
-- 
2.11.0



[PATCH 0/5] pull request for net: batman-adv 2018-03-19

2018-03-19 Thread Simon Wunderlich
Hi David,

here are some more bugfixes for net.

Please pull or let me know of any problem!

Thank you,
  Simon

The following changes since commit f22e08932c2960f29b5e828e745c9f3fb7c1bb86:

  batman-adv: Fix internal interface indices types (2018-02-25 20:19:34 +0100)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batadv-net-for-davem-20180319

for you to fetch changes up to fc04fdb2c8a894283259f5621d31d75610701091:

  batman-adv: Fix skbuff rcsum on packet reroute (2018-03-18 13:20:32 +0100)


Here are some batman-adv bugfixes:

 - fix possible IPv6 packet loss when multicast extension is used, by Linus 
Luessing

 - fix SKB handling issues for TTVN and DAT, by Matthias Schiffer (two patches)

 - fix include for eventpoll, by Sven Eckelmann

 - fix skb checksum for ttvn reroutes, by Sven Eckelmann


Linus Lüssing (1):
  batman-adv: Fix multicast packet loss with a single WANT_ALL_IPV4/6 flag

Matthias Schiffer (2):
  batman-adv: update data pointers after skb_cow()
  batman-adv: fix header size check in batadv_dbg_arp()

Sven Eckelmann (2):
  batman-adv: Add missing include for EPOLL* constants
  batman-adv: Fix skbuff rcsum on packet reroute

 net/batman-adv/distributed-arp-table.c |  2 +-
 net/batman-adv/icmp_socket.c   |  1 +
 net/batman-adv/log.c   |  1 +
 net/batman-adv/multicast.c |  4 ++--
 net/batman-adv/routing.c   | 25 +++--
 5 files changed, 20 insertions(+), 13 deletions(-)


[PATCH 4/5] batman-adv: Add missing include for EPOLL* constants

2018-03-19 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

Fixes: a9a08845e9ac ("vfs: do bulk POLL* -> EPOLL* replacement")
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/icmp_socket.c | 1 +
 net/batman-adv/log.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c
index e91f29c7c638..5daa3d50da17 100644
--- a/net/batman-adv/icmp_socket.c
+++ b/net/batman-adv/icmp_socket.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/log.c b/net/batman-adv/log.c
index dc9fa37ddd14..cdbe0e5e208b 100644
--- a/net/batman-adv/log.c
+++ b/net/batman-adv/log.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.11.0



[PATCH 1/5] batman-adv: Fix multicast packet loss with a single WANT_ALL_IPV4/6 flag

2018-03-19 Thread Simon Wunderlich
From: Linus Lüssing <linus.luess...@c0d3.blue>

As the kernel doc describes too the code is supposed to skip adding
multicast TT entries if both the WANT_ALL_IPV4 and WANT_ALL_IPV6 flags
are present.

Unfortunately, the current code even skips adding multicast TT entries
if only either the WANT_ALL_IPV4 or WANT_ALL_IPV6 is present.

This could lead to IPv6 multicast packet loss if only an IGMP but not an
MLD querier is present for instance or vice versa.

Fixes: 687937ab3489 ("batman-adv: Add multicast optimization support for 
bridged setups")
Signed-off-by: Linus Lüssing <linus.luess...@c0d3.blue>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/multicast.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index cbdeb47ec3f6..d70640135e3a 100644
--- a/net/batman-adv/multicast.c
+++ b/net/batman-adv/multicast.c
@@ -543,8 +543,8 @@ static bool batadv_mcast_mla_tvlv_update(struct batadv_priv 
*bat_priv)
bat_priv->mcast.enabled = true;
}
 
-   return !(mcast_data.flags &
-(BATADV_MCAST_WANT_ALL_IPV4 | BATADV_MCAST_WANT_ALL_IPV6));
+   return !(mcast_data.flags & BATADV_MCAST_WANT_ALL_IPV4 &&
+mcast_data.flags & BATADV_MCAST_WANT_ALL_IPV6);
 }
 
 /**
-- 
2.11.0



[PATCH 3/5] batman-adv: fix header size check in batadv_dbg_arp()

2018-03-19 Thread Simon Wunderlich
From: Matthias Schiffer <mschif...@universe-factory.net>

Checking for 0 is insufficient: when an SKB without a batadv header, but
with a VLAN header is received, hdr_size will be 4, making the following
code interpret the Ethernet header as a batadv header.

Fixes: be1db4f6615b ("batman-adv: make the Distributed ARP Table vlan aware")
Signed-off-by: Matthias Schiffer <mschif...@universe-factory.net>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/distributed-arp-table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/distributed-arp-table.c 
b/net/batman-adv/distributed-arp-table.c
index 9703c791ffc5..87cd962d28d5 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -393,7 +393,7 @@ static void batadv_dbg_arp(struct batadv_priv *bat_priv, 
struct sk_buff *skb,
   batadv_arp_hw_src(skb, hdr_size), _src,
   batadv_arp_hw_dst(skb, hdr_size), _dst);
 
-   if (hdr_size == 0)
+   if (hdr_size < sizeof(struct batadv_unicast_packet))
return;
 
unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
-- 
2.11.0



[PATCH 2/5] batman-adv: update data pointers after skb_cow()

2018-03-19 Thread Simon Wunderlich
From: Matthias Schiffer <mschif...@universe-factory.net>

batadv_check_unicast_ttvn() calls skb_cow(), so pointers into the SKB data
must be (re)set after calling it. The ethhdr variable is dropped
altogether.

Fixes: 7cdcf6dddc42 ("batman-adv: add UNICAST_4ADDR packet type")
Signed-off-by: Matthias Schiffer <mschif...@universe-factory.net>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/routing.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index b6891e8b741c..6a9242658c8d 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -968,14 +968,10 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
struct batadv_orig_node *orig_node = NULL, *orig_node_gw = NULL;
int check, hdr_size = sizeof(*unicast_packet);
enum batadv_subtype subtype;
-   struct ethhdr *ethhdr;
int ret = NET_RX_DROP;
bool is4addr, is_gw;
 
unicast_packet = (struct batadv_unicast_packet *)skb->data;
-   unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data;
-   ethhdr = eth_hdr(skb);
-
is4addr = unicast_packet->packet_type == BATADV_UNICAST_4ADDR;
/* the caller function should have already pulled 2 bytes */
if (is4addr)
@@ -995,12 +991,14 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size))
goto free_skb;
 
+   unicast_packet = (struct batadv_unicast_packet *)skb->data;
+
/* packet for me */
if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) {
/* If this is a unicast packet from another backgone gw,
 * drop it.
 */
-   orig_addr_gw = ethhdr->h_source;
+   orig_addr_gw = eth_hdr(skb)->h_source;
orig_node_gw = batadv_orig_hash_find(bat_priv, orig_addr_gw);
if (orig_node_gw) {
is_gw = batadv_bla_is_backbone_gw(skb, orig_node_gw,
@@ -1015,6 +1013,8 @@ int batadv_recv_unicast_packet(struct sk_buff *skb,
}
 
if (is4addr) {
+   unicast_4addr_packet =
+   (struct batadv_unicast_4addr_packet *)skb->data;
subtype = unicast_4addr_packet->subtype;
batadv_dat_inc_counter(bat_priv, subtype);
 
-- 
2.11.0



[PATCH 3/7] batman-adv: Ignore invalid batadv_iv_gw during netlink send

2018-03-02 Thread Simon Wunderlich
From: Sven Eckelmann <sven.eckelm...@openmesh.com>

The function batadv_iv_gw_dump stops the processing loop when
batadv_iv_gw_dump_entry returns a non-0 return code. This should only
happen when the buffer is full. Otherwise, an empty message may be
returned by batadv_gw_dump. This empty message will then stop the netlink
dumping of gateway entries. At worst, not a single entry is returned to
userspace even when plenty of possible gateways exist.

Fixes: efb766af06e3 ("batman-adv: add B.A.T.M.A.N. IV bat_gw_dump 
implementations")
Signed-off-by: Sven Eckelmann <sven.eckelm...@openmesh.com>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_iv_ogm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 79e326383726..8f64439647e3 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -2729,7 +2729,7 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, 
u32 portid, u32 seq,
struct batadv_neigh_ifinfo *router_ifinfo = NULL;
struct batadv_neigh_node *router;
struct batadv_gw_node *curr_gw;
-   int ret = -EINVAL;
+   int ret = 0;
void *hdr;
 
router = batadv_orig_router_get(gw_node->orig_node, BATADV_IF_DEFAULT);
-- 
2.11.0



[PATCH 7/7] batman-adv: Fix internal interface indices types

2018-03-02 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

batman-adv uses internal indices for each enabled and active interface.
It is currently used by the B.A.T.M.A.N. IV algorithm to identifify the
correct position in the ogm_cnt bitmaps.

The type for the number of enabled interfaces (which defines the next
interface index) was set to char. This type can be (depending on the
architecture) either signed (limiting batman-adv to 127 active slave
interfaces) or unsigned (limiting batman-adv to 255 active slave
interfaces).

This limit was not correctly checked when an interface was enabled and thus
an overflow happened. This was only catched on systems with the signed char
type when the B.A.T.M.A.N. IV code tried to resize its counter arrays with
a negative size.

The if_num interface index was only a s16 and therefore significantly
smaller than the ifindex (int) used by the code net code.

Both _hard_iface->if_num and _priv->num_ifaces must be
(unsigned) int to support the same number of slave interfaces as the net
core code. And the interface activation code must check the number of
active slave interfaces to avoid integer overflows.

Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_iv_ogm.c | 24 ++--
 net/batman-adv/hard-interface.c |  9 +++--
 net/batman-adv/originator.c |  4 ++--
 net/batman-adv/originator.h |  4 ++--
 net/batman-adv/types.h  | 11 ++-
 5 files changed, 31 insertions(+), 21 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 8f64439647e3..99abeadf416e 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -157,7 +157,7 @@ static void batadv_iv_ogm_orig_free(struct batadv_orig_node 
*orig_node)
  * Return: 0 on success, a negative error code otherwise.
  */
 static int batadv_iv_ogm_orig_add_if(struct batadv_orig_node *orig_node,
-int max_if_num)
+unsigned int max_if_num)
 {
void *data_ptr;
size_t old_size;
@@ -201,7 +201,8 @@ static int batadv_iv_ogm_orig_add_if(struct 
batadv_orig_node *orig_node,
  */
 static void
 batadv_iv_ogm_drop_bcast_own_entry(struct batadv_orig_node *orig_node,
-  int max_if_num, int del_if_num)
+  unsigned int max_if_num,
+  unsigned int del_if_num)
 {
size_t chunk_size;
size_t if_offset;
@@ -239,7 +240,8 @@ batadv_iv_ogm_drop_bcast_own_entry(struct batadv_orig_node 
*orig_node,
  */
 static void
 batadv_iv_ogm_drop_bcast_own_sum_entry(struct batadv_orig_node *orig_node,
-  int max_if_num, int del_if_num)
+  unsigned int max_if_num,
+  unsigned int del_if_num)
 {
size_t if_offset;
void *data_ptr;
@@ -276,7 +278,8 @@ batadv_iv_ogm_drop_bcast_own_sum_entry(struct 
batadv_orig_node *orig_node,
  * Return: 0 on success, a negative error code otherwise.
  */
 static int batadv_iv_ogm_orig_del_if(struct batadv_orig_node *orig_node,
-int max_if_num, int del_if_num)
+unsigned int max_if_num,
+unsigned int del_if_num)
 {
spin_lock_bh(_node->bat_iv.ogm_cnt_lock);
 
@@ -311,7 +314,8 @@ static struct batadv_orig_node *
 batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const u8 *addr)
 {
struct batadv_orig_node *orig_node;
-   int size, hash_added;
+   int hash_added;
+   size_t size;
 
orig_node = batadv_orig_hash_find(bat_priv, addr);
if (orig_node)
@@ -893,7 +897,7 @@ batadv_iv_ogm_slide_own_bcast_window(struct 
batadv_hard_iface *hard_iface)
u32 i;
size_t word_index;
u8 *w;
-   int if_num;
+   unsigned int if_num;
 
for (i = 0; i < hash->size; i++) {
head = >table[i];
@@ -1023,7 +1027,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
struct batadv_neigh_node *tmp_neigh_node = NULL;
struct batadv_neigh_node *router = NULL;
struct batadv_orig_node *orig_node_tmp;
-   int if_num;
+   unsigned int if_num;
u8 sum_orig, sum_neigh;
u8 *neigh_addr;
u8 tq_avg;
@@ -1182,7 +1186,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node 
*orig_node,
u8 total_count;
u8 orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own;
unsigned int neigh_rq_inv_cube, neigh_rq_max_cube;
-   int if_num;
+   unsigned int if_num;
unsigned int tq_asym_penalty, inv_asym_penalty;
unsigned int combined_tq;
unsigned int tq_iface_penalty;
@@ -1702,9 +1706,9 @@ 

[PATCH 1/7] batman-adv: fix packet checksum in receive path

2018-03-02 Thread Simon Wunderlich
From: Matthias Schiffer <mschif...@universe-factory.net>

eth_type_trans() internally calls skb_pull(), which does not adjust the
skb checksum; skb_postpull_rcsum() is necessary to avoid log spam of the
form "bat0: hw csum failure" when packets with CHECKSUM_COMPLETE are
received.

Note that in usual setups, packets don't reach batman-adv with
CHECKSUM_COMPLETE (I assume NICs bail out of checksumming when they see
batadv's ethtype?), which is why the log messages do not occur on every
system using batman-adv. I could reproduce this issue by stacking
batman-adv on top of a VXLAN interface.

Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
Tested-by: Maximilian Wilhelm <max@sdn.clinic>
Signed-off-by: Matthias Schiffer <mschif...@universe-factory.net>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/soft-interface.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 900c5ce21cd4..367a81fb785f 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -459,13 +459,7 @@ void batadv_interface_rx(struct net_device *soft_iface,
 
/* skb->dev & skb->pkt_type are set here */
skb->protocol = eth_type_trans(skb, soft_iface);
-
-   /* should not be necessary anymore as we use skb_pull_rcsum()
-* TODO: please verify this and remove this TODO
-* -- Dec 21st 2009, Simon Wunderlich
-*/
-
-   /* skb->ip_summed = CHECKSUM_UNNECESSARY; */
+   skb_postpull_rcsum(skb, eth_hdr(skb), ETH_HLEN);
 
batadv_inc_counter(bat_priv, BATADV_CNT_RX);
batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES,
-- 
2.11.0



[PATCH 2/7] batman-adv: invalidate checksum on fragment reassembly

2018-03-02 Thread Simon Wunderlich
From: Matthias Schiffer <mschif...@universe-factory.net>

A more sophisticated implementation could try to combine fragment checksums
when all fragments have CHECKSUM_COMPLETE and are split at even offsets.
For now, we just set ip_summed to CHECKSUM_NONE to avoid "hw csum failure"
warnings in the kernel log when fragmented frames are received. In
consequence, skb_pull_rcsum() can be replaced with skb_pull().

Note that in usual setups, packets don't reach batman-adv with
CHECKSUM_COMPLETE (I assume NICs bail out of checksumming when they see
batadv's ethtype?), which is why the log messages do not occur on every
system using batman-adv. I could reproduce this issue by stacking
batman-adv on top of a VXLAN interface.

Fixes: 610bfc6bc99b ("batman-adv: Receive fragmented packets and merge")
Tested-by: Maximilian Wilhelm <max@sdn.clinic>
Signed-off-by: Matthias Schiffer <mschif...@universe-factory.net>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/fragmentation.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index 22dde42fd80e..5afe641ee4b0 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -288,7 +288,8 @@ batadv_frag_merge_packets(struct hlist_head *chain)
/* Move the existing MAC header to just before the payload. (Override
 * the fragment header.)
 */
-   skb_pull_rcsum(skb_out, hdr_size);
+   skb_pull(skb_out, hdr_size);
+   skb_out->ip_summed = CHECKSUM_NONE;
memmove(skb_out->data - ETH_HLEN, skb_mac_header(skb_out), ETH_HLEN);
skb_set_mac_header(skb_out, -ETH_HLEN);
skb_reset_network_header(skb_out);
-- 
2.11.0



[PATCH 0/7] pull request for net: batman-adv 2018-03-02

2018-03-02 Thread Simon Wunderlich
Hi David,

here are some bugfixes which we would like to see integrated into net.

Please pull or let me know of any problem!

Thank you,
  Simon

The following changes since commit 7928b2cbe55b2a410a0f5c1f154610059c57b1b2:

  Linux 4.16-rc1 (2018-02-11 15:04:29 -0800)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batadv-net-for-davem-20180302

for you to fetch changes up to f22e08932c2960f29b5e828e745c9f3fb7c1bb86:

  batman-adv: Fix internal interface indices types (2018-02-25 20:19:34 +0100)


Here are some batman-adv bugfixes:

 - fix skb checksum issues, by Matthias Schiffer (2 patches)

 - fix exception handling when dumping data objects through netlink,
   by Sven Eckelmann (4 patches)

 - fix handling of interface indices, by Sven Eckelmann


Matthias Schiffer (2):
  batman-adv: fix packet checksum in receive path
  batman-adv: invalidate checksum on fragment reassembly

Sven Eckelmann (5):
  batman-adv: Ignore invalid batadv_iv_gw during netlink send
  batman-adv: Ignore invalid batadv_v_gw during netlink send
  batman-adv: Fix netlink dumping of BLA claims
  batman-adv: Fix netlink dumping of BLA backbones
  batman-adv: Fix internal interface indices types

 net/batman-adv/bat_iv_ogm.c| 26 +++---
 net/batman-adv/bat_v.c |  2 +-
 net/batman-adv/bridge_loop_avoidance.c | 22 ++
 net/batman-adv/fragmentation.c |  3 ++-
 net/batman-adv/hard-interface.c|  9 +++--
 net/batman-adv/originator.c|  4 ++--
 net/batman-adv/originator.h|  4 ++--
 net/batman-adv/soft-interface.c|  8 +---
 net/batman-adv/types.h | 11 ++-
 9 files changed, 50 insertions(+), 39 deletions(-)


[PATCH 4/7] batman-adv: Ignore invalid batadv_v_gw during netlink send

2018-03-02 Thread Simon Wunderlich
From: Sven Eckelmann <sven.eckelm...@openmesh.com>

The function batadv_v_gw_dump stops the processing loop when
batadv_v_gw_dump_entry returns a non-0 return code. This should only
happen when the buffer is full. Otherwise, an empty message may be
returned by batadv_gw_dump. This empty message will then stop the netlink
dumping of gateway entries. At worst, not a single entry is returned to
userspace even when plenty of possible gateways exist.

Fixes: b71bb6f924fe ("batman-adv: add B.A.T.M.A.N. V bat_gw_dump 
implementations")
Signed-off-by: Sven Eckelmann <sven.eckelm...@openmesh.com>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_v.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index 27e165ac9302..c74f81341dab 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -928,7 +928,7 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 
portid, u32 seq,
struct batadv_neigh_ifinfo *router_ifinfo = NULL;
struct batadv_neigh_node *router;
struct batadv_gw_node *curr_gw;
-   int ret = -EINVAL;
+   int ret = 0;
void *hdr;
 
router = batadv_orig_router_get(gw_node->orig_node, BATADV_IF_DEFAULT);
-- 
2.11.0



[PATCH 6/7] batman-adv: Fix netlink dumping of BLA backbones

2018-03-02 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The function batadv_bla_backbone_dump_bucket must be able to handle
non-complete dumps of a single bucket. It tries to do that by saving the
latest dumped index in *idx_skip to inform the caller about the current
state.

But the caller only assumes that buckets were not completely dumped when
the return code is non-zero. This function must therefore also return a
non-zero index when the dumping of an entry failed. Otherwise the caller
will just skip all remaining buckets.

And the function must also reset *idx_skip back to zero when it finished a
bucket. Otherwise it will skip the same number of entries in the next
bucket as the previous one had.

Fixes: ea4152e11716 ("batman-adv: add backbone table netlink support")
Reported-by: Linus Lüssing <linus.luess...@c0d3.blue>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bridge_loop_avoidance.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/batman-adv/bridge_loop_avoidance.c 
b/net/batman-adv/bridge_loop_avoidance.c
index 20b548ea5a0a..b1a08374088b 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -2394,22 +2394,25 @@ batadv_bla_backbone_dump_bucket(struct sk_buff *msg, 
u32 portid, u32 seq,
 {
struct batadv_bla_backbone_gw *backbone_gw;
int idx = 0;
+   int ret = 0;
 
rcu_read_lock();
hlist_for_each_entry_rcu(backbone_gw, head, hash_entry) {
if (idx++ < *idx_skip)
continue;
-   if (batadv_bla_backbone_dump_entry(msg, portid, seq,
-  primary_if, backbone_gw)) {
+
+   ret = batadv_bla_backbone_dump_entry(msg, portid, seq,
+primary_if, backbone_gw);
+   if (ret) {
*idx_skip = idx - 1;
goto unlock;
}
}
 
-   *idx_skip = idx;
+   *idx_skip = 0;
 unlock:
rcu_read_unlock();
-   return 0;
+   return ret;
 }
 
 /**
-- 
2.11.0



[PATCH 5/7] batman-adv: Fix netlink dumping of BLA claims

2018-03-02 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The function batadv_bla_claim_dump_bucket must be able to handle
non-complete dumps of a single bucket. It tries to do that by saving the
latest dumped index in *idx_skip to inform the caller about the current
state.

But the caller only assumes that buckets were not completely dumped when
the return code is non-zero. This function must therefore also return a
non-zero index when the dumping of an entry failed. Otherwise the caller
will just skip all remaining buckets.

And the function must also reset *idx_skip back to zero when it finished a
bucket. Otherwise it will skip the same number of entries in the next
bucket as the previous one had.

Fixes: 04f3f5bf1883 ("batman-adv: add B.A.T.M.A.N. Dump BLA claims via netlink")
Reported-by: Linus Lüssing <linus.luess...@c0d3.blue>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bridge_loop_avoidance.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/batman-adv/bridge_loop_avoidance.c 
b/net/batman-adv/bridge_loop_avoidance.c
index fad47853ad3c..20b548ea5a0a 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -2161,22 +2161,25 @@ batadv_bla_claim_dump_bucket(struct sk_buff *msg, u32 
portid, u32 seq,
 {
struct batadv_bla_claim *claim;
int idx = 0;
+   int ret = 0;
 
rcu_read_lock();
hlist_for_each_entry_rcu(claim, head, hash_entry) {
if (idx++ < *idx_skip)
continue;
-   if (batadv_bla_claim_dump_entry(msg, portid, seq,
-   primary_if, claim)) {
+
+   ret = batadv_bla_claim_dump_entry(msg, portid, seq,
+ primary_if, claim);
+   if (ret) {
*idx_skip = idx - 1;
goto unlock;
}
}
 
-   *idx_skip = idx;
+   *idx_skip = 0;
 unlock:
rcu_read_unlock();
-   return 0;
+   return ret;
 }
 
 /**
-- 
2.11.0



[PATCH 2/5] batman-adv: Update copyright years for 2018

2018-03-02 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 include/uapi/linux/batadv_packet.h | 2 +-
 include/uapi/linux/batman_adv.h| 2 +-
 net/batman-adv/Kconfig | 2 +-
 net/batman-adv/Makefile| 2 +-
 net/batman-adv/bat_algo.c  | 2 +-
 net/batman-adv/bat_algo.h  | 2 +-
 net/batman-adv/bat_iv_ogm.c| 2 +-
 net/batman-adv/bat_iv_ogm.h| 2 +-
 net/batman-adv/bat_v.c | 2 +-
 net/batman-adv/bat_v.h | 2 +-
 net/batman-adv/bat_v_elp.c | 2 +-
 net/batman-adv/bat_v_elp.h | 2 +-
 net/batman-adv/bat_v_ogm.c | 2 +-
 net/batman-adv/bat_v_ogm.h | 2 +-
 net/batman-adv/bitarray.c  | 2 +-
 net/batman-adv/bitarray.h  | 2 +-
 net/batman-adv/bridge_loop_avoidance.c | 2 +-
 net/batman-adv/bridge_loop_avoidance.h | 2 +-
 net/batman-adv/debugfs.c   | 2 +-
 net/batman-adv/debugfs.h   | 2 +-
 net/batman-adv/distributed-arp-table.c | 2 +-
 net/batman-adv/distributed-arp-table.h | 2 +-
 net/batman-adv/fragmentation.c | 2 +-
 net/batman-adv/fragmentation.h | 2 +-
 net/batman-adv/gateway_client.c| 2 +-
 net/batman-adv/gateway_client.h| 2 +-
 net/batman-adv/gateway_common.c| 2 +-
 net/batman-adv/gateway_common.h| 2 +-
 net/batman-adv/hard-interface.c| 2 +-
 net/batman-adv/hard-interface.h| 2 +-
 net/batman-adv/hash.c  | 2 +-
 net/batman-adv/hash.h  | 2 +-
 net/batman-adv/icmp_socket.c   | 2 +-
 net/batman-adv/icmp_socket.h   | 2 +-
 net/batman-adv/log.c   | 2 +-
 net/batman-adv/log.h   | 2 +-
 net/batman-adv/main.c  | 2 +-
 net/batman-adv/main.h  | 2 +-
 net/batman-adv/multicast.c | 2 +-
 net/batman-adv/multicast.h | 2 +-
 net/batman-adv/netlink.c   | 2 +-
 net/batman-adv/netlink.h   | 2 +-
 net/batman-adv/network-coding.c| 2 +-
 net/batman-adv/network-coding.h| 2 +-
 net/batman-adv/originator.c| 2 +-
 net/batman-adv/originator.h| 2 +-
 net/batman-adv/routing.c   | 2 +-
 net/batman-adv/routing.h   | 2 +-
 net/batman-adv/send.c  | 2 +-
 net/batman-adv/send.h  | 2 +-
 net/batman-adv/soft-interface.c| 2 +-
 net/batman-adv/soft-interface.h| 2 +-
 net/batman-adv/sysfs.c | 2 +-
 net/batman-adv/sysfs.h | 2 +-
 net/batman-adv/tp_meter.c  | 2 +-
 net/batman-adv/tp_meter.h  | 2 +-
 net/batman-adv/translation-table.c | 2 +-
 net/batman-adv/translation-table.h | 2 +-
 net/batman-adv/tvlv.c  | 2 +-
 net/batman-adv/tvlv.h  | 2 +-
 net/batman-adv/types.h | 2 +-
 61 files changed, 61 insertions(+), 61 deletions(-)

diff --git a/include/uapi/linux/batadv_packet.h 
b/include/uapi/linux/batadv_packet.h
index 5cb360be2a11..daefd7283896 100644
--- a/include/uapi/linux/batadv_packet.h
+++ b/include/uapi/linux/batadv_packet.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) */
-/* Copyright (C) 2007-2017  B.A.T.M.A.N. contributors:
+/* Copyright (C) 2007-2018  B.A.T.M.A.N. contributors:
  *
  * Marek Lindner, Simon Wunderlich
  *
diff --git a/include/uapi/linux/batman_adv.h b/include/uapi/linux/batman_adv.h
index ae00c99cbed0..56ae28934070 100644
--- a/include/uapi/linux/batman_adv.h
+++ b/include/uapi/linux/batman_adv.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: MIT */
-/* Copyright (C) 2016-2017  B.A.T.M.A.N. contributors:
+/* Copyright (C) 2016-2018  B.A.T.M.A.N. contributors:
  *
  * Matthias Schiffer
  *
diff --git a/net/batman-adv/Kconfig b/net/batman-adv/Kconfig
index c44f6515be5e..e4e2e02b7380 100644
--- a/net/batman-adv/Kconfig
+++ b/net/batman-adv/Kconfig
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-# Copyright (C) 2007-2017  B.A.T.M.A.N. contributors:
+# Copyright (C) 2007-2018  B.A.T.M.A.N. contributors:
 #
 # Marek Lindner, Simon Wunderlich
 #
diff --git a/net/batman-adv/Makefile b/net/batman-adv/Makefile
index 022f6e77307b..b97ba6fb8353 100644
--- a/net/batman-adv/Makefile
+++ b/net/batman-adv/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
-# Copyright (C) 2007-2017  B.A.T.M.A.N. contributors:
+# Copyright (C) 2007-2018  B.A.T.M.A.N. contributors:
 #
 # Marek Lindner, Simon Wunderlich
 #
diff --git a/net/batman-adv/bat_algo.c b/net/batman-adv/bat_algo.c
index 80c72c7d3cad..ea309ad06175 100644
--- a/net/batman-adv/bat_algo.c
+++ b/net/batman-adv/bat_algo.c
@@ -1,5 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
-/* Copyright (C) 2007-2017  B.A.T.M.A.N. contributors:
+/* Copyright (C) 2007-2018  B.A.T.M.A.N. contributors:
  *

[PATCH 0/5] pull request for net-next: batman-adv 2018-03-02

2018-03-02 Thread Simon Wunderlich
Hi David,

here is a little cleanup pull request of batman-adv to go into net-next.

Please pull or let me know of any problem!

Thank you,
  Simon

The following changes since commit 7928b2cbe55b2a410a0f5c1f154610059c57b1b2:

  Linux 4.16-rc1 (2018-02-11 15:04:29 -0800)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batadv-next-for-davem-20180302

for you to fetch changes up to a163dc22d515d17844435c8217ff66193d35b3fa:

  batman-adv: always assume 2-byte packet alignment (2018-02-27 13:02:54 +0100)


This cleanup patchset includes the following patches:

 - bump version strings, by Simon Wunderlich

 - bump copyright years, by Sven Eckelmann

 - fix macro indendation for checkpatch, by Sven Eckelmann

 - fix comparison operator for bool returning functions,
   by Sven Eckelmann

 - assume 2-byte packet alignments for all packet types,
   by Matthias Schiffer


Matthias Schiffer (1):
  batman-adv: always assume 2-byte packet alignment

Simon Wunderlich (1):
  batman-adv: Start new development cycle

Sven Eckelmann (3):
  batman-adv: Update copyright years for 2018
  batman-adv: Fix indentation of batadv_seq_before
  batman-adv: Avoid relation operator comparison with bool

 include/uapi/linux/batadv_packet.h | 15 +++
 include/uapi/linux/batman_adv.h|  2 +-
 net/batman-adv/Kconfig |  2 +-
 net/batman-adv/Makefile|  2 +-
 net/batman-adv/bat_algo.c  |  2 +-
 net/batman-adv/bat_algo.h  |  2 +-
 net/batman-adv/bat_iv_ogm.c|  2 +-
 net/batman-adv/bat_iv_ogm.h|  2 +-
 net/batman-adv/bat_v.c |  2 +-
 net/batman-adv/bat_v.h |  2 +-
 net/batman-adv/bat_v_elp.c |  2 +-
 net/batman-adv/bat_v_elp.h |  2 +-
 net/batman-adv/bat_v_ogm.c |  2 +-
 net/batman-adv/bat_v_ogm.h |  2 +-
 net/batman-adv/bitarray.c  |  2 +-
 net/batman-adv/bitarray.h  |  2 +-
 net/batman-adv/bridge_loop_avoidance.c |  2 +-
 net/batman-adv/bridge_loop_avoidance.h |  2 +-
 net/batman-adv/debugfs.c   |  2 +-
 net/batman-adv/debugfs.h   |  2 +-
 net/batman-adv/distributed-arp-table.c |  4 ++--
 net/batman-adv/distributed-arp-table.h |  2 +-
 net/batman-adv/fragmentation.c |  2 +-
 net/batman-adv/fragmentation.h |  2 +-
 net/batman-adv/gateway_client.c|  2 +-
 net/batman-adv/gateway_client.h|  2 +-
 net/batman-adv/gateway_common.c|  2 +-
 net/batman-adv/gateway_common.h|  2 +-
 net/batman-adv/hard-interface.c|  2 +-
 net/batman-adv/hard-interface.h|  2 +-
 net/batman-adv/hash.c  |  2 +-
 net/batman-adv/hash.h  |  2 +-
 net/batman-adv/icmp_socket.c   |  2 +-
 net/batman-adv/icmp_socket.h   |  2 +-
 net/batman-adv/log.c   |  2 +-
 net/batman-adv/log.h   |  2 +-
 net/batman-adv/main.c  |  2 +-
 net/batman-adv/main.h  | 16 +---
 net/batman-adv/multicast.c |  2 +-
 net/batman-adv/multicast.h |  2 +-
 net/batman-adv/netlink.c   |  2 +-
 net/batman-adv/netlink.h   |  2 +-
 net/batman-adv/network-coding.c|  2 +-
 net/batman-adv/network-coding.h|  2 +-
 net/batman-adv/originator.c|  2 +-
 net/batman-adv/originator.h|  2 +-
 net/batman-adv/routing.c   |  2 +-
 net/batman-adv/routing.h   |  2 +-
 net/batman-adv/send.c  |  2 +-
 net/batman-adv/send.h  |  2 +-
 net/batman-adv/soft-interface.c|  2 +-
 net/batman-adv/soft-interface.h|  2 +-
 net/batman-adv/sysfs.c |  2 +-
 net/batman-adv/sysfs.h |  2 +-
 net/batman-adv/tp_meter.c  |  2 +-
 net/batman-adv/tp_meter.h  |  2 +-
 net/batman-adv/translation-table.c |  2 +-
 net/batman-adv/translation-table.h |  2 +-
 net/batman-adv/tvlv.c  |  2 +-
 net/batman-adv/tvlv.h  |  2 +-
 net/batman-adv/types.h |  2 +-
 61 files changed, 72 insertions(+), 79 deletions(-)


[PATCH 3/5] batman-adv: Fix indentation of batadv_seq_before

2018-03-02 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

Also multiline macros should have their statements start on a tabstop. This
was detected by checkpatch.pl after commit a134f8de9f40 ("checkpatch:
improve the TABSTOP test to include declarations").

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/main.h | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index d5d65999207e..057a28a9fe88 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -331,11 +331,13 @@ static inline bool batadv_has_timed_out(unsigned long 
timestamp,
  *
  * Return: true when x is a predecessor of y, false otherwise
  */
-#define batadv_seq_before(x, y) ({typeof(x)_d1 = (x); \
-typeof(y)_d2 = (y); \
-typeof(x)_dummy = (_d1 - _d2); \
-(void)(&_d1 == &_d2); \
-_dummy > batadv_smallest_signed_int(_dummy); })
+#define batadv_seq_before(x, y) ({ \
+   typeof(x)_d1 = (x); \
+   typeof(y)_d2 = (y); \
+   typeof(x)_dummy = (_d1 - _d2); \
+   (void)(&_d1 == &_d2); \
+   _dummy > batadv_smallest_signed_int(_dummy); \
+})
 
 /**
  * batadv_seq_after() - Checks if a sequence number x is a successor of y
-- 
2.11.0



[PATCH 5/5] batman-adv: always assume 2-byte packet alignment

2018-03-02 Thread Simon Wunderlich
From: Matthias Schiffer <mschif...@universe-factory.net>

NIC drivers generally try to ensure that the "network header" is aligned
to a 4-byte boundary. This is not always possible: When Ethernet frames are
encapsulated in other packets with 4-byte aligned headers, the inner
Ethernet header will have 4-byte alignment, and in consequence, the inner
network header is aligned to 2, but not to 4 bytes.

Most parts of batman-adv only care about 2-byte alignment; in particular,
no unaligned accesses occur in performance-critical paths that handle
actual payload data. This is not true for OGM handling: the seqno and crc
fields are accessed as 32-bit values. To avoid these unaligned accesses,
this patch reduces the expected packet alignment to 2 bytes for all of
batadv's packet types.

As no unaligned accesses existed on the performance-critical paths anyways,
this chance does have any (positive or negative) effect on performance, but
it still makes sense to avoid these accesses to prevent log noise when
examining other unaligned accesses in the kernel while batman-adv is
active.

Signed-off-by: Matthias Schiffer <mschif...@universe-factory.net>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 include/uapi/linux/batadv_packet.h | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/include/uapi/linux/batadv_packet.h 
b/include/uapi/linux/batadv_packet.h
index daefd7283896..894d8d2f713d 100644
--- a/include/uapi/linux/batadv_packet.h
+++ b/include/uapi/linux/batadv_packet.h
@@ -196,8 +196,6 @@ struct batadv_bla_claim_dst {
__be16 group;   /* group id */
 };
 
-#pragma pack()
-
 /**
  * struct batadv_ogm_packet - ogm (routing protocol) packet
  * @packet_type: batman-adv packet type, part of the general header
@@ -222,9 +220,6 @@ struct batadv_ogm_packet {
__u8   reserved;
__u8   tq;
__be16 tvlv_len;
-   /* __packed is not needed as the struct size is divisible by 4,
-* and the largest data type in this struct has a size of 4.
-*/
 };
 
 #define BATADV_OGM_HLEN sizeof(struct batadv_ogm_packet)
@@ -249,9 +244,6 @@ struct batadv_ogm2_packet {
__u8   orig[ETH_ALEN];
__be16 tvlv_len;
__be32 throughput;
-   /* __packed is not needed as the struct size is divisible by 4,
-* and the largest data type in this struct has a size of 4.
-*/
 };
 
 #define BATADV_OGM2_HLEN sizeof(struct batadv_ogm2_packet)
@@ -405,7 +397,6 @@ struct batadv_icmp_packet_rr {
  * misalignment of the payload after the ethernet header. It may also lead to
  * leakage of information when the padding it not initialized before sending.
  */
-#pragma pack(2)
 
 /**
  * struct batadv_unicast_packet - unicast packet for network payload
@@ -533,8 +524,6 @@ struct batadv_coded_packet {
__be16 coded_len;
 };
 
-#pragma pack()
-
 /**
  * struct batadv_unicast_tvlv_packet - generic unicast packet with tvlv payload
  * @packet_type: batman-adv packet type, part of the general header
@@ -641,4 +630,6 @@ struct batadv_tvlv_mcast_data {
__u8 reserved[3];
 };
 
+#pragma pack()
+
 #endif /* _UAPI_LINUX_BATADV_PACKET_H_ */
-- 
2.11.0



[PATCH 4/5] batman-adv: Avoid relation operator comparison with bool

2018-03-02 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

commit 785ea1144182 ("batman-adv: Distributed ARP Table - create DHT helper
functions") introduced a return check of batadv_compare_eth which uses a
boolean return value since commit 16af73458aca ("batman-adv: main,
batadv_compare_eth return bool"). A relational (<, >, <= or >=) operator
is not the right one for such a check.

Reported-by: David Binderman <dcb...@hotmail.com>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Acked-by: Antonio Quartulli <a...@unstable.cc>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/distributed-arp-table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/distributed-arp-table.c 
b/net/batman-adv/distributed-arp-table.c
index 19b15de455ab..4469dcc1558f 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -495,7 +495,7 @@ static bool batadv_is_orig_node_eligible(struct 
batadv_dat_candidate *res,
 * the one with the lowest address
 */
if (tmp_max == max && max_orig_node &&
-   batadv_compare_eth(candidate->orig, max_orig_node->orig) > 0)
+   batadv_compare_eth(candidate->orig, max_orig_node->orig))
goto out;
 
ret = true;
-- 
2.11.0



[PATCH 1/5] batman-adv: Start new development cycle

2018-03-02 Thread Simon Wunderlich
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/main.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index f7ba3f96d8f3..69bfedfad174 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -25,7 +25,7 @@
 #define BATADV_DRIVER_DEVICE "batman-adv"
 
 #ifndef BATADV_SOURCE_VERSION
-#define BATADV_SOURCE_VERSION "2018.0"
+#define BATADV_SOURCE_VERSION "2018.1"
 #endif
 
 /* B.A.T.M.A.N. parameters */
-- 
2.11.0



[PATCH 07/19] batman-adv: include gfp.h for GFP_* defines

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The linux/gfp.h provides the GFP_ATOMIC and GFP_KERNEL define. It should
therefore be included instead of linux/fs.h.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_iv_ogm.c| 2 +-
 net/batman-adv/bat_v_elp.c | 2 +-
 net/batman-adv/bat_v_ogm.c | 2 +-
 net/batman-adv/bridge_loop_avoidance.c | 2 +-
 net/batman-adv/distributed-arp-table.c | 2 +-
 net/batman-adv/fragmentation.c | 2 +-
 net/batman-adv/gateway_client.c| 2 +-
 net/batman-adv/hard-interface.c| 2 +-
 net/batman-adv/hash.c  | 2 +-
 net/batman-adv/icmp_socket.c   | 1 +
 net/batman-adv/log.c   | 1 +
 net/batman-adv/main.c  | 2 +-
 net/batman-adv/multicast.c | 2 +-
 net/batman-adv/netlink.c   | 2 +-
 net/batman-adv/network-coding.c| 2 +-
 net/batman-adv/originator.c| 2 +-
 net/batman-adv/send.c  | 2 +-
 net/batman-adv/soft-interface.c| 2 +-
 net/batman-adv/sysfs.c | 2 +-
 net/batman-adv/tp_meter.c  | 2 +-
 net/batman-adv/translation-table.c | 2 +-
 net/batman-adv/tvlv.c  | 2 +-
 22 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index bff5ec66a2e1..27d9c8adf2ca 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index 8375fd679db3..92b56bb5686d 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -25,7 +25,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c
index 22d2bafa814a..7055a9483788 100644
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -23,7 +23,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/bridge_loop_avoidance.c 
b/net/batman-adv/bridge_loop_avoidance.c
index 007147f3ed9e..ce124a21fce5 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -25,7 +25,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/distributed-arp-table.c 
b/net/batman-adv/distributed-arp-table.c
index 3c2faf773335..f704bbc76e2a 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -24,7 +24,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index 22ce4c0c86c3..741c6b91664e 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -23,7 +23,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index e8db19940ab8..21db0165175b 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -23,7 +23,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 2f067a507fd5..394e69b77535 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -23,7 +23,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/hash.c b/net/batman-adv/hash.c
index a6dbaf2e9fc9..2ce0d5673f40 100644
--- a/net/batman-adv/hash.c
+++ b/net/batman-adv/hash.c
@@ -19,7 +19,7 @@
 #include "hash.h"
 #include "main.h"
 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c
index cc76f1365300..71ba58cc51fa 100644
--- a/net/batman-adv/icmp_socket.c
+++ b/net/batman-adv/icmp_socket.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/log.c b/net/batman-adv/log.c
index 148e64e846d2..6fbcdd40a332 100644
--- a/net/batman-adv/log.c
+++ b/net/batman-adv/log.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 5ce2007ea11b..0c3664aa6a58 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -23,8 +23,8 @@
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index 01546a42b7ad..d8617c2794db 100644
--- a/net/batman-adv/multic

[PATCH 19/19] batman-adv: Add kernel-doc to externally visible functions

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

According to the kernel-doc documentation, externally visible functions
should be documented. This refers to all all non-static function which can
(and will) be used by functions in other sources files.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_algo.c  | 27 
 net/batman-adv/bat_iv_ogm.c|  5 +
 net/batman-adv/debugfs.c   | 16 ++
 net/batman-adv/gateway_client.c| 38 +
 net/batman-adv/gateway_common.c|  9 
 net/batman-adv/hard-interface.c| 36 ++-
 net/batman-adv/hash.c  | 17 +--
 net/batman-adv/icmp_socket.c   |  9 
 net/batman-adv/log.c   | 17 +++
 net/batman-adv/main.c  | 31 +++
 net/batman-adv/originator.c| 43 ++
 net/batman-adv/routing.c   | 29 +
 net/batman-adv/send.c  | 18 
 net/batman-adv/soft-interface.c| 20 ++
 net/batman-adv/sysfs.c | 32 
 net/batman-adv/translation-table.c | 37 
 16 files changed, 381 insertions(+), 3 deletions(-)

diff --git a/net/batman-adv/bat_algo.c b/net/batman-adv/bat_algo.c
index aed7ced059df..80c72c7d3cad 100644
--- a/net/batman-adv/bat_algo.c
+++ b/net/batman-adv/bat_algo.c
@@ -61,6 +61,12 @@ static struct batadv_algo_ops *batadv_algo_get(char *name)
return bat_algo_ops;
 }
 
+/**
+ * batadv_algo_register() - Register callbacks for a mesh algorithm
+ * @bat_algo_ops: mesh algorithm callbacks to add
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
 int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops)
 {
struct batadv_algo_ops *bat_algo_ops_tmp;
@@ -90,6 +96,19 @@ int batadv_algo_register(struct batadv_algo_ops 
*bat_algo_ops)
return 0;
 }
 
+/**
+ * batadv_algo_select() - Select algorithm of soft interface
+ * @bat_priv: the bat priv with all the soft interface information
+ * @name: name of the algorithm to select
+ *
+ * The algorithm callbacks for the soft interface will be set when the 
algorithm
+ * with the correct name was found. Any previous selected algorithm will not be
+ * deinitialized and the new selected algorithm will also not be initialized.
+ * It is therefore not allowed to call batadv_algo_select outside the creation
+ * function of the soft interface.
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
 int batadv_algo_select(struct batadv_priv *bat_priv, char *name)
 {
struct batadv_algo_ops *bat_algo_ops;
@@ -104,6 +123,14 @@ int batadv_algo_select(struct batadv_priv *bat_priv, char 
*name)
 }
 
 #ifdef CONFIG_BATMAN_ADV_DEBUGFS
+
+/**
+ * batadv_algo_seq_print_text() - Print the supported algorithms in a seq file
+ * @seq: seq file to print on
+ * @offset: not used
+ *
+ * Return: always 0
+ */
 int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
 {
struct batadv_algo_ops *bat_algo_ops;
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 0973e8c5a063..c9955f29a2bf 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -2853,6 +2853,11 @@ static struct batadv_algo_ops batadv_batman_iv 
__read_mostly = {
},
 };
 
+/**
+ * batadv_iv_init() - B.A.T.M.A.N. IV initialization function
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
 int __init batadv_iv_init(void)
 {
int ret;
diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c
index 97d6eb45cbf2..21d1189957a7 100644
--- a/net/batman-adv/debugfs.c
+++ b/net/batman-adv/debugfs.c
@@ -259,6 +259,9 @@ static struct batadv_debuginfo *batadv_hardif_debuginfos[] 
= {
NULL,
 };
 
+/**
+ * batadv_debugfs_init() - Initialize soft interface independent debugfs 
entries
+ */
 void batadv_debugfs_init(void)
 {
struct batadv_debuginfo **bat_debug;
@@ -289,6 +292,9 @@ void batadv_debugfs_init(void)
batadv_debugfs = NULL;
 }
 
+/**
+ * batadv_debugfs_destroy() - Remove all debugfs entries
+ */
 void batadv_debugfs_destroy(void)
 {
debugfs_remove_recursive(batadv_debugfs);
@@ -355,6 +361,12 @@ void batadv_debugfs_del_hardif(struct batadv_hard_iface 
*hard_iface)
}
 }
 
+/**
+ * batadv_debugfs_add_meshif() - Initialize interface dependent debugfs entries
+ * @dev: netdev struct of the soft interface
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
 int batadv_debugfs_add_meshif(struct net_device *dev)
 {
struct batadv_priv *bat_priv = netdev_priv(dev);
@@ -401,6 +413,10 @@ int batadv_debugfs_add_meshif(struct net_device *dev)

[PATCH 17/19] batman-adv: Add kernel-doc to enums in headers

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

All enums in types.h are already documented. But some other headers
still have private enums which also should be documented.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/hard-interface.h | 23 +++
 net/batman-adv/main.h   | 32 
 2 files changed, 55 insertions(+)

diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index fb7a5d6b5ce3..1e61aacac539 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -31,12 +31,35 @@
 struct net_device;
 struct net;
 
+/**
+ * enum batadv_hard_if_state - State of a hard interface
+ */
 enum batadv_hard_if_state {
+   /**
+* @BATADV_IF_NOT_IN_USE: interface is not used as slave interface of a
+* batman-adv soft interface
+*/
BATADV_IF_NOT_IN_USE,
+
+   /**
+* @BATADV_IF_TO_BE_REMOVED: interface will be removed from soft
+* interface
+*/
BATADV_IF_TO_BE_REMOVED,
+
+   /** @BATADV_IF_INACTIVE: interface is deactivated */
BATADV_IF_INACTIVE,
+
+   /** @BATADV_IF_ACTIVE: interface is used */
BATADV_IF_ACTIVE,
+
+   /** @BATADV_IF_TO_BE_ACTIVATED: interface is getting activated */
BATADV_IF_TO_BE_ACTIVATED,
+
+   /**
+* @BATADV_IF_I_WANT_YOU: interface is queued up (using sysfs) for being
+* added as slave interface of a batman-adv soft interface
+*/
BATADV_IF_I_WANT_YOU,
 };
 
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 7f6a3123e1a4..633e6e41ba14 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -141,24 +141,56 @@
  */
 #define BATADV_TP_MAX_NUM 5
 
+/**
+ * enum batadv_mesh_state - State of a soft interface
+ */
 enum batadv_mesh_state {
+   /** @BATADV_MESH_INACTIVE: soft interface is not yet running */
BATADV_MESH_INACTIVE,
+
+   /** @BATADV_MESH_ACTIVE: interface is up and running */
BATADV_MESH_ACTIVE,
+
+   /** @BATADV_MESH_DEACTIVATING: interface is getting shut down */
BATADV_MESH_DEACTIVATING,
 };
 
 #define BATADV_BCAST_QUEUE_LEN 256
 #define BATADV_BATMAN_QUEUE_LEN256
 
+/**
+ * enum batadv_uev_action - action type of uevent
+ */
 enum batadv_uev_action {
+   /** @BATADV_UEV_ADD: gateway was selected (after none was selected) */
BATADV_UEV_ADD = 0,
+
+   /**
+* @BATADV_UEV_DEL: selected gateway was removed and none is selected
+* anymore
+*/
BATADV_UEV_DEL,
+
+   /**
+* @BATADV_UEV_CHANGE: a different gateway was selected as based gateway
+*/
BATADV_UEV_CHANGE,
+
+   /**
+* @BATADV_UEV_LOOPDETECT: loop was detected which cannot be handled by
+* bridge loop avoidance
+*/
BATADV_UEV_LOOPDETECT,
 };
 
+/**
+ * enum batadv_uev_type - Type of uevent
+ */
 enum batadv_uev_type {
+   /** @BATADV_UEV_GW: selected gateway was modified */
BATADV_UEV_GW = 0,
+
+   /** @BATADV_UEV_BLA: bridge loop avoidance event */
BATADV_UEV_BLA,
 };
 
-- 
2.11.0



[PATCH 09/19] batman-adv: Include net.h for net_ratelimited_function

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The linux/net.h provides the net_ratelimited_function. It should
therefore be included directly before it is used.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/network-coding.c| 1 +
 net/batman-adv/translation-table.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
index d37fe5ed6117..bd421408d9e7 100644
--- a/net/batman-adv/network-coding.c
+++ b/net/batman-adv/network-coding.c
@@ -36,6 +36,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/translation-table.c 
b/net/batman-adv/translation-table.c
index 27a0c34a5ad0..b4b20ad1ed9a 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -37,6 +37,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.11.0



[PATCH 06/19] batman-adv: Change batman_adv.h license to MIT

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The ISC license is considered as not recommended in "Linux kernel licensing
rules". It should only be used for existing code or for importing code from
a different project with that license.

But the kernel still has the similar sounding MIT/Expat license under the
preferred licenses. Switching to this license for this relatively new file
should therefore allow batman-adv to better follow the new licensing rules.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Acked-by: Antonio Quartulli <a...@unstable.cc>
Acked-by: Matthias Schiffer <mschif...@universe-factory.net>
Acked-by: Andrew Lunn <and...@lunn.ch>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 include/uapi/linux/batman_adv.h | 28 +---
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/include/uapi/linux/batman_adv.h b/include/uapi/linux/batman_adv.h
index fb4533826163..ae00c99cbed0 100644
--- a/include/uapi/linux/batman_adv.h
+++ b/include/uapi/linux/batman_adv.h
@@ -1,19 +1,25 @@
-/* SPDX-License-Identifier: ISC */
+/* SPDX-License-Identifier: MIT */
 /* Copyright (C) 2016-2017  B.A.T.M.A.N. contributors:
  *
  * Matthias Schiffer
  *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 
 #ifndef _UAPI_LINUX_BATMAN_ADV_H_
-- 
2.11.0



[PATCH 05/19] batman-adv: Add license header to Kconfig

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The last remaining file without license notice and/or SPDX license
identifier under net/batman-adv/ is the Kconfig. It should have been
licensed under the same conditions as the rest of batman-adv and the
Makefile which uses the CONFIG_* variables from Kconfig.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/Kconfig | 17 +
 1 file changed, 17 insertions(+)

diff --git a/net/batman-adv/Kconfig b/net/batman-adv/Kconfig
index b73b96a2854b..c44f6515be5e 100644
--- a/net/batman-adv/Kconfig
+++ b/net/batman-adv/Kconfig
@@ -1,3 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2007-2017  B.A.T.M.A.N. contributors:
+#
+# Marek Lindner, Simon Wunderlich
+#
+# 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, see <http://www.gnu.org/licenses/>.
+
 #
 # B.A.T.M.A.N meshing protocol
 #
-- 
2.11.0



[PATCH 10/19] batman-adv: include kobject.h for kobject_* functions

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The linux/kobject.h provides the kobject_* function declarations and should
therefore be included directly before they are used.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/sysfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index 374ff46feb8e..227a072dc1d3 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.11.0



[PATCH 08/19] batman-adv: include build_bug.h for BUILD_BUG_ON define

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

commit bc6245e5efd7 ("bug: split BUILD_BUG stuff out into
") added a new header for BUILD_BUG_ON. It should
therefore be included instead of linux/bug.h

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/main.c  | 2 +-
 net/batman-adv/tp_meter.c  | 2 +-
 net/batman-adv/translation-table.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 0c3664aa6a58..6f6c500e8aa8 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -19,7 +19,7 @@
 #include "main.h"
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c
index e33f64f0fcb8..fe9eb2970ec9 100644
--- a/net/batman-adv/tp_meter.c
+++ b/net/batman-adv/tp_meter.c
@@ -20,7 +20,7 @@
 #include "main.h"
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/translation-table.c 
b/net/batman-adv/translation-table.c
index db40ca6243b3..27a0c34a5ad0 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -21,7 +21,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
-- 
2.11.0



[PATCH 16/19] batman-adv: Add kernel-doc to structs in headers

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

All structs in types.h are already documented. But some other headers
still have private structs which also should be documented.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/hash.h  | 14 +++---
 net/batman-adv/sysfs.h | 13 +
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h
index c92fde593959..65396b126f3b 100644
--- a/net/batman-adv/hash.h
+++ b/net/batman-adv/hash.h
@@ -46,10 +46,18 @@ typedef bool (*batadv_hashdata_compare_cb)(const struct 
hlist_node *,
 typedef u32 (*batadv_hashdata_choose_cb)(const void *, u32);
 typedef void (*batadv_hashdata_free_cb)(struct hlist_node *, void *);
 
+/**
+ * struct batadv_hashtable - Wrapper of simple hlist based hashtable
+ */
 struct batadv_hashtable {
-   struct hlist_head *table;   /* the hashtable itself with the buckets */
-   spinlock_t *list_locks; /* spinlock for each hash list entry */
-   u32 size;   /* size of hashtable */
+   /** @table: the hashtable itself with the buckets */
+   struct hlist_head *table;
+
+   /** @list_locks: spinlock for each hash list entry */
+   spinlock_t *list_locks;
+
+   /** @size: size of hashtable */
+   u32 size;
 };
 
 /* allocates and clears the hash */
diff --git a/net/batman-adv/sysfs.h b/net/batman-adv/sysfs.h
index 0384cb6c406b..bbeee61221fa 100644
--- a/net/batman-adv/sysfs.h
+++ b/net/batman-adv/sysfs.h
@@ -36,10 +36,23 @@ struct net_device;
  */
 #define BATADV_SYSFS_VLAN_SUBDIR_PREFIX "vlan"
 
+/**
+ * struct batadv_attribute - sysfs export helper for batman-adv attributes
+ */
 struct batadv_attribute {
+   /** @attr: sysfs attribute file */
struct attribute attr;
+
+   /**
+* @show: function to export the current attribute's content to sysfs
+*/
ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
char *buf);
+
+   /**
+* @store: function to load new value from character buffer and save it
+* in batman-adv attribute
+*/
ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
 char *buf, size_t count);
 };
-- 
2.11.0



[PATCH 11/19] batman-adv: Remove unused sched.h include

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The linux/wait.h include was removed with commit 421d988b2c08 ("batman-adv:
Consolidate logging related functions"). The previously required (but not
unused) linux/sched.h include can also be dropped now.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/debugfs.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c
index d94585dc2dbe..fddf16a3dc89 100644
--- a/net/batman-adv/debugfs.c
+++ b/net/batman-adv/debugfs.c
@@ -26,7 +26,6 @@
 #include 
 #include 
 #include 
-#include  /* for linux/wait.h */
 #include 
 #include 
 #include 
-- 
2.11.0



[PATCH 12/19] batman-adv: Add missing kernel-doc to packet.h

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/packet.h | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 4eaf4b426726..dccbd4a6f019 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -22,6 +22,12 @@
 #include 
 #include 
 
+/**
+ * batadv_tp_is_error() - Check throughput meter return code for error
+ * @n: throughput meter return code
+ *
+ * Return: 0 when not error was detected, != 0 otherwise
+ */
 #define batadv_tp_is_error(n) ((u8)(n) > 127 ? 1 : 0)
 
 /**
@@ -89,7 +95,15 @@ enum batadv_iv_flags {
BATADV_DIRECTLINK  = BIT(2),
 };
 
-/* ICMP message types */
+/**
+ * enum batadv_icmp_packettype - ICMP message types
+ * @BATADV_ECHO_REPLY: success reply to BATADV_ECHO_REQUEST
+ * @BATADV_DESTINATION_UNREACHABLE: failure when route to destination not found
+ * @BATADV_ECHO_REQUEST: request BATADV_ECHO_REPLY from destination
+ * @BATADV_TTL_EXCEEDED: error after BATADV_ECHO_REQUEST traversed too many 
hops
+ * @BATADV_PARAMETER_PROBLEM: return code for malformed messages
+ * @BATADV_TP: throughput meter packet
+ */
 enum batadv_icmp_packettype {
BATADV_ECHO_REPLY  = 0,
BATADV_DESTINATION_UNREACHABLE = 3,
@@ -137,7 +151,14 @@ enum batadv_vlan_flags {
BATADV_VLAN_HAS_TAG = BIT(15),
 };
 
-/* claim frame types for the bridge loop avoidance */
+/**
+ * enum batadv_bla_claimframe - claim frame types for the bridge loop avoidance
+ * @BATADV_CLAIM_TYPE_CLAIM: claim of a client mac address
+ * @BATADV_CLAIM_TYPE_UNCLAIM: unclaim of a client mac address
+ * @BATADV_CLAIM_TYPE_ANNOUNCE: announcement of backbone with current crc
+ * @BATADV_CLAIM_TYPE_REQUEST: request of full claim table
+ * @BATADV_CLAIM_TYPE_LOOPDETECT: mesh-traversing loop detect packet
+ */
 enum batadv_bla_claimframe {
BATADV_CLAIM_TYPE_CLAIM = 0x00,
BATADV_CLAIM_TYPE_UNCLAIM   = 0x01,
-- 
2.11.0



[PATCH 14/19] batman-adv: Use inline kernel-doc for enum/struct

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The inline kernel-doc comments make it easier to keep changes to the
struct/enum synchronized with the documentation of the it. And it makes it
easier for larger structures like struct batadv_priv to read the
documentation inside the code.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_iv_ogm.c |   17 +-
 net/batman-adv/gateway_common.h |5 +-
 net/batman-adv/hard-interface.h |   27 +-
 net/batman-adv/log.h|   26 +-
 net/batman-adv/multicast.h  |   16 +-
 net/batman-adv/types.h  | 1989 +++
 6 files changed, 1444 insertions(+), 636 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 1fc67aa8d7df..0973e8c5a063 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -73,16 +73,23 @@ static void 
batadv_iv_send_outstanding_bat_ogm_packet(struct work_struct *work);
 
 /**
  * enum batadv_dup_status - duplicate status
- * @BATADV_NO_DUP: the packet is no duplicate
- * @BATADV_ORIG_DUP: OGM is a duplicate in the originator (but not for the
- *  neighbor)
- * @BATADV_NEIGH_DUP: OGM is a duplicate for the neighbor
- * @BATADV_PROTECTED: originator is currently protected (after reboot)
  */
 enum batadv_dup_status {
+   /** @BATADV_NO_DUP: the packet is no duplicate */
BATADV_NO_DUP = 0,
+
+   /**
+* @BATADV_ORIG_DUP: OGM is a duplicate in the originator (but not for
+*  the neighbor)
+*/
BATADV_ORIG_DUP,
+
+   /** @BATADV_NEIGH_DUP: OGM is a duplicate for the neighbor */
BATADV_NEIGH_DUP,
+
+   /**
+* @BATADV_PROTECTED: originator is currently protected (after reboot)
+*/
BATADV_PROTECTED,
 };
 
diff --git a/net/batman-adv/gateway_common.h b/net/batman-adv/gateway_common.h
index 7c298b05c1dc..afebd9c7edf4 100644
--- a/net/batman-adv/gateway_common.h
+++ b/net/batman-adv/gateway_common.h
@@ -33,11 +33,12 @@ enum batadv_gw_modes {
 
 /**
  * enum batadv_bandwidth_units - bandwidth unit types
- * @BATADV_BW_UNIT_KBIT: unit type kbit
- * @BATADV_BW_UNIT_MBIT: unit type mbit
  */
 enum batadv_bandwidth_units {
+   /** @BATADV_BW_UNIT_KBIT: unit type kbit */
BATADV_BW_UNIT_KBIT,
+
+   /** @BATADV_BW_UNIT_MBIT: unit type mbit */
BATADV_BW_UNIT_MBIT,
 };
 
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index a7f9036f0e3a..fb7a5d6b5ce3 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -42,25 +42,40 @@ enum batadv_hard_if_state {
 
 /**
  * enum batadv_hard_if_bcast - broadcast avoidance options
- * @BATADV_HARDIF_BCAST_OK: Do broadcast on according hard interface
- * @BATADV_HARDIF_BCAST_NORECIPIENT: Broadcast not needed, there is no 
recipient
- * @BATADV_HARDIF_BCAST_DUPFWD: There is just the neighbor we got it from
- * @BATADV_HARDIF_BCAST_DUPORIG: There is just the originator
  */
 enum batadv_hard_if_bcast {
+   /** @BATADV_HARDIF_BCAST_OK: Do broadcast on according hard interface */
BATADV_HARDIF_BCAST_OK = 0,
+
+   /**
+* @BATADV_HARDIF_BCAST_NORECIPIENT: Broadcast not needed, there is no
+*  recipient
+*/
BATADV_HARDIF_BCAST_NORECIPIENT,
+
+   /**
+* @BATADV_HARDIF_BCAST_DUPFWD: There is just the neighbor we got it
+*  from
+*/
BATADV_HARDIF_BCAST_DUPFWD,
+
+   /** @BATADV_HARDIF_BCAST_DUPORIG: There is just the originator */
BATADV_HARDIF_BCAST_DUPORIG,
 };
 
 /**
  * enum batadv_hard_if_cleanup - Cleanup modi for soft_iface after slave 
removal
- * @BATADV_IF_CLEANUP_KEEP: Don't automatically delete soft-interface
- * @BATADV_IF_CLEANUP_AUTO: Delete soft-interface after last slave was removed
  */
 enum batadv_hard_if_cleanup {
+   /**
+* @BATADV_IF_CLEANUP_KEEP: Don't automatically delete soft-interface
+*/
BATADV_IF_CLEANUP_KEEP,
+
+   /**
+* @BATADV_IF_CLEANUP_AUTO: Delete soft-interface after last slave was
+*  removed
+*/
BATADV_IF_CLEANUP_AUTO,
 };
 
diff --git a/net/batman-adv/log.h b/net/batman-adv/log.h
index 6744a64143c0..dd22e17b84b4 100644
--- a/net/batman-adv/log.h
+++ b/net/batman-adv/log.h
@@ -45,25 +45,33 @@ static inline void batadv_debug_log_cleanup(struct 
batadv_priv *bat_priv)
 
 /**
  * enum batadv_dbg_level - available log levels
- * @BATADV_DBG_BATMAN: OGM and TQ computations related messages
- * @BATADV_DBG_ROUTES: route added / changed / deleted
- * @BATADV_DBG_TT: translation table messages
- * @BATADV_DBG_BLA: bridge loop avoidance messages
- * @BATADV_DBG_DAT: ARP snooping and DAT related messages
- * @BATADV_DBG_NC: network coding related messages
- * @BATADV_DBG_MCAST: multicast related messages
- * @BATADV_DBG_TP_METER: throughput meter messages
- * @BATADV_DBG_ALL: the unio

[PATCH 04/19] batman-adv: Add SPDX license identifier to batman-adv.rst

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The "Linux licensing rules" require that also the restructuredText files
are marked with the appropriate SPDX license identifier.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 Documentation/networking/batman-adv.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/networking/batman-adv.rst 
b/Documentation/networking/batman-adv.rst
index a342b2cc3dc6..245fb6c0ab6f 100644
--- a/Documentation/networking/batman-adv.rst
+++ b/Documentation/networking/batman-adv.rst
@@ -1,3 +1,5 @@
+.. SPDX-License-Identifier: GPL-2.0
+
 ==
 batman-adv
 ==
-- 
2.11.0



[PATCH 00/19] pull request for net-next: batman-adv 2017-12-20

2017-12-20 Thread Simon Wunderlich
Hi David,

here is the updated feature/cleanup pull request of batman-adv to go
into net-next. Compared to batman-adv 2017-12-15 pull request, we have 
dropped the 'batman-adv: Add License-Filename to GPL-2.0 files' as per
your suggestion.

Please pull or let me know of any problem!

Thank you,
  Simon

The following changes since commit 4fbd8d194f06c8a3fd2af1ce560ddb31f7ec8323:

  Linux 4.15-rc1 (2017-11-26 16:01:47 -0800)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batadv-next-for-davem-20171220

for you to fetch changes up to ff15c27c97303fbe5abc49c25c73ea299ab72d31:

  batman-adv: Add kernel-doc to externally visible functions (2017-12-15 
17:29:24 +0100)


This feature/cleanup patchset includes the following patches:

 - bump version strings, by Simon Wunderlich

 - de-inline hash functions to save memory footprint, by Denys Vlasenko

 - Add License information to various files, by Sven Eckelmann (3 patches)

 - Change batman_adv.h from ISC to MIT, by Sven Eckelmann

 - Improve various includes, by Sven Eckelmann (5 patches)

 - Lots of kernel-doc work by Sven Eckelmann (8 patches)


Denys Vlasenko (1):
  batman-adv: Deinline batadv_orig_hash_find, save 7339 bytes

Simon Wunderlich (1):
  batman-adv: Start new development cycle

Sven Eckelmann (17):
  batman-adv: Add SPDX license identifier above copyright header
  batman-adv: Add SPDX license identifier to batman-adv.rst
  batman-adv: Add license header to Kconfig
  batman-adv: Change batman_adv.h license to MIT
  batman-adv: include gfp.h for GFP_* defines
  batman-adv: include build_bug.h for BUILD_BUG_ON define
  batman-adv: Include net.h for net_ratelimited_function
  batman-adv: include kobject.h for kobject_* functions
  batman-adv: Remove unused sched.h include
  batman-adv: Add missing kernel-doc to packet.h
  batman-adv: Use parentheses in function kernel-doc
  batman-adv: Use inline kernel-doc for enum/struct
  batman-adv: Fix kernel-doc references to struct members
  batman-adv: Add kernel-doc to structs in headers
  batman-adv: Add kernel-doc to enums in headers
  batman-adv: Add kernel-doc to functions in headers
  batman-adv: Add kernel-doc to externally visible functions

 Documentation/networking/batman-adv.rst |2 +
 include/uapi/linux/batman_adv.h |   27 +-
 net/batman-adv/Kconfig  |   17 +
 net/batman-adv/Makefile |2 +-
 net/batman-adv/bat_algo.c   |   35 +-
 net/batman-adv/bat_algo.h   |1 +
 net/batman-adv/bat_iv_ogm.c |  105 +-
 net/batman-adv/bat_iv_ogm.h |1 +
 net/batman-adv/bat_v.c  |   49 +-
 net/batman-adv/bat_v.h  |1 +
 net/batman-adv/bat_v_elp.c  |   27 +-
 net/batman-adv/bat_v_elp.h  |1 +
 net/batman-adv/bat_v_ogm.c  |   37 +-
 net/batman-adv/bat_v_ogm.h  |1 +
 net/batman-adv/bitarray.c   |3 +-
 net/batman-adv/bitarray.h   |   10 +-
 net/batman-adv/bridge_loop_avoidance.c  |  112 +-
 net/batman-adv/bridge_loop_avoidance.h  |5 +-
 net/batman-adv/debugfs.c|   30 +-
 net/batman-adv/debugfs.h|1 +
 net/batman-adv/distributed-arp-table.c  |   80 +-
 net/batman-adv/distributed-arp-table.h  |7 +-
 net/batman-adv/fragmentation.c  |   23 +-
 net/batman-adv/fragmentation.h  |3 +-
 net/batman-adv/gateway_client.c |   65 +-
 net/batman-adv/gateway_client.h |1 +
 net/batman-adv/gateway_common.c |   28 +-
 net/batman-adv/gateway_common.h |6 +-
 net/batman-adv/hard-interface.c |   65 +-
 net/batman-adv/hard-interface.h |   59 +-
 net/batman-adv/hash.c   |   20 +-
 net/batman-adv/hash.h   |   28 +-
 net/batman-adv/icmp_socket.c|   15 +-
 net/batman-adv/icmp_socket.h|1 +
 net/batman-adv/log.c|   19 +
 net/batman-adv/log.h|   62 +-
 net/batman-adv/main.c   |   52 +-
 net/batman-adv/main.h   |  123 +-
 net/batman-adv/multicast.c  |   81 +-
 net/batman-adv/multicast.h  |   17 +-
 net/batman-adv/netlink.c|   25 +-
 net/batman-adv/netlink.h|1 +
 net/batman-adv/network-coding.c |  124 +-
 net/batman-adv/network-coding.h |1 +
 net/batman-adv/originator.c |  154 ++-
 net/batman-adv/originator.h |   47 +-
 net/batman-adv/packet.h |   26 +-
 net/batman-adv/routing.c|   54 +-
 net/batman-adv/routing.h|1 +
 net/batman-adv/send.c   |   66 +-
 net/batman-adv/send.h

[PATCH 01/19] batman-adv: Start new development cycle

2017-12-20 Thread Simon Wunderlich
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/main.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index edb2f239d04d..bb8003cf2296 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -24,7 +24,7 @@
 #define BATADV_DRIVER_DEVICE "batman-adv"
 
 #ifndef BATADV_SOURCE_VERSION
-#define BATADV_SOURCE_VERSION "2017.4"
+#define BATADV_SOURCE_VERSION "2018.0"
 #endif
 
 /* B.A.T.M.A.N. parameters */
-- 
2.11.0



[PATCH 15/19] batman-adv: Fix kernel-doc references to struct members

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The correct syntax to create references in kernel-doc to a struct member is
not "struct_name::member"" but "_name->member" or
"_name.member". The correct syntax is required to get the correct
cross-referencing in the reStructuredText text output.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/types.h | 49 ++---
 1 file changed, 26 insertions(+), 23 deletions(-)

diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index c39f879d7dde..77b145eba193 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -234,7 +234,7 @@ struct batadv_hard_iface {
  * struct batadv_orig_ifinfo - originator info per outgoing interface
  */
 struct batadv_orig_ifinfo {
-   /** @list: list node for orig_node::ifinfo_list */
+   /** @list: list node for _orig_node.ifinfo_list */
struct hlist_node list;
 
/** @if_outgoing: pointer to outgoing hard-interface */
@@ -320,7 +320,7 @@ struct batadv_orig_node_vlan {
/** @tt: VLAN specific TT attributes */
struct batadv_vlan_tt tt;
 
-   /** @list: list node for orig_node::vlan_list */
+   /** @list: list node for _orig_node.vlan_list */
struct hlist_node list;
 
/**
@@ -467,7 +467,7 @@ struct batadv_orig_node {
 */
spinlock_t neigh_list_lock;
 
-   /** @hash_entry: hlist node for batadv_priv::orig_hash */
+   /** @hash_entry: hlist node for _priv.orig_hash */
struct hlist_node hash_entry;
 
/** @bat_priv: pointer to soft_iface this orig node belongs to */
@@ -539,7 +539,7 @@ enum batadv_orig_capabilities {
  * struct batadv_gw_node - structure for orig nodes announcing gw capabilities
  */
 struct batadv_gw_node {
-   /** @list: list node for batadv_priv_gw::list */
+   /** @list: list node for _priv_gw.list */
struct hlist_node list;
 
/** @orig_node: pointer to corresponding orig node */
@@ -588,7 +588,7 @@ struct batadv_hardif_neigh_node_bat_v {
  * struct batadv_hardif_neigh_node - unique neighbor per hard-interface
  */
 struct batadv_hardif_neigh_node {
-   /** @list: list node for batadv_hard_iface::neigh_list */
+   /** @list: list node for _hard_iface.neigh_list */
struct hlist_node list;
 
/** @addr: the MAC address of the neighboring interface */
@@ -621,7 +621,7 @@ struct batadv_hardif_neigh_node {
  * struct batadv_neigh_node - structure for single hops neighbors
  */
 struct batadv_neigh_node {
-   /** @list: list node for batadv_orig_node::neigh_list */
+   /** @list: list node for _orig_node.neigh_list */
struct hlist_node list;
 
/** @orig_node: pointer to corresponding orig_node */
@@ -697,7 +697,7 @@ struct batadv_neigh_ifinfo_bat_v {
  * struct batadv_neigh_ifinfo - neighbor information per outgoing interface
  */
 struct batadv_neigh_ifinfo {
-   /** @list: list node for batadv_neigh_node::ifinfo_list */
+   /** @list: list node for _neigh_node.ifinfo_list */
struct hlist_node list;
 
/** @if_outgoing: pointer to outgoing hard-interface */
@@ -1308,7 +1308,7 @@ struct batadv_tp_unacked {
/** @len: length of the packet */
u16 len;
 
-   /** @list: list node for batadv_tp_vars::unacked_list */
+   /** @list: list node for _tp_vars.unacked_list */
struct list_head list;
 };
 
@@ -1327,7 +1327,7 @@ enum batadv_tp_meter_role {
  * struct batadv_tp_vars - tp meter private variables per session
  */
 struct batadv_tp_vars {
-   /** @list: list node for bat_priv::tp_list */
+   /** @list: list node for _priv.tp_list */
struct hlist_node list;
 
/** @timer: timer for ack (receiver) and retry (sender) */
@@ -1459,7 +1459,7 @@ struct batadv_softif_vlan {
/** @tt: TT private attributes (VLAN specific) */
struct batadv_vlan_tt tt;
 
-   /** @list: list node for bat_priv::softif_vlan_list */
+   /** @list: list node for _priv.softif_vlan_list */
struct hlist_node list;
 
/**
@@ -1727,7 +1727,7 @@ struct batadv_socket_client {
  * struct batadv_socket_packet - layer2 icmp packet for socket client
  */
 struct batadv_socket_packet {
-   /** @list: list node for batadv_socket_client::queue_list */
+   /** @list: list node for _socket_client.queue_list */
struct list_head list;
 
/** @icmp_len: size of the layer2 icmp packet */
@@ -1752,7 +1752,7 @@ struct batadv_bla_backbone_gw {
/** @vid: vlan id this gateway was detected on */
unsigned short vid;
 
-   /** @hash_entry: hlist node for batadv_priv_bla::backbone_hash */
+   /** @hash_entry: hlist node for _priv_bla.backbone_hash */
struct hlist_node hash_entry;
 
/** @bat_priv: pointer to soft_iface this backbone gateway bel

[PATCH 03/19] batman-adv: Add SPDX license identifier above copyright header

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The "Linux kernel licensing rules" require that each file has a SPDX
license identifier as first line (and sometimes as second line).

The FSFE REUSE practices [1] would also require the same tags but have no
restrictions on the placement in the source file. Using the "Linux kernel
licensing rules" is therefore also fulfilling the FSFE REUSE practices
requirements at the same time.

[1] https://reuse.software/practices/

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 include/uapi/linux/batman_adv.h| 1 +
 net/batman-adv/Makefile| 2 +-
 net/batman-adv/bat_algo.c  | 1 +
 net/batman-adv/bat_algo.h  | 1 +
 net/batman-adv/bat_iv_ogm.c| 1 +
 net/batman-adv/bat_iv_ogm.h| 1 +
 net/batman-adv/bat_v.c | 1 +
 net/batman-adv/bat_v.h | 1 +
 net/batman-adv/bat_v_elp.c | 1 +
 net/batman-adv/bat_v_elp.h | 1 +
 net/batman-adv/bat_v_ogm.c | 1 +
 net/batman-adv/bat_v_ogm.h | 1 +
 net/batman-adv/bitarray.c  | 1 +
 net/batman-adv/bitarray.h  | 1 +
 net/batman-adv/bridge_loop_avoidance.c | 1 +
 net/batman-adv/bridge_loop_avoidance.h | 1 +
 net/batman-adv/debugfs.c   | 1 +
 net/batman-adv/debugfs.h   | 1 +
 net/batman-adv/distributed-arp-table.c | 1 +
 net/batman-adv/distributed-arp-table.h | 1 +
 net/batman-adv/fragmentation.c | 1 +
 net/batman-adv/fragmentation.h | 1 +
 net/batman-adv/gateway_client.c| 1 +
 net/batman-adv/gateway_client.h| 1 +
 net/batman-adv/gateway_common.c| 1 +
 net/batman-adv/gateway_common.h| 1 +
 net/batman-adv/hard-interface.c| 1 +
 net/batman-adv/hard-interface.h| 1 +
 net/batman-adv/hash.c  | 1 +
 net/batman-adv/hash.h  | 1 +
 net/batman-adv/icmp_socket.c   | 1 +
 net/batman-adv/icmp_socket.h   | 1 +
 net/batman-adv/log.c   | 1 +
 net/batman-adv/log.h   | 1 +
 net/batman-adv/main.c  | 1 +
 net/batman-adv/main.h  | 1 +
 net/batman-adv/multicast.c | 1 +
 net/batman-adv/multicast.h | 1 +
 net/batman-adv/netlink.c   | 1 +
 net/batman-adv/netlink.h   | 1 +
 net/batman-adv/network-coding.c| 1 +
 net/batman-adv/network-coding.h| 1 +
 net/batman-adv/originator.c| 1 +
 net/batman-adv/originator.h| 1 +
 net/batman-adv/packet.h| 1 +
 net/batman-adv/routing.c   | 1 +
 net/batman-adv/routing.h   | 1 +
 net/batman-adv/send.c  | 1 +
 net/batman-adv/send.h  | 1 +
 net/batman-adv/soft-interface.c| 1 +
 net/batman-adv/soft-interface.h| 1 +
 net/batman-adv/sysfs.c | 1 +
 net/batman-adv/sysfs.h | 1 +
 net/batman-adv/tp_meter.c  | 1 +
 net/batman-adv/tp_meter.h  | 1 +
 net/batman-adv/translation-table.c | 1 +
 net/batman-adv/translation-table.h | 1 +
 net/batman-adv/tvlv.c  | 1 +
 net/batman-adv/tvlv.h  | 1 +
 net/batman-adv/types.h | 1 +
 60 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/batman_adv.h b/include/uapi/linux/batman_adv.h
index efd641c8a5d6..fb4533826163 100644
--- a/include/uapi/linux/batman_adv.h
+++ b/include/uapi/linux/batman_adv.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: ISC */
 /* Copyright (C) 2016-2017  B.A.T.M.A.N. contributors:
  *
  * Matthias Schiffer
diff --git a/net/batman-adv/Makefile b/net/batman-adv/Makefile
index 915987bc6d29..022f6e77307b 100644
--- a/net/batman-adv/Makefile
+++ b/net/batman-adv/Makefile
@@ -1,4 +1,4 @@
-#
+# SPDX-License-Identifier: GPL-2.0
 # Copyright (C) 2007-2017  B.A.T.M.A.N. contributors:
 #
 # Marek Lindner, Simon Wunderlich
diff --git a/net/batman-adv/bat_algo.c b/net/batman-adv/bat_algo.c
index 44fd073b7546..fa306b25a78b 100644
--- a/net/batman-adv/bat_algo.c
+++ b/net/batman-adv/bat_algo.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /* Copyright (C) 2007-2017  B.A.T.M.A.N. contributors:
  *
  * Marek Lindner, Simon Wunderlich
diff --git a/net/batman-adv/bat_algo.h b/net/batman-adv/bat_algo.h
index 29f6312f9bf1..029221615ba3 100644
--- a/net/batman-adv/bat_algo.h
+++ b/net/batman-adv/bat_algo.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /* Copyright (C) 2011-2017  B.A.T.M.A.N. contributors:
  *
  * Marek Lindner, Linus Lüssing
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 1b659ab652fb..bff5ec66a2e1 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /* Copyright (C) 2007-2017  B.A.T.M.A.N. cont

[PATCH 02/19] batman-adv: Deinline batadv_orig_hash_find, save 7339 bytes

2017-12-20 Thread Simon Wunderlich
From: Denys Vlasenko <dvlas...@redhat.com>

This function compiles to 288 bytes of machine code for Linux 4.14 on
Debian Stretch amd64 and (6.3.0-18) with the default configuration. 27
callsites (25 used in default config).

   textdata bss dec hex filename
 179291   103174416  194024   2f5e8 batman-adv.ko.pre
 171952   103174416  186685   2d93d batman-adv.ko.post

Signed-off-by: Denys Vlasenko <dvlas...@redhat.com>
[s...@narfation.org: Fix includes, correct sizes+counts in commit message]
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/originator.c | 32 
 net/batman-adv/originator.h | 37 ++---
 2 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 2967b86c13da..0a565d0422bb 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -30,10 +30,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -55,6 +57,36 @@
 /* hash class keys */
 static struct lock_class_key batadv_orig_hash_lock_class_key;
 
+struct batadv_orig_node *
+batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data)
+{
+   struct batadv_hashtable *hash = bat_priv->orig_hash;
+   struct hlist_head *head;
+   struct batadv_orig_node *orig_node, *orig_node_tmp = NULL;
+   int index;
+
+   if (!hash)
+   return NULL;
+
+   index = batadv_choose_orig(data, hash->size);
+   head = >table[index];
+
+   rcu_read_lock();
+   hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
+   if (!batadv_compare_eth(orig_node, data))
+   continue;
+
+   if (!kref_get_unless_zero(_node->refcount))
+   continue;
+
+   orig_node_tmp = orig_node;
+   break;
+   }
+   rcu_read_unlock();
+
+   return orig_node_tmp;
+}
+
 static void batadv_purge_orig(struct work_struct *work);
 
 /**
diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h
index d94220a6d21a..40c7f039d5d7 100644
--- a/net/batman-adv/originator.h
+++ b/net/batman-adv/originator.h
@@ -23,14 +23,8 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 
 
-#include "hash.h"
-
 struct netlink_callback;
 struct seq_file;
 struct sk_buff;
@@ -100,34 +94,7 @@ static inline u32 batadv_choose_orig(const void *data, u32 
size)
return hash % size;
 }
 
-static inline struct batadv_orig_node *
-batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data)
-{
-   struct batadv_hashtable *hash = bat_priv->orig_hash;
-   struct hlist_head *head;
-   struct batadv_orig_node *orig_node, *orig_node_tmp = NULL;
-   int index;
-
-   if (!hash)
-   return NULL;
-
-   index = batadv_choose_orig(data, hash->size);
-   head = >table[index];
-
-   rcu_read_lock();
-   hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
-   if (!batadv_compare_eth(orig_node, data))
-   continue;
-
-   if (!kref_get_unless_zero(_node->refcount))
-   continue;
-
-   orig_node_tmp = orig_node;
-   break;
-   }
-   rcu_read_unlock();
-
-   return orig_node_tmp;
-}
+struct batadv_orig_node *
+batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data);
 
 #endif /* _NET_BATMAN_ADV_ORIGINATOR_H_ */
-- 
2.11.0



[PATCH 18/19] batman-adv: Add kernel-doc to functions in headers

2017-12-20 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

Externally visible functions should be documented with kernel-doc. This
usually refers to non-static functions but also static inline files in
headers are visible in other files and should therefore be documented.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bitarray.h   |  7 +++-
 net/batman-adv/hard-interface.h |  6 +++
 net/batman-adv/hash.h   | 11 +-
 net/batman-adv/log.h| 35 +-
 net/batman-adv/main.h   | 82 ++---
 net/batman-adv/originator.h |  9 -
 6 files changed, 131 insertions(+), 19 deletions(-)

diff --git a/net/batman-adv/bitarray.h b/net/batman-adv/bitarray.h
index 0508353fa28d..ca9d0753dd6b 100644
--- a/net/batman-adv/bitarray.h
+++ b/net/batman-adv/bitarray.h
@@ -47,7 +47,12 @@ static inline bool batadv_test_bit(const unsigned long 
*seq_bits,
return test_bit(diff, seq_bits) != 0;
 }
 
-/* turn corresponding bit on, so we can remember that we got the packet */
+/**
+ * batadv_set_bit() - Turn corresponding bit on, so we can remember that we got
+ *  the packet
+ * @seq_bits: bitmap of the packet receive window
+ * @n: relative sequence number of newly received packet
+ */
 static inline void batadv_set_bit(unsigned long *seq_bits, s32 n)
 {
/* if too old, just drop it */
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index 1e61aacac539..de5e9a374ece 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -130,6 +130,12 @@ static inline void batadv_hardif_put(struct 
batadv_hard_iface *hard_iface)
kref_put(_iface->refcount, batadv_hardif_release);
 }
 
+/**
+ * batadv_primary_if_get_selected() - Get reference to primary interface
+ * @bat_priv: the bat priv with all the soft interface information
+ *
+ * Return: primary interface (with increased refcnt), otherwise NULL
+ */
 static inline struct batadv_hard_iface *
 batadv_primary_if_get_selected(struct batadv_priv *bat_priv)
 {
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h
index 65396b126f3b..4ce1b6d3ad5c 100644
--- a/net/batman-adv/hash.h
+++ b/net/batman-adv/hash.h
@@ -121,8 +121,15 @@ static inline int batadv_hash_add(struct batadv_hashtable 
*hash,
return ret;
 }
 
-/* removes data from hash, if found. data could be the structure you use with
- * just the key filled, we just need the key for comparing.
+/**
+ * batadv_hash_remove() - Removes data from hash, if found
+ * @hash: hash table
+ * @compare: callback to determine if 2 hash elements are identical
+ * @choose: callback calculating the hash index
+ * @data: data passed to the aforementioned callbacks as argument
+ *
+ * ata could be the structure you use with  just the key filled, we just need
+ * the key for comparing.
  *
  * Return: returns pointer do data on success, so you can remove the used
  * structure yourself, or NULL on error
diff --git a/net/batman-adv/log.h b/net/batman-adv/log.h
index dd22e17b84b4..35e02b2b9e72 100644
--- a/net/batman-adv/log.h
+++ b/net/batman-adv/log.h
@@ -79,7 +79,14 @@ enum batadv_dbg_level {
 int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
 __printf(2, 3);
 
-/* possibly ratelimited debug output */
+/**
+ * _batadv_dbg() - Store debug output with(out) ratelimiting
+ * @type: type of debug message
+ * @bat_priv: the bat priv with all the soft interface information
+ * @ratelimited: whether output should be rate limited
+ * @fmt: format string
+ * @arg...: variable arguments
+ */
 #define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...)  \
do {\
struct batadv_priv *__batpriv = (bat_priv); \
@@ -98,11 +105,30 @@ static inline void _batadv_dbg(int type __always_unused,
 }
 #endif
 
+/**
+ * batadv_dbg() - Store debug output without ratelimiting
+ * @type: type of debug message
+ * @bat_priv: the bat priv with all the soft interface information
+ * @arg...: format string and variable arguments
+ */
 #define batadv_dbg(type, bat_priv, arg...) \
_batadv_dbg(type, bat_priv, 0, ## arg)
+
+/**
+ * batadv_dbg_ratelimited() - Store debug output with ratelimiting
+ * @type: type of debug message
+ * @bat_priv: the bat priv with all the soft interface information
+ * @arg...: format string and variable arguments
+ */
 #define batadv_dbg_ratelimited(type, bat_priv, arg...) \
_batadv_dbg(type, bat_priv, 1, ## arg)
 
+/**
+ * batadv_info() - Store message in debug buffer and print it to kmsg buffer
+ * @net_dev: the soft interface net device
+ * @fmt: format string
+ * @arg...: variable arguments
+ */
 #define batadv_info(net_dev, fmt, arg...)  \
do {\
struc

[PATCH 05/20] batman-adv: Add SPDX license identifier to batman-adv.rst

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The "Linux licensing rules" require that also the restructuredText files
are marked with the appropriate SPDX license identifier.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 Documentation/networking/batman-adv.rst | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/networking/batman-adv.rst 
b/Documentation/networking/batman-adv.rst
index a342b2cc3dc6..245fb6c0ab6f 100644
--- a/Documentation/networking/batman-adv.rst
+++ b/Documentation/networking/batman-adv.rst
@@ -1,3 +1,5 @@
+.. SPDX-License-Identifier: GPL-2.0
+
 ==
 batman-adv
 ==
-- 
2.11.0



[PATCH 04/20] batman-adv: Add SPDX license identifier above copyright header

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The "Linux kernel licensing rules" require that each file has a SPDX
license identifier as first line (and sometimes as second line).

The FSFE REUSE practices [1] would also require the same tags but have no
restrictions on the placement in the source file. Using the "Linux kernel
licensing rules" is therefore also fulfilling the FSFE REUSE practices
requirements at the same time.

[1] https://reuse.software/practices/

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 include/uapi/linux/batman_adv.h| 1 +
 net/batman-adv/Makefile| 2 +-
 net/batman-adv/bat_algo.c  | 1 +
 net/batman-adv/bat_algo.h  | 1 +
 net/batman-adv/bat_iv_ogm.c| 1 +
 net/batman-adv/bat_iv_ogm.h| 1 +
 net/batman-adv/bat_v.c | 1 +
 net/batman-adv/bat_v.h | 1 +
 net/batman-adv/bat_v_elp.c | 1 +
 net/batman-adv/bat_v_elp.h | 1 +
 net/batman-adv/bat_v_ogm.c | 1 +
 net/batman-adv/bat_v_ogm.h | 1 +
 net/batman-adv/bitarray.c  | 1 +
 net/batman-adv/bitarray.h  | 1 +
 net/batman-adv/bridge_loop_avoidance.c | 1 +
 net/batman-adv/bridge_loop_avoidance.h | 1 +
 net/batman-adv/debugfs.c   | 1 +
 net/batman-adv/debugfs.h   | 1 +
 net/batman-adv/distributed-arp-table.c | 1 +
 net/batman-adv/distributed-arp-table.h | 1 +
 net/batman-adv/fragmentation.c | 1 +
 net/batman-adv/fragmentation.h | 1 +
 net/batman-adv/gateway_client.c| 1 +
 net/batman-adv/gateway_client.h| 1 +
 net/batman-adv/gateway_common.c| 1 +
 net/batman-adv/gateway_common.h| 1 +
 net/batman-adv/hard-interface.c| 1 +
 net/batman-adv/hard-interface.h| 1 +
 net/batman-adv/hash.c  | 1 +
 net/batman-adv/hash.h  | 1 +
 net/batman-adv/icmp_socket.c   | 1 +
 net/batman-adv/icmp_socket.h   | 1 +
 net/batman-adv/log.c   | 1 +
 net/batman-adv/log.h   | 1 +
 net/batman-adv/main.c  | 1 +
 net/batman-adv/main.h  | 1 +
 net/batman-adv/multicast.c | 1 +
 net/batman-adv/multicast.h | 1 +
 net/batman-adv/netlink.c   | 1 +
 net/batman-adv/netlink.h   | 1 +
 net/batman-adv/network-coding.c| 1 +
 net/batman-adv/network-coding.h| 1 +
 net/batman-adv/originator.c| 1 +
 net/batman-adv/originator.h| 1 +
 net/batman-adv/packet.h| 1 +
 net/batman-adv/routing.c   | 1 +
 net/batman-adv/routing.h   | 1 +
 net/batman-adv/send.c  | 1 +
 net/batman-adv/send.h  | 1 +
 net/batman-adv/soft-interface.c| 1 +
 net/batman-adv/soft-interface.h| 1 +
 net/batman-adv/sysfs.c | 1 +
 net/batman-adv/sysfs.h | 1 +
 net/batman-adv/tp_meter.c  | 1 +
 net/batman-adv/tp_meter.h  | 1 +
 net/batman-adv/translation-table.c | 1 +
 net/batman-adv/translation-table.h | 1 +
 net/batman-adv/tvlv.c  | 1 +
 net/batman-adv/tvlv.h  | 1 +
 net/batman-adv/types.h | 1 +
 60 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/batman_adv.h b/include/uapi/linux/batman_adv.h
index efd641c8a5d6..fb4533826163 100644
--- a/include/uapi/linux/batman_adv.h
+++ b/include/uapi/linux/batman_adv.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: ISC */
 /* Copyright (C) 2016-2017  B.A.T.M.A.N. contributors:
  *
  * Matthias Schiffer
diff --git a/net/batman-adv/Makefile b/net/batman-adv/Makefile
index f70dbd8a2935..93165ca0ea0c 100644
--- a/net/batman-adv/Makefile
+++ b/net/batman-adv/Makefile
@@ -1,4 +1,4 @@
-#
+# SPDX-License-Identifier: GPL-2.0
 # Copyright (C) 2007-2017  B.A.T.M.A.N. contributors:
 #
 # Marek Lindner, Simon Wunderlich
diff --git a/net/batman-adv/bat_algo.c b/net/batman-adv/bat_algo.c
index 921700ab306d..36407f5bde08 100644
--- a/net/batman-adv/bat_algo.c
+++ b/net/batman-adv/bat_algo.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /* Copyright (C) 2007-2017  B.A.T.M.A.N. contributors:
  *
  * Marek Lindner, Simon Wunderlich
diff --git a/net/batman-adv/bat_algo.h b/net/batman-adv/bat_algo.h
index 78836cf312d4..5c0a260eee5f 100644
--- a/net/batman-adv/bat_algo.h
+++ b/net/batman-adv/bat_algo.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /* Copyright (C) 2011-2017  B.A.T.M.A.N. contributors:
  *
  * Marek Lindner, Linus Lüssing
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 96bc5d46548f..4de912c87c23 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /* Copyright (C) 2007-2017  B.A.T.M.A.N. cont

[PATCH 06/20] batman-adv: Add license header to Kconfig

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The last remaining file without license notice and/or SPDX license
identifier under net/batman-adv/ is the Kconfig. It should have been
licensed under the same conditions as the rest of batman-adv and the
Makefile which uses the CONFIG_* variables from Kconfig.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/Kconfig | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/net/batman-adv/Kconfig b/net/batman-adv/Kconfig
index b73b96a2854b..73d84707965a 100644
--- a/net/batman-adv/Kconfig
+++ b/net/batman-adv/Kconfig
@@ -1,3 +1,22 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2007-2017  B.A.T.M.A.N. contributors:
+#
+# Marek Lindner, Simon Wunderlich
+#
+# 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, see <http://www.gnu.org/licenses/>.
+#
+# License-Filename: LICENSES/preferred/GPL-2.0
+
 #
 # B.A.T.M.A.N meshing protocol
 #
-- 
2.11.0



[PATCH 16/20] batman-adv: Fix kernel-doc references to struct members

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The correct syntax to create references in kernel-doc to a struct member is
not "struct_name::member"" but "_name->member" or
"_name.member". The correct syntax is required to get the correct
cross-referencing in the reStructuredText text output.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/types.h | 49 ++---
 1 file changed, 26 insertions(+), 23 deletions(-)

diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index cd68b30879d0..e4a79f9e2e24 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -236,7 +236,7 @@ struct batadv_hard_iface {
  * struct batadv_orig_ifinfo - originator info per outgoing interface
  */
 struct batadv_orig_ifinfo {
-   /** @list: list node for orig_node::ifinfo_list */
+   /** @list: list node for _orig_node.ifinfo_list */
struct hlist_node list;
 
/** @if_outgoing: pointer to outgoing hard-interface */
@@ -322,7 +322,7 @@ struct batadv_orig_node_vlan {
/** @tt: VLAN specific TT attributes */
struct batadv_vlan_tt tt;
 
-   /** @list: list node for orig_node::vlan_list */
+   /** @list: list node for _orig_node.vlan_list */
struct hlist_node list;
 
/**
@@ -469,7 +469,7 @@ struct batadv_orig_node {
 */
spinlock_t neigh_list_lock;
 
-   /** @hash_entry: hlist node for batadv_priv::orig_hash */
+   /** @hash_entry: hlist node for _priv.orig_hash */
struct hlist_node hash_entry;
 
/** @bat_priv: pointer to soft_iface this orig node belongs to */
@@ -541,7 +541,7 @@ enum batadv_orig_capabilities {
  * struct batadv_gw_node - structure for orig nodes announcing gw capabilities
  */
 struct batadv_gw_node {
-   /** @list: list node for batadv_priv_gw::list */
+   /** @list: list node for _priv_gw.list */
struct hlist_node list;
 
/** @orig_node: pointer to corresponding orig node */
@@ -590,7 +590,7 @@ struct batadv_hardif_neigh_node_bat_v {
  * struct batadv_hardif_neigh_node - unique neighbor per hard-interface
  */
 struct batadv_hardif_neigh_node {
-   /** @list: list node for batadv_hard_iface::neigh_list */
+   /** @list: list node for _hard_iface.neigh_list */
struct hlist_node list;
 
/** @addr: the MAC address of the neighboring interface */
@@ -623,7 +623,7 @@ struct batadv_hardif_neigh_node {
  * struct batadv_neigh_node - structure for single hops neighbors
  */
 struct batadv_neigh_node {
-   /** @list: list node for batadv_orig_node::neigh_list */
+   /** @list: list node for _orig_node.neigh_list */
struct hlist_node list;
 
/** @orig_node: pointer to corresponding orig_node */
@@ -699,7 +699,7 @@ struct batadv_neigh_ifinfo_bat_v {
  * struct batadv_neigh_ifinfo - neighbor information per outgoing interface
  */
 struct batadv_neigh_ifinfo {
-   /** @list: list node for batadv_neigh_node::ifinfo_list */
+   /** @list: list node for _neigh_node.ifinfo_list */
struct hlist_node list;
 
/** @if_outgoing: pointer to outgoing hard-interface */
@@ -1310,7 +1310,7 @@ struct batadv_tp_unacked {
/** @len: length of the packet */
u16 len;
 
-   /** @list: list node for batadv_tp_vars::unacked_list */
+   /** @list: list node for _tp_vars.unacked_list */
struct list_head list;
 };
 
@@ -1329,7 +1329,7 @@ enum batadv_tp_meter_role {
  * struct batadv_tp_vars - tp meter private variables per session
  */
 struct batadv_tp_vars {
-   /** @list: list node for bat_priv::tp_list */
+   /** @list: list node for _priv.tp_list */
struct hlist_node list;
 
/** @timer: timer for ack (receiver) and retry (sender) */
@@ -1461,7 +1461,7 @@ struct batadv_softif_vlan {
/** @tt: TT private attributes (VLAN specific) */
struct batadv_vlan_tt tt;
 
-   /** @list: list node for bat_priv::softif_vlan_list */
+   /** @list: list node for _priv.softif_vlan_list */
struct hlist_node list;
 
/**
@@ -1729,7 +1729,7 @@ struct batadv_socket_client {
  * struct batadv_socket_packet - layer2 icmp packet for socket client
  */
 struct batadv_socket_packet {
-   /** @list: list node for batadv_socket_client::queue_list */
+   /** @list: list node for _socket_client.queue_list */
struct list_head list;
 
/** @icmp_len: size of the layer2 icmp packet */
@@ -1754,7 +1754,7 @@ struct batadv_bla_backbone_gw {
/** @vid: vlan id this gateway was detected on */
unsigned short vid;
 
-   /** @hash_entry: hlist node for batadv_priv_bla::backbone_hash */
+   /** @hash_entry: hlist node for _priv_bla.backbone_hash */
struct hlist_node hash_entry;
 
/** @bat_priv: pointer to soft_iface this backbone gateway bel

[PATCH 20/20] batman-adv: Add kernel-doc to externally visible functions

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

According to the kernel-doc documentation, externally visible functions
should be documented. This refers to all all non-static function which can
(and will) be used by functions in other sources files.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_algo.c  | 27 
 net/batman-adv/bat_iv_ogm.c|  5 +
 net/batman-adv/debugfs.c   | 16 ++
 net/batman-adv/gateway_client.c| 38 +
 net/batman-adv/gateway_common.c|  9 
 net/batman-adv/hard-interface.c| 36 ++-
 net/batman-adv/hash.c  | 17 +--
 net/batman-adv/icmp_socket.c   |  9 
 net/batman-adv/log.c   | 17 +++
 net/batman-adv/main.c  | 31 +++
 net/batman-adv/originator.c| 43 ++
 net/batman-adv/routing.c   | 29 +
 net/batman-adv/send.c  | 18 
 net/batman-adv/soft-interface.c| 20 ++
 net/batman-adv/sysfs.c | 32 
 net/batman-adv/translation-table.c | 37 
 16 files changed, 381 insertions(+), 3 deletions(-)

diff --git a/net/batman-adv/bat_algo.c b/net/batman-adv/bat_algo.c
index 06139233bb54..37390a21e5e9 100644
--- a/net/batman-adv/bat_algo.c
+++ b/net/batman-adv/bat_algo.c
@@ -63,6 +63,12 @@ static struct batadv_algo_ops *batadv_algo_get(char *name)
return bat_algo_ops;
 }
 
+/**
+ * batadv_algo_register() - Register callbacks for a mesh algorithm
+ * @bat_algo_ops: mesh algorithm callbacks to add
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
 int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops)
 {
struct batadv_algo_ops *bat_algo_ops_tmp;
@@ -92,6 +98,19 @@ int batadv_algo_register(struct batadv_algo_ops 
*bat_algo_ops)
return 0;
 }
 
+/**
+ * batadv_algo_select() - Select algorithm of soft interface
+ * @bat_priv: the bat priv with all the soft interface information
+ * @name: name of the algorithm to select
+ *
+ * The algorithm callbacks for the soft interface will be set when the 
algorithm
+ * with the correct name was found. Any previous selected algorithm will not be
+ * deinitialized and the new selected algorithm will also not be initialized.
+ * It is therefore not allowed to call batadv_algo_select outside the creation
+ * function of the soft interface.
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
 int batadv_algo_select(struct batadv_priv *bat_priv, char *name)
 {
struct batadv_algo_ops *bat_algo_ops;
@@ -106,6 +125,14 @@ int batadv_algo_select(struct batadv_priv *bat_priv, char 
*name)
 }
 
 #ifdef CONFIG_BATMAN_ADV_DEBUGFS
+
+/**
+ * batadv_algo_seq_print_text() - Print the supported algorithms in a seq file
+ * @seq: seq file to print on
+ * @offset: not used
+ *
+ * Return: always 0
+ */
 int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
 {
struct batadv_algo_ops *bat_algo_ops;
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index b65cd2366e60..4055338de7f0 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -2855,6 +2855,11 @@ static struct batadv_algo_ops batadv_batman_iv 
__read_mostly = {
},
 };
 
+/**
+ * batadv_iv_init() - B.A.T.M.A.N. IV initialization function
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
 int __init batadv_iv_init(void)
 {
int ret;
diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c
index a36c5ad90912..f179172dd051 100644
--- a/net/batman-adv/debugfs.c
+++ b/net/batman-adv/debugfs.c
@@ -261,6 +261,9 @@ static struct batadv_debuginfo *batadv_hardif_debuginfos[] 
= {
NULL,
 };
 
+/**
+ * batadv_debugfs_init() - Initialize soft interface independent debugfs 
entries
+ */
 void batadv_debugfs_init(void)
 {
struct batadv_debuginfo **bat_debug;
@@ -291,6 +294,9 @@ void batadv_debugfs_init(void)
batadv_debugfs = NULL;
 }
 
+/**
+ * batadv_debugfs_destroy() - Remove all debugfs entries
+ */
 void batadv_debugfs_destroy(void)
 {
debugfs_remove_recursive(batadv_debugfs);
@@ -357,6 +363,12 @@ void batadv_debugfs_del_hardif(struct batadv_hard_iface 
*hard_iface)
}
 }
 
+/**
+ * batadv_debugfs_add_meshif() - Initialize interface dependent debugfs entries
+ * @dev: netdev struct of the soft interface
+ *
+ * Return: 0 on success or negative error number in case of failure
+ */
 int batadv_debugfs_add_meshif(struct net_device *dev)
 {
struct batadv_priv *bat_priv = netdev_priv(dev);
@@ -403,6 +415,10 @@ int batadv_debugfs_add_meshif(struct net_device *dev)

[PATCH 07/20] batman-adv: Change batman_adv.h license to MIT

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The ISC license is considered as not recommended in "Linux kernel licensing
rules". It should only be used for existing code or for importing code from
a different project with that license.

But the kernel still has the similar sounding MIT/Expat license under the
preferred licenses. Switching to this license for this relatively new file
should therefore allow batman-adv to better follow the new licensing rules.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Acked-by: Antonio Quartulli <a...@unstable.cc>
Acked-by: Matthias Schiffer <mschif...@universe-factory.net>
Acked-by: Andrew Lunn <and...@lunn.ch>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 include/uapi/linux/batman_adv.h | 28 +---
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/include/uapi/linux/batman_adv.h b/include/uapi/linux/batman_adv.h
index fb4533826163..ae00c99cbed0 100644
--- a/include/uapi/linux/batman_adv.h
+++ b/include/uapi/linux/batman_adv.h
@@ -1,19 +1,25 @@
-/* SPDX-License-Identifier: ISC */
+/* SPDX-License-Identifier: MIT */
 /* Copyright (C) 2016-2017  B.A.T.M.A.N. contributors:
  *
  * Matthias Schiffer
  *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 
 #ifndef _UAPI_LINUX_BATMAN_ADV_H_
-- 
2.11.0



[PATCH 17/20] batman-adv: Add kernel-doc to structs in headers

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

All structs in types.h are already documented. But some other headers
still have private structs which also should be documented.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/hash.h  | 14 +++---
 net/batman-adv/sysfs.h | 13 +
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h
index 7647757d3660..239f394512b9 100644
--- a/net/batman-adv/hash.h
+++ b/net/batman-adv/hash.h
@@ -48,10 +48,18 @@ typedef bool (*batadv_hashdata_compare_cb)(const struct 
hlist_node *,
 typedef u32 (*batadv_hashdata_choose_cb)(const void *, u32);
 typedef void (*batadv_hashdata_free_cb)(struct hlist_node *, void *);
 
+/**
+ * struct batadv_hashtable - Wrapper of simple hlist based hashtable
+ */
 struct batadv_hashtable {
-   struct hlist_head *table;   /* the hashtable itself with the buckets */
-   spinlock_t *list_locks; /* spinlock for each hash list entry */
-   u32 size;   /* size of hashtable */
+   /** @table: the hashtable itself with the buckets */
+   struct hlist_head *table;
+
+   /** @list_locks: spinlock for each hash list entry */
+   spinlock_t *list_locks;
+
+   /** @size: size of hashtable */
+   u32 size;
 };
 
 /* allocates and clears the hash */
diff --git a/net/batman-adv/sysfs.h b/net/batman-adv/sysfs.h
index 0a3d41d52208..7cf7da70e1a5 100644
--- a/net/batman-adv/sysfs.h
+++ b/net/batman-adv/sysfs.h
@@ -38,10 +38,23 @@ struct net_device;
  */
 #define BATADV_SYSFS_VLAN_SUBDIR_PREFIX "vlan"
 
+/**
+ * struct batadv_attribute - sysfs export helper for batman-adv attributes
+ */
 struct batadv_attribute {
+   /** @attr: sysfs attribute file */
struct attribute attr;
+
+   /**
+* @show: function to export the current attribute's content to sysfs
+*/
ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
char *buf);
+
+   /**
+* @store: function to load new value from character buffer and save it
+* in batman-adv attribute
+*/
ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
 char *buf, size_t count);
 };
-- 
2.11.0



[PATCH 18/20] batman-adv: Add kernel-doc to enums in headers

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

All enums in types.h are already documented. But some other headers
still have private enums which also should be documented.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/hard-interface.h | 23 +++
 net/batman-adv/main.h   | 32 
 2 files changed, 55 insertions(+)

diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index d90d9cfa7a7a..f29974b487cc 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -33,12 +33,35 @@
 struct net_device;
 struct net;
 
+/**
+ * enum batadv_hard_if_state - State of a hard interface
+ */
 enum batadv_hard_if_state {
+   /**
+* @BATADV_IF_NOT_IN_USE: interface is not used as slave interface of a
+* batman-adv soft interface
+*/
BATADV_IF_NOT_IN_USE,
+
+   /**
+* @BATADV_IF_TO_BE_REMOVED: interface will be removed from soft
+* interface
+*/
BATADV_IF_TO_BE_REMOVED,
+
+   /** @BATADV_IF_INACTIVE: interface is deactivated */
BATADV_IF_INACTIVE,
+
+   /** @BATADV_IF_ACTIVE: interface is used */
BATADV_IF_ACTIVE,
+
+   /** @BATADV_IF_TO_BE_ACTIVATED: interface is getting activated */
BATADV_IF_TO_BE_ACTIVATED,
+
+   /**
+* @BATADV_IF_I_WANT_YOU: interface is queued up (using sysfs) for being
+* added as slave interface of a batman-adv soft interface
+*/
BATADV_IF_I_WANT_YOU,
 };
 
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 63b3ee0bbc40..53f386bedd3b 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -143,24 +143,56 @@
  */
 #define BATADV_TP_MAX_NUM 5
 
+/**
+ * enum batadv_mesh_state - State of a soft interface
+ */
 enum batadv_mesh_state {
+   /** @BATADV_MESH_INACTIVE: soft interface is not yet running */
BATADV_MESH_INACTIVE,
+
+   /** @BATADV_MESH_ACTIVE: interface is up and running */
BATADV_MESH_ACTIVE,
+
+   /** @BATADV_MESH_DEACTIVATING: interface is getting shut down */
BATADV_MESH_DEACTIVATING,
 };
 
 #define BATADV_BCAST_QUEUE_LEN 256
 #define BATADV_BATMAN_QUEUE_LEN256
 
+/**
+ * enum batadv_uev_action - action type of uevent
+ */
 enum batadv_uev_action {
+   /** @BATADV_UEV_ADD: gateway was selected (after none was selected) */
BATADV_UEV_ADD = 0,
+
+   /**
+* @BATADV_UEV_DEL: selected gateway was removed and none is selected
+* anymore
+*/
BATADV_UEV_DEL,
+
+   /**
+* @BATADV_UEV_CHANGE: a different gateway was selected as based gateway
+*/
BATADV_UEV_CHANGE,
+
+   /**
+* @BATADV_UEV_LOOPDETECT: loop was detected which cannot be handled by
+* bridge loop avoidance
+*/
BATADV_UEV_LOOPDETECT,
 };
 
+/**
+ * enum batadv_uev_type - Type of uevent
+ */
 enum batadv_uev_type {
+   /** @BATADV_UEV_GW: selected gateway was modified */
BATADV_UEV_GW = 0,
+
+   /** @BATADV_UEV_BLA: bridge loop avoidance event */
BATADV_UEV_BLA,
 };
 
-- 
2.11.0



[PATCH 15/20] batman-adv: Use inline kernel-doc for enum/struct

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The inline kernel-doc comments make it easier to keep changes to the
struct/enum synchronized with the documentation of the it. And it makes it
easier for larger structures like struct batadv_priv to read the
documentation inside the code.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_iv_ogm.c |   17 +-
 net/batman-adv/gateway_common.h |5 +-
 net/batman-adv/hard-interface.h |   27 +-
 net/batman-adv/log.h|   26 +-
 net/batman-adv/multicast.h  |   16 +-
 net/batman-adv/types.h  | 1989 +++
 6 files changed, 1444 insertions(+), 636 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 86e5a6f90bce..b65cd2366e60 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -75,16 +75,23 @@ static void 
batadv_iv_send_outstanding_bat_ogm_packet(struct work_struct *work);
 
 /**
  * enum batadv_dup_status - duplicate status
- * @BATADV_NO_DUP: the packet is no duplicate
- * @BATADV_ORIG_DUP: OGM is a duplicate in the originator (but not for the
- *  neighbor)
- * @BATADV_NEIGH_DUP: OGM is a duplicate for the neighbor
- * @BATADV_PROTECTED: originator is currently protected (after reboot)
  */
 enum batadv_dup_status {
+   /** @BATADV_NO_DUP: the packet is no duplicate */
BATADV_NO_DUP = 0,
+
+   /**
+* @BATADV_ORIG_DUP: OGM is a duplicate in the originator (but not for
+*  the neighbor)
+*/
BATADV_ORIG_DUP,
+
+   /** @BATADV_NEIGH_DUP: OGM is a duplicate for the neighbor */
BATADV_NEIGH_DUP,
+
+   /**
+* @BATADV_PROTECTED: originator is currently protected (after reboot)
+*/
BATADV_PROTECTED,
 };
 
diff --git a/net/batman-adv/gateway_common.h b/net/batman-adv/gateway_common.h
index a1fb66f9ca72..372331aca69f 100644
--- a/net/batman-adv/gateway_common.h
+++ b/net/batman-adv/gateway_common.h
@@ -35,11 +35,12 @@ enum batadv_gw_modes {
 
 /**
  * enum batadv_bandwidth_units - bandwidth unit types
- * @BATADV_BW_UNIT_KBIT: unit type kbit
- * @BATADV_BW_UNIT_MBIT: unit type mbit
  */
 enum batadv_bandwidth_units {
+   /** @BATADV_BW_UNIT_KBIT: unit type kbit */
BATADV_BW_UNIT_KBIT,
+
+   /** @BATADV_BW_UNIT_MBIT: unit type mbit */
BATADV_BW_UNIT_MBIT,
 };
 
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index ba7b117c8926..d90d9cfa7a7a 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -44,25 +44,40 @@ enum batadv_hard_if_state {
 
 /**
  * enum batadv_hard_if_bcast - broadcast avoidance options
- * @BATADV_HARDIF_BCAST_OK: Do broadcast on according hard interface
- * @BATADV_HARDIF_BCAST_NORECIPIENT: Broadcast not needed, there is no 
recipient
- * @BATADV_HARDIF_BCAST_DUPFWD: There is just the neighbor we got it from
- * @BATADV_HARDIF_BCAST_DUPORIG: There is just the originator
  */
 enum batadv_hard_if_bcast {
+   /** @BATADV_HARDIF_BCAST_OK: Do broadcast on according hard interface */
BATADV_HARDIF_BCAST_OK = 0,
+
+   /**
+* @BATADV_HARDIF_BCAST_NORECIPIENT: Broadcast not needed, there is no
+*  recipient
+*/
BATADV_HARDIF_BCAST_NORECIPIENT,
+
+   /**
+* @BATADV_HARDIF_BCAST_DUPFWD: There is just the neighbor we got it
+*  from
+*/
BATADV_HARDIF_BCAST_DUPFWD,
+
+   /** @BATADV_HARDIF_BCAST_DUPORIG: There is just the originator */
BATADV_HARDIF_BCAST_DUPORIG,
 };
 
 /**
  * enum batadv_hard_if_cleanup - Cleanup modi for soft_iface after slave 
removal
- * @BATADV_IF_CLEANUP_KEEP: Don't automatically delete soft-interface
- * @BATADV_IF_CLEANUP_AUTO: Delete soft-interface after last slave was removed
  */
 enum batadv_hard_if_cleanup {
+   /**
+* @BATADV_IF_CLEANUP_KEEP: Don't automatically delete soft-interface
+*/
BATADV_IF_CLEANUP_KEEP,
+
+   /**
+* @BATADV_IF_CLEANUP_AUTO: Delete soft-interface after last slave was
+*  removed
+*/
BATADV_IF_CLEANUP_AUTO,
 };
 
diff --git a/net/batman-adv/log.h b/net/batman-adv/log.h
index f880d8741c7f..67e25121a4de 100644
--- a/net/batman-adv/log.h
+++ b/net/batman-adv/log.h
@@ -47,25 +47,33 @@ static inline void batadv_debug_log_cleanup(struct 
batadv_priv *bat_priv)
 
 /**
  * enum batadv_dbg_level - available log levels
- * @BATADV_DBG_BATMAN: OGM and TQ computations related messages
- * @BATADV_DBG_ROUTES: route added / changed / deleted
- * @BATADV_DBG_TT: translation table messages
- * @BATADV_DBG_BLA: bridge loop avoidance messages
- * @BATADV_DBG_DAT: ARP snooping and DAT related messages
- * @BATADV_DBG_NC: network coding related messages
- * @BATADV_DBG_MCAST: multicast related messages
- * @BATADV_DBG_TP_METER: throughput meter messages
- * @BATADV_DBG_ALL: the unio

[PATCH 11/20] batman-adv: include kobject.h for kobject_* functions

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The linux/kobject.h provides the kobject_* function declarations and should
therefore be included directly before they are used.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/sysfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index 5c29e38a1ad1..9eed06647065 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.11.0



[PATCH 13/20] batman-adv: Add missing kernel-doc to packet.h

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/packet.h | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index d58288c3a99d..ebe0605d1505 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -24,6 +24,12 @@
 #include 
 #include 
 
+/**
+ * batadv_tp_is_error() - Check throughput meter return code for error
+ * @n: throughput meter return code
+ *
+ * Return: 0 when not error was detected, != 0 otherwise
+ */
 #define batadv_tp_is_error(n) ((u8)(n) > 127 ? 1 : 0)
 
 /**
@@ -91,7 +97,15 @@ enum batadv_iv_flags {
BATADV_DIRECTLINK  = BIT(2),
 };
 
-/* ICMP message types */
+/**
+ * enum batadv_icmp_packettype - ICMP message types
+ * @BATADV_ECHO_REPLY: success reply to BATADV_ECHO_REQUEST
+ * @BATADV_DESTINATION_UNREACHABLE: failure when route to destination not found
+ * @BATADV_ECHO_REQUEST: request BATADV_ECHO_REPLY from destination
+ * @BATADV_TTL_EXCEEDED: error after BATADV_ECHO_REQUEST traversed too many 
hops
+ * @BATADV_PARAMETER_PROBLEM: return code for malformed messages
+ * @BATADV_TP: throughput meter packet
+ */
 enum batadv_icmp_packettype {
BATADV_ECHO_REPLY  = 0,
BATADV_DESTINATION_UNREACHABLE = 3,
@@ -139,7 +153,14 @@ enum batadv_vlan_flags {
BATADV_VLAN_HAS_TAG = BIT(15),
 };
 
-/* claim frame types for the bridge loop avoidance */
+/**
+ * enum batadv_bla_claimframe - claim frame types for the bridge loop avoidance
+ * @BATADV_CLAIM_TYPE_CLAIM: claim of a client mac address
+ * @BATADV_CLAIM_TYPE_UNCLAIM: unclaim of a client mac address
+ * @BATADV_CLAIM_TYPE_ANNOUNCE: announcement of backbone with current crc
+ * @BATADV_CLAIM_TYPE_REQUEST: request of full claim table
+ * @BATADV_CLAIM_TYPE_LOOPDETECT: mesh-traversing loop detect packet
+ */
 enum batadv_bla_claimframe {
BATADV_CLAIM_TYPE_CLAIM = 0x00,
BATADV_CLAIM_TYPE_UNCLAIM   = 0x01,
-- 
2.11.0



[PATCH 19/20] batman-adv: Add kernel-doc to functions in headers

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

Externally visible functions should be documented with kernel-doc. This
usually refers to non-static functions but also static inline files in
headers are visible in other files and should therefore be documented.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bitarray.h   |  7 +++-
 net/batman-adv/hard-interface.h |  6 +++
 net/batman-adv/hash.h   | 11 +-
 net/batman-adv/log.h| 35 +-
 net/batman-adv/main.h   | 82 ++---
 net/batman-adv/originator.h |  9 -
 6 files changed, 131 insertions(+), 19 deletions(-)

diff --git a/net/batman-adv/bitarray.h b/net/batman-adv/bitarray.h
index 25c2cca948e3..611a609da80b 100644
--- a/net/batman-adv/bitarray.h
+++ b/net/batman-adv/bitarray.h
@@ -49,7 +49,12 @@ static inline bool batadv_test_bit(const unsigned long 
*seq_bits,
return test_bit(diff, seq_bits) != 0;
 }
 
-/* turn corresponding bit on, so we can remember that we got the packet */
+/**
+ * batadv_set_bit() - Turn corresponding bit on, so we can remember that we got
+ *  the packet
+ * @seq_bits: bitmap of the packet receive window
+ * @n: relative sequence number of newly received packet
+ */
 static inline void batadv_set_bit(unsigned long *seq_bits, s32 n)
 {
/* if too old, just drop it */
diff --git a/net/batman-adv/hard-interface.h b/net/batman-adv/hard-interface.h
index f29974b487cc..52cdc7efbf97 100644
--- a/net/batman-adv/hard-interface.h
+++ b/net/batman-adv/hard-interface.h
@@ -132,6 +132,12 @@ static inline void batadv_hardif_put(struct 
batadv_hard_iface *hard_iface)
kref_put(_iface->refcount, batadv_hardif_release);
 }
 
+/**
+ * batadv_primary_if_get_selected() - Get reference to primary interface
+ * @bat_priv: the bat priv with all the soft interface information
+ *
+ * Return: primary interface (with increased refcnt), otherwise NULL
+ */
 static inline struct batadv_hard_iface *
 batadv_primary_if_get_selected(struct batadv_priv *bat_priv)
 {
diff --git a/net/batman-adv/hash.h b/net/batman-adv/hash.h
index 239f394512b9..29a2842c4ed8 100644
--- a/net/batman-adv/hash.h
+++ b/net/batman-adv/hash.h
@@ -123,8 +123,15 @@ static inline int batadv_hash_add(struct batadv_hashtable 
*hash,
return ret;
 }
 
-/* removes data from hash, if found. data could be the structure you use with
- * just the key filled, we just need the key for comparing.
+/**
+ * batadv_hash_remove() - Removes data from hash, if found
+ * @hash: hash table
+ * @compare: callback to determine if 2 hash elements are identical
+ * @choose: callback calculating the hash index
+ * @data: data passed to the aforementioned callbacks as argument
+ *
+ * ata could be the structure you use with  just the key filled, we just need
+ * the key for comparing.
  *
  * Return: returns pointer do data on success, so you can remove the used
  * structure yourself, or NULL on error
diff --git a/net/batman-adv/log.h b/net/batman-adv/log.h
index 67e25121a4de..09d457e385fe 100644
--- a/net/batman-adv/log.h
+++ b/net/batman-adv/log.h
@@ -81,7 +81,14 @@ enum batadv_dbg_level {
 int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
 __printf(2, 3);
 
-/* possibly ratelimited debug output */
+/**
+ * _batadv_dbg() - Store debug output with(out) ratelimiting
+ * @type: type of debug message
+ * @bat_priv: the bat priv with all the soft interface information
+ * @ratelimited: whether output should be rate limited
+ * @fmt: format string
+ * @arg...: variable arguments
+ */
 #define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...)  \
do {\
struct batadv_priv *__batpriv = (bat_priv); \
@@ -100,11 +107,30 @@ static inline void _batadv_dbg(int type __always_unused,
 }
 #endif
 
+/**
+ * batadv_dbg() - Store debug output without ratelimiting
+ * @type: type of debug message
+ * @bat_priv: the bat priv with all the soft interface information
+ * @arg...: format string and variable arguments
+ */
 #define batadv_dbg(type, bat_priv, arg...) \
_batadv_dbg(type, bat_priv, 0, ## arg)
+
+/**
+ * batadv_dbg_ratelimited() - Store debug output with ratelimiting
+ * @type: type of debug message
+ * @bat_priv: the bat priv with all the soft interface information
+ * @arg...: format string and variable arguments
+ */
 #define batadv_dbg_ratelimited(type, bat_priv, arg...) \
_batadv_dbg(type, bat_priv, 1, ## arg)
 
+/**
+ * batadv_info() - Store message in debug buffer and print it to kmsg buffer
+ * @net_dev: the soft interface net device
+ * @fmt: format string
+ * @arg...: variable arguments
+ */
 #define batadv_info(net_dev, fmt, arg...)  \
do {\

[PATCH 12/20] batman-adv: Remove unused sched.h include

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The linux/wait.h include was removed with commit 421d988b2c08 ("batman-adv:
Consolidate logging related functions"). The previously required (but not
unused) linux/sched.h include can also be dropped now.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/debugfs.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c
index e5f76c76f3ed..96df39597ae7 100644
--- a/net/batman-adv/debugfs.c
+++ b/net/batman-adv/debugfs.c
@@ -28,7 +28,6 @@
 #include 
 #include 
 #include 
-#include  /* for linux/wait.h */
 #include 
 #include 
 #include 
-- 
2.11.0



[PATCH 09/20] batman-adv: include build_bug.h for BUILD_BUG_ON define

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

commit bc6245e5efd7 ("bug: split BUILD_BUG stuff out into
") added a new header for BUILD_BUG_ON. It should
therefore be included instead of linux/bug.h

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 compat-include/linux/build_bug.h   | 34 ++
 net/batman-adv/main.c  |  2 +-
 net/batman-adv/tp_meter.c  |  2 +-
 net/batman-adv/translation-table.c |  2 +-
 4 files changed, 37 insertions(+), 3 deletions(-)
 create mode 100644 compat-include/linux/build_bug.h

diff --git a/compat-include/linux/build_bug.h b/compat-include/linux/build_bug.h
new file mode 100644
index ..d1ebfa71e2b6
--- /dev/null
+++ b/compat-include/linux/build_bug.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2007-2017  B.A.T.M.A.N. contributors:
+ *
+ * Marek Lindner, Simon Wunderlich
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * License-Filename: LICENSES/preferred/GPL-2.0
+ *
+ * This file contains macros for maintaining compatibility with older versions
+ * of the Linux kernel.
+ */
+
+#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_BUILD_BUG_H_
+#define _NET_BATMAN_ADV_COMPAT_LINUX_BUILD_BUG_H_
+
+#include 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
+#include_next 
+#else
+#include 
+#endif
+
+#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_BUILD_BUG_H_ */
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 45f0f4ff8a08..107b50e5ecc2 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -21,7 +21,7 @@
 #include "main.h"
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c
index 45e7a77e5127..6f3dca80d74f 100644
--- a/net/batman-adv/tp_meter.c
+++ b/net/batman-adv/tp_meter.c
@@ -22,7 +22,7 @@
 #include "main.h"
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/translation-table.c 
b/net/batman-adv/translation-table.c
index 66092c6b2f6a..db7a67ee9599 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -23,7 +23,7 @@
 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
-- 
2.11.0



[PATCH 10/20] batman-adv: Include net.h for net_ratelimited_function

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The linux/net.h provides the net_ratelimited_function. It should
therefore be included directly before it is used.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/network-coding.c| 1 +
 net/batman-adv/translation-table.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
index f614d74fe74a..64f14f66a56b 100644
--- a/net/batman-adv/network-coding.c
+++ b/net/batman-adv/network-coding.c
@@ -38,6 +38,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/translation-table.c 
b/net/batman-adv/translation-table.c
index db7a67ee9599..ce90bfd70cd2 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.11.0



[PATCH 08/20] batman-adv: include gfp.h for GFP_* defines

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The linux/gfp.h provides the GFP_ATOMIC and GFP_KERNEL define. It should
therefore be included instead of linux/fs.h.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_iv_ogm.c| 2 +-
 net/batman-adv/bat_v_elp.c | 2 +-
 net/batman-adv/bat_v_ogm.c | 2 +-
 net/batman-adv/bridge_loop_avoidance.c | 2 +-
 net/batman-adv/distributed-arp-table.c | 2 +-
 net/batman-adv/fragmentation.c | 2 +-
 net/batman-adv/gateway_client.c| 2 +-
 net/batman-adv/hard-interface.c| 2 +-
 net/batman-adv/hash.c  | 2 +-
 net/batman-adv/icmp_socket.c   | 1 +
 net/batman-adv/log.c   | 1 +
 net/batman-adv/main.c  | 2 +-
 net/batman-adv/multicast.c | 2 +-
 net/batman-adv/netlink.c   | 2 +-
 net/batman-adv/network-coding.c| 2 +-
 net/batman-adv/originator.c| 2 +-
 net/batman-adv/send.c  | 2 +-
 net/batman-adv/soft-interface.c| 2 +-
 net/batman-adv/sysfs.c | 2 +-
 net/batman-adv/tp_meter.c  | 2 +-
 net/batman-adv/translation-table.c | 2 +-
 net/batman-adv/tvlv.c  | 2 +-
 22 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 4de912c87c23..250cb4fb66e7 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -29,7 +29,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c
index 1aa175a41d62..39fbed58e4c8 100644
--- a/net/batman-adv/bat_v_elp.c
+++ b/net/batman-adv/bat_v_elp.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c
index 0ce2d95a10aa..3cc5cd2f267e 100644
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -25,7 +25,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/bridge_loop_avoidance.c 
b/net/batman-adv/bridge_loop_avoidance.c
index f5b917b634df..2f12a556b6b0 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -27,7 +27,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/distributed-arp-table.c 
b/net/batman-adv/distributed-arp-table.c
index e708fda4654d..1035c53af616 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -26,7 +26,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index c49ca0503030..1c2024487eda 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -25,7 +25,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index b962430a45ee..cffa9e7f3665 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -25,7 +25,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
index 464c98f2a0c6..7f4596796c46 100644
--- a/net/batman-adv/hard-interface.c
+++ b/net/batman-adv/hard-interface.c
@@ -25,7 +25,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/hash.c b/net/batman-adv/hash.c
index 33fd8fae2a1d..0569ee47684f 100644
--- a/net/batman-adv/hash.c
+++ b/net/batman-adv/hash.c
@@ -21,7 +21,7 @@
 #include "hash.h"
 #include "main.h"
 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c
index ca51c488f159..f1a67eaaf5f5 100644
--- a/net/batman-adv/icmp_socket.c
+++ b/net/batman-adv/icmp_socket.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/log.c b/net/batman-adv/log.c
index 78e4dddb7f2d..59a1eb138e6a 100644
--- a/net/batman-adv/log.c
+++ b/net/batman-adv/log.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 6b3db9b42b08..45f0f4ff8a08 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -25,8 +25,8 @@
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
index 3cef5a764f8d..30c442e42d6f 100644
--- a/net/batman-adv/multic

[PATCH 02/20] batman-adv: Deinline batadv_orig_hash_find, save 7339 bytes

2017-12-15 Thread Simon Wunderlich
From: Denys Vlasenko <dvlas...@redhat.com>

This function compiles to 288 bytes of machine code for Linux 4.14 on
Debian Stretch amd64 and (6.3.0-18) with the default configuration. 27
callsites (25 used in default config).

   textdata bss dec hex filename
 179291   103174416  194024   2f5e8 batman-adv.ko.pre
 171952   103174416  186685   2d93d batman-adv.ko.post

Signed-off-by: Denys Vlasenko <dvlas...@redhat.com>
[s...@narfation.org: Fix includes, correct sizes+counts in commit message]
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/originator.c | 32 
 net/batman-adv/originator.h | 37 ++---
 2 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c
index 2967b86c13da..0a565d0422bb 100644
--- a/net/batman-adv/originator.c
+++ b/net/batman-adv/originator.c
@@ -30,10 +30,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -55,6 +57,36 @@
 /* hash class keys */
 static struct lock_class_key batadv_orig_hash_lock_class_key;
 
+struct batadv_orig_node *
+batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data)
+{
+   struct batadv_hashtable *hash = bat_priv->orig_hash;
+   struct hlist_head *head;
+   struct batadv_orig_node *orig_node, *orig_node_tmp = NULL;
+   int index;
+
+   if (!hash)
+   return NULL;
+
+   index = batadv_choose_orig(data, hash->size);
+   head = >table[index];
+
+   rcu_read_lock();
+   hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
+   if (!batadv_compare_eth(orig_node, data))
+   continue;
+
+   if (!kref_get_unless_zero(_node->refcount))
+   continue;
+
+   orig_node_tmp = orig_node;
+   break;
+   }
+   rcu_read_unlock();
+
+   return orig_node_tmp;
+}
+
 static void batadv_purge_orig(struct work_struct *work);
 
 /**
diff --git a/net/batman-adv/originator.h b/net/batman-adv/originator.h
index d94220a6d21a..40c7f039d5d7 100644
--- a/net/batman-adv/originator.h
+++ b/net/batman-adv/originator.h
@@ -23,14 +23,8 @@
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
-#include 
 #include 
 
-#include "hash.h"
-
 struct netlink_callback;
 struct seq_file;
 struct sk_buff;
@@ -100,34 +94,7 @@ static inline u32 batadv_choose_orig(const void *data, u32 
size)
return hash % size;
 }
 
-static inline struct batadv_orig_node *
-batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data)
-{
-   struct batadv_hashtable *hash = bat_priv->orig_hash;
-   struct hlist_head *head;
-   struct batadv_orig_node *orig_node, *orig_node_tmp = NULL;
-   int index;
-
-   if (!hash)
-   return NULL;
-
-   index = batadv_choose_orig(data, hash->size);
-   head = >table[index];
-
-   rcu_read_lock();
-   hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
-   if (!batadv_compare_eth(orig_node, data))
-   continue;
-
-   if (!kref_get_unless_zero(_node->refcount))
-   continue;
-
-   orig_node_tmp = orig_node;
-   break;
-   }
-   rcu_read_unlock();
-
-   return orig_node_tmp;
-}
+struct batadv_orig_node *
+batadv_orig_hash_find(struct batadv_priv *bat_priv, const void *data);
 
 #endif /* _NET_BATMAN_ADV_ORIGINATOR_H_ */
-- 
2.11.0



[PATCH 03/20] batman-adv: Add License-Filename to GPL-2.0 files

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The FSFE REUSE practices [1] recommend to add a "License-Filename" tag to
files which don't contain the complete license text. The GPL-2.0 files
usually only have a small notice at the beginning of the file. The longer
license is usually stored in a separate file and therefore should be
referenced accordingly.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/Makefile| 1 +
 net/batman-adv/bat_algo.c  | 2 ++
 net/batman-adv/bat_algo.h  | 2 ++
 net/batman-adv/bat_iv_ogm.c| 2 ++
 net/batman-adv/bat_iv_ogm.h| 2 ++
 net/batman-adv/bat_v.c | 2 ++
 net/batman-adv/bat_v.h | 2 ++
 net/batman-adv/bat_v_elp.c | 2 ++
 net/batman-adv/bat_v_elp.h | 2 ++
 net/batman-adv/bat_v_ogm.c | 2 ++
 net/batman-adv/bat_v_ogm.h | 2 ++
 net/batman-adv/bitarray.c  | 2 ++
 net/batman-adv/bitarray.h  | 2 ++
 net/batman-adv/bridge_loop_avoidance.c | 2 ++
 net/batman-adv/bridge_loop_avoidance.h | 2 ++
 net/batman-adv/debugfs.c   | 2 ++
 net/batman-adv/debugfs.h   | 2 ++
 net/batman-adv/distributed-arp-table.c | 2 ++
 net/batman-adv/distributed-arp-table.h | 2 ++
 net/batman-adv/fragmentation.c | 2 ++
 net/batman-adv/fragmentation.h | 2 ++
 net/batman-adv/gateway_client.c| 2 ++
 net/batman-adv/gateway_client.h| 2 ++
 net/batman-adv/gateway_common.c| 2 ++
 net/batman-adv/gateway_common.h| 2 ++
 net/batman-adv/hard-interface.c| 2 ++
 net/batman-adv/hard-interface.h| 2 ++
 net/batman-adv/hash.c  | 2 ++
 net/batman-adv/hash.h  | 2 ++
 net/batman-adv/icmp_socket.c   | 2 ++
 net/batman-adv/icmp_socket.h   | 2 ++
 net/batman-adv/log.c   | 2 ++
 net/batman-adv/log.h   | 2 ++
 net/batman-adv/main.c  | 2 ++
 net/batman-adv/main.h  | 2 ++
 net/batman-adv/multicast.c | 2 ++
 net/batman-adv/multicast.h | 2 ++
 net/batman-adv/netlink.c   | 2 ++
 net/batman-adv/netlink.h   | 2 ++
 net/batman-adv/network-coding.c| 2 ++
 net/batman-adv/network-coding.h| 2 ++
 net/batman-adv/originator.c| 2 ++
 net/batman-adv/originator.h| 2 ++
 net/batman-adv/packet.h| 2 ++
 net/batman-adv/routing.c   | 2 ++
 net/batman-adv/routing.h   | 2 ++
 net/batman-adv/send.c  | 2 ++
 net/batman-adv/send.h  | 2 ++
 net/batman-adv/soft-interface.c| 2 ++
 net/batman-adv/soft-interface.h| 2 ++
 net/batman-adv/sysfs.c | 2 ++
 net/batman-adv/sysfs.h | 2 ++
 net/batman-adv/tp_meter.c  | 2 ++
 net/batman-adv/tp_meter.h  | 2 ++
 net/batman-adv/translation-table.c | 2 ++
 net/batman-adv/translation-table.h | 2 ++
 net/batman-adv/tvlv.c  | 2 ++
 net/batman-adv/tvlv.h  | 2 ++
 net/batman-adv/types.h | 2 ++
 59 files changed, 117 insertions(+)

diff --git a/net/batman-adv/Makefile b/net/batman-adv/Makefile
index 915987bc6d29..f70dbd8a2935 100644
--- a/net/batman-adv/Makefile
+++ b/net/batman-adv/Makefile
@@ -15,6 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 #
+# License-Filename: LICENSES/preferred/GPL-2.0
 
 obj-$(CONFIG_BATMAN_ADV) += batman-adv.o
 batman-adv-y += bat_algo.o
diff --git a/net/batman-adv/bat_algo.c b/net/batman-adv/bat_algo.c
index 44fd073b7546..921700ab306d 100644
--- a/net/batman-adv/bat_algo.c
+++ b/net/batman-adv/bat_algo.c
@@ -13,6 +13,8 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * License-Filename: LICENSES/preferred/GPL-2.0
  */
 
 #include "main.h"
diff --git a/net/batman-adv/bat_algo.h b/net/batman-adv/bat_algo.h
index 29f6312f9bf1..78836cf312d4 100644
--- a/net/batman-adv/bat_algo.h
+++ b/net/batman-adv/bat_algo.h
@@ -13,6 +13,8 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * License-Filename: LICENSES/preferred/GPL-2.0
  */
 
 #ifndef _NET_BATMAN_ADV_BAT_ALGO_H_
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 1b659ab652fb..96bc5d46548f 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -13,6 +13,8 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ *

[PATCH 01/20] batman-adv: Start new development cycle

2017-12-15 Thread Simon Wunderlich
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/main.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index edb2f239d04d..bb8003cf2296 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -24,7 +24,7 @@
 #define BATADV_DRIVER_DEVICE "batman-adv"
 
 #ifndef BATADV_SOURCE_VERSION
-#define BATADV_SOURCE_VERSION "2017.4"
+#define BATADV_SOURCE_VERSION "2018.0"
 #endif
 
 /* B.A.T.M.A.N. parameters */
-- 
2.11.0



[PATCH 00/20] pull request for net-next: batman-adv 2017-12-15

2017-12-15 Thread Simon Wunderlich
Hi David,

here is a feature/cleanup pull request of batman-adv to go into net-next.

Please pull or let me know of any problem!

Thank you,
  Simon

The following changes since commit 4fbd8d194f06c8a3fd2af1ce560ddb31f7ec8323:

  Linux 4.15-rc1 (2017-11-26 16:01:47 -0800)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batadv-next-for-davem-20171215

for you to fetch changes up to 74027aab7f808eca71521b61d55fc06e040ec89e:

  batman-adv: Add kernel-doc to externally visible functions (2017-12-04 
13:22:25 +0100)


This feature/cleanup patchset includes the following patches:

 - bump version strings, by Simon Wunderlich

 - de-inline hash functions to save memory footprint, by Denys Vlasenko

 - Add License information to various files, by Sven Eckelmann (4 patches)

 - Change batman_adv.h from ISC to MIT, by Sven Eckelmann

 - Improve various includes, by Sven Eckelmann (5 patches)

 - Lots of kernel-doc work by Sven Eckelmann (8 patches)


Denys Vlasenko (1):
  batman-adv: Deinline batadv_orig_hash_find, save 7339 bytes

Simon Wunderlich (1):
  batman-adv: Start new development cycle

Sven Eckelmann (18):
  batman-adv: Add License-Filename to GPL-2.0 files
  batman-adv: Add SPDX license identifier above copyright header
  batman-adv: Add SPDX license identifier to batman-adv.rst
  batman-adv: Add license header to Kconfig
  batman-adv: Change batman_adv.h license to MIT
  batman-adv: include gfp.h for GFP_* defines
  batman-adv: include build_bug.h for BUILD_BUG_ON define
  batman-adv: Include net.h for net_ratelimited_function
  batman-adv: include kobject.h for kobject_* functions
  batman-adv: Remove unused sched.h include
  batman-adv: Add missing kernel-doc to packet.h
  batman-adv: Use parentheses in function kernel-doc
  batman-adv: Use inline kernel-doc for enum/struct
  batman-adv: Fix kernel-doc references to struct members
  batman-adv: Add kernel-doc to structs in headers
  batman-adv: Add kernel-doc to enums in headers
  batman-adv: Add kernel-doc to functions in headers
  batman-adv: Add kernel-doc to externally visible functions

 Documentation/networking/batman-adv.rst |2 +
 compat-include/linux/build_bug.h|   34 +
 include/uapi/linux/batman_adv.h |   27 +-
 net/batman-adv/Kconfig  |   19 +
 net/batman-adv/Makefile |3 +-
 net/batman-adv/bat_algo.c   |   37 +-
 net/batman-adv/bat_algo.h   |3 +
 net/batman-adv/bat_iv_ogm.c |  107 +-
 net/batman-adv/bat_iv_ogm.h |3 +
 net/batman-adv/bat_v.c  |   51 +-
 net/batman-adv/bat_v.h  |3 +
 net/batman-adv/bat_v_elp.c  |   29 +-
 net/batman-adv/bat_v_elp.h  |3 +
 net/batman-adv/bat_v_ogm.c  |   39 +-
 net/batman-adv/bat_v_ogm.h  |3 +
 net/batman-adv/bitarray.c   |5 +-
 net/batman-adv/bitarray.h   |   12 +-
 net/batman-adv/bridge_loop_avoidance.c  |  114 +-
 net/batman-adv/bridge_loop_avoidance.h  |7 +-
 net/batman-adv/debugfs.c|   32 +-
 net/batman-adv/debugfs.h|3 +
 net/batman-adv/distributed-arp-table.c  |   82 +-
 net/batman-adv/distributed-arp-table.h  |9 +-
 net/batman-adv/fragmentation.c  |   25 +-
 net/batman-adv/fragmentation.h  |5 +-
 net/batman-adv/gateway_client.c |   67 +-
 net/batman-adv/gateway_client.h |3 +
 net/batman-adv/gateway_common.c |   30 +-
 net/batman-adv/gateway_common.h |8 +-
 net/batman-adv/hard-interface.c |   67 +-
 net/batman-adv/hard-interface.h |   61 +-
 net/batman-adv/hash.c   |   22 +-
 net/batman-adv/hash.h   |   30 +-
 net/batman-adv/icmp_socket.c|   17 +-
 net/batman-adv/icmp_socket.h|3 +
 net/batman-adv/log.c|   21 +
 net/batman-adv/log.h|   64 +-
 net/batman-adv/main.c   |   54 +-
 net/batman-adv/main.h   |  125 +-
 net/batman-adv/multicast.c  |   83 +-
 net/batman-adv/multicast.h  |   19 +-
 net/batman-adv/netlink.c|   27 +-
 net/batman-adv/netlink.h|3 +
 net/batman-adv/network-coding.c |  126 +-
 net/batman-adv/network-coding.h |3 +
 net/batman-adv/originator.c |  156 ++-
 net/batman-adv/originator.h |   49 +-
 net/batman-adv/packet.h |   28 +-
 net/batman-adv/routing.c|   56 +-
 net/batman-adv/routing.h|3 +
 net/batman-adv/send.c   |   68 +-
 net/batman-adv/send.h   |7 +-
 net/batman-adv/soft

[PATCH 2/4] batman-adv: Fix check of retrieved orig_gw in batadv_v_gw_is_eligible

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <sven.eckelm...@openmesh.com>

The batadv_v_gw_is_eligible function already assumes that orig_node is not
NULL. But batadv_gw_node_get may have failed to find the originator. It
must therefore be checked whether the batadv_gw_node_get failed and not
whether orig_node is NULL to detect this error.

Fixes: 50164d8f500f ("batman-adv: B.A.T.M.A.N. V - implement GW selection 
logic")
Signed-off-by: Sven Eckelmann <sven.eckelm...@openmesh.com>
Acked-by: Antonio Quartulli <a...@unstable.cc>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_v.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index 341ceab8338d..e0e2bfcd6b3e 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -814,7 +814,7 @@ static bool batadv_v_gw_is_eligible(struct batadv_priv 
*bat_priv,
}
 
orig_gw = batadv_gw_node_get(bat_priv, orig_node);
-   if (!orig_node)
+   if (!orig_gw)
goto out;
 
if (batadv_v_gw_throughput_get(orig_gw, _throughput) < 0)
-- 
2.11.0



[PATCH 3/4] batman-adv: Fix kernel-doc for timer functions

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The commit e99e88a9d2b0 ("treewide: setup_timer() -> timer_setup()")
changed the argument name and type of the timer function but didn't adjust
the kernel-doc of these functions.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Acked-by: Kees Cook <keesc...@chromium.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/tp_meter.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c
index 15cd2139381e..ebc4e2241c77 100644
--- a/net/batman-adv/tp_meter.c
+++ b/net/batman-adv/tp_meter.c
@@ -482,7 +482,7 @@ static void batadv_tp_reset_sender_timer(struct 
batadv_tp_vars *tp_vars)
 
 /**
  * batadv_tp_sender_timeout - timer that fires in case of packet loss
- * @arg: address of the related tp_vars
+ * @t: address to timer_list inside tp_vars
  *
  * If fired it means that there was packet loss.
  * Switch to Slow Start, set the ss_threshold to half of the current cwnd and
@@ -1106,7 +1106,7 @@ static void batadv_tp_reset_receiver_timer(struct 
batadv_tp_vars *tp_vars)
 /**
  * batadv_tp_receiver_shutdown - stop a tp meter receiver when timeout is
  *  reached without received ack
- * @arg: address of the related tp_vars
+ * @t: address to timer_list inside tp_vars
  */
 static void batadv_tp_receiver_shutdown(struct timer_list *t)
 {
-- 
2.11.0



[PATCH 0/4] pull request for net: batman-adv 2017-12-15

2017-12-15 Thread Simon Wunderlich
Hi David,

here are a couple of fixes which we would like to see integrated into net.

Please pull or let me know of any problem!

Thank you,
  Simon

The following changes since commit 4fbd8d194f06c8a3fd2af1ce560ddb31f7ec8323:

  Linux 4.15-rc1 (2017-11-26 16:01:47 -0800)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batadv-net-for-davem-20171215

for you to fetch changes up to 5ba7dcfe77037b67016263ea597a8b431692ecab:

  batman-adv: Fix lock for ogm cnt access in batadv_iv_ogm_calc_tq (2017-12-04 
11:47:33 +0100)


Here are some batman-adv bugfixes:

 - Initialize the fragment headers, by Sven Eckelmann

 - Fix a NULL check in BATMAN V, by Sven Eckelmann

 - Fix kernel doc for the time_setup() change, by Sven Eckelmann

 - Use the right lock in BATMAN IV OGM Update, by Sven Eckelmann


Sven Eckelmann (4):
  batman-adv: Always initialize fragment header priority
  batman-adv: Fix check of retrieved orig_gw in batadv_v_gw_is_eligible
  batman-adv: Fix kernel-doc for timer functions
  batman-adv: Fix lock for ogm cnt access in batadv_iv_ogm_calc_tq

 net/batman-adv/bat_iv_ogm.c| 4 ++--
 net/batman-adv/bat_v.c | 2 +-
 net/batman-adv/fragmentation.c | 2 ++
 net/batman-adv/tp_meter.c  | 4 ++--
 4 files changed, 7 insertions(+), 5 deletions(-)


[PATCH 1/4] batman-adv: Always initialize fragment header priority

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <sven.eckelm...@open-mesh.com>

The batman-adv unuicast fragment header contains 3 bits for the priority of
the packet. These bits will be initialized when the skb->priority contains
a value between 256 and 263. But otherwise, the uninitialized bits from the
stack will be used.

Fixes: c0f25c802b33 ("batman-adv: Include frame priority in fragment header")
Signed-off-by: Sven Eckelmann <sven.eckelm...@open-mesh.com>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/fragmentation.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
index a98cf1104a30..ebe6e38934e4 100644
--- a/net/batman-adv/fragmentation.c
+++ b/net/batman-adv/fragmentation.c
@@ -499,6 +499,8 @@ int batadv_frag_send_packet(struct sk_buff *skb,
 */
if (skb->priority >= 256 && skb->priority <= 263)
frag_header.priority = skb->priority - 256;
+   else
+   frag_header.priority = 0;
 
ether_addr_copy(frag_header.orig, primary_if->net_dev->dev_addr);
ether_addr_copy(frag_header.dest, orig_node->orig);
-- 
2.11.0



[PATCH 4/4] batman-adv: Fix lock for ogm cnt access in batadv_iv_ogm_calc_tq

2017-12-15 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The originator node object orig_neigh_node is used to when accessing the
bcast_own(_sum) and real_packet_count information. The access to them has
to be protected with the spinlock in orig_neigh_node.

But the function uses the lock in orig_node instead. This is incorrect
because they could be two different originator node objects.

Fixes: 0ede9f41b217 ("batman-adv: protect bit operations to count OGMs with 
spinlock")
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_iv_ogm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 1b659ab652fb..bbe8414b6ee7 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -1214,7 +1214,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node 
*orig_node,
orig_node->last_seen = jiffies;
 
/* find packet count of corresponding one hop neighbor */
-   spin_lock_bh(_node->bat_iv.ogm_cnt_lock);
+   spin_lock_bh(_neigh_node->bat_iv.ogm_cnt_lock);
if_num = if_incoming->if_num;
orig_eq_count = orig_neigh_node->bat_iv.bcast_own_sum[if_num];
neigh_ifinfo = batadv_neigh_ifinfo_new(neigh_node, if_outgoing);
@@ -1224,7 +1224,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node 
*orig_node,
} else {
neigh_rq_count = 0;
}
-   spin_unlock_bh(_node->bat_iv.ogm_cnt_lock);
+   spin_unlock_bh(_neigh_node->bat_iv.ogm_cnt_lock);
 
/* pay attention to not get a value bigger than 100 % */
if (orig_eq_count > neigh_rq_count)
-- 
2.11.0



[PATCH 1/3] batman-adv: Add missing kerneldoc for extack

2017-10-23 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The parameter extack was added to batadv_softif_slave_add without adding
the kernel-doc for it. This caused kernel-doc warnings.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Acked-by: David Ahern <dsah...@gmail.com>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/soft-interface.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 543d2c3e0f0d..9f673cdfecf8 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -863,6 +863,7 @@ static int batadv_softif_init_late(struct net_device *dev)
  * batadv_softif_slave_add - Add a slave interface to a batadv_soft_interface
  * @dev: batadv_soft_interface used as master interface
  * @slave_dev: net_device which should become the slave interface
+ * @extack: extended ACK report struct
  *
  * Return: 0 if successful or error otherwise.
  */
-- 
2.11.0



[PATCH 0/3] pull request for net-next: batman-adv 2017-10-23

2017-10-23 Thread Simon Wunderlich
Hi David,

here is another small documentation/cleanup pull request of batman-adv to go
into net-next.

Please pull or let me know of any problem!

Thank you,
  Simon

The following changes since commit 4bc4e64c2cfdafa6b8ecdcc5edf10cc1a147587f:

  Merge tag 'batadv-next-for-davem-20171006' of 
git://git.open-mesh.org/linux-merge (2017-10-06 10:12:52 -0700)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batadv-next-for-davem-20171023

for you to fetch changes up to 40b16b9be5773a314948656c96adf7bf7cfdbd0b:

  batman-adv: use inline kernel-doc for uapi constants (2017-10-23 14:22:25 
+0200)


This documentation/cleanup patchset includes the following patches:

 - Fix parameter kerneldoc which caused kerneldoc warnings, by Sven Eckelmann

 - Remove spurious warnings in B.A.T.M.A.N. V neighbor comparison,
   by Sven Eckelmann

 - Use inline kernel-doc style for UAPI constants, by Sven Eckelmann


Sven Eckelmann (3):
  batman-adv: Add missing kerneldoc for extack
  batman-adv: Avoid spurious warnings from bat_v neigh_cmp implementation
  batman-adv: use inline kernel-doc for uapi constants

 include/uapi/linux/batman_adv.h | 369 +++-
 net/batman-adv/bat_v.c  |   9 +-
 net/batman-adv/soft-interface.c |   1 +
 3 files changed, 295 insertions(+), 84 deletions(-)


[PATCH 2/3] batman-adv: Avoid spurious warnings from bat_v neigh_cmp implementation

2017-10-23 Thread Simon Wunderlich
From: Sven Eckelmann <sven.eckelm...@openmesh.com>

The neighbor compare API implementation for B.A.T.M.A.N. V checks whether
the neigh_ifinfo for this neighbor on a specific interface exists. A
warning is printed when it isn't found.

But it is not called inside a lock which would prevent that this
information is lost right before batadv_neigh_ifinfo_get. It must therefore
be expected that batadv_v_neigh_(cmp|is_sob) might not be able to get the
requested neigh_ifinfo.

A WARN_ON for such a situation seems not to be appropriate because this
will only flood the kernel logs. The warnings must therefore be removed.

Signed-off-by: Sven Eckelmann <sven.eckelm...@openmesh.com>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_v.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
index 93ef1c06227e..341ceab8338d 100644
--- a/net/batman-adv/bat_v.c
+++ b/net/batman-adv/bat_v.c
@@ -19,7 +19,6 @@
 #include "main.h"
 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -623,11 +622,11 @@ static int batadv_v_neigh_cmp(struct batadv_neigh_node 
*neigh1,
int ret = 0;
 
ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1);
-   if (WARN_ON(!ifinfo1))
+   if (!ifinfo1)
goto err_ifinfo1;
 
ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2);
-   if (WARN_ON(!ifinfo2))
+   if (!ifinfo2)
goto err_ifinfo2;
 
ret = ifinfo1->bat_v.throughput - ifinfo2->bat_v.throughput;
@@ -649,11 +648,11 @@ static bool batadv_v_neigh_is_sob(struct 
batadv_neigh_node *neigh1,
bool ret = false;
 
ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1);
-   if (WARN_ON(!ifinfo1))
+   if (!ifinfo1)
goto err_ifinfo1;
 
ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2);
-   if (WARN_ON(!ifinfo2))
+   if (!ifinfo2)
goto err_ifinfo2;
 
threshold = ifinfo1->bat_v.throughput / 4;
-- 
2.11.0



[PATCH 3/3] batman-adv: use inline kernel-doc for uapi constants

2017-10-23 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The enums of constants for netlink tends to become rather large over time.
Documenting them is easier when the kernel-doc is actually next to constant
and not in a different block above the enum.

Also inline kernel-doc allows multi-paragraph description. This could be
required to better document the netlink command types and the expected
return values.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 include/uapi/linux/batman_adv.h | 369 +++-
 1 file changed, 290 insertions(+), 79 deletions(-)

diff --git a/include/uapi/linux/batman_adv.h b/include/uapi/linux/batman_adv.h
index a83ddb7b63db..efd641c8a5d6 100644
--- a/include/uapi/linux/batman_adv.h
+++ b/include/uapi/linux/batman_adv.h
@@ -24,20 +24,6 @@
 
 /**
  * enum batadv_tt_client_flags - TT client specific flags
- * @BATADV_TT_CLIENT_DEL: the client has to be deleted from the table
- * @BATADV_TT_CLIENT_ROAM: the client roamed to/from another node and the new
- *  update telling its new real location has not been received/sent yet
- * @BATADV_TT_CLIENT_WIFI: this client is connected through a wifi interface.
- *  This information is used by the "AP Isolation" feature
- * @BATADV_TT_CLIENT_ISOLA: this client is considered "isolated". This
- *  information is used by the Extended Isolation feature
- * @BATADV_TT_CLIENT_NOPURGE: this client should never be removed from the 
table
- * @BATADV_TT_CLIENT_NEW: this client has been added to the local table but has
- *  not been announced yet
- * @BATADV_TT_CLIENT_PENDING: this client is marked for removal but it is kept
- *  in the table for one more originator interval for consistency purposes
- * @BATADV_TT_CLIENT_TEMP: this global client has been detected to be part of
- *  the network but no nnode has already announced it
  *
  * Bits from 0 to 7 are called _remote flags_ because they are sent on the 
wire.
  * Bits from 8 to 15 are called _local flags_ because they are used for local
@@ -48,160 +34,385 @@
  * in the TT CRC computation.
  */
 enum batadv_tt_client_flags {
+   /**
+* @BATADV_TT_CLIENT_DEL: the client has to be deleted from the table
+*/
BATADV_TT_CLIENT_DEL = (1 << 0),
+
+   /**
+* @BATADV_TT_CLIENT_ROAM: the client roamed to/from another node and
+* the new update telling its new real location has not been
+* received/sent yet
+*/
BATADV_TT_CLIENT_ROAM= (1 << 1),
+
+   /**
+* @BATADV_TT_CLIENT_WIFI: this client is connected through a wifi
+* interface. This information is used by the "AP Isolation" feature
+*/
BATADV_TT_CLIENT_WIFI= (1 << 4),
+
+   /**
+* @BATADV_TT_CLIENT_ISOLA: this client is considered "isolated". This
+* information is used by the Extended Isolation feature
+*/
BATADV_TT_CLIENT_ISOLA   = (1 << 5),
+
+   /**
+* @BATADV_TT_CLIENT_NOPURGE: this client should never be removed from
+* the table
+*/
BATADV_TT_CLIENT_NOPURGE = (1 << 8),
+
+   /**
+* @BATADV_TT_CLIENT_NEW: this client has been added to the local table
+* but has not been announced yet
+*/
BATADV_TT_CLIENT_NEW = (1 << 9),
+
+   /**
+* @BATADV_TT_CLIENT_PENDING: this client is marked for removal but it
+* is kept in the table for one more originator interval for consistency
+* purposes
+*/
BATADV_TT_CLIENT_PENDING = (1 << 10),
+
+   /**
+* @BATADV_TT_CLIENT_TEMP: this global client has been detected to be
+* part of the network but no nnode has already announced it
+*/
BATADV_TT_CLIENT_TEMP= (1 << 11),
 };
 
 /**
  * enum batadv_nl_attrs - batman-adv netlink attributes
- *
- * @BATADV_ATTR_UNSPEC: unspecified attribute to catch errors
- * @BATADV_ATTR_VERSION: batman-adv version string
- * @BATADV_ATTR_ALGO_NAME: name of routing algorithm
- * @BATADV_ATTR_MESH_IFINDEX: index of the batman-adv interface
- * @BATADV_ATTR_MESH_IFNAME: name of the batman-adv interface
- * @BATADV_ATTR_MESH_ADDRESS: mac address of the batman-adv interface
- * @BATADV_ATTR_HARD_IFINDEX: index of the non-batman-adv interface
- * @BATADV_ATTR_HARD_IFNAME: name of the non-batman-adv interface
- * @BATADV_ATTR_HARD_ADDRESS: mac address of the non-batman-adv interface
- * @BATADV_ATTR_ORIG_ADDRESS: originator mac address
- * @BATADV_ATTR_TPMETER_RESULT: result of run (see batadv_tp_meter_status)
- * @BATADV_ATTR_TPMETER_TEST_TIME: time (msec) the run took
- * @BATADV_ATTR_TPMETER_BYTES: amount of acked bytes during run
- * @BATADV_ATTR_TPMETER_COOKIE: session cookie to match tp_meter session
- * @BATADV_ATTR_PAD: attribute used for padding for 64-bit alignment
- * @BATADV_AT

[PATCH 1/4] batman-adv: Start new development cycle

2017-10-06 Thread Simon Wunderlich
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/main.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 05cc7637c064..edb2f239d04d 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -24,7 +24,7 @@
 #define BATADV_DRIVER_DEVICE "batman-adv"
 
 #ifndef BATADV_SOURCE_VERSION
-#define BATADV_SOURCE_VERSION "2017.3"
+#define BATADV_SOURCE_VERSION "2017.4"
 #endif
 
 /* B.A.T.M.A.N. parameters */
-- 
2.11.0



[PATCH 2/4] batman-adv: Remove unnecessary parentheses

2017-10-06 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

checkpatch introduced with commit 63b7c73ec86b ("checkpatch: add --strict
check for ifs with unnecessary parentheses") an additional test which
identifies some unnecessary parentheses.

Remove these unnecessary parentheses to avoid the warnings and to unify the
coding style slightly more.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_iv_ogm.c| 24 
 net/batman-adv/bat_v.c |  2 +-
 net/batman-adv/bat_v_elp.c |  6 +++---
 net/batman-adv/bat_v_ogm.c | 12 ++--
 net/batman-adv/distributed-arp-table.c |  4 ++--
 net/batman-adv/gateway_client.c|  8 
 net/batman-adv/gateway_common.c| 18 +-
 net/batman-adv/hard-interface.c| 12 ++--
 net/batman-adv/icmp_socket.c   |  4 ++--
 net/batman-adv/main.c  |  4 ++--
 net/batman-adv/multicast.c |  2 +-
 net/batman-adv/originator.c| 26 +-
 net/batman-adv/routing.c   |  6 +++---
 net/batman-adv/send.c  |  6 +++---
 net/batman-adv/soft-interface.c|  2 +-
 net/batman-adv/sysfs.c |  4 ++--
 net/batman-adv/tp_meter.c  |  2 +-
 17 files changed, 71 insertions(+), 71 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 83ba5483455a..1b659ab652fb 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -916,8 +916,8 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface 
*hard_iface)
u16 tvlv_len = 0;
unsigned long send_time;
 
-   if ((hard_iface->if_status == BATADV_IF_NOT_IN_USE) ||
-   (hard_iface->if_status == BATADV_IF_TO_BE_REMOVED))
+   if (hard_iface->if_status == BATADV_IF_NOT_IN_USE ||
+   hard_iface->if_status == BATADV_IF_TO_BE_REMOVED)
return;
 
/* the interface gets activated here to avoid race conditions between
@@ -1264,7 +1264,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node 
*orig_node,
 * drops as they can't send and receive at the same time.
 */
tq_iface_penalty = BATADV_TQ_MAX_VALUE;
-   if (if_outgoing && (if_incoming == if_outgoing) &&
+   if (if_outgoing && if_incoming == if_outgoing &&
batadv_is_wifi_hardif(if_outgoing))
tq_iface_penalty = batadv_hop_penalty(BATADV_TQ_MAX_VALUE,
  bat_priv);
@@ -1369,7 +1369,7 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
ret = BATADV_NEIGH_DUP;
} else {
set_mark = 0;
-   if (is_dup && (ret != BATADV_NEIGH_DUP))
+   if (is_dup && ret != BATADV_NEIGH_DUP)
ret = BATADV_ORIG_DUP;
}
 
@@ -1515,7 +1515,7 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff 
*skb, int ogm_offset,
/* drop packet if sender is not a direct neighbor and if we
 * don't route towards it
 */
-   if (!is_single_hop_neigh && (!orig_neigh_router)) {
+   if (!is_single_hop_neigh && !orig_neigh_router) {
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
   "Drop packet: OGM via unknown neighbor!\n");
goto out_neigh;
@@ -1535,7 +1535,7 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff 
*skb, int ogm_offset,
sameseq = orig_ifinfo->last_real_seqno == ntohl(ogm_packet->seqno);
similar_ttl = (orig_ifinfo->last_ttl - 3) <= ogm_packet->ttl;
 
-   if (is_bidirect && ((dup_status == BATADV_NO_DUP) ||
+   if (is_bidirect && (dup_status == BATADV_NO_DUP ||
(sameseq && similar_ttl))) {
batadv_iv_ogm_orig_update(bat_priv, orig_node,
  orig_ifinfo, ethhdr,
@@ -1553,8 +1553,8 @@ batadv_iv_ogm_process_per_outif(const struct sk_buff 
*skb, int ogm_offset,
/* OGMs from secondary interfaces should only scheduled once
 * per interface where it has been received, not multiple times
 */
-   if ((ogm_packet->ttl <= 2) &&
-   (if_incoming != if_outgoing)) {
+   if (ogm_packet->ttl <= 2 &&
+   if_incoming != if_outgoing) {
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
   "Drop packet: OGM from secondary interface 
and wrong outgoing interface\n");
goto out_neigh;
@@ -1590,7 +1590,7 @@ batadv_iv_

[PATCH 0/4] pull request for net-next: batman-adv 2017-10-06

2017-10-06 Thread Simon Wunderlich
Hi David,

here is a small cleanup pull request of batman-adv to go into net-next.

Please pull or let me know of any problem!

Thank you,
  Simon

The following changes since commit 242c1a28eb61cb34974e8aa05235d84355940a8a:

  net: Remove useless function skb_header_release (2017-09-22 20:43:13 -0700)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batadv-next-for-davem-20171006

for you to fetch changes up to 706cc9f51d9a22528af18d4b3ffbd17b30a1d3b0:

  batman-adv: Add argument names for function ptr definitions (2017-09-30 
09:31:34 +0200)


This cleanup patchset includes the following patches:

 - bump version strings, by Simon Wunderlich

 - Cleanup patches to make checkpatch happy, by Sven Eckelmann (3 patches)


Simon Wunderlich (1):
  batman-adv: Start new development cycle

Sven Eckelmann (3):
  batman-adv: Remove unnecessary parentheses
  batman-adv: Fix "line over 80 characters" checkpatch warning
  batman-adv: Add argument names for function ptr definitions

 net/batman-adv/bat_iv_ogm.c| 24 
 net/batman-adv/bat_v.c |  2 +-
 net/batman-adv/bat_v_elp.c |  6 +++---
 net/batman-adv/bat_v_ogm.c | 12 ++--
 net/batman-adv/distributed-arp-table.c |  4 ++--
 net/batman-adv/gateway_client.c|  8 
 net/batman-adv/gateway_common.c| 18 +-
 net/batman-adv/hard-interface.c| 12 ++--
 net/batman-adv/icmp_socket.c   |  4 ++--
 net/batman-adv/main.c  | 12 ++--
 net/batman-adv/main.h  |  2 +-
 net/batman-adv/multicast.c |  2 +-
 net/batman-adv/originator.c| 26 +-
 net/batman-adv/routing.c   |  6 +++---
 net/batman-adv/send.c  |  6 +++---
 net/batman-adv/soft-interface.c|  6 +++---
 net/batman-adv/sysfs.c |  4 ++--
 net/batman-adv/tp_meter.c  |  2 +-
 18 files changed, 78 insertions(+), 78 deletions(-)


[PATCH 4/4] batman-adv: Add argument names for function ptr definitions

2017-10-06 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

checkpatch started to report unnamed arguments in function pointer
definitions. Add the corresponding names to these definitions to avoid this
warning.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/main.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
index 033819aefc39..4daed7ad46f2 100644
--- a/net/batman-adv/main.c
+++ b/net/batman-adv/main.c
@@ -73,8 +73,8 @@
  * list traversals just rcu-locked
  */
 struct list_head batadv_hardif_list;
-static int (*batadv_rx_handler[256])(struct sk_buff *,
-struct batadv_hard_iface *);
+static int (*batadv_rx_handler[256])(struct sk_buff *skb,
+struct batadv_hard_iface *recv_if);
 
 unsigned char batadv_broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 
@@ -540,8 +540,8 @@ batadv_recv_handler_register(u8 packet_type,
 int (*recv_handler)(struct sk_buff *,
 struct batadv_hard_iface *))
 {
-   int (*curr)(struct sk_buff *,
-   struct batadv_hard_iface *);
+   int (*curr)(struct sk_buff *skb,
+   struct batadv_hard_iface *recv_if);
curr = batadv_rx_handler[packet_type];
 
if (curr != batadv_recv_unhandled_packet &&
-- 
2.11.0



[PATCH 3/4] batman-adv: Fix "line over 80 characters" checkpatch warning

2017-10-06 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

Fixes: 242c1a28eb61 ("net: Remove useless function skb_header_release")
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/soft-interface.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index 7c8288245f80..3af4b0b29b23 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -69,8 +69,8 @@ int batadv_skb_head_push(struct sk_buff *skb, unsigned int 
len)
int result;
 
/* TODO: We must check if we can release all references to non-payload
-* data using __skb_header_release in our skbs to allow skb_cow_header 
to
-* work optimally. This means that those skbs are not allowed to read
+* data using __skb_header_release in our skbs to allow skb_cow_header
+* to work optimally. This means that those skbs are not allowed to read
 * or write any data which is before the current position of skb->data
 * after that call and thus allow other skbs with the same data buffer
 * to write freely in that area.
-- 
2.11.0



[PATCH 0/1] pull request for net: batman-adv 2017-08-02

2017-08-02 Thread Simon Wunderlich
Hi David,

here is a bugfix which we would like to see integrated into net.

Please pull or let me know of any problem!

Thank you,
  Simon

The following changes since commit 5771a8c08880cdca3bfb4a3fc6d309d6bba20877:

  Linux v4.13-rc1 (2017-07-15 15:22:10 -0700)

are available in the git repository at:

  git://git.open-mesh.org/linux-merge.git tags/batadv-net-for-davem-20170802

for you to fetch changes up to 54e22f265e872ae140755b3318521d400a094605:

  batman-adv: fix TT sync flag inconsistencies (2017-07-31 11:17:38 +0200)


Here is a batman-adv bugfix:

 - fix TT sync flag inconsistency problems, which can lead to excess packets,
   by Linus Luessing


Linus Lüssing (1):
  batman-adv: fix TT sync flag inconsistencies

 net/batman-adv/translation-table.c | 60 --
 net/batman-adv/types.h |  2 ++
 2 files changed, 53 insertions(+), 9 deletions(-)


[PATCH 1/1] batman-adv: fix TT sync flag inconsistencies

2017-08-02 Thread Simon Wunderlich
From: Linus Lüssing <linus.luess...@c0d3.blue>

This patch fixes an issue in the translation table code potentially
leading to a TT Request + Response storm. The issue may occur for nodes
involving BLA and an inconsistent configuration of the batman-adv AP
isolation feature. However, since the new multicast optimizations, a
single, malformed packet may lead to a mesh-wide, persistent
Denial-of-Service, too.

The issue occurs because nodes are currently OR-ing the TT sync flags of
all originators announcing a specific MAC address via the
translation table. When an intermediate node now receives a TT Request
and wants to answer this on behalf of the destination node, then this
intermediate node now responds with an altered flag field and broken
CRC. The next OGM of the real destination will lead to a CRC mismatch
and triggering a TT Request and Response again.

Furthermore, the OR-ing is currently never undone as long as at least
one originator announcing the according MAC address remains, leading to
the potential persistency of this issue.

This patch fixes this issue by storing the flags used in the CRC
calculation on a a per TT orig entry basis to be able to respond with
the correct, original flags in an intermediate TT Response for one
thing. And to be able to correctly unset sync flags once all nodes
announcing a sync flag vanish for another.

Fixes: e9c00136a475 ("batman-adv: fix tt_global_entries flags update")
Signed-off-by: Linus Lüssing <linus.luess...@c0d3.blue>
Acked-by: Antonio Quartulli <a...@unstable.cc>
[sw: typo in commit message]
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/translation-table.c | 60 --
 net/batman-adv/types.h |  2 ++
 2 files changed, 53 insertions(+), 9 deletions(-)

diff --git a/net/batman-adv/translation-table.c 
b/net/batman-adv/translation-table.c
index e1133bc634b5..8a3ce79b1307 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1549,9 +1549,41 @@ batadv_tt_global_entry_has_orig(const struct 
batadv_tt_global_entry *entry,
return found;
 }
 
+/**
+ * batadv_tt_global_sync_flags - update TT sync flags
+ * @tt_global: the TT global entry to update sync flags in
+ *
+ * Updates the sync flag bits in the tt_global flag attribute with a logical
+ * OR of all sync flags from any of its TT orig entries.
+ */
+static void
+batadv_tt_global_sync_flags(struct batadv_tt_global_entry *tt_global)
+{
+   struct batadv_tt_orig_list_entry *orig_entry;
+   const struct hlist_head *head;
+   u16 flags = BATADV_NO_FLAGS;
+
+   rcu_read_lock();
+   head = _global->orig_list;
+   hlist_for_each_entry_rcu(orig_entry, head, list)
+   flags |= orig_entry->flags;
+   rcu_read_unlock();
+
+   flags |= tt_global->common.flags & (~BATADV_TT_SYNC_MASK);
+   tt_global->common.flags = flags;
+}
+
+/**
+ * batadv_tt_global_orig_entry_add - add or update a TT orig entry
+ * @tt_global: the TT global entry to add an orig entry in
+ * @orig_node: the originator to add an orig entry for
+ * @ttvn: translation table version number of this changeset
+ * @flags: TT sync flags
+ */
 static void
 batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global,
-   struct batadv_orig_node *orig_node, int ttvn)
+   struct batadv_orig_node *orig_node, int ttvn,
+   u8 flags)
 {
struct batadv_tt_orig_list_entry *orig_entry;
 
@@ -1561,7 +1593,8 @@ batadv_tt_global_orig_entry_add(struct 
batadv_tt_global_entry *tt_global,
 * was added during a "temporary client detection"
 */
orig_entry->ttvn = ttvn;
-   goto out;
+   orig_entry->flags = flags;
+   goto sync_flags;
}
 
orig_entry = kmem_cache_zalloc(batadv_tt_orig_cache, GFP_ATOMIC);
@@ -1573,6 +1606,7 @@ batadv_tt_global_orig_entry_add(struct 
batadv_tt_global_entry *tt_global,
batadv_tt_global_size_inc(orig_node, tt_global->common.vid);
orig_entry->orig_node = orig_node;
orig_entry->ttvn = ttvn;
+   orig_entry->flags = flags;
kref_init(_entry->refcount);
 
spin_lock_bh(_global->list_lock);
@@ -1582,6 +1616,8 @@ batadv_tt_global_orig_entry_add(struct 
batadv_tt_global_entry *tt_global,
spin_unlock_bh(_global->list_lock);
atomic_inc(_global->orig_list_count);
 
+sync_flags:
+   batadv_tt_global_sync_flags(tt_global);
 out:
if (orig_entry)
batadv_tt_orig_list_entry_put(orig_entry);
@@ -1703,10 +1739,10 @@ static bool batadv_tt_global_add(struct batadv_priv 
*bat_priv,
}
 
/* the change can carry possible "attribute" flags like the
-* TT_CLIENT_WIFI, therefo

[PATCH 1/6] batman-adv: Start new development cycle

2017-08-02 Thread Simon Wunderlich
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/main.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 2be8f1f46529..05cc7637c064 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -24,7 +24,7 @@
 #define BATADV_DRIVER_DEVICE "batman-adv"
 
 #ifndef BATADV_SOURCE_VERSION
-#define BATADV_SOURCE_VERSION "2017.2"
+#define BATADV_SOURCE_VERSION "2017.3"
 #endif
 
 /* B.A.T.M.A.N. parameters */
-- 
2.11.0



[PATCH 3/6] batman-adv: Remove too short %pM printk field width

2017-08-02 Thread Simon Wunderlich
From: Sven Eckelmann <s...@narfation.org>

The string representation for a mac address produced by %pM is 17
characters long. Left-aligning the output in a 15 character wide field
width %-15pM is therefore misleading and unnecessary.

Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_iv_ogm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index a3501173e200..c27001d38574 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -1281,7 +1281,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node 
*orig_node,
batadv_ogm_packet->tq = combined_tq;
 
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
-  "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = 
%2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, iface_penalty: %3i, 
total tq: %3i, if_incoming = %s, if_outgoing = %s\n",
+  "bidirectional: orig = %pM neigh = %pM => own_bcast = %2i, 
real recv = %2i, local tq: %3i, asym_penalty: %3i, iface_penalty: %3i, total 
tq: %3i, if_incoming = %s, if_outgoing = %s\n",
   orig_node->orig, orig_neigh_node->orig, total_count,
   neigh_rq_count, tq_own, tq_asym_penalty, tq_iface_penalty,
   batadv_ogm_packet->tq, if_incoming->net_dev->name,
-- 
2.11.0



[PATCH 5/6] batman-adv: fix various spelling mistakes

2017-08-02 Thread Simon Wunderlich
From: Colin Ian King <colin.k...@canonical.com>

Trivial fix to spelling mistakes in batadv_dbg debug messages and
also in a comment and ensure comment line is not wider than 80
characters

"ourselve" -> "ourselves"
"surpressed" -> "suppressed"
"troughput" -> "throughput"

Signed-off-by: Colin Ian King <colin.k...@canonical.com>
Signed-off-by: Sven Eckelmann <s...@narfation.org>
Signed-off-by: Simon Wunderlich <s...@simonwunderlich.de>
---
 net/batman-adv/bat_v_ogm.c | 12 ++--
 net/batman-adv/send.c  |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c
index 894c96371e41..8be61734fc43 100644
--- a/net/batman-adv/bat_v_ogm.c
+++ b/net/batman-adv/bat_v_ogm.c
@@ -200,7 +200,7 @@ static void batadv_v_ogm_send(struct work_struct *work)
type = "unknown";
}
 
-   batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "OGM2 from 
ourselve on %s surpressed: %s\n",
+   batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "OGM2 from 
ourselves on %s suppressed: %s\n",
   hard_iface->net_dev->name, type);
 
batadv_hardif_put(hard_iface);
@@ -683,18 +683,18 @@ static void batadv_v_ogm_process(const struct sk_buff 
*skb, int ogm_offset,
ogm_throughput = ntohl(ogm_packet->throughput);
 
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
-  "Received OGM2 packet via NB: %pM, IF: %s [%pM] (from OG: 
%pM, seqno %u, troughput %u, TTL %u, V %u, tvlv_len %u)\n",
+  "Received OGM2 packet via NB: %pM, IF: %s [%pM] (from OG: 
%pM, seqno %u, throughput %u, TTL %u, V %u, tvlv_len %u)\n",
   ethhdr->h_source, if_incoming->net_dev->name,
   if_incoming->net_dev->dev_addr, ogm_packet->orig,
   ntohl(ogm_packet->seqno), ogm_throughput, ogm_packet->ttl,
   ogm_packet->version, ntohs(ogm_packet->tvlv_len));
 
-   /* If the troughput metric is 0, immediately drop the packet. No need to
-* create orig_node / neigh_node for an unusable route.
+   /* If the throughput metric is 0, immediately drop the packet. No need
+* to create orig_node / neigh_node for an unusable route.
 */
if (ogm_throughput == 0) {
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
-  "Drop packet: originator packet with troughput 
metric of 0\n");
+  "Drop packet: originator packet with throughput 
metric of 0\n");
return;
}
 
@@ -762,7 +762,7 @@ static void batadv_v_ogm_process(const struct sk_buff *skb, 
int ogm_offset,
type = "unknown";
}
 
-   batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "OGM2 packet 
from %pM on %s surpressed: %s\n",
+   batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "OGM2 packet 
from %pM on %s suppressed: %s\n",
   ogm_packet->orig, hard_iface->net_dev->name,
   type);
 
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c
index d239a9d72ac3..054a65e6eb68 100644
--- a/net/batman-adv/send.c
+++ b/net/batman-adv/send.c
@@ -911,7 +911,7 @@ static void batadv_send_outstanding_bcast_packet(struct 
work_struct *work)
type = "unknown";
}
 
-   batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "BCAST packet 
from orig %pM on %s surpressed: %s\n",
+   batadv_dbg(BATADV_DBG_BATMAN, bat_priv, "BCAST packet 
from orig %pM on %s suppressed: %s\n",
   bcast_packet->orig,
   hard_iface->net_dev->name, type);
 
-- 
2.11.0



  1   2   3   4   >