diff mbox

[v2,maint,3/4] batman-adv: Fix broken TT capability check

Message ID 1435940999-3829-4-git-send-email-linus.luessing@c0d3.blue
State Accepted, archived
Commit a4824ffaa200050a0b3e68101ebe074a7c45b7d5
Headers show

Commit Message

Linus Lüssing July 3, 2015, 4:29 p.m. UTC
The introduction of set_bit() and clear_bit() calls in batman-adv
wrongly passed bitmasks and not the bit numbers to these functions.
This leads to broken capability checks.

Fixing this by making the capability enum a non-bitmasked one and by
that passing non-masked values to set_bit()/clear_bit().

Fixes: a51fa16ecf3f ("batman-adv: Make TT capability changes atomic")
Reported-by: Def <def@laposte.net>
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
---
 translation-table.c |    3 ++-
 types.h             |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Marek Lindner July 7, 2015, 8:46 a.m. UTC | #1
On Friday, July 03, 2015 18:29:58 Linus Lüssing wrote:
> The introduction of set_bit() and clear_bit() calls in batman-adv
> wrongly passed bitmasks and not the bit numbers to these functions.
> This leads to broken capability checks.
> 
> Fixing this by making the capability enum a non-bitmasked one and by
> that passing non-masked values to set_bit()/clear_bit().
> 
> Fixes: a51fa16ecf3f ("batman-adv: Make TT capability changes atomic")
> Reported-by: Def <def@laposte.net>
> Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
> ---
>  translation-table.c |    3 ++-
>  types.h             |    2 +-
>  2 files changed, 3 insertions(+), 2 deletions(-)

Applied in revision a4824ff.

Thanks,
Marek
diff mbox

Patch

diff --git a/translation-table.c b/translation-table.c
index b6c0f52..d73b103 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -3323,7 +3323,8 @@  static void batadv_tt_update_orig(struct batadv_priv *bat_priv,
 	bool has_tt_init;
 
 	tt_vlan = (struct batadv_tvlv_tt_vlan_data *)tt_buff;
-	has_tt_init = orig_node->capa_initialized & BATADV_ORIG_CAPA_HAS_TT;
+	has_tt_init = test_bit(BATADV_ORIG_CAPA_HAS_TT,
+			       &orig_node->capa_initialized);
 
 	/* orig table not initialised AND first diff is in the OGM OR the ttvn
 	 * increased by one -> we can apply the attached changes
diff --git a/types.h b/types.h
index cb7ccb1..6f4486c 100644
--- a/types.h
+++ b/types.h
@@ -301,7 +301,7 @@  struct batadv_orig_node {
 enum batadv_orig_capabilities {
 	BATADV_ORIG_CAPA_HAS_DAT,
 	BATADV_ORIG_CAPA_HAS_NC,
-	BATADV_ORIG_CAPA_HAS_TT = BIT(2),
+	BATADV_ORIG_CAPA_HAS_TT,
 	BATADV_ORIG_CAPA_HAS_MCAST = BIT(3),
 };