[B.A.T.M.A.N.] [PATCHv2 maint 1/4] batman-adv: Fix broken DAT capability check

Linus Lüssing linus.luessing at c0d3.blue
Fri Jul 3 18:29:56 CEST 2015


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 at laposte.net>
Signed-off-by: Linus Lüssing <linus.luessing at c0d3.blue>
---
 distributed-arp-table.c |    2 +-
 types.h                 |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

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),
-- 
1.7.10.4



More information about the B.A.T.M.A.N mailing list