batman-adv: 2013.2.0 updated stability fixes
authorMarek Lindner <lindner_marek@yahoo.de>
Mon, 10 Jun 2013 03:26:47 +0000 (11:26 +0800)
committerMarek Lindner <lindner_marek@yahoo.de>
Mon, 10 Jun 2013 03:26:47 +0000 (11:26 +0800)
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
batman-adv/Makefile
batman-adv/patches/0001-batman-adv-use-the-proper-header-len-when-checking-t.patch
batman-adv/patches/0002-batman-adv-vlan-add-protocol-argument-to-packet-tagging-fun.patch
batman-adv/patches/0003-batman-adv-check-proto-length-before-accessing-proto.patch
batman-adv/patches/0004-batman-adv-check-return-value-of-pskb_trim_rcsum.patch
batman-adv/patches/0005-batman-adv-make-DAT-drop-ARP-requests-targeting-loca.patch
batman-adv/patches/0006-batman-adv-reorder-clean-up-routine-in-order-to-avoi.patch
batman-adv/patches/0007-batman-adv-Avoid-double-freeing-of-bat_counters.patch [new file with mode: 0644]
batman-adv/patches/0008-batman-adv-wait-for-rtnl-in-batadv_store_mesh_iface-.patch [new file with mode: 0644]
batman-adv/patches/0009-batman-adv-Don-t-handle-address-updates-when-bla-is-.patch [new file with mode: 0644]
batman-adv/patches/0010-batman-adv-forward-late-OGMs-from-best-next-hop.patch [new file with mode: 0644]

index 51dc797b4c49b8ca2cbd48f47988dc1cde09fa96..1e77051e8ea73a8dd23ce73b9af9b7f582384c60 100644 (file)
@@ -12,7 +12,7 @@ PKG_NAME:=batman-adv
 
 PKG_VERSION:=2013.2.0
 BATCTL_VERSION:=2013.2.0
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 PKG_MD5SUM:=9ec18300b96df22f0ed21c9f51e4ccef
 BATCTL_MD5SUM:=712f86cdd0f9076503fc48acf37e109e
 
index 0327e033e24cf438c383a80ebb2fbf2a00ec6885..525dbac5fcd48a6bfa1ba4975b02a22978ee3641 100644 (file)
@@ -1,8 +1,8 @@
 From 9b96ecbae7295269aaa0320667f646870de65661 Mon Sep 17 00:00:00 2001
 From: Antonio Quartulli <antonio@open-mesh.com>
 Date: Wed, 3 Apr 2013 10:14:20 +0200
-Subject: [PATCH 1/6] batman-adv: use the proper header len when checking the
- TTVN
+Subject: [PATCH 01/10] batman-adv: use the proper header len when checking
the TTVN
 
 Unicast packet might be of type either UNICAST or
 UNICAST4ADDR.
index f00a33f99260316b1f1509393860d5aba5d3fa58..608bd4382353e39041eb04b8f0142494c0b10f35 100644 (file)
@@ -1,7 +1,7 @@
 From 82d1a8ebf19a1b9841ee44ce7b2448114be3e772 Mon Sep 17 00:00:00 2001
 From: Patrick McHardy <kaber@trash.net>
 Date: Wed, 24 Apr 2013 17:42:56 +0200
-Subject: [PATCH 2/6] net: vlan: add protocol argument to packet tagging
+Subject: [PATCH 02/10] net: vlan: add protocol argument to packet tagging
  functions
 
 Add a protocol argument to the VLAN packet tagging functions. In case of HW
index b7cb91fd43b50eb280aa1b67f978612c3409b583..f6270fa8ad49db40b4d8c681499f5dd11dd0540e 100644 (file)
@@ -1,7 +1,7 @@
 From aa7d19a5b97fe48657e075e8e4d130bd6916551e Mon Sep 17 00:00:00 2001
 From: Marek Lindner <lindner_marek@yahoo.de>
 Date: Sat, 27 Apr 2013 16:22:28 +0800
-Subject: [PATCH 3/6] batman-adv: check proto length before accessing proto
+Subject: [PATCH 03/10] batman-adv: check proto length before accessing proto
  string buffer
 
 batadv_param_set_ra() strips the trailing '\n' from the supplied
index 29962a5a4fd85e00e8eb8ad5957e473ae544c9c8..e38596bdcb571f6d6b328d8515c7706fc2b57fff 100644 (file)
@@ -1,7 +1,7 @@
 From d22ebef1431aab13099370b89afa4ba55eb95c35 Mon Sep 17 00:00:00 2001
 From: Marek Lindner <lindner_marek@yahoo.de>
 Date: Tue, 7 May 2013 19:25:02 +0800
-Subject: [PATCH 4/6] batman-adv: check return value of pskb_trim_rcsum()
+Subject: [PATCH 04/10] batman-adv: check return value of pskb_trim_rcsum()
 MIME-Version: 1.0
 Content-Type: text/plain; charset=UTF-8
 Content-Transfer-Encoding: 8bit
index dd17f770041de31896ac2e2e4ac1c8785258a05e..e617ad31db89c75e2cfd86608307394a5f721557 100644 (file)
@@ -1,7 +1,7 @@
 From d6bd8b36fa1f3d72a6fd5942a6e9bde6ddafcd0d Mon Sep 17 00:00:00 2001
 From: Antonio Quartulli <ordex@autistici.org>
 Date: Thu, 9 May 2013 09:35:45 +0200
-Subject: [PATCH 5/6] batman-adv: make DAT drop ARP requests targeting local
+Subject: [PATCH 05/10] batman-adv: make DAT drop ARP requests targeting local
  clients
 
 In the outgoing ARP request snooping routine in DAT, ARP
index 8fa5f4772d49cc67bf64f4efec554936f9dd50e9..967fb318e5598fd1ef354879a33523904a6de910 100644 (file)
@@ -1,7 +1,7 @@
 From 763f413b9c74ccb25cb066408f49f07e5dd78f9b Mon Sep 17 00:00:00 2001
 From: Antonio Quartulli <ordex@autistici.org>
 Date: Tue, 7 May 2013 01:06:18 +0200
-Subject: [PATCH 6/6] batman-adv: reorder clean up routine in order to avoid
+Subject: [PATCH 06/10] batman-adv: reorder clean up routine in order to avoid
  race conditions
 
 nc_worker accesses the originator table during its periodic
diff --git a/batman-adv/patches/0007-batman-adv-Avoid-double-freeing-of-bat_counters.patch b/batman-adv/patches/0007-batman-adv-Avoid-double-freeing-of-bat_counters.patch
new file mode 100644 (file)
index 0000000..d4f3806
--- /dev/null
@@ -0,0 +1,47 @@
+From a5d79639a76d7a71116abbc369a246bd1fcbf947 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Martin=20Hundeb=C3=B8ll?= <martin@hundeboll.net>
+Date: Wed, 17 Apr 2013 21:13:16 +0200
+Subject: [PATCH 07/10] batman-adv: Avoid double freeing of bat_counters
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+On errors in batadv_mesh_init(), bat_counters will be freed in both
+batadv_mesh_free() and batadv_softif_init_late(). This patch fixes this
+by returning earlier from batadv_softif_init_late() in case of errors in
+batadv_mesh_init() and by setting bat_counters to NULL after freeing.
+
+Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
+Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
+---
+ main.c           |    1 +
+ soft-interface.c |    1 +
+ 2 files changed, 2 insertions(+)
+
+diff --git a/main.c b/main.c
+index 1240f07..51aafd6 100644
+--- a/main.c
++++ b/main.c
+@@ -181,6 +181,7 @@ void batadv_mesh_free(struct net_device *soft_iface)
+       batadv_originator_free(bat_priv);
+       free_percpu(bat_priv->bat_counters);
++      bat_priv->bat_counters = NULL;
+       atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
+ }
+diff --git a/soft-interface.c b/soft-interface.c
+index 6f20d33..819dfb0 100644
+--- a/soft-interface.c
++++ b/soft-interface.c
+@@ -505,6 +505,7 @@ unreg_debugfs:
+       batadv_debugfs_del_meshif(dev);
+ free_bat_counters:
+       free_percpu(bat_priv->bat_counters);
++      bat_priv->bat_counters = NULL;
+       return ret;
+ }
+-- 
+1.7.10.4
+
diff --git a/batman-adv/patches/0008-batman-adv-wait-for-rtnl-in-batadv_store_mesh_iface-.patch b/batman-adv/patches/0008-batman-adv-wait-for-rtnl-in-batadv_store_mesh_iface-.patch
new file mode 100644 (file)
index 0000000..87a2940
--- /dev/null
@@ -0,0 +1,42 @@
+From 96cd7725540f4dccdd6fbb4fde59243e1cc1ad80 Mon Sep 17 00:00:00 2001
+From: Matthias Schiffer <mschiffer@universe-factory.net>
+Date: Tue, 28 May 2013 17:32:32 +0200
+Subject: [PATCH 08/10] batman-adv: wait for rtnl in batadv_store_mesh_iface
+ instead of failing if it is taken
+
+The rtnl_lock in batadv_store_mesh_iface has been converted to a rtnl_trylock
+some time ago to avoid a possible deadlock between rtnl and s_active on removal
+of the sysfs nodes.
+
+The behaviour introduced by that was quite confusing as it could lead to the
+sysfs store to fail, making batman-adv setup scripts unreliable. As recently the
+sysfs removal was postponed to a worker not running with the rtnl taken, the
+deadlock can't occur any more and it is safe to change the trylock back to a
+lock to make the sysfs store reliable again.
+
+Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
+Reviewed-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
+Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
+---
+ sysfs.c |    5 +----
+ 1 file changed, 1 insertion(+), 4 deletions(-)
+
+diff --git a/sysfs.c b/sysfs.c
+index 15a22ef..929e304 100644
+--- a/sysfs.c
++++ b/sysfs.c
+@@ -582,10 +582,7 @@ static ssize_t batadv_store_mesh_iface(struct kobject *kobj,
+           (strncmp(hard_iface->soft_iface->name, buff, IFNAMSIZ) == 0))
+               goto out;
+-      if (!rtnl_trylock()) {
+-              ret = -ERESTARTSYS;
+-              goto out;
+-      }
++      rtnl_lock();
+       if (status_tmp == BATADV_IF_NOT_IN_USE) {
+               batadv_hardif_disable_interface(hard_iface,
+-- 
+1.7.10.4
+
diff --git a/batman-adv/patches/0009-batman-adv-Don-t-handle-address-updates-when-bla-is-.patch b/batman-adv/patches/0009-batman-adv-Don-t-handle-address-updates-when-bla-is-.patch
new file mode 100644 (file)
index 0000000..52e1acd
--- /dev/null
@@ -0,0 +1,35 @@
+From 518fba156ed911c6183cf5cb34955a6fdf1b4637 Mon Sep 17 00:00:00 2001
+From: Simon Wunderlich <simon@open-mesh.com>
+Date: Fri, 7 Jun 2013 16:52:05 +0200
+Subject: [PATCH 09/10] batman-adv: Don't handle address updates when bla is
+ disabled
+
+The bridge loop avoidance has a hook to handle address updates of the
+originator. These should not be handled when bridge loop avoidance is
+disabled - it might send some bridge loop avoidance packets which should
+not appear if bla is disabled.
+
+Signed-off-by: Simon Wunderlich <simon@open-mesh.com>
+Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
+---
+ bridge_loop_avoidance.c |    4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c
+index 379061c..de27b31 100644
+--- a/bridge_loop_avoidance.c
++++ b/bridge_loop_avoidance.c
+@@ -1067,6 +1067,10 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
+       group = htons(crc16(0, primary_if->net_dev->dev_addr, ETH_ALEN));
+       bat_priv->bla.claim_dest.group = group;
++      /* purge everything when bridge loop avoidance is turned off */
++      if (!atomic_read(&bat_priv->bridge_loop_avoidance))
++              oldif = NULL;
++
+       if (!oldif) {
+               batadv_bla_purge_claims(bat_priv, NULL, 1);
+               batadv_bla_purge_backbone_gw(bat_priv, 1);
+-- 
+1.7.10.4
+
diff --git a/batman-adv/patches/0010-batman-adv-forward-late-OGMs-from-best-next-hop.patch b/batman-adv/patches/0010-batman-adv-forward-late-OGMs-from-best-next-hop.patch
new file mode 100644 (file)
index 0000000..843ee89
--- /dev/null
@@ -0,0 +1,226 @@
+From 3d999e5116f44b47c742aa16d6382721c360a6d0 Mon Sep 17 00:00:00 2001
+From: Simon Wunderlich <simon@open-mesh.com>
+Date: Thu, 23 May 2013 13:07:42 +0200
+Subject: [PATCH 10/10] batman-adv: forward late OGMs from best next hop
+
+When a packet is received from another node first and later from the
+best next hop, this packet is dropped. However the first OGM was sent
+with the BATADV_NOT_BEST_NEXT_HOP flag and thus dropped by neighbors.
+The late OGM from the best neighbor is then dropped because it is a
+duplicate.
+
+If this situation happens constantly, a node might end up not forwarding
+the "valid" OGMs anymore, and nodes behind will starve from not getting
+valid OGMs.
+
+Fix this by refining the duplicate checking behaviour: The actions
+should depend on whether it was a duplicate for a neighbor only or for
+the originator. OGMs which are not duplicates for a specific neighbor
+will now be considered in batadv_iv_ogm_forward(), but only actually
+forwarded for the best next hop. Therefore, late OGMs from the best
+next hop are forwarded now and not dropped as duplicates anymore.
+
+Signed-off-by: Simon Wunderlich <simon@open-mesh.com>
+Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
+---
+ bat_iv_ogm.c |   86 +++++++++++++++++++++++++++++++++++++---------------------
+ 1 file changed, 55 insertions(+), 31 deletions(-)
+
+diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
+index 071f288..f680ee1 100644
+--- a/bat_iv_ogm.c
++++ b/bat_iv_ogm.c
+@@ -29,6 +29,21 @@
+ #include "bat_algo.h"
+ #include "network-coding.h"
++/**
++ * batadv_dup_status - duplicate status
++ * @BATADV_NO_DUP: the packet is a 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 = 0,
++      BATADV_ORIG_DUP,
++      BATADV_NEIGH_DUP,
++      BATADV_PROTECTED,
++};
++
+ static struct batadv_neigh_node *
+ batadv_iv_ogm_neigh_new(struct batadv_hard_iface *hard_iface,
+                       const uint8_t *neigh_addr,
+@@ -650,7 +665,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
+                         const struct batadv_ogm_packet *batadv_ogm_packet,
+                         struct batadv_hard_iface *if_incoming,
+                         const unsigned char *tt_buff,
+-                        int is_duplicate)
++                        enum batadv_dup_status dup_status)
+ {
+       struct batadv_neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL;
+       struct batadv_neigh_node *router = NULL;
+@@ -676,7 +691,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
+                       continue;
+               }
+-              if (is_duplicate)
++              if (dup_status != BATADV_NO_DUP)
+                       continue;
+               spin_lock_bh(&tmp_neigh_node->lq_update_lock);
+@@ -718,7 +733,7 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
+       neigh_node->tq_avg = batadv_ring_buffer_avg(neigh_node->tq_recv);
+       spin_unlock_bh(&neigh_node->lq_update_lock);
+-      if (!is_duplicate) {
++      if (dup_status == BATADV_NO_DUP) {
+               orig_node->last_ttl = batadv_ogm_packet->header.ttl;
+               neigh_node->last_ttl = batadv_ogm_packet->header.ttl;
+       }
+@@ -902,15 +917,16 @@ out:
+       return ret;
+ }
+-/* processes a batman packet for all interfaces, adjusts the sequence number and
+- * finds out whether it is a duplicate.
+- * returns:
+- *   1 the packet is a duplicate
+- *   0 the packet has not yet been received
+- *  -1 the packet is old and has been received while the seqno window
+- *     was protected. Caller should drop it.
++/**
++ * batadv_iv_ogm_update_seqnos -  process a batman packet for all interfaces,
++ *  adjust the sequence number and find out whether it is a duplicate
++ * @ethhdr: ethernet header of the packet
++ * @batadv_ogm_packet: OGM packet to be considered
++ * @if_incoming: interface on which the OGM packet was received
++ *
++ * Returns duplicate status as enum batadv_dup_status
+  */
+-static int
++static enum batadv_dup_status
+ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
+                           const struct batadv_ogm_packet *batadv_ogm_packet,
+                           const struct batadv_hard_iface *if_incoming)
+@@ -918,17 +934,18 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
+       struct batadv_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
+       struct batadv_orig_node *orig_node;
+       struct batadv_neigh_node *tmp_neigh_node;
+-      int is_duplicate = 0;
++      int is_dup;
+       int32_t seq_diff;
+       int need_update = 0;
+-      int set_mark, ret = -1;
++      int set_mark;
++      enum batadv_dup_status ret = BATADV_NO_DUP;
+       uint32_t seqno = ntohl(batadv_ogm_packet->seqno);
+       uint8_t *neigh_addr;
+       uint8_t packet_count;
+       orig_node = batadv_get_orig_node(bat_priv, batadv_ogm_packet->orig);
+       if (!orig_node)
+-              return 0;
++              return BATADV_NO_DUP;
+       spin_lock_bh(&orig_node->ogm_cnt_lock);
+       seq_diff = seqno - orig_node->last_real_seqno;
+@@ -936,22 +953,29 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
+       /* signalize caller that the packet is to be dropped. */
+       if (!hlist_empty(&orig_node->neigh_list) &&
+           batadv_window_protected(bat_priv, seq_diff,
+-                                  &orig_node->batman_seqno_reset))
++                                  &orig_node->batman_seqno_reset)) {
++              ret = BATADV_PROTECTED;
+               goto out;
++      }
+       rcu_read_lock();
+       hlist_for_each_entry_rcu(tmp_neigh_node,
+                                &orig_node->neigh_list, list) {
+-              is_duplicate |= batadv_test_bit(tmp_neigh_node->real_bits,
+-                                              orig_node->last_real_seqno,
+-                                              seqno);
+-
+               neigh_addr = tmp_neigh_node->addr;
++              is_dup = batadv_test_bit(tmp_neigh_node->real_bits,
++                                       orig_node->last_real_seqno,
++                                       seqno);
++
+               if (batadv_compare_eth(neigh_addr, ethhdr->h_source) &&
+-                  tmp_neigh_node->if_incoming == if_incoming)
++                  tmp_neigh_node->if_incoming == if_incoming) {
+                       set_mark = 1;
+-              else
++                      if (is_dup)
++                              ret = BATADV_NEIGH_DUP;
++              } else {
+                       set_mark = 0;
++                      if (is_dup && (ret != BATADV_NEIGH_DUP))
++                              ret = BATADV_ORIG_DUP;
++              }
+               /* if the window moved, set the update flag. */
+               need_update |= batadv_bit_get_packet(bat_priv,
+@@ -971,8 +995,6 @@ batadv_iv_ogm_update_seqnos(const struct ethhdr *ethhdr,
+               orig_node->last_real_seqno = seqno;
+       }
+-      ret = is_duplicate;
+-
+ out:
+       spin_unlock_bh(&orig_node->ogm_cnt_lock);
+       batadv_orig_node_free_ref(orig_node);
+@@ -994,7 +1016,8 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
+       int is_broadcast = 0, is_bidirect;
+       bool is_single_hop_neigh = false;
+       bool is_from_best_next_hop = false;
+-      int is_duplicate, sameseq, simlar_ttl;
++      int sameseq, similar_ttl;
++      enum batadv_dup_status dup_status;
+       uint32_t if_incoming_seqno;
+       uint8_t *prev_sender;
+@@ -1138,10 +1161,10 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
+       if (!orig_node)
+               return;
+-      is_duplicate = batadv_iv_ogm_update_seqnos(ethhdr, batadv_ogm_packet,
+-                                                 if_incoming);
++      dup_status = batadv_iv_ogm_update_seqnos(ethhdr, batadv_ogm_packet,
++                                               if_incoming);
+-      if (is_duplicate == -1) {
++      if (dup_status == BATADV_PROTECTED) {
+               batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
+                          "Drop packet: packet within seqno protection time (sender: %pM)\n",
+                          ethhdr->h_source);
+@@ -1211,11 +1234,12 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
+        * seqno and similar ttl as the non-duplicate
+        */
+       sameseq = orig_node->last_real_seqno == ntohl(batadv_ogm_packet->seqno);
+-      simlar_ttl = orig_node->last_ttl - 3 <= batadv_ogm_packet->header.ttl;
+-      if (is_bidirect && (!is_duplicate || (sameseq && simlar_ttl)))
++      similar_ttl = orig_node->last_ttl - 3 <= batadv_ogm_packet->header.ttl;
++      if (is_bidirect && ((dup_status == BATADV_NO_DUP) ||
++                          (sameseq && similar_ttl)))
+               batadv_iv_ogm_orig_update(bat_priv, orig_node, ethhdr,
+                                         batadv_ogm_packet, if_incoming,
+-                                        tt_buff, is_duplicate);
++                                        tt_buff, dup_status);
+       /* is single hop (direct) neighbor */
+       if (is_single_hop_neigh) {
+@@ -1236,7 +1260,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
+               goto out_neigh;
+       }
+-      if (is_duplicate) {
++      if (dup_status == BATADV_NEIGH_DUP) {
+               batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
+                          "Drop packet: duplicate packet received\n");
+               goto out_neigh;
+-- 
+1.7.10.4
+