[v2,maint,1/4] batman-adv: Fix broken DAT capability check

Message ID 1435940999-3829-2-git-send-email-linus.luessing@c0d3.blue (mailing list archive)
State Accepted, archived
Commit de4666781c5a64cd55aa6688f77de95f8f66b2c0
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: bfd0fbaef270 ("batman-adv: Make DAT capability changes atomic")
Reported-by: Def <def@laposte.net>
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
---
 distributed-arp-table.c |    2 +-
 types.h                 |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
  

Comments

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

Applied in revision de46667.

Thanks,
Marek
  

Patch

diff --git a/distributed-arp-table.c b/distributed-arp-table.c
index b2cc19b..c0c514d 100644
--- a/distributed-arp-table.c
+++ b/distributed-arp-table.c
@@ -422,7 +422,7 @@  static bool batadv_is_orig_node_eligible(struct batadv_dat_candidate *res,
 	int j;
 
 	/* check if orig node candidate is running DAT */
-	if (!(candidate->capabilities & BATADV_ORIG_CAPA_HAS_DAT))
+	if (!(test_bit(BATADV_ORIG_CAPA_HAS_DAT, &candidate->capabilities)))
 		goto out;
 
 	/* Check if this node has already been selected... */
diff --git a/types.h b/types.h
index 65dc6bf..08a6343 100644
--- a/types.h
+++ b/types.h
@@ -299,7 +299,7 @@  struct batadv_orig_node {
  *  (= orig node announces a tvlv of type BATADV_TVLV_MCAST)
  */
 enum batadv_orig_capabilities {
-	BATADV_ORIG_CAPA_HAS_DAT = BIT(0),
+	BATADV_ORIG_CAPA_HAS_DAT,
 	BATADV_ORIG_CAPA_HAS_NC = BIT(1),
 	BATADV_ORIG_CAPA_HAS_TT = BIT(2),
 	BATADV_ORIG_CAPA_HAS_MCAST = BIT(3),