From: Andreas Pape <apape(a)phoenixcontact.com>
Like in the case of the patch for batadv_bla_tx to handle a race
condition when claiming a mac address for bla, a similar situation
can occur when claiming is triggered via batadv_bla_rx. This patch
solves this with a similar approach as for batadv_bla_tx.
Signed-off-by: Andreas Pape <apape(a)phoenixcontact.com>
---
net/batman-adv/bridge_loop_avoidance.c | 31 ++++++++++++++++++++-----------
net/batman-adv/translation-table.c | 26 ++++++++++++++++++++++++++
net/batman-adv/translation-table.h | 3 +++
3 files changed, 49 insertions(+), 11 deletions(-)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index d07e89e..cab8980 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1847,19 +1847,28 @@ bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
if (!claim) {
/* possible optimization: race for a claim */
- /* No claim exists yet, claim it for us!
+ /* Make sure this packet is not looping back
+ * from our own backbone.
*/
- batadv_dbg(BATADV_DBG_BLA, bat_priv,
- "bla_rx(): Unclaimed MAC %pM found. Claim it. Local: %s\n",
- ethhdr->h_source,
- batadv_is_my_client(bat_priv,
- ethhdr->h_source, vid) ?
- "yes" : "no");
- batadv_handle_claim(bat_priv, primary_if,
- primary_if->net_dev->dev_addr,
- ethhdr->h_source, vid);
- goto allow;
+ if (batadv_tt_local_has_timed_out(bat_priv, ethhdr->h_source,
+ vid, 100)) {
+ /* No claim exists yet, claim it for us!
+ */
+ batadv_dbg(BATADV_DBG_BLA, bat_priv,
+ "bla_rx(): Unclaimed MAC %pM found. Claim it. Local: %s\n",
+ ethhdr->h_source,
+ batadv_is_my_client(bat_priv,
+ ethhdr->h_source, vid) ?
+ "yes" : "no");
+
+ batadv_handle_claim(bat_priv, primary_if,
+ primary_if->net_dev->dev_addr,
+ ethhdr->h_source, vid);
+ goto allow;
+ } else {
+ goto handled;
+ }
}
/* if it is our own claim ... */
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index e75b493..b908195 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -4380,3 +4380,29 @@ void batadv_tt_cache_destroy(void)
kmem_cache_destroy(batadv_tt_req_cache);
kmem_cache_destroy(batadv_tt_roam_cache);
}
+
+bool batadv_tt_local_has_timed_out(struct batadv_priv *bat_priv,
+ const u8 *addr, unsigned short vid,
+ unsigned int timeout)
+{
+ struct batadv_tt_local_entry *tt_local_entry;
+ bool ret = true;
+
+ tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr, vid);
+ if (!tt_local_entry)
+ goto out;
+ /* Check if the client has been logically deleted (but is kept for
+ * consistency purpose)
+ */
+ if ((tt_local_entry->common.flags & BATADV_TT_CLIENT_PENDING) ||
+ (tt_local_entry->common.flags & BATADV_TT_CLIENT_ROAM))
+ goto out;
+ /* Check that the tt_local_entry has a certain age */
+ if (!batadv_has_timed_out(tt_local_entry->last_seen, timeout))
+ ret = false;
+
+out:
+ if (tt_local_entry)
+ batadv_tt_local_entry_put(tt_local_entry);
+ return ret;
+}
diff --git a/net/batman-adv/translation-table.h b/net/batman-adv/translation-table.h
index 411d586..b05d0d8 100644
--- a/net/batman-adv/translation-table.h
+++ b/net/batman-adv/translation-table.h
@@ -65,5 +65,8 @@ bool batadv_tt_global_is_isolated(struct batadv_priv *bat_priv,
int batadv_tt_cache_init(void);
void batadv_tt_cache_destroy(void);
+bool batadv_tt_local_has_timed_out(struct batadv_priv *bat_priv,
+ const u8 *addr, unsigned short vid,
+ unsigned int timeout);
#endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */
--
1.7.0.4
Hi David,
this is our first feature pull request for batman-adv (mostly containing
code cleanup stuff), there are at least two more to come.
Please pull or let me know of any problem!
Thank you,
Simon
The following changes since commit 29fbff8698fc0ac1a1d74584b258e0bf18b469f9:
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (2016-10-13 21:40:23 -0700)
are available in the git repository at:
git://git.open-mesh.org/linux-merge.git tags/batadv-next-for-davem-20161027
for you to fetch changes up to 4c7da0f6dbcde2431d773ce03cde5e7abede54e0:
batman-adv: Avoid precedence issues in macros (2016-10-19 08:37:54 +0200)
----------------------------------------------------------------
This code cleanup patchset includes the following changes (chronological
order):
- bump version strings, by Simon Wunderlich
- README updates/clean up, by Sven Eckelmann (4 patches)
- Code clean up and restructuring by Sven Eckelmann (2 patches)
- Kerneldoc fix in forw_packet structure, by Linus Luessing
- Remove unused argument in dbg_arp, by Antonio Quartulli
- Add support to build batman-adv without wireless, by Linus Luessing
- Restructure error handling for is_ap_isolated, by Markus Elfring
- Remove unused initialization in various functions, by Sven Eckelmann
- Use better names for fragment and gateway list heads, by Sven
Eckelmann (2 patches)
- Convert to octal permissions for files, by Sven Eckelmann
- Avoid precedence issues for some macros, by Sven Eckelmann
----------------------------------------------------------------
Antonio Quartulli (1):
batman-adv: remove unsed argument from batadv_dbg_arp() function
Linus Lüssing (2):
batman-adv: fix batadv_forw_packet kerneldoc for list attribute
batman-adv: Allow selecting BATMAN V if CFG80211 is not built
Markus Elfring (1):
batman-adv: Less function calls in batadv_is_ap_isolated() after error detection
Simon Wunderlich (1):
batman-adv: Start new development cycle
Sven Eckelmann (12):
batman-adv: Add B.A.T.M.A.N. V sysfs files to README
batman-adv: Add network_coding and mcast sysfs files to README
batman-adv: Add dat, mcast, nc and neighbor debugfs files to README
batman-adv: Document new nc, mcast and tpmeter log levels
batman-adv: Remove unused function batadv_hash_delete
batman-adv: Move batadv_sum_counter to soft-interface.c
batman-adv: Remove unused batadv_icmp_user_cmd_type
batman-adv: Remove needless init of variables on stack
batman-adv: Use proper name for fragments list head
batman-adv: Use proper name for gateway list head
batman-adv: Use octal permissions instead of macros
batman-adv: Avoid precedence issues in macros
Documentation/networking/batman-adv.txt | 35 ++++++++++++----------
net/batman-adv/Kconfig | 2 +-
net/batman-adv/bat_iv_ogm.c | 6 ++--
net/batman-adv/bat_v.c | 8 ++---
net/batman-adv/bat_v_ogm.c | 4 +--
net/batman-adv/debugfs.c | 26 ++++++++--------
net/batman-adv/distributed-arp-table.c | 17 ++++-------
net/batman-adv/fragmentation.c | 18 +++++------
net/batman-adv/fragmentation.h | 2 +-
net/batman-adv/gateway_client.c | 9 +++---
net/batman-adv/hash.h | 30 -------------------
net/batman-adv/icmp_socket.c | 5 ++--
net/batman-adv/log.c | 4 +--
net/batman-adv/log.h | 12 ++++----
net/batman-adv/main.c | 2 +-
net/batman-adv/main.h | 27 ++---------------
net/batman-adv/network-coding.c | 8 ++---
net/batman-adv/originator.c | 10 +++----
net/batman-adv/packet.h | 12 +-------
net/batman-adv/send.c | 2 +-
net/batman-adv/soft-interface.c | 21 +++++++++++++
net/batman-adv/sysfs.c | 53 ++++++++++++++-------------------
net/batman-adv/translation-table.c | 25 +++++++---------
net/batman-adv/types.h | 16 +++++-----
24 files changed, 149 insertions(+), 205 deletions(-)
On Mittwoch, 25. Januar 2017 03:18:10 CET jens wrote:
> On 24.01.2017 14:39, Sven Eckelmann wrote:
> > There is no artificial limit added by batman-adv. But transmitting a lot of
> > broadcasts over 255 virtual links sharing the same physical link
> > might get interesting (independent of batman-adv).
>
> this made me curious , and i modified your script a bit - turns out
> after the 127. IF you add to batman-adv you get an Error -
> all 510 gretap links was succesfully build ...
> # ifconfig |grep gre| wc -l
> 515
> # batctl if|sort|wc -l
> 127
> the error is mainly
> *Error - can't write to file
> '/sys/class/net/gre128/batman_adv/mesh_iface': Cannot allocate memory
[...]
> [113990.684947] [<ffffffff8107c16e>] ? __warn+0xbe/0xe0 [113990.684955]
> [<ffffffffc017a804>] ? batadv_orig_hash_add_if+0x94/0x140 [batman_adv]
> [113990.684961] [<ffffffff811a7b10>] ? kmalloc_slab+0x90/0xa0
> [113990.684966] [<ffffffff811e08c5>] ? __kmalloc+0x25/0x580
> [113990.684971] [<ffffffff815ef9d7>] ? _raw_spin_lock_irqsave+0x17/0x39
> [113990.684977] [<ffffffff81432c11>] ? _crng_backtrack_protect+0x31/0x70
> [113990.684981] [<ffffffff811e0ebc>] ? kmem_cache_alloc_trace+0x9c/0x540
> [113990.684986] [<ffffffff814340b7>] ? get_random_bytes+0xe7/0x1c0
> [113990.684991] [<ffffffffc017a804>] ?
[...]
I would guess that your system mostly fails becauseit cannot handle the
allocation of the "large" arrays which store:
* @bcast_own: set of bitfields (one per hard-interface) where each one counts
* the number of our OGMs this orig_node rebroadcasted "back" to us (relative
* to last_real_seqno). Every bitfield is BATADV_TQ_LOCAL_WINDOW_SIZE bits long.
* @bcast_own_sum: sum of bcast_own
Kind regards,
Sven
Hi,
Here is a first patchset to reintroduce aggregation support for BATMAN V, too -
as well as any other packet type with a broadcast destination.
Branch:
* https://git.open-mesh.org/batman-adv.git/shortlog/refs/heads/linus/aggregat…
Regards, Linus
PS: Requires: "batman-adv: Introduce packet type independent TVLV handler API"
(40e5c9e798ec, available on patchwork or linus/aggregation branch)
---
Changelog:
v2:
* reset skb->cb on the soft-iface reception path, too [PATCH 5/6]
(thanks Sven!)
RFC->v1:
* removed tvlv (un)pack ctx wrappers
* fixed a crash when deaggregating ARP packets
* now compile tested down to 3.2, too (no issues found)
* now stress tested with multicast traffic of a larger, public mesh setup
From: Gao Feng <fgao(a)ikuai8.com>
Because the func batadv_softif_init_late allocate some resources and
it would be invoked in register_netdevice. So we need to invoke the
func batadv_softif_free instead of free_netdev to cleanup when fail
to register_netdevice.
Signed-off-by: Gao Feng <fgao(a)ikuai8.com>
---
net/batman-adv/soft-interface.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index d042c99..90bf990 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -1011,7 +1011,7 @@ struct net_device *batadv_softif_create(struct net *net, const char *name)
if (ret < 0) {
pr_err("Unable to register the batman interface '%s': %i\n",
name, ret);
- free_netdev(soft_iface);
+ batadv_softif_free(soft_iface);
return NULL;
}
--
1.9.1
The stats are generated by batadv_interface_stats and must not be stored
directly in the net_device stats member variable. The batadv_priv
bat_counters information is assembled when ndo_get_stats is called. The
stats previously stored in net_device::stats is then overwritten.
The batman-adv counters must therefore be increased when an ARP packet is
answered locally via the distributed arp table.
Fixes: 75ca71d858f5 ("batman-adv: Distributed ARP Table - add snooping functions for ARP messages")
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
net/batman-adv/distributed-arp-table.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
This patch is only compile tested.
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 013e970..000ca2f 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -1064,8 +1064,9 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
skb_new->protocol = eth_type_trans(skb_new, soft_iface);
- soft_iface->stats.rx_packets++;
- soft_iface->stats.rx_bytes += skb->len + ETH_HLEN + hdr_size;
+ batadv_inc_counter(bat_priv, BATADV_CNT_RX);
+ batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES,
+ skb->len + ETH_HLEN + hdr_size);
netif_rx(skb_new);
batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied locally\n");
--
2.11.0
Hi list!
Been lurking for almost a year on the battlemesh list and recently
joined here as well.
I'm curious about how well batman-adv scales. Would a network of 10 000
nodes work well? What about 100 000 nodes or 1 000 000?
Thanks!
fuumind
Hi community,
We have batman-adv working on OpenWRT Chaos Calmer.
- Atheros ar9331 MIPS platform + built-in ath9k WiFi
- batman-adv version 2016.1
- routing_algos = BATMAN_IV
- Wireless interface MTU = 1532, adhoc network encryption "psk2-ccmp"
- bat0 interface MTU = 1500
We have batman-adv running on 10+ sites. For each site, there are 10-20
nodes in the mesh network.
batman-adv runs almost perfectly (*almost*). Occasionally (occurrence
rate is low), node drops off the batman-adv / adhoc mesh.
- Sometimes, node can recover (re-joins the mesh network automatically),
but not always.
Any suggestions? Does batman-adv works perfectly in the field (i.e.
running for 1 year with 100+ nodes without any issues)?
What about I use one node as Master, and other nodes ping this Master
every 10s (or 30 seconds) (to keep mesh from inactivity)? Does this help?
Thanks.
Xuebing Wang
This patch is a workaround for the following issue:
[...]/batman-adv/build/net/batman-adv/../../../compat-sources/net/core/skbuff.o
./include/linux/if.h:27:11: error: unable to open 'sys/socket.h'
In file included from ./include/linux/compat.h:16:0,
from ./include/linux/ethtool.h:16,
from [...]/batman-adv/build/../compat-include/linux/ethtool.h:25,
from ./include/linux/netdevice.h:42,
from [...]/batman-adv/build/../compat-include/linux/netdevice.h:25,
from ./include/linux/icmpv6.h:12,
from ./include/linux/ipv6.h:82,
from [...]/batman-adv/build/net/batman-adv/../../../compat-sources/net/core/skbuff.c:36:
./include/linux/if.h:27:54: fatal error: sys/socket.h: No such file or directory
#include <sys/socket.h> /* for struct sockaddr. */
It seems to occur since:
"uapi: fix linux/if.h userspace compilation errors"
(2618be7dcc, Linux 4.11-rc1)
Simply including an empty sys/socket.h makes the kernel module compile
again. (The #ifndef __KERNEL__, which kernel-package / make-kpkg
stripped, should have removed this include for kernel modules anyway.)
Signed-off-by: Linus Lüssing <linus.luessing(a)c0d3.blue>
---
Fixes:
- https://www.open-mesh.org/issues/333
---
compat-include/sys/socket.h | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 compat-include/sys/socket.h
diff --git a/compat-include/sys/socket.h b/compat-include/sys/socket.h
new file mode 100644
index 0000000..8722e57
--- /dev/null
+++ b/compat-include/sys/socket.h
@@ -0,0 +1,3 @@
+/*
+ * Workaround for Debian's kernel-package
+ */
--
2.1.4