batman-adv: fix mac addr change and symmetry check
[feed/routing.git] / patches / 0003-batman-adv-Fix-symmetry-check-route-flapping-in-mult.patch
1 From 6c9d9eeac0fb5d6625256cd119d0a4994c63e965 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Linus=20L=C3=BCssing?= <linus.luessing@web.de>
3 Date: Tue, 18 Sep 2012 03:01:08 +0200
4 Subject: [PATCH] batman-adv: Fix symmetry check / route flapping in multi
5 interface setups
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 If receiving an OGM from a neighbor other than the currently selected
11 and if it has the same TQ then we are supposed to switch if this
12 neighbor provides a more symmetric link than the currently selected one.
13
14 However this symmetry check currently is broken if the interface of the
15 neighbor we received the OGM from and the one of the currently selected
16 neighbor differ: We are currently trying to determine the symmetry of the
17 link towards the selected router via the link we received the OGM from
18 instead of just checking via the link towards the currently selected
19 router.
20
21 This leads to way more route switches than necessary and can lead to
22 permanent route flapping in many common multi interface setups.
23
24 This patch fixes this issue by using the right interface for this
25 symmetry check.
26
27 Signed-off-by: Linus Lüssing <linus.luessing@web.de>
28 ---
29 bat_iv_ogm.c | 13 +++++++------
30 1 files changed, 7 insertions(+), 6 deletions(-)
31
32 diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
33 index e877af8..469daab 100644
34 --- a/bat_iv_ogm.c
35 +++ b/bat_iv_ogm.c
36 @@ -642,7 +642,8 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
37 struct batadv_neigh_node *router = NULL;
38 struct batadv_orig_node *orig_node_tmp;
39 struct hlist_node *node;
40 - uint8_t bcast_own_sum_orig, bcast_own_sum_neigh;
41 + int if_num;
42 + uint8_t sum_orig, sum_neigh;
43 uint8_t *neigh_addr;
44
45 batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
46 @@ -727,17 +728,17 @@ batadv_iv_ogm_orig_update(struct batadv_priv *bat_priv,
47 if (router && (neigh_node->tq_avg == router->tq_avg)) {
48 orig_node_tmp = router->orig_node;
49 spin_lock_bh(&orig_node_tmp->ogm_cnt_lock);
50 - bcast_own_sum_orig =
51 - orig_node_tmp->bcast_own_sum[if_incoming->if_num];
52 + if_num = router->if_incoming->if_num;
53 + sum_orig = orig_node_tmp->bcast_own_sum[if_num];
54 spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock);
55
56 orig_node_tmp = neigh_node->orig_node;
57 spin_lock_bh(&orig_node_tmp->ogm_cnt_lock);
58 - bcast_own_sum_neigh =
59 - orig_node_tmp->bcast_own_sum[if_incoming->if_num];
60 + if_num = neigh_node->if_incoming->if_num;
61 + sum_neigh = orig_node_tmp->bcast_own_sum[if_num];
62 spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock);
63
64 - if (bcast_own_sum_orig >= bcast_own_sum_neigh)
65 + if (sum_orig >= sum_neigh)
66 goto update_tt;
67 }
68
69 --
70 1.7.9.1
71