batman-adv: 2015.1 bugfixes & stability updates
[feed/routing.git] / batman-adv / patches / 0009-batman-adv-detect-local-excess-vlans-in-TT-request.patch
1 From 2dd1d9f06ac1208b1921aa90d479c3940bc70b4f Mon Sep 17 00:00:00 2001
2 From: Simon Wunderlich <sw@simonwunderlich.de>
3 Date: Wed, 2 Sep 2015 20:09:56 +0200
4 Subject: [PATCH 9/9] batman-adv: detect local excess vlans in TT request
5
6 If the local representation of the global TT table of one originator has
7 more VLAN entries than the respective TT update, there is some
8 inconsistency present. By detecting and reporting this inconsistency,
9 the global table gets updated and the excess VLAN will get removed in
10 the process.
11
12 Reported-by: Alessandro Bolletta <alessandro@mediaspot.net>
13 Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
14 Acked-by: Antonio Quartulli <antonio@meshcoding.com>
15 Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
16 ---
17 net/batman-adv/translation-table.c | 14 +++++++++++++-
18 1 file changed, 13 insertions(+), 1 deletion(-)
19
20 diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
21 index 9ac1a46..7e4657e 100644
22 --- a/net/batman-adv/translation-table.c
23 +++ b/net/batman-adv/translation-table.c
24 @@ -2394,8 +2394,8 @@ static bool batadv_tt_global_check_crc(struct batadv_orig_node *orig_node,
25 {
26 struct batadv_tvlv_tt_vlan_data *tt_vlan_tmp;
27 struct batadv_orig_node_vlan *vlan;
28 + int i, orig_num_vlan;
29 uint32_t crc;
30 - int i;
31
32 /* check if each received CRC matches the locally stored one */
33 for (i = 0; i < num_vlan; i++) {
34 @@ -2421,6 +2421,18 @@ static bool batadv_tt_global_check_crc(struct batadv_orig_node *orig_node,
35 return false;
36 }
37
38 + /* check if any excess VLANs exist locally for the originator
39 + * which are not mentioned in the TVLV from the originator.
40 + */
41 + rcu_read_lock();
42 + orig_num_vlan = 0;
43 + list_for_each_entry_rcu(vlan, &orig_node->vlan_list, list)
44 + orig_num_vlan++;
45 + rcu_read_unlock();
46 +
47 + if (orig_num_vlan > num_vlan)
48 + return false;
49 +
50 return true;
51 }
52
53 --
54 2.5.0
55