From patchwork Mon Oct 15 20:38:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 2369 Return-Path: Received: from cora.hrz.tu-chemnitz.de (cora.hrz.tu-chemnitz.de [134.109.228.40]) by open-mesh.org (Postfix) with ESMTPS id 8E2E060134B for ; Mon, 15 Oct 2012 22:38:27 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass reason="1024-bit key; insecure key" header.i=@tu-chemnitz.de header.b=DxrBE7LY; dkim-adsp=none (insecure policy); dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tu-chemnitz.de; s=dkim2010; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=pAp9+jCUKWah0+sfiCek+iu8dFG/JzSb/vF0Go+NSJs=; b=DxrBE7LYf1tMqfv2iX6tpgO7Eteyi3LEF57hgKiFkXIO15K06fQO+cm7K3ePrDg0LD9Q8bmWw7Blnxe5O3vskdvtYB7ab7VHnrYg4zuvbDOLn8xwOzHRC/RzUhenXXTD5YUGURtZWm3yKhQ2rlBLWuSy+Oh/mxIPo/9dHhTmFnY=; Received: from p57aa1adf.dip0.t-ipconnect.de ([87.170.26.223] helo=pandem0nium) by cora.hrz.tu-chemnitz.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.80) (envelope-from ) id 1TNrQg-000616-SH; Mon, 15 Oct 2012 22:38:27 +0200 Received: from dotslash by pandem0nium with local (Exim 4.72) (envelope-from ) id 1TNrQV-0006C6-A7; Mon, 15 Oct 2012 22:38:15 +0200 From: Simon Wunderlich To: b.a.t.m.a.n@lists.open-mesh.org Date: Mon, 15 Oct 2012 22:38:04 +0200 Message-Id: <1350333484-23781-2-git-send-email-siwu@hrz.tu-chemnitz.de> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1350332596-23684-1-git-send-email-siwu@hrz.tu-chemnitz.de> References: <1350332596-23684-1-git-send-email-siwu@hrz.tu-chemnitz.de> X-purgate: clean X-purgate-type: clean X-purgate-ID: 154106::1350333507-00000CD1-AC989C44/0-0/0-0 X-Scan-AV: cora.hrz.tu-chemnitz.de; 2012-10-15 22:38:27; f0af92b0ab8e3e4ce7dae96af1668709 X-Scan-SA: cora.hrz.tu-chemnitz.de; 2012-10-15 22:38:27; 4961cf9d7bde9076ba69db7a6e54df6c X-Spam-Score: -1.0 (-) X-Spam-Report: --- Textanalyse SpamAssassin 3.3.1 (-1.0 Punkte) Fragen an/questions to: Postmaster TU Chemnitz * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP --- Ende Textanalyse Cc: Simon Wunderlich Subject: [B.A.T.M.A.N.] [PATCHv2 2/2] batman-adv: fix bla compare function 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: Mon, 15 Oct 2012 20:38:27 -0000 The address and the VLAN VID may not be packed in the respective structs. Fix this by comparing the elements individually. Reported-by: Marek Lindner Reported-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- bridge_loop_avoidance.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 758d921..a617f2c 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -77,8 +77,15 @@ static int batadv_compare_backbone_gw(const struct hlist_node *node, { const void *data1 = container_of(node, struct batadv_backbone_gw, hash_entry); + const struct batadv_backbone_gw *gw1 = data1, *gw2 = data2; - return (memcmp(data1, data2, ETH_ALEN + sizeof(short)) == 0 ? 1 : 0); + if (memcmp(gw1->orig, gw2->orig, ETH_ALEN)) + return 0; + + if (gw1->vid != gw2->vid) + return 0; + + return 1; } /* compares address and vid of two claims */ @@ -87,8 +94,15 @@ static int batadv_compare_claim(const struct hlist_node *node, { const void *data1 = container_of(node, struct batadv_claim, hash_entry); + const struct batadv_claim *cl1 = data1, *cl2 = data2; - return (memcmp(data1, data2, ETH_ALEN + sizeof(short)) == 0 ? 1 : 0); + if (memcmp(cl1->addr, cl2->addr, ETH_ALEN)) + return 0; + + if (cl1->vid != cl2->vid) + return 0; + + return 1; } /* free a backbone gw */