From patchwork Mon Oct 15 20:23:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 2366 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 75A706012F9 for ; Mon, 15 Oct 2012 22:23:57 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass reason="1024-bit key; insecure key" header.i=@tu-chemnitz.de header.b=E60JigRu; 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=RZjuI1K4eNmrRgVCYJTAq367ntnu5sMqtbneCeiQhRo=; b=E60JigRuhvGU1ItNsRHSEiXadcWynCpc8ohSuaOJsAfvvtBAXL0A5QQ+ta7xRDZB2KI6O234ZlUvGXmbdAFMO0BpufyS4ATx5K/qiAQAkHLJW49TfxYib+84fdact4Ux1cjUR2DJXjjt20dLV3PElhdaA0Lqq1dqW94FCYJntRI=; 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 1TNrCe-0004u6-NG; Mon, 15 Oct 2012 22:23:57 +0200 Received: from dotslash by pandem0nium with local (Exim 4.72) (envelope-from ) id 1TNrCT-0006AX-7c; Mon, 15 Oct 2012 22:23:45 +0200 From: Simon Wunderlich To: b.a.t.m.a.n@lists.open-mesh.org Date: Mon, 15 Oct 2012 22:23:16 +0200 Message-Id: <1350332596-23684-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::1350332636-00000CD1-FA713E14/0-0/0-0 X-Scan-AV: cora.hrz.tu-chemnitz.de; 2012-10-15 22:23:56; 2dcf355e3223a97641065bef367782ed X-Scan-SA: cora.hrz.tu-chemnitz.de; 2012-10-15 22:23:57; 79c1fc556f620ef2065df845b4aca816 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.] [PATCH 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:23:57 -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 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bridge_loop_avoidance.c b/bridge_loop_avoidance.c index 758d921..8313322 100644 --- a/bridge_loop_avoidance.c +++ b/bridge_loop_avoidance.c @@ -77,8 +77,10 @@ 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); + return (((memcmp(gw1->orig, gw2->orig, ETH_ALEN) == 0) && + (gw1->vid == gw2->vid)) ? 1 : 0); } /* compares address and vid of two claims */ @@ -87,8 +89,10 @@ 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); + return (((memcmp(cl1->addr, cl2->addr, ETH_ALEN) == 0) && + (cl1->vid == cl2->vid)) ? 1 : 0); } /* free a backbone gw */