c6e907822172e3c3baaca83f0356ce219fdaa400
[feed/routing.git] / batman-adv / patches / 0005-batman-adv-Make-TT-capability-changes-atomic.patch
1 From a51fa16ecf3f079518baaa56bffae343bd5694f0 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Linus=20L=C3=BCssing?= <linus.luessing@c0d3.blue>
3 Date: Tue, 16 Jun 2015 17:10:24 +0200
4 Subject: [PATCH 05/17] batman-adv: Make TT capability changes atomic
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Bitwise OR/AND assignments in C aren't guaranteed to be atomic. One
10 OGM handler might undo the set/clear of a specific bit from another
11 handler run in between.
12
13 Fix this by using the atomic set_bit()/clear_bit() functions.
14
15 Fixes: 5d2121af6d31 ("batman-adv: introduce capability initialization bitfield")
16 Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
17 Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
18 ---
19 translation-table.c | 4 ++--
20 types.h | 2 +-
21 2 files changed, 3 insertions(+), 3 deletions(-)
22
23 diff --git a/translation-table.c b/translation-table.c
24 index b098e53..e95a424 100644
25 --- a/translation-table.c
26 +++ b/translation-table.c
27 @@ -1843,7 +1843,7 @@ void batadv_tt_global_del_orig(struct batadv_priv *bat_priv,
28 }
29 spin_unlock_bh(list_lock);
30 }
31 - orig_node->capa_initialized &= ~BATADV_ORIG_CAPA_HAS_TT;
32 + clear_bit(BATADV_ORIG_CAPA_HAS_TT, &orig_node->capa_initialized);
33 }
34
35 static bool batadv_tt_global_to_purge(struct batadv_tt_global_entry *tt_global,
36 @@ -2802,7 +2802,7 @@ static void _batadv_tt_update_changes(struct batadv_priv *bat_priv,
37 return;
38 }
39 }
40 - orig_node->capa_initialized |= BATADV_ORIG_CAPA_HAS_TT;
41 + set_bit(BATADV_ORIG_CAPA_HAS_TT, &orig_node->capa_initialized);
42 }
43
44 static void batadv_tt_fill_gtable(struct batadv_priv *bat_priv,
45 diff --git a/types.h b/types.h
46 index e33b5aa..c6ec558 100644
47 --- a/types.h
48 +++ b/types.h
49 @@ -257,7 +257,7 @@ struct batadv_orig_node {
50 struct hlist_node mcast_want_all_ipv6_node;
51 #endif
52 unsigned long capabilities;
53 - uint8_t capa_initialized;
54 + unsigned long capa_initialized;
55 atomic_t last_ttvn;
56 unsigned char *tt_buff;
57 int16_t tt_buff_len;
58 --
59 2.1.4
60