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(-)
From: Andreas Pape <APape(a)phoenixcontact.com>
If dat is enabled it must be made sure that only the backbone gw which has
claimed the remote destination for the ARP request answers the ARP request
directly if the MAC address is known due to the local dat table. This
prevents multiple ARP replies in a common backbone if more than one
gateway already knows the remote mac searched for in the ARP request.
Signed-off-by: Andreas Pape <apape(a)phoenixcontact.com>
Acked-by: Simon Wunderlich <sw(a)simonwunderlich.de>
[sven(a)narfation.org: fix conflicts with current version]
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
net/batman-adv/bridge_loop_avoidance.c | 49 ++++++++++++++++++++++++++++++++++
net/batman-adv/bridge_loop_avoidance.h | 11 ++++++++
net/batman-adv/distributed-arp-table.c | 15 +++++++++++
3 files changed, 75 insertions(+)
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index e7f690b..41ab4a6 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -2450,3 +2450,52 @@ out:
return ret;
}
+
+#ifdef CONFIG_BATMAN_ADV_DAT
+/**
+ * batadv_bla_check_claim - check if address is claimed
+ *
+ * @bat_priv: the bat priv with all the soft interface information
+ * @addr: mac address of which the claim status is checked
+ * @vid: the VLAN ID
+ *
+ * addr is checked if this address is claimed by the local device itself.
+ *
+ * Return: true if bla is disabled or the mac is claimed by the device,
+ * false if the device addr is already claimed by another gateway
+ */
+bool batadv_bla_check_claim(struct batadv_priv *bat_priv,
+ u8 *addr, unsigned short vid)
+{
+ struct batadv_bla_claim search_claim;
+ struct batadv_bla_claim *claim = NULL;
+ struct batadv_hard_iface *primary_if = NULL;
+ bool ret = true;
+
+ if (!atomic_read(&bat_priv->bridge_loop_avoidance))
+ return ret;
+
+ primary_if = batadv_primary_if_get_selected(bat_priv);
+ if (!primary_if)
+ return ret;
+
+ /* First look if the mac address is claimed */
+ ether_addr_copy(search_claim.addr, addr);
+ search_claim.vid = vid;
+
+ claim = batadv_claim_hash_find(bat_priv, &search_claim);
+
+ /* If there is a claim and we are not owner of the claim,
+ * return false.
+ */
+ if (claim) {
+ if (!batadv_compare_eth(claim->backbone_gw->orig,
+ primary_if->net_dev->dev_addr))
+ ret = false;
+ batadv_claim_put(claim);
+ }
+
+ batadv_hardif_put(primary_if);
+ return ret;
+}
+#endif
diff --git a/net/batman-adv/bridge_loop_avoidance.h b/net/batman-adv/bridge_loop_avoidance.h
index 1ae93e4..86b8740 100644
--- a/net/batman-adv/bridge_loop_avoidance.h
+++ b/net/batman-adv/bridge_loop_avoidance.h
@@ -51,6 +51,10 @@ void batadv_bla_status_update(struct net_device *net_dev);
int batadv_bla_init(struct batadv_priv *bat_priv);
void batadv_bla_free(struct batadv_priv *bat_priv);
int batadv_bla_claim_dump(struct sk_buff *msg, struct netlink_callback *cb);
+#ifdef CONFIG_BATMAN_ADV_DAT
+bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
+ unsigned short vid);
+#endif
#define BATADV_BLA_CRC_INIT 0
#else /* ifdef CONFIG_BATMAN_ADV_BLA */
@@ -127,6 +131,13 @@ static inline int batadv_bla_backbone_dump(struct sk_buff *msg,
return -EOPNOTSUPP;
}
+static inline
+bool batadv_bla_check_claim(struct batadv_priv *bat_priv, u8 *addr,
+ unsigned short vid)
+{
+ return true;
+}
+
#endif /* ifdef CONFIG_BATMAN_ADV_BLA */
#endif /* ifndef _NET_BATMAN_ADV_BLA_H_ */
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index e257efd..cf53404 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -43,6 +43,7 @@
#include <linux/workqueue.h>
#include <net/arp.h>
+#include "bridge_loop_avoidance.h"
#include "hard-interface.h"
#include "hash.h"
#include "log.h"
@@ -1007,6 +1008,20 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
goto out;
}
+ /* If BLA is enabled, only send ARP replies if we have claimed
+ * the destination for the ARP request or if no one else of
+ * the backbone gws belonging to our backbone has claimed the
+ * destination.
+ */
+ if (!batadv_bla_check_claim(bat_priv,
+ dat_entry->mac_addr, vid)) {
+ batadv_dbg(BATADV_DBG_DAT, bat_priv,
+ "Device %pM claimed by another backbone gw. Don't send ARP reply!",
+ dat_entry->mac_addr);
+ ret = true;
+ goto out;
+ }
+
skb_new = arp_create(ARPOP_REPLY, ETH_P_ARP, ip_src,
bat_priv->soft_iface, ip_dst, hw_src,
dat_entry->mac_addr, hw_src);
--
2.9.3
Hello Antonio Quartulli,
The patch 7ea7b4a14275: "batman-adv: make the TT CRC logic VLAN
specific" from Jul 30, 2013, leads to the following static checker
warning:
net/batman-adv/translation-table.c:3294 batadv_send_my_tt_response()
error: uninitialized symbol 'tt_change'.
net/batman-adv/translation-table.c
3282 if (!full_table) {
3283 spin_lock_bh(&bat_priv->tt.last_changeset_lock);
3284
3285 tt_len = bat_priv->tt.last_changeset_len;
3286 tvlv_len = batadv_tt_prepare_tvlv_local_data(bat_priv,
3287 &tvlv_tt_data,
3288 &tt_change,
3289 &tt_len);
3290 if (!tt_len)
3291 goto unlock;
This should probably be changed to:
if (!tt_len || !tvlv_len)
goto unlock;
There seems to be an assumption that "tt_len" is set to zero on the
error path? That's another way to fix this, I suppose.
3292
3293 /* Copy the last orig_node's OGM buffer */
3294 memcpy(tt_change, bat_priv->tt.last_changeset,
3295 bat_priv->tt.last_changeset_len);
3296 spin_unlock_bh(&bat_priv->tt.last_changeset_lock);
3297 } else {
See also:
net/batman-adv/translation-table.c:3313 batadv_send_my_tt_response()
error: uninitialized symbol 'tt_change'.
regards,
dan carpenter
batadv_tt_prepare_tvlv_local_data can fail to allocate the memory for the
new TVLV block. The caller is informed about this problem with the returned
length of 0. Not checking this value results in an invalid memory access
when either tt_data or tt_change is accessed.
Reported-by: Dan Carpenter <dan.carpenter(a)oracle.com>
Fixes: 21a57f6e7a3b ("batman-adv: make the TT CRC logic VLAN specific")
Signed-off-by: Sven Eckelmann <sven(a)narfation.org>
---
The very good report from Dan Carpenter can be found at
https://lists.open-mesh.org/pipermail/b.a.t.m.a.n/2016-November/016713.html
net/batman-adv/translation-table.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 7f66309..0dc85eb 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -3282,7 +3282,7 @@ static bool batadv_send_my_tt_response(struct batadv_priv *bat_priv,
&tvlv_tt_data,
&tt_change,
&tt_len);
- if (!tt_len)
+ if (!tt_len || !tvlv_len)
goto unlock;
/* Copy the last orig_node's OGM buffer */
@@ -3300,7 +3300,7 @@ static bool batadv_send_my_tt_response(struct batadv_priv *bat_priv,
&tvlv_tt_data,
&tt_change,
&tt_len);
- if (!tt_len)
+ if (!tt_len || !tvlv_len)
goto out;
/* fill the rest of the tvlv with the real TT entries */
--
2.10.2