2015-06-21 13:04:04 +02:00
|
|
|
From 201a54ba710ab7f40b82ad3c109f702c47d0761f Mon Sep 17 00:00:00 2001
|
|
|
|
From: =?UTF-8?q?Linus=20L=C3=BCssing?= <linus.luessing@c0d3.blue>
|
|
|
|
Date: Tue, 16 Jun 2015 17:10:25 +0200
|
2015-07-07 10:51:36 +02:00
|
|
|
Subject: [PATCH 06/17] batman-adv: Make MCAST capability changes atomic
|
2015-06-21 13:04:04 +02:00
|
|
|
MIME-Version: 1.0
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
|
|
|
|
Bitwise OR/AND assignments in C aren't guaranteed to be atomic. One
|
|
|
|
OGM handler might undo the set/clear of a specific bit from another
|
|
|
|
handler run in between.
|
|
|
|
|
|
|
|
Fix this by using the atomic set_bit()/clear_bit() functions.
|
|
|
|
|
|
|
|
Fixes: 77ec494490d6 ("batman-adv: Announce new capability via multicast TVLV")
|
|
|
|
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
|
|
|
|
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
|
|
|
|
---
|
|
|
|
multicast.c | 6 +++---
|
|
|
|
1 file changed, 3 insertions(+), 3 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/multicast.c b/multicast.c
|
|
|
|
index 09f2838..00612bf 100644
|
|
|
|
--- a/multicast.c
|
|
|
|
+++ b/multicast.c
|
|
|
|
@@ -684,7 +684,7 @@ static void batadv_mcast_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
|
|
|
|
!(orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST)) {
|
|
|
|
if (orig_initialized)
|
|
|
|
atomic_dec(&bat_priv->mcast.num_disabled);
|
|
|
|
- orig->capabilities |= BATADV_ORIG_CAPA_HAS_MCAST;
|
|
|
|
+ set_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities);
|
|
|
|
/* If mcast support is being switched off or if this is an initial
|
|
|
|
* OGM without mcast support then increase the disabled mcast
|
|
|
|
* node counter.
|
|
|
|
@@ -693,10 +693,10 @@ static void batadv_mcast_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
|
|
|
|
(orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST ||
|
|
|
|
!orig_initialized)) {
|
|
|
|
atomic_inc(&bat_priv->mcast.num_disabled);
|
|
|
|
- orig->capabilities &= ~BATADV_ORIG_CAPA_HAS_MCAST;
|
|
|
|
+ clear_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities);
|
|
|
|
}
|
|
|
|
|
|
|
|
- orig->capa_initialized |= BATADV_ORIG_CAPA_HAS_MCAST;
|
|
|
|
+ set_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capa_initialized);
|
|
|
|
|
|
|
|
if (orig_mcast_enabled && tvlv_value &&
|
|
|
|
(tvlv_value_len >= sizeof(mcast_flags)))
|
|
|
|
--
|
|
|
|
2.1.4
|
|
|
|
|