alfred: bump version to 2015.1
[feed/routing.git] / batman-adv / patches / 0017-batman-adv-Fix-broken-MCAST-capability-check.patch
1 From 1798ad3fb6ba72f8c6f96024b27ad27193648787 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Linus=20L=C3=BCssing?= <linus.luessing@c0d3.blue>
3 Date: Fri, 3 Jul 2015 18:29:59 +0200
4 Subject: [PATCH 17/17] batman-adv: Fix broken MCAST capability check
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 The introduction of set_bit() and clear_bit() calls in batman-adv
10 wrongly passed bitmasks and not the bit numbers to these functions.
11 This leads to broken capability checks.
12
13 Fixing this by making the capability enum a non-bitmasked one and by
14 that passing non-masked values to set_bit()/clear_bit().
15
16 Fixes: 201a54ba710a ("batman-adv: Make MCAST capability changes atomic")
17 Reported-by: Def <def@laposte.net>
18 Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
19 Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
20 ---
21 multicast.c | 11 ++++++-----
22 types.h | 2 +-
23 2 files changed, 7 insertions(+), 6 deletions(-)
24
25 diff --git a/multicast.c b/multicast.c
26 index b75bcc3..ee8317f 100644
27 --- a/multicast.c
28 +++ b/multicast.c
29 @@ -709,14 +709,15 @@ static void batadv_mcast_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
30 mcast_flags = *(uint8_t *)tvlv_value;
31
32 spin_lock_bh(&orig->mcast_handler_lock);
33 - orig_initialized = orig->capa_initialized & BATADV_ORIG_CAPA_HAS_MCAST;
34 + orig_initialized = test_bit(BATADV_ORIG_CAPA_HAS_MCAST,
35 + &orig->capa_initialized);
36
37 /* If mcast support is turned on decrease the disabled mcast node
38 * counter only if we had increased it for this node before. If this
39 * is a completely new orig_node no need to decrease the counter.
40 */
41 if (orig_mcast_enabled &&
42 - !(orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST)) {
43 + !(test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities))) {
44 if (orig_initialized)
45 atomic_dec(&bat_priv->mcast.num_disabled);
46 set_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities);
47 @@ -725,7 +726,7 @@ static void batadv_mcast_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
48 * node counter.
49 */
50 } else if (!orig_mcast_enabled &&
51 - (orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST ||
52 + (test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities) ||
53 !orig_initialized)) {
54 atomic_inc(&bat_priv->mcast.num_disabled);
55 clear_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities);
56 @@ -774,8 +775,8 @@ void batadv_mcast_purge_orig(struct batadv_orig_node *orig)
57
58 spin_lock_bh(&orig->mcast_handler_lock);
59
60 - if (!(orig->capabilities & BATADV_ORIG_CAPA_HAS_MCAST) &&
61 - orig->capa_initialized & BATADV_ORIG_CAPA_HAS_MCAST)
62 + if (!(test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capabilities)) &&
63 + test_bit(BATADV_ORIG_CAPA_HAS_MCAST, &orig->capa_initialized))
64 atomic_dec(&bat_priv->mcast.num_disabled);
65
66 batadv_mcast_want_unsnoop_update(bat_priv, orig, BATADV_NO_FLAGS);
67 diff --git a/types.h b/types.h
68 index 6f4486c..3baf595 100644
69 --- a/types.h
70 +++ b/types.h
71 @@ -302,7 +302,7 @@ enum batadv_orig_capabilities {
72 BATADV_ORIG_CAPA_HAS_DAT,
73 BATADV_ORIG_CAPA_HAS_NC,
74 BATADV_ORIG_CAPA_HAS_TT,
75 - BATADV_ORIG_CAPA_HAS_MCAST = BIT(3),
76 + BATADV_ORIG_CAPA_HAS_MCAST,
77 };
78
79 /**
80 --
81 2.1.4
82