b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Antonio Quartulli <ordex@autistici.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
	Simon Wunderlich <siwu@hrz.tu-chemnitz.de>,
	Marek Lindner <lindner_marek@yahoo.de>
Subject: [B.A.T.M.A.N.] [PATCH 02/10] batman-adv: fix bla compare function
Date: Mon, 19 Nov 2012 09:24:03 +0100	[thread overview]
Message-ID: <1353313451-2930-3-git-send-email-ordex@autistici.org> (raw)
In-Reply-To: <1353313451-2930-1-git-send-email-ordex@autistici.org>

From: Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>

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 <lindner_marek@yahoo.de>
Reported-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 net/batman-adv/bridge_loop_avoidance.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index bda8b17..7ffef8b 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/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 (!batadv_compare_eth(gw1->orig, gw2->orig))
+		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 (!batadv_compare_eth(cl1->addr, cl2->addr))
+		return 0;
+
+	if (cl1->vid != cl2->vid)
+		return 0;
+
+	return 1;
 }
 
 /* free a backbone gw */
-- 
1.8.0


  parent reply	other threads:[~2012-11-19  8:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-19  8:24 [B.A.T.M.A.N.] pull request: batman-adv 2012-11-19 Antonio Quartulli
2012-11-19  8:24 ` [B.A.T.M.A.N.] [PATCH 01/10] batman-adv: Mark best gateway in transtable_global debugfs Antonio Quartulli
2012-11-19  8:24 ` Antonio Quartulli [this message]
2012-11-19  8:24 ` [B.A.T.M.A.N.] [PATCH 03/10] batman-adv: support array of debugfs general attributes Antonio Quartulli
2012-11-19  8:24 ` [B.A.T.M.A.N.] [PATCH 04/10] batman-adv: export compatibility version via debugfs Antonio Quartulli
2012-11-19 18:52   ` Ben Hutchings
2012-11-19 19:10     ` David Miller
2012-11-19 19:29     ` Sven Eckelmann
2012-11-19 19:40       ` Ben Hutchings
2012-11-19 20:25         ` Sven Eckelmann
2012-11-19 19:47       ` David Miller
2012-11-19 21:09         ` Antonio Quartulli
2012-11-19  8:24 ` [B.A.T.M.A.N.] [PATCH 05/10] batman-adv: Add wrapper to look up neighbor and send skb Antonio Quartulli
2012-11-19  8:24 ` [B.A.T.M.A.N.] [PATCH 06/10] batman-adv: sysfs documentation should keep alphabetical order Antonio Quartulli
2012-11-19  8:24 ` [B.A.T.M.A.N.] [PATCH 07/10] batman-adv: Add function to calculate crc32c for the skb payload Antonio Quartulli
2012-11-19  8:24 ` [B.A.T.M.A.N.] [PATCH 08/10] batman-adv: Fix broadcast duplist for fragmentation Antonio Quartulli
2012-11-19  8:24 ` [B.A.T.M.A.N.] [PATCH 09/10] batman-adv: Start new development cycle Antonio Quartulli
2012-11-19  8:24 ` [B.A.T.M.A.N.] [PATCH 10/10] batman-adv: Use packing of 2 for all headers before an ethernet header Antonio Quartulli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1353313451-2930-3-git-send-email-ordex@autistici.org \
    --to=ordex@autistici.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=lindner_marek@yahoo.de \
    --cc=netdev@vger.kernel.org \
    --cc=siwu@hrz.tu-chemnitz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).