From patchwork Fri Jul 3 16:29:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 4574 Return-Path: Received-SPF: None (no SPF record) identity=mailfrom; client-ip=188.40.49.9; helo=mail.passe0815.de; envelope-from=linus.luessing@c0d3.blue; receiver=b.a.t.m.a.n@lists.open-mesh.org Received: from mail.passe0815.de (mail.passe0815.de [188.40.49.9]) by open-mesh.org (Postfix) with ESMTPS id 3F3236013EF for ; Fri, 3 Jul 2015 18:30:03 +0200 (CEST) Received: from mail.passe0815.de (localhost [127.0.0.1]) by mail.passe0815.de (Postfix) with ESMTP id 5187C58689F for ; Fri, 3 Jul 2015 18:30:02 +0200 (CEST) Received: from localhost (unknown [IPv6:2a01:170:1112:0:25ba:497d:c476:d561]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.passe0815.de (Postfix) with ESMTPSA id EA1F4586897; Fri, 3 Jul 2015 18:30:01 +0200 (CEST) From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Fri, 3 Jul 2015 18:29:56 +0200 Message-Id: <1435940999-3829-2-git-send-email-linus.luessing@c0d3.blue> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1435940999-3829-1-git-send-email-linus.luessing@c0d3.blue> References: <1435940999-3829-1-git-send-email-linus.luessing@c0d3.blue> MIME-Version: 1.0 X-GPG-Mailgate: Not encrypted, public key not found Subject: [B.A.T.M.A.N.] [PATCHv2 maint 1/4] batman-adv: Fix broken DAT capability check X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Jul 2015 16:30:03 -0000 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 Signed-off-by: Linus Lüssing --- 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),