1 From bfd0fbaef270ac4ed8e4457a38ef8d91190c0540 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:22 +0200
4 Subject: [PATCH 03/17] batman-adv: Make DAT capability changes atomic
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
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.
13 Fix this by using the atomic set_bit()/clear_bit() functions.
15 Fixes: 2b1c07b918d2 ("batman-adv: tvlv - add distributed arp table container")
16 Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
17 Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
19 distributed-arp-table.c | 4 ++--
21 2 files changed, 3 insertions(+), 3 deletions(-)
23 diff --git a/distributed-arp-table.c b/distributed-arp-table.c
24 index 0d791dc..b2cc19b 100644
25 --- a/distributed-arp-table.c
26 +++ b/distributed-arp-table.c
27 @@ -682,9 +682,9 @@ static void batadv_dat_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
28 uint16_t tvlv_value_len)
30 if (flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND)
31 - orig->capabilities &= ~BATADV_ORIG_CAPA_HAS_DAT;
32 + clear_bit(BATADV_ORIG_CAPA_HAS_DAT, &orig->capabilities);
34 - orig->capabilities |= BATADV_ORIG_CAPA_HAS_DAT;
35 + set_bit(BATADV_ORIG_CAPA_HAS_DAT, &orig->capabilities);
39 diff --git a/types.h b/types.h
40 index 28f2461..e33b5aa 100644
43 @@ -256,7 +256,7 @@ struct batadv_orig_node {
44 struct hlist_node mcast_want_all_ipv4_node;
45 struct hlist_node mcast_want_all_ipv6_node;
47 - uint8_t capabilities;
48 + unsigned long capabilities;
49 uint8_t capa_initialized;
51 unsigned char *tt_buff;