batman-adv: Merge bugfixes from 2017.4
[feed/routing.git] / batman-adv / patches / 0023-batman-adv-Fix-lock-for-ogm-cnt-access-in-batadv_iv_.patch
1 From: Sven Eckelmann <sven@narfation.org>
2 Date: Sun, 3 Dec 2017 11:26:45 +0100
3 Subject: [PATCH] batman-adv: Fix lock for ogm cnt access in batadv_iv_ogm_calc_tq
4
5 The originator node object orig_neigh_node is used to when accessing the
6 bcast_own(_sum) and real_packet_count information. The access to them has
7 to be protected with the spinlock in orig_neigh_node.
8
9 But the function uses the lock in orig_node instead. This is incorrect
10 because they could be two different originator node objects.
11
12 Fixes: f14416760b62 ("batman-adv: protect bit operations to count OGMs with spinlock")
13 Signed-off-by: Sven Eckelmann <sven@narfation.org>
14 Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
15
16 Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/9a3b195410e5d2f285cdf0073fef721ff8d9474d
17 ---
18 net/batman-adv/bat_iv_ogm.c | 4 ++--
19 1 file changed, 2 insertions(+), 2 deletions(-)
20
21 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
22 index 7bfd0d7ef49df8e699f91e2b827b824aa3657c0d..56b4984d738e87098c24213d4aa277a2ef948fec 100644
23 --- a/net/batman-adv/bat_iv_ogm.c
24 +++ b/net/batman-adv/bat_iv_ogm.c
25 @@ -1214,7 +1214,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
26 orig_node->last_seen = jiffies;
27
28 /* find packet count of corresponding one hop neighbor */
29 - spin_lock_bh(&orig_node->bat_iv.ogm_cnt_lock);
30 + spin_lock_bh(&orig_neigh_node->bat_iv.ogm_cnt_lock);
31 if_num = if_incoming->if_num;
32 orig_eq_count = orig_neigh_node->bat_iv.bcast_own_sum[if_num];
33 neigh_ifinfo = batadv_neigh_ifinfo_new(neigh_node, if_outgoing);
34 @@ -1224,7 +1224,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
35 } else {
36 neigh_rq_count = 0;
37 }
38 - spin_unlock_bh(&orig_node->bat_iv.ogm_cnt_lock);
39 + spin_unlock_bh(&orig_neigh_node->bat_iv.ogm_cnt_lock);
40
41 /* pay attention to not get a value bigger than 100 % */
42 if (orig_eq_count > neigh_rq_count)