[batman-adv] master: Merge branch 'maint' (e43855ab)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit e43855ab699668f85c35740ada7ba6d41ebc0aa2
Merge: ab3618d9 382d020f
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Mon Jul 31 11:14:58 2017 +0200
Merge branch 'maint'
>---------------------------------------------------------------
e43855ab699668f85c35740ada7ba6d41ebc0aa2
net/batman-adv/translation-table.c | 60 ++++++++++++++++++++++++++++++++------
net/batman-adv/types.h | 2 ++
2 files changed, 53 insertions(+), 9 deletions(-)
5 years, 6 months
[batman-adv] maint: batman-adv: fix TT sync flag inconsistencies (382d020f)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : maint
>---------------------------------------------------------------
commit 382d020fe3fa528b1f65f8107df8fc023eb8cacb
Author: Linus Lüssing <linus.luessing(a)c0d3.blue>
Date: Thu Jul 6 07:02:25 2017 +0200
batman-adv: fix TT sync flag inconsistencies
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: fa614fd04692 ("batman-adv: fix tt_global_entries flags update")
Signed-off-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
Acked-by: Antonio Quartulli <a(a)unstable.cc>
[sw: typo in commit message]
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
>---------------------------------------------------------------
382d020fe3fa528b1f65f8107df8fc023eb8cacb
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 e1133bc6..8a3ce79b 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 = &tt_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(&orig_entry->refcount);
spin_lock_bh(&tt_global->list_lock);
@@ -1582,6 +1616,8 @@ batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global,
spin_unlock_bh(&tt_global->list_lock);
atomic_inc(&tt_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, therefore they have to be copied in the
+ * TT_CLIENT_TEMP, therefore they have to be copied in the
* client entry
*/
- common->flags |= flags;
+ common->flags |= flags & (~BATADV_TT_SYNC_MASK);
/* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
* one originator left in the list and we previously received a
@@ -1723,7 +1759,8 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
}
add_orig_entry:
/* add the new orig_entry (if needed) or update it */
- batadv_tt_global_orig_entry_add(tt_global_entry, orig_node, ttvn);
+ batadv_tt_global_orig_entry_add(tt_global_entry, orig_node, ttvn,
+ flags & BATADV_TT_SYNC_MASK);
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Creating new global tt entry: %pM (vid: %d, via %pM)\n",
@@ -1946,6 +1983,7 @@ batadv_tt_global_dump_subentry(struct sk_buff *msg, u32 portid, u32 seq,
struct batadv_tt_orig_list_entry *orig,
bool best)
{
+ u16 flags = (common->flags & (~BATADV_TT_SYNC_MASK)) | orig->flags;
void *hdr;
struct batadv_orig_node_vlan *vlan;
u8 last_ttvn;
@@ -1975,7 +2013,7 @@ batadv_tt_global_dump_subentry(struct sk_buff *msg, u32 portid, u32 seq,
nla_put_u8(msg, BATADV_ATTR_TT_LAST_TTVN, last_ttvn) ||
nla_put_u32(msg, BATADV_ATTR_TT_CRC32, crc) ||
nla_put_u16(msg, BATADV_ATTR_TT_VID, common->vid) ||
- nla_put_u32(msg, BATADV_ATTR_TT_FLAGS, common->flags))
+ nla_put_u32(msg, BATADV_ATTR_TT_FLAGS, flags))
goto nla_put_failure;
if (best && nla_put_flag(msg, BATADV_ATTR_FLAG_BEST))
@@ -2589,6 +2627,7 @@ static u32 batadv_tt_global_crc(struct batadv_priv *bat_priv,
unsigned short vid)
{
struct batadv_hashtable *hash = bat_priv->tt.global_hash;
+ struct batadv_tt_orig_list_entry *tt_orig;
struct batadv_tt_common_entry *tt_common;
struct batadv_tt_global_entry *tt_global;
struct hlist_head *head;
@@ -2627,8 +2666,9 @@ static u32 batadv_tt_global_crc(struct batadv_priv *bat_priv,
/* find out if this global entry is announced by this
* originator
*/
- if (!batadv_tt_global_entry_has_orig(tt_global,
- orig_node))
+ tt_orig = batadv_tt_global_orig_entry_find(tt_global,
+ orig_node);
+ if (!tt_orig)
continue;
/* use network order to read the VID: this ensures that
@@ -2640,10 +2680,12 @@ static u32 batadv_tt_global_crc(struct batadv_priv *bat_priv,
/* compute the CRC on flags that have to be kept in sync
* among nodes
*/
- flags = tt_common->flags & BATADV_TT_SYNC_MASK;
+ flags = tt_orig->flags;
crc_tmp = crc32c(crc_tmp, &flags, sizeof(flags));
crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN);
+
+ batadv_tt_orig_list_entry_put(tt_orig);
}
rcu_read_unlock();
}
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index ea43a644..a6279586 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1260,6 +1260,7 @@ struct batadv_tt_global_entry {
* struct batadv_tt_orig_list_entry - orig node announcing a non-mesh client
* @orig_node: pointer to orig node announcing this non-mesh client
* @ttvn: translation table version number which added the non-mesh client
+ * @flags: per orig entry TT sync flags
* @list: list node for batadv_tt_global_entry::orig_list
* @refcount: number of contexts the object is used
* @rcu: struct used for freeing in an RCU-safe manner
@@ -1267,6 +1268,7 @@ struct batadv_tt_global_entry {
struct batadv_tt_orig_list_entry {
struct batadv_orig_node *orig_node;
u8 ttvn;
+ u8 flags;
struct hlist_node list;
struct kref refcount;
struct rcu_head rcu;
5 years, 6 months
[batctl] master: Merge branch 'maint' (5e8a144)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batctl
On branch : master
>---------------------------------------------------------------
commit 5e8a144c1b2e94790c315f310ab293b15a5fdc13
Merge: 5fb3a49 c3466e2
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Mon Jul 31 11:13:00 2017 +0200
Merge branch 'maint'
>---------------------------------------------------------------
5e8a144c1b2e94790c315f310ab293b15a5fdc13
CHANGELOG | 6 ++++++
1 file changed, 6 insertions(+)
diff --cc CHANGELOG
index 6e13d69,c6bc969..679b1e5
--- a/CHANGELOG
+++ b/CHANGELOG
@@@ -1,3 -1,11 +1,9 @@@
+ batctl 2017.2
+
+ * coding style cleanups and refactoring
- * bugs squashed:
- - Fix error messages on traceroute send failures
+
+ -- Fri, 28 Jul 2017 13:42:03 +0200
+
batctl 2017.1
* (no changes)
5 years, 6 months
[alfred] master: alfred: Use bitmap to store dataset change events (27330db)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/alfred
On branch : master
>---------------------------------------------------------------
commit 27330db508cb004f73524946f253da71804c181d
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Mon Jul 24 23:18:52 2017 +0200
alfred: Use bitmap to store dataset change events
The implementation for --update-command uses a double linked list to store
the detected modifications of datasets. This implementation requires 24
bytes (1 byte data type, 7 bytes padding, 16 bytes linked list pointers) on
amd64 for each element of the list. Each modified dataset type requires an
own list item. Each list item is allocated using malloc and therefore
additional overhead for the libc allocator information has also to be
stored next to it. The list head uses a similar amount of memory (16 byte
list pointers, 2 byte counter, 6 byte padding) but doesn't require
additional allocations.
The list based implementation provides information about modified dataset
type and the order in which these modifications were detected. But the
latter is not actually required fr --update-command and can therefore be
omitted.
A simple 256 bit wide storage element (32 bytes) is enough to keep the
required information when only the detected modified data types have to be
registered. BIT(i) is either 1 when dataset type i was modified or 0 when
no modification was detected. This removes the (de)allocation CPU + memory
overhead and avoids list searches when adding newly detected modifications.
Cc: Anatoliy Lapitskiy <anatoliy.lapitskiy(a)gmail.com>
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
>---------------------------------------------------------------
27330db508cb004f73524946f253da71804c181d
alfred.h | 4 +-
bitops.h | 379 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
main.c | 3 +-
server.c | 46 ++++----
4 files changed, 401 insertions(+), 31 deletions(-)
diff --git a/alfred.h b/alfred.h
index 9ffdc52..6b751d6 100644
--- a/alfred.h
+++ b/alfred.h
@@ -31,6 +31,7 @@
#include <time.h>
#include <sys/select.h>
#include <sys/types.h>
+#include "bitops.h"
#include "list.h"
#include "packet.h"
@@ -134,8 +135,7 @@ struct globals {
const char *unix_path;
const char *update_command;
- struct list_head changed_data_types;
- uint16_t changed_data_type_count; /* maximum is 256 */
+ DECLARE_BITMAP(changed_data_types, ALFRED_NUM_TYPES);
struct timespec if_check;
struct timespec sync_period;
diff --git a/bitops.h b/bitops.h
new file mode 100644
index 0000000..37ce7e8
--- /dev/null
+++ b/bitops.h
@@ -0,0 +1,379 @@
+/* Minimal Linux-like bit manipulation helper functions
+ * (reduced version for alfred)
+ *
+ * Copyright (c) 2012-2014, Sven Eckelmann <sven(a)narfation.org>
+ *
+ * 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 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 __LINUX_LIKE_BITOPS_H__
+#define __LINUX_LIKE_BITOPS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+
+#if defined(__GNUC__)
+#define BITOPS_BUILTIN_USE 1
+#endif
+
+#if defined(_MSC_VER)
+#define __inline__ __inline
+#endif
+
+/**
+ * BITOPS_BUILD_BUG_ON - create "negative array" build error on expression
+ * @e: expression which is considered to be a "bug"
+ */
+#define BITOPS_BUILD_BUG_ON(e) ((void)sizeof(char[1 - 2 * !!(e)]))
+
+/**
+ * BITOPS_DIV_CEIL - calculate quotient of integer division (round up)
+ * @numerator: side effect free expression for numerator of division
+ * @denominator: side effect free expression for denominator of division
+ *
+ * numerator and denominator must be from a type which can store
+ * denominator + numerator without overflow. denominator must be larger than 0
+ * and numerator must be positive.
+ *
+ * WARNING @numerator expression must be side-effect free
+ */
+#define BITOPS_DIV_CEIL(numerator, denominator) \
+ (((numerator) + (denominator) - 1) / (denominator))
+
+/**
+ * BITS_PER_BYTE - number of bits per byte/char
+ */
+#define BITS_PER_BYTE 8
+
+/**
+ * BITS_PER_LONG - number of bits per long
+ */
+#define BITS_PER_LONG (sizeof(unsigned long) * BITS_PER_BYTE)
+
+/**
+ * BITS_TO_LONGS - return number of longs to save at least bit 0..(bits - 1)
+ * @bits: number of required bits
+ */
+#define BITS_TO_LONGS(bits) \
+ BITOPS_DIV_CEIL(bits, BITS_PER_LONG)
+
+/**
+ * DECLARE_BITMAP - declare bitmap to store at least bit 0..(bits -1)
+ * @bitmap: name for the new bitmap
+ * @bits: number of required bits
+ */
+#define DECLARE_BITMAP(bitmap, bits) \
+ unsigned long bitmap[BITS_TO_LONGS(bits)]
+
+/**
+ * BITMAP_FIRST_WORD_MASK - return unsigned long mask for least significant long
+ * @start: offset to first bits
+ *
+ * All bits which can be modified in the least significant unsigned long for
+ * offset @start in the bitmap will be set to 1. All other bits will be set to
+ * zero
+ */
+#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG))
+
+/**
+ * BITMAP_LAST_WORD_MASK - return unsigned long mask for most significant long
+ * @bits: number of bits in complete bitmap
+ *
+ * All bits which can be modified in the most significant unsigned long in the
+ * bitmap will be set to 1. All other bits will be set to zero
+ */
+#define BITMAP_LAST_WORD_MASK(bits) (~0UL >> (-(bits) % BITS_PER_LONG))
+
+/**
+ * bitops_ffs() - find (least significant) first set bit plus one
+ * @x: unsigned long to check
+ *
+ * Return: plus-one index of first set bit; zero when x is zero
+ */
+static __inline__ size_t bitops_ffs(unsigned long x)
+{
+#ifdef BITOPS_BUILTIN_USE
+ return __builtin_ffsl(x);
+#else
+ size_t i = 1;
+
+ BITOPS_BUILD_BUG_ON(BITS_PER_LONG != 32 && BITS_PER_LONG != 64);
+
+ if (x == 0)
+ return 0;
+
+ if (BITS_PER_LONG == 64) {
+ if ((0x00000000fffffffful & x) == 0) {
+ i += 32;
+ x >>= 32;
+ }
+ }
+
+ if ((0x0000fffful & x) == 0) {
+ i += 16;
+ x >>= 16;
+ }
+
+ if ((0x00fful & x) == 0) {
+ i += 8;
+ x >>= 8;
+ }
+
+ if ((0x0ful & x) == 0) {
+ i += 4;
+ x >>= 4;
+ }
+
+ if ((0x3ul & x) == 0) {
+ i += 2;
+ x >>= 2;
+ }
+
+ if ((0x1ul & x) == 0) {
+ i += 1;
+ x >>= 1;
+ }
+
+ return i;
+#endif
+}
+
+/**
+ * hweight32() - number of set bits in an uint32_t
+ * @x: uint32_t to sum up
+ *
+ * Return: number of set bits
+ */
+static __inline__ unsigned int hweight32(uint32_t x)
+{
+ static const uint32_t m1 = UINT32_C(0x55555555);
+ static const uint32_t m2 = UINT32_C(0x33333333);
+ static const uint32_t m4 = UINT32_C(0x0f0f0f0f);
+
+ /* x = (x & m1) + ((x >> 1) & m1); */
+ x -= (x >> 1) & m1;
+ x = (x & m2) + ((x >> 2) & m2);
+ x = (x + (x >> 4)) & m4;
+ x += x >> 8;
+ x += x >> 16;
+
+ return x & 0x3f;
+}
+
+/**
+ * hweight64() - number of set bits in an uint64_t
+ * @x: uint64_t to sum up
+ *
+ * Return: number of set bits
+ */
+static __inline__ unsigned int hweight64(uint64_t x)
+{
+ if (BITS_PER_LONG >= 64) {
+ static const uint64_t m1 = UINT64_C(0x5555555555555555);
+ static const uint64_t m2 = UINT64_C(0x3333333333333333);
+ static const uint64_t m4 = UINT64_C(0x0f0f0f0f0f0f0f0f);
+
+ /* x = (x & m1) + ((x >> 1) & m1); */
+ x -= (x >> 1) & m1;
+ x = (x & m2) + ((x >> 2) & m2);
+ x = (x + (x >> 4)) & m4;
+ x += x >> 8;
+ x += x >> 16;
+ x += x >> 32;
+
+ return x & 0x7f;
+ } else {
+ return hweight32((uint32_t)x) + hweight32((uint32_t)(x >> 32));
+ }
+}
+
+/**
+ * hweight_long() - number of set bits in an unsigned long
+ * @x: unsigned long to sum up
+ *
+ * Return: number of set bits
+ */
+static __inline__ unsigned int hweight_long(unsigned long x)
+{
+#ifdef BITOPS_BUILTIN_USE
+ return __builtin_popcountl(x);
+#else
+ size_t i;
+
+ if (BITS_PER_LONG == 64)
+ return hweight64((uint64_t)x);
+
+ if (BITS_PER_LONG == 32)
+ return hweight32((uint32_t)x);
+
+ for (i = 0; x; i++)
+ x &= x - 1;
+
+ return i;
+#endif
+}
+
+/**
+ * bitmap_zero() - Initializes bitmap with zero
+ * @bitmap: bitmap to modify
+ * @bits: number of bits
+ *
+ * Initializes all bits to zero. This also includes the overhead bits in the
+ * last unsigned long which will not be used.
+ */
+static __inline__ void bitmap_zero(unsigned long *bitmap, size_t bits)
+{
+ memset(bitmap, 0, BITS_TO_LONGS(bits) * sizeof(unsigned long));
+}
+
+/**
+ * set_bit() - Set bit in bitmap to one
+ * @bit: address of bit to modify
+ * @bitmap: bitmap to modify
+ */
+static __inline__ void set_bit(size_t bit, unsigned long *bitmap)
+{
+ size_t l = bit / BITS_PER_LONG;
+ size_t b = bit % BITS_PER_LONG;
+
+ bitmap[l] |= 1UL << b;
+}
+
+/**
+ * find_next_bit() - Find next set bit in bitmap
+ * @bitmap: bitmap to check
+ * @bits: number of bits in @bitmap
+ * @start: start of bits to check
+ *
+ * Checks the modifiable bits in the bitmap. The overhead bits in the last
+ * unsigned long will not be checked
+ *
+ * Return: bit position of next set bit, @bits when no set bit was found
+ */
+static __inline__ size_t find_next_bit(unsigned long *bitmap, size_t bits,
+ size_t start)
+{
+ size_t i;
+ size_t pos;
+ unsigned long t;
+ size_t l = BITS_TO_LONGS(bits);
+ size_t first_long = start / BITS_PER_LONG;
+ size_t long_lower = start - (start % BITS_PER_LONG);
+
+ if (start >= bits)
+ return bits;
+
+ t = bitmap[first_long] & BITMAP_FIRST_WORD_MASK(start);
+ for (i = first_long + 1; !t && i < l; i++) {
+ /* search until valid t is found */
+ long_lower += BITS_PER_LONG;
+ t = bitmap[i];
+ }
+
+ if (!t)
+ return bits;
+
+ pos = long_lower + bitops_ffs(t) - 1;
+ if (pos >= bits)
+ return bits;
+
+ return pos;
+}
+
+/**
+ * find_first_bit - Find first set bit in bitmap
+ * @bitmap: bitmap to check
+ * @bits: number of bits in @bitmap
+ *
+ * Checks the modifiable bits in the bitmap. The overhead bits in the last
+ * unsigned long will not be checked
+ *
+ * Return: bit position of fist set bit, @bits when no set bit was found
+ */
+#define find_first_bit(bitmap, bits) find_next_bit(bitmap, bits, 0)
+
+/**
+ * for_each_set_bit - iterate over set bits in bitmap
+ * @bit: current bit
+ * @bitmap: bitmap to iterate over
+ * @bits: number of bits in @bitmap
+ *
+ * WARNING expressions @bitmap and @bits must be side-effect free
+ */
+#define for_each_set_bit(bit, bitmap, bits) \
+ for (bit = find_first_bit(bitmap, bits); \
+ bit < (bits); \
+ bit = find_next_bit(bitmap, bits, bit + 1))
+
+/**
+ * bitmap_weight() - Calculate number of set bits in bitmap
+ * @bitmap: bitmap to sum up
+ * @bits: number of bits
+ *
+ * Sums the modifiable bits in the bitmap. The overhead bits in the last
+ * unsigned long will not summed up
+ *
+ * Return: number of set bits
+ */
+static __inline__ size_t bitmap_weight(const unsigned long *bitmap, size_t bits)
+{
+ size_t l = BITS_TO_LONGS(bits);
+ size_t i;
+ size_t sum = 0;
+
+ for (i = 0; i < l - 1; i++)
+ sum += hweight_long(bitmap[i]);
+
+ return sum + hweight_long(bitmap[l - 1] & BITMAP_LAST_WORD_MASK(bits));
+}
+
+/**
+ * bitmap_empty() - Check if no bit is set in bitmap
+ * @bitmap: bitmap to test
+ * @bits: number of bits
+ *
+ * Check the modifiable bits in the bitmap for zero. The overhead bits in the
+ * last unsigned long will not be checked
+ *
+ * Return: true when usable bits were all zero and false otherwise
+ */
+static __inline__ bool bitmap_empty(const unsigned long *bitmap, size_t bits)
+{
+ size_t l = BITS_TO_LONGS(bits);
+ size_t i;
+
+ for (i = 0; i < l - 1; i++) {
+ if (bitmap[i])
+ return false;
+ }
+
+ return !(bitmap[l - 1] & BITMAP_LAST_WORD_MASK(bits));
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __LINUX_LIKE_BITOPS_H__ */
diff --git a/main.c b/main.c
index ad6d081..cf1e460 100644
--- a/main.c
+++ b/main.c
@@ -202,8 +202,7 @@ static struct globals *alfred_init(int argc, char *argv[])
globals->update_command = NULL;
globals->sync_period.tv_sec = ALFRED_INTERVAL;
globals->sync_period.tv_nsec = 0;
- INIT_LIST_HEAD(&globals->changed_data_types);
- globals->changed_data_type_count = 0;
+ bitmap_zero(globals->changed_data_types, ALFRED_NUM_TYPES);
time_random_seed();
diff --git a/server.c b/server.c
index b6f0812..63a3b2a 100644
--- a/server.c
+++ b/server.c
@@ -37,6 +37,7 @@
#include <unistd.h>
#include <time.h>
#include "alfred.h"
+#include "bitops.h"
#include "batadv_query.h"
#include "hash.h"
#include "list.h"
@@ -139,23 +140,10 @@ static int set_best_server(struct globals *globals)
void changed_data_type(struct globals *globals, uint8_t arg)
{
- struct changed_data_type *data_type = NULL;
-
if (!globals->update_command)
return;
- list_for_each_entry(data_type, &globals->changed_data_types, list) {
- if (data_type->data_type == arg)
- return;
- }
-
- data_type = malloc(sizeof(*data_type));
- if (!data_type)
- return;
-
- data_type->data_type = arg;
- list_add(&data_type->list, &globals->changed_data_types);
- globals->changed_data_type_count++;
+ set_bit(arg, globals->changed_data_types);
}
static int purge_data(struct globals *globals)
@@ -343,20 +331,27 @@ static void execute_update_command(struct globals *globals)
pid_t script_pid;
size_t command_len;
char *command;
- struct changed_data_type *data_type, *is;
- /* data type is uint8_t, so 255 is maximum (3 chars)
- * space for appending + terminating null byte
+ size_t data_type;
+ size_t changed_data_type_count;
+ /* data type is limited by ALFRED_NUM_TYPES to 255 (3 chars), plus
+ * 1x space for appending + terminating null byte
*/
char buf[5];
- if (!globals->update_command || !globals->changed_data_type_count)
+ if (!globals->update_command)
+ return;
+
+ if (bitmap_empty(globals->changed_data_types, ALFRED_NUM_TYPES))
return;
+ changed_data_type_count = bitmap_weight(globals->changed_data_types,
+ ALFRED_NUM_TYPES);
+
/* length of script + 4 bytes per data type (space +3 chars)
* + 1 for terminating null byte
*/
command_len = strlen(globals->update_command);
- command_len += 4 * globals->changed_data_type_count + 1;
+ command_len += 4 * changed_data_type_count + 1;
command = malloc(command_len);
if (!command)
return;
@@ -364,17 +359,14 @@ static void execute_update_command(struct globals *globals)
strncpy(command, globals->update_command, command_len - 1);
command[command_len - 1] = '\0';
- list_for_each_entry_safe(data_type, is, &globals->changed_data_types,
- list) {
+ for_each_set_bit (data_type, globals->changed_data_types,
+ ALFRED_NUM_TYPES) {
/* append the datatype to command line */
- snprintf(buf, sizeof(buf), " %d", data_type->data_type);
+ snprintf(buf, sizeof(buf), " %zu", data_type);
strncat(command, buf, command_len - strlen(command) - 1);
-
- /* clean the list */
- list_del(&data_type->list);
- free(data_type);
}
- globals->changed_data_type_count = 0;
+
+ bitmap_zero(globals->changed_data_types, ALFRED_NUM_TYPES);
printf("executing: %s\n", command);
5 years, 6 months
[alfred] master: alfred: Use constant to define data type range (dd46491)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/alfred
On branch : master
>---------------------------------------------------------------
commit dd464916ec0c9e9a1a1ab49dd90e0f49cca1b743
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Mon Jul 24 23:18:51 2017 +0200
alfred: Use constant to define data type range
The maximum number of data types supported by alfred is limited by the
range of an uint8_t (0-255). alfred checks in the client mode whether data
type parameter is in the supported range by comparing it against
ALFRED_MAX_RESERVED_TYPE as lower bound and the magic number 255 as upper
bound.
Instead of using 255 in multiple places, define a named constant which can
be referenced. This makes it easier to understand these comparisons and to
reference this limit in a consistent way.
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
>---------------------------------------------------------------
dd464916ec0c9e9a1a1ab49dd90e0f49cca1b743
main.c | 6 ++++--
packet.h | 1 +
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/main.c b/main.c
index 446eecf..ad6d081 100644
--- a/main.c
+++ b/main.c
@@ -213,7 +213,8 @@ static struct globals *alfred_init(int argc, char *argv[])
case 'r':
globals->clientmode = CLIENT_REQUEST_DATA;
i = atoi(optarg);
- if (i < ALFRED_MAX_RESERVED_TYPE || i > 255) {
+ if (i < ALFRED_MAX_RESERVED_TYPE ||
+ i >= ALFRED_NUM_TYPES) {
fprintf(stderr, "bad data type argument\n");
return NULL;
}
@@ -223,7 +224,8 @@ static struct globals *alfred_init(int argc, char *argv[])
case 's':
globals->clientmode = CLIENT_SET_DATA;
i = atoi(optarg);
- if (i < ALFRED_MAX_RESERVED_TYPE || i > 255) {
+ if (i < ALFRED_MAX_RESERVED_TYPE ||
+ i >= ALFRED_NUM_TYPES) {
fprintf(stderr, "bad data type argument\n");
return NULL;
}
diff --git a/packet.h b/packet.h
index afd3715..425459f 100644
--- a/packet.h
+++ b/packet.h
@@ -177,5 +177,6 @@ struct alfred_status_v0 {
#define ALFRED_VERSION 0
#define ALFRED_PORT 0x4242
#define ALFRED_MAX_RESERVED_TYPE 64
+#define ALFRED_NUM_TYPES 256
#endif
5 years, 6 months
[batman-adv] master: batman-adv: fix TT sync flag inconsistencies (2035bb89)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit 2035bb8942673223b034265a2e3d11520ab63589
Author: Linus Lüssing <linus.luessing(a)c0d3.blue>
Date: Thu Jul 6 07:02:25 2017 +0200
batman-adv: fix TT sync flag inconsistencies
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: fa614fd04692 ("batman-adv: fix tt_global_entries flags update")
Signed-off-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
Acked-by: Antonio Quartulli <a(a)unstable.cc>
[sw: typo in commit message]
Signed-off-by: Simon Wunderlich <sw(a)simonwunderlich.de>
>---------------------------------------------------------------
2035bb8942673223b034265a2e3d11520ab63589
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 e1133bc6..8a3ce79b 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 = &tt_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(&orig_entry->refcount);
spin_lock_bh(&tt_global->list_lock);
@@ -1582,6 +1616,8 @@ batadv_tt_global_orig_entry_add(struct batadv_tt_global_entry *tt_global,
spin_unlock_bh(&tt_global->list_lock);
atomic_inc(&tt_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, therefore they have to be copied in the
+ * TT_CLIENT_TEMP, therefore they have to be copied in the
* client entry
*/
- common->flags |= flags;
+ common->flags |= flags & (~BATADV_TT_SYNC_MASK);
/* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
* one originator left in the list and we previously received a
@@ -1723,7 +1759,8 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
}
add_orig_entry:
/* add the new orig_entry (if needed) or update it */
- batadv_tt_global_orig_entry_add(tt_global_entry, orig_node, ttvn);
+ batadv_tt_global_orig_entry_add(tt_global_entry, orig_node, ttvn,
+ flags & BATADV_TT_SYNC_MASK);
batadv_dbg(BATADV_DBG_TT, bat_priv,
"Creating new global tt entry: %pM (vid: %d, via %pM)\n",
@@ -1946,6 +1983,7 @@ batadv_tt_global_dump_subentry(struct sk_buff *msg, u32 portid, u32 seq,
struct batadv_tt_orig_list_entry *orig,
bool best)
{
+ u16 flags = (common->flags & (~BATADV_TT_SYNC_MASK)) | orig->flags;
void *hdr;
struct batadv_orig_node_vlan *vlan;
u8 last_ttvn;
@@ -1975,7 +2013,7 @@ batadv_tt_global_dump_subentry(struct sk_buff *msg, u32 portid, u32 seq,
nla_put_u8(msg, BATADV_ATTR_TT_LAST_TTVN, last_ttvn) ||
nla_put_u32(msg, BATADV_ATTR_TT_CRC32, crc) ||
nla_put_u16(msg, BATADV_ATTR_TT_VID, common->vid) ||
- nla_put_u32(msg, BATADV_ATTR_TT_FLAGS, common->flags))
+ nla_put_u32(msg, BATADV_ATTR_TT_FLAGS, flags))
goto nla_put_failure;
if (best && nla_put_flag(msg, BATADV_ATTR_FLAG_BEST))
@@ -2589,6 +2627,7 @@ static u32 batadv_tt_global_crc(struct batadv_priv *bat_priv,
unsigned short vid)
{
struct batadv_hashtable *hash = bat_priv->tt.global_hash;
+ struct batadv_tt_orig_list_entry *tt_orig;
struct batadv_tt_common_entry *tt_common;
struct batadv_tt_global_entry *tt_global;
struct hlist_head *head;
@@ -2627,8 +2666,9 @@ static u32 batadv_tt_global_crc(struct batadv_priv *bat_priv,
/* find out if this global entry is announced by this
* originator
*/
- if (!batadv_tt_global_entry_has_orig(tt_global,
- orig_node))
+ tt_orig = batadv_tt_global_orig_entry_find(tt_global,
+ orig_node);
+ if (!tt_orig)
continue;
/* use network order to read the VID: this ensures that
@@ -2640,10 +2680,12 @@ static u32 batadv_tt_global_crc(struct batadv_priv *bat_priv,
/* compute the CRC on flags that have to be kept in sync
* among nodes
*/
- flags = tt_common->flags & BATADV_TT_SYNC_MASK;
+ flags = tt_orig->flags;
crc_tmp = crc32c(crc_tmp, &flags, sizeof(flags));
crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN);
+
+ batadv_tt_orig_list_entry_put(tt_orig);
}
rcu_read_unlock();
}
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index ea43a644..a6279586 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -1260,6 +1260,7 @@ struct batadv_tt_global_entry {
* struct batadv_tt_orig_list_entry - orig node announcing a non-mesh client
* @orig_node: pointer to orig node announcing this non-mesh client
* @ttvn: translation table version number which added the non-mesh client
+ * @flags: per orig entry TT sync flags
* @list: list node for batadv_tt_global_entry::orig_list
* @refcount: number of contexts the object is used
* @rcu: struct used for freeing in an RCU-safe manner
@@ -1267,6 +1268,7 @@ struct batadv_tt_global_entry {
struct batadv_tt_orig_list_entry {
struct batadv_orig_node *orig_node;
u8 ttvn;
+ u8 flags;
struct hlist_node list;
struct kref refcount;
struct rcu_head rcu;
5 years, 6 months
[linux-merge]linux integration; annotated tag, v4.13-rc3, created. v4.13-rc3
by postmaster@open-mesh.org
The annotated tag, v4.13-rc3 has been created
at f7965d62aac0f3728499ca12d77525afdda2ede9 (tag)
tagging 16f73eb02d7e1765ccab3d2018e0bd98eb93d973 (commit)
replaces v4.13-rc2
tagged by Linus Torvalds
on Sun Jul 30 12:40:48 2017 -0700
- Shortlog ------------------------------------------------------------
Linux 4.13-rc3
-----BEGIN PGP SIGNATURE-----
iQEcBAABAgAGBQJZfjZAAAoJEHm+PkMAQRiGXAYH/RrAAFj46/TwwUam93e5LSQg
VC8OltmJJoJ5FmzfeXmydgXzR23JvVcMaKfQH0xK8sXWbg8+fteQi9GzqctAWaNS
N9YwheXIO0QY/m9L0nDBM//TsmekO8X1EVXub4siMpstJezGie1Q5DFg+ZkjTV2L
S5VgkjuxtFEJTaI8kYxi48OgF0muMCiCFm2U8znEMyjN3YP6in7C3C/Ufn/cZQvz
i6mt5T6DGz0EjVBc8XL+ZDhIODjfL7XbaPF/Uwgn0YZYjg0MSYzECfAN6Gxm3lwd
+6z2dZ2yR1U+520sjaGhZzw5G+Fd1zfJMS1hOgsUCx8J8NYgQA4/yw4rEYOsfgI=
=RThI
-----END PGP SIGNATURE-----
-----------------------------------------------------------------------
--
linux integration
5 years, 6 months
[batman-adv] master: batman-adv: Convert batman-adv.txt to reStructuredText (ab3618d9)
by postmaster@open-mesh.org
Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
>---------------------------------------------------------------
commit ab3618d92710b2e09f2c9dddf8099eb339f4fbb9
Author: Sven Eckelmann <sven(a)narfation.org>
Date: Wed Jul 12 13:14:48 2017 +0200
batman-adv: Convert batman-adv.txt to reStructuredText
Converting the freeform text to parsable reStructuredText, allows the
integration in the sphinx based documentation system of the kernel. It will
therefore be accessible as hypertext under
https://www.kernel.org/doc/html/latest/
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
>---------------------------------------------------------------
ab3618d92710b2e09f2c9dddf8099eb339f4fbb9
Documentation/networking/batman-adv.rst | 220 ++++++++++++++++++++++++++++++++
Documentation/networking/batman-adv.txt | 215 -------------------------------
MAINTAINERS | 2 +-
README | 2 +-
4 files changed, 222 insertions(+), 217 deletions(-)
diff --git a/Documentation/networking/batman-adv.rst b/Documentation/networking/batman-adv.rst
new file mode 100644
index 00000000..a342b2cc
--- /dev/null
+++ b/Documentation/networking/batman-adv.rst
@@ -0,0 +1,220 @@
+==========
+batman-adv
+==========
+
+Batman advanced is a new approach to wireless networking which does no longer
+operate on the IP basis. Unlike the batman daemon, which exchanges information
+using UDP packets and sets routing tables, batman-advanced operates on ISO/OSI
+Layer 2 only and uses and routes (or better: bridges) Ethernet Frames. It
+emulates a virtual network switch of all nodes participating. Therefore all
+nodes appear to be link local, thus all higher operating protocols won't be
+affected by any changes within the network. You can run almost any protocol
+above batman advanced, prominent examples are: IPv4, IPv6, DHCP, IPX.
+
+Batman advanced was implemented as a Linux kernel driver to reduce the overhead
+to a minimum. It does not depend on any (other) network driver, and can be used
+on wifi as well as ethernet lan, vpn, etc ... (anything with ethernet-style
+layer 2).
+
+
+Configuration
+=============
+
+Load the batman-adv module into your kernel::
+
+ $ insmod batman-adv.ko
+
+The module is now waiting for activation. You must add some interfaces on which
+batman can operate. After loading the module batman advanced will scan your
+systems interfaces to search for compatible interfaces. Once found, it will
+create subfolders in the ``/sys`` directories of each supported interface,
+e.g.::
+
+ $ ls /sys/class/net/eth0/batman_adv/
+ elp_interval iface_status mesh_iface throughput_override
+
+If an interface does not have the ``batman_adv`` subfolder, it probably is not
+supported. Not supported interfaces are: loopback, non-ethernet and batman's
+own interfaces.
+
+Note: After the module was loaded it will continuously watch for new
+interfaces to verify the compatibility. There is no need to reload the module
+if you plug your USB wifi adapter into your machine after batman advanced was
+initially loaded.
+
+The batman-adv soft-interface can be created using the iproute2 tool ``ip``::
+
+ $ ip link add name bat0 type batadv
+
+To activate a given interface simply attach it to the ``bat0`` interface::
+
+ $ ip link set dev eth0 master bat0
+
+Repeat this step for all interfaces you wish to add. Now batman starts
+using/broadcasting on this/these interface(s).
+
+By reading the "iface_status" file you can check its status::
+
+ $ cat /sys/class/net/eth0/batman_adv/iface_status
+ active
+
+To deactivate an interface you have to detach it from the "bat0" interface::
+
+ $ ip link set dev eth0 nomaster
+
+
+All mesh wide settings can be found in batman's own interface folder::
+
+ $ ls /sys/class/net/bat0/mesh/
+ aggregated_ogms fragmentation isolation_mark routing_algo
+ ap_isolation gw_bandwidth log_level vlan0
+ bonding gw_mode multicast_mode
+ bridge_loop_avoidance gw_sel_class network_coding
+ distributed_arp_table hop_penalty orig_interval
+
+There is a special folder for debugging information::
+
+ $ ls /sys/kernel/debug/batman_adv/bat0/
+ bla_backbone_table log neighbors transtable_local
+ bla_claim_table mcast_flags originators
+ dat_cache nc socket
+ gateways nc_nodes transtable_global
+
+Some of the files contain all sort of status information regarding the mesh
+network. For example, you can view the table of originators (mesh
+participants) with::
+
+ $ cat /sys/kernel/debug/batman_adv/bat0/originators
+
+Other files allow to change batman's behaviour to better fit your requirements.
+For instance, you can check the current originator interval (value in
+milliseconds which determines how often batman sends its broadcast packets)::
+
+ $ cat /sys/class/net/bat0/mesh/orig_interval
+ 1000
+
+and also change its value::
+
+ $ echo 3000 > /sys/class/net/bat0/mesh/orig_interval
+
+In very mobile scenarios, you might want to adjust the originator interval to a
+lower value. This will make the mesh more responsive to topology changes, but
+will also increase the overhead.
+
+
+Usage
+=====
+
+To make use of your newly created mesh, batman advanced provides a new
+interface "bat0" which you should use from this point on. All interfaces added
+to batman advanced are not relevant any longer because batman handles them for
+you. Basically, one "hands over" the data by using the batman interface and
+batman will make sure it reaches its destination.
+
+The "bat0" interface can be used like any other regular interface. It needs an
+IP address which can be either statically configured or dynamically (by using
+DHCP or similar services)::
+
+ NodeA: ip link set up dev bat0
+ NodeA: ip addr add 192.168.0.1/24 dev bat0
+
+ NodeB: ip link set up dev bat0
+ NodeB: ip addr add 192.168.0.2/24 dev bat0
+ NodeB: ping 192.168.0.1
+
+Note: In order to avoid problems remove all IP addresses previously assigned to
+interfaces now used by batman advanced, e.g.::
+
+ $ ip addr flush dev eth0
+
+
+Logging/Debugging
+=================
+
+All error messages, warnings and information messages are sent to the kernel
+log. Depending on your operating system distribution this can be read in one of
+a number of ways. Try using the commands: ``dmesg``, ``logread``, or looking in
+the files ``/var/log/kern.log`` or ``/var/log/syslog``. All batman-adv messages
+are prefixed with "batman-adv:" So to see just these messages try::
+
+ $ dmesg | grep batman-adv
+
+When investigating problems with your mesh network, it is sometimes necessary to
+see more detail debug messages. This must be enabled when compiling the
+batman-adv module. When building batman-adv as part of kernel, use "make
+menuconfig" and enable the option ``B.A.T.M.A.N. debugging``
+(``CONFIG_BATMAN_ADV_DEBUG=y``).
+
+Those additional debug messages can be accessed using a special file in
+debugfs::
+
+ $ cat /sys/kernel/debug/batman_adv/bat0/log
+
+The additional debug output is by default disabled. It can be enabled during
+run time. Following log_levels are defined:
+
+.. flat-table::
+
+ * - 0
+ - All debug output disabled
+ * - 1
+ - Enable messages related to routing / flooding / broadcasting
+ * - 2
+ - Enable messages related to route added / changed / deleted
+ * - 4
+ - Enable messages related to translation table operations
+ * - 8
+ - Enable messages related to bridge loop avoidance
+ * - 16
+ - Enable messages related to DAT, ARP snooping and parsing
+ * - 32
+ - Enable messages related to network coding
+ * - 64
+ - Enable messages related to multicast
+ * - 128
+ - Enable messages related to throughput meter
+ * - 255
+ - Enable all messages
+
+The debug output can be changed at runtime using the file
+``/sys/class/net/bat0/mesh/log_level``. e.g.::
+
+ $ echo 6 > /sys/class/net/bat0/mesh/log_level
+
+will enable debug messages for when routes change.
+
+Counters for different types of packets entering and leaving the batman-adv
+module are available through ethtool::
+
+ $ ethtool --statistics bat0
+
+
+batctl
+======
+
+As batman advanced operates on layer 2, all hosts participating in the virtual
+switch are completely transparent for all protocols above layer 2. Therefore
+the common diagnosis tools do not work as expected. To overcome these problems,
+batctl was created. At the moment the batctl contains ping, traceroute, tcpdump
+and interfaces to the kernel module settings.
+
+For more information, please see the manpage (``man batctl``).
+
+batctl is available on https://www.open-mesh.org/
+
+
+Contact
+=======
+
+Please send us comments, experiences, questions, anything :)
+
+IRC:
+ #batman on irc.freenode.org
+Mailing-list:
+ b.a.t.m.a.n(a)open-mesh.org (optional subscription at
+ https://lists.open-mesh.org/mm/listinfo/b.a.t.m.a.n)
+
+You can also contact the Authors:
+
+* Marek Lindner <mareklindner(a)neomailbox.ch>
+* Simon Wunderlich <sw(a)simonwunderlich.de>
diff --git a/Documentation/networking/batman-adv.txt b/Documentation/networking/batman-adv.txt
deleted file mode 100644
index ccf94677..00000000
--- a/Documentation/networking/batman-adv.txt
+++ /dev/null
@@ -1,215 +0,0 @@
-BATMAN-ADV
-----------
-
-Batman advanced is a new approach to wireless networking which
-does no longer operate on the IP basis. Unlike the batman daemon,
-which exchanges information using UDP packets and sets routing
-tables, batman-advanced operates on ISO/OSI Layer 2 only and uses
-and routes (or better: bridges) Ethernet Frames. It emulates a
-virtual network switch of all nodes participating. Therefore all
-nodes appear to be link local, thus all higher operating proto-
-cols won't be affected by any changes within the network. You can
-run almost any protocol above batman advanced, prominent examples
-are: IPv4, IPv6, DHCP, IPX.
-
-Batman advanced was implemented as a Linux kernel driver to re-
-duce the overhead to a minimum. It does not depend on any (other)
-network driver, and can be used on wifi as well as ethernet lan,
-vpn, etc ... (anything with ethernet-style layer 2).
-
-
-CONFIGURATION
--------------
-
-Load the batman-adv module into your kernel:
-
-# insmod batman-adv.ko
-
-The module is now waiting for activation. You must add some in-
-terfaces on which batman can operate. After loading the module
-batman advanced will scan your systems interfaces to search for
-compatible interfaces. Once found, it will create subfolders in
-the /sys directories of each supported interface, e.g.
-
-# ls /sys/class/net/eth0/batman_adv/
-# elp_interval iface_status mesh_iface throughput_override
-
-If an interface does not have the "batman_adv" subfolder it prob-
-ably is not supported. Not supported interfaces are: loopback,
-non-ethernet and batman's own interfaces.
-
-Note: After the module was loaded it will continuously watch for
-new interfaces to verify the compatibility. There is no need to
-reload the module if you plug your USB wifi adapter into your ma-
-chine after batman advanced was initially loaded.
-
-The batman-adv soft-interface can be created using the iproute2
-tool "ip"
-
-# ip link add name bat0 type batadv
-
-To activate a given interface simply attach it to the "bat0"
-interface
-
-# ip link set dev eth0 master bat0
-
-Repeat this step for all interfaces you wish to add. Now batman
-starts using/broadcasting on this/these interface(s).
-
-By reading the "iface_status" file you can check its status:
-
-# cat /sys/class/net/eth0/batman_adv/iface_status
-# active
-
-To deactivate an interface you have to detach it from the
-"bat0" interface:
-
-# ip link set dev eth0 nomaster
-
-
-All mesh wide settings can be found in batman's own interface
-folder:
-
-# ls /sys/class/net/bat0/mesh/
-# aggregated_ogms fragmentation isolation_mark routing_algo
-# ap_isolation gw_bandwidth log_level vlan0
-# bonding gw_mode multicast_mode
-# bridge_loop_avoidance gw_sel_class network_coding
-# distributed_arp_table hop_penalty orig_interval
-
-There is a special folder for debugging information:
-
-# ls /sys/kernel/debug/batman_adv/bat0/
-# bla_backbone_table log neighbors transtable_local
-# bla_claim_table mcast_flags originators
-# dat_cache nc socket
-# gateways nc_nodes transtable_global
-
-Some of the files contain all sort of status information regard-
-ing the mesh network. For example, you can view the table of
-originators (mesh participants) with:
-
-# cat /sys/kernel/debug/batman_adv/bat0/originators
-
-Other files allow to change batman's behaviour to better fit your
-requirements. For instance, you can check the current originator
-interval (value in milliseconds which determines how often batman
-sends its broadcast packets):
-
-# cat /sys/class/net/bat0/mesh/orig_interval
-# 1000
-
-and also change its value:
-
-# echo 3000 > /sys/class/net/bat0/mesh/orig_interval
-
-In very mobile scenarios, you might want to adjust the originator
-interval to a lower value. This will make the mesh more respon-
-sive to topology changes, but will also increase the overhead.
-
-
-USAGE
------
-
-To make use of your newly created mesh, batman advanced provides
-a new interface "bat0" which you should use from this point on.
-All interfaces added to batman advanced are not relevant any
-longer because batman handles them for you. Basically, one "hands
-over" the data by using the batman interface and batman will make
-sure it reaches its destination.
-
-The "bat0" interface can be used like any other regular inter-
-face. It needs an IP address which can be either statically con-
-figured or dynamically (by using DHCP or similar services):
-
-# NodeA: ip link set up dev bat0
-# NodeA: ip addr add 192.168.0.1/24 dev bat0
-
-# NodeB: ip link set up dev bat0
-# NodeB: ip addr add 192.168.0.2/24 dev bat0
-# NodeB: ping 192.168.0.1
-
-Note: In order to avoid problems remove all IP addresses previ-
-ously assigned to interfaces now used by batman advanced, e.g.
-
-# ip addr flush dev eth0
-
-
-LOGGING/DEBUGGING
------------------
-
-All error messages, warnings and information messages are sent to
-the kernel log. Depending on your operating system distribution
-this can be read in one of a number of ways. Try using the com-
-mands: dmesg, logread, or looking in the files /var/log/kern.log
-or /var/log/syslog. All batman-adv messages are prefixed with
-"batman-adv:" So to see just these messages try
-
-# dmesg | grep batman-adv
-
-When investigating problems with your mesh network it is some-
-times necessary to see more detail debug messages. This must be
-enabled when compiling the batman-adv module. When building bat-
-man-adv as part of kernel, use "make menuconfig" and enable the
-option "B.A.T.M.A.N. debugging".
-
-Those additional debug messages can be accessed using a special
-file in debugfs
-
-# cat /sys/kernel/debug/batman_adv/bat0/log
-
-The additional debug output is by default disabled. It can be en-
-abled during run time. Following log_levels are defined:
-
- 0 - All debug output disabled
- 1 - Enable messages related to routing / flooding / broadcasting
- 2 - Enable messages related to route added / changed / deleted
- 4 - Enable messages related to translation table operations
- 8 - Enable messages related to bridge loop avoidance
- 16 - Enable messages related to DAT, ARP snooping and parsing
- 32 - Enable messages related to network coding
- 64 - Enable messages related to multicast
-128 - Enable messages related to throughput meter
-255 - Enable all messages
-
-The debug output can be changed at runtime using the file
-/sys/class/net/bat0/mesh/log_level. e.g.
-
-# echo 6 > /sys/class/net/bat0/mesh/log_level
-
-will enable debug messages for when routes change.
-
-Counters for different types of packets entering and leaving the
-batman-adv module are available through ethtool:
-
-# ethtool --statistics bat0
-
-
-BATCTL
-------
-
-As batman advanced operates on layer 2 all hosts participating in
-the virtual switch are completely transparent for all protocols
-above layer 2. Therefore the common diagnosis tools do not work
-as expected. To overcome these problems batctl was created. At
-the moment the batctl contains ping, traceroute, tcpdump and
-interfaces to the kernel module settings.
-
-For more information, please see the manpage (man batctl).
-
-batctl is available on https://www.open-mesh.org/
-
-
-CONTACT
--------
-
-Please send us comments, experiences, questions, anything :)
-
-IRC: #batman on irc.freenode.org
-Mailing-list: b.a.t.m.a.n(a)open-mesh.org (optional subscription
- at https://lists.open-mesh.org/mm/listinfo/b.a.t.m.a.n)
-
-You can also contact the Authors:
-
-Marek Lindner <mareklindner(a)neomailbox.ch>
-Simon Wunderlich <sw(a)simonwunderlich.de>
diff --git a/MAINTAINERS b/MAINTAINERS
index ff0322de..3045edcc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8,6 +8,6 @@ Q: https://patchwork.open-mesh.org/project/batman/list/
S: Maintained
F: Documentation/ABI/testing/sysfs-class-net-batman-adv
F: Documentation/ABI/testing/sysfs-class-net-mesh
-F: Documentation/networking/batman-adv.txt
+F: Documentation/networking/batman-adv.rst
F: include/uapi/linux/batman_adv.h
F: net/batman-adv/
diff --git a/README b/README
index 209342fe..87a80914 120000
--- a/README
+++ b/README
@@ -1 +1 @@
-Documentation/networking/batman-adv.txt
\ No newline at end of file
+Documentation/networking/batman-adv.rst
\ No newline at end of file
5 years, 6 months