[v2,maint,2/4] batman-adv: Fix broken NC capability check

Message ID 1435940999-3829-3-git-send-email-linus.luessing@c0d3.blue (mailing list archive)
State Accepted, archived
Commit dfb27e75b5586e356e88b9d827d772a6cbdf3cc1
Headers

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: 586df9e2537b ("batman-adv: Make NC capability changes atomic")
Reported-by: Def <def@laposte.net>
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
---
 network-coding.c |    2 +-
 types.h          |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
  

Comments

Marek Lindner July 7, 2015, 8:45 a.m. UTC | #1
On Friday, July 03, 2015 18:29:57 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: 586df9e2537b ("batman-adv: Make NC capability changes atomic")
> Reported-by: Def <def@laposte.net>
> Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
> ---
>  network-coding.c |    2 +-
>  types.h          |    2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Applied in revision 188ac4f.

Thanks,
Marek
  

Patch

diff --git a/network-coding.c b/network-coding.c
index 3ce493e..0309c2c 100644
--- a/network-coding.c
+++ b/network-coding.c
@@ -871,7 +871,7 @@  void batadv_nc_update_nc_node(struct batadv_priv *bat_priv,
 		goto out;
 
 	/* check if orig node is network coding enabled */
-	if (!(orig_node->capabilities & BATADV_ORIG_CAPA_HAS_NC))
+	if (!(test_bit(BATADV_ORIG_CAPA_HAS_NC, &orig_node->capabilities)))
 		goto out;
 
 	/* accept ogms from 'good' neighbors and single hop neighbors */
diff --git a/types.h b/types.h
index 08a6343..cb7ccb1 100644
--- a/types.h
+++ b/types.h
@@ -300,7 +300,7 @@  struct batadv_orig_node {
  */
 enum batadv_orig_capabilities {
 	BATADV_ORIG_CAPA_HAS_DAT,
-	BATADV_ORIG_CAPA_HAS_NC = BIT(1),
+	BATADV_ORIG_CAPA_HAS_NC,
 	BATADV_ORIG_CAPA_HAS_TT = BIT(2),
 	BATADV_ORIG_CAPA_HAS_MCAST = BIT(3),
 };