All of lore.kernel.org
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@meshcoding.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
	Marek Lindner <lindner_marek@yahoo.de>,
	Antonio Quartulli <antonio@open-mesh.com>
Subject: [B.A.T.M.A.N.] [PATCH 06/18] batman-adv: use vid when computing local and global TT CRC
Date: Sun, 20 Oct 2013 00:21:58 +0200	[thread overview]
Message-ID: <1382221330-3769-7-git-send-email-antonio@meshcoding.com> (raw)
In-Reply-To: <1382221330-3769-1-git-send-email-antonio@meshcoding.com>

From: Antonio Quartulli <antonio@open-mesh.com>

now that each TT entry is characterised by a VLAN ID, the
latter has to be taken into consideration when computing the
local/global table CRC as it would be theoretically possible
to have the same client in two different VLANs

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
---
 net/batman-adv/translation-table.c | 35 +++++++++++++++++++++++++++++++----
 1 file changed, 31 insertions(+), 4 deletions(-)

diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 63adb97..c8fc303 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1506,6 +1506,24 @@ out:
  * batadv_tt_global_crc - calculates the checksum of the local table belonging
  *  to the given orig_node
  * @bat_priv: the bat priv with all the soft interface information
+ * @orig_node: originator for which the CRC should be computed
+ *
+ * This function computes the checksum for the global table corresponding to a
+ * specific originator. In particular, the checksum is computed as follows: For
+ * each client connected to the originator the CRC32C of the MAC address and the
+ * VID is computed and then all the CRC32Cs of the various clients are xor'ed
+ * together.
+ *
+ * The idea behind is that CRC32C should be used as much as possible in order to
+ * produce a unique hash of the table, but since the order which is used to feed
+ * the CRC32C function affects the result and since every node in the network
+ * probably sorts the clients differently, the hash function cannot be directly
+ * computed over the entire table. Hence the CRC32C is used only on
+ * the single client entry, while all the results are then xor'ed together
+ * because the XOR operation can combine them all while trying to reduce the
+ * noise as much as possible.
+ *
+ * Returns the checksum of the global table of a given originator.
  */
 static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
 				     struct batadv_orig_node *orig_node)
@@ -1514,7 +1532,7 @@ static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
 	struct batadv_tt_common_entry *tt_common;
 	struct batadv_tt_global_entry *tt_global;
 	struct hlist_head *head;
-	uint32_t i, crc = 0;
+	uint32_t i, crc_tmp, crc = 0;
 
 	for (i = 0; i < hash->size; i++) {
 		head = &hash->table[i];
@@ -1545,7 +1563,9 @@ static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
 							     orig_node))
 				continue;
 
-			crc ^= crc32c(0, tt_common->addr, ETH_ALEN);
+			crc_tmp = crc32c(0, &tt_common->vid,
+					 sizeof(tt_common->vid));
+			crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN);
 		}
 		rcu_read_unlock();
 	}
@@ -1556,13 +1576,18 @@ static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
 /**
  * batadv_tt_local_crc - calculates the checksum of the local table
  * @bat_priv: the bat priv with all the soft interface information
+ *
+ * For details about the computation, please refer to the documentation for
+ * batadv_tt_global_crc().
+ *
+ * Returns the checksum of the local table
  */
 static uint32_t batadv_tt_local_crc(struct batadv_priv *bat_priv)
 {
 	struct batadv_hashtable *hash = bat_priv->tt.local_hash;
 	struct batadv_tt_common_entry *tt_common;
 	struct hlist_head *head;
-	uint32_t i, crc = 0;
+	uint32_t i, crc_tmp, crc = 0;
 
 	for (i = 0; i < hash->size; i++) {
 		head = &hash->table[i];
@@ -1575,7 +1600,9 @@ static uint32_t batadv_tt_local_crc(struct batadv_priv *bat_priv)
 			if (tt_common->flags & BATADV_TT_CLIENT_NEW)
 				continue;
 
-			crc ^= crc32c(0, tt_common->addr, ETH_ALEN);
+			crc_tmp = crc32c(0, &tt_common->vid,
+					 sizeof(tt_common->vid));
+			crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN);
 		}
 		rcu_read_unlock();
 	}
-- 
1.8.4


WARNING: multiple messages have this Message-ID (diff)
From: Antonio Quartulli <antonio@meshcoding.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
	Antonio Quartulli <antonio@open-mesh.com>,
	Marek Lindner <lindner_marek@yahoo.de>
Subject: [PATCH 06/18] batman-adv: use vid when computing local and global TT CRC
Date: Sun, 20 Oct 2013 00:21:58 +0200	[thread overview]
Message-ID: <1382221330-3769-7-git-send-email-antonio@meshcoding.com> (raw)
In-Reply-To: <1382221330-3769-1-git-send-email-antonio@meshcoding.com>

From: Antonio Quartulli <antonio@open-mesh.com>

now that each TT entry is characterised by a VLAN ID, the
latter has to be taken into consideration when computing the
local/global table CRC as it would be theoretically possible
to have the same client in two different VLANs

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
---
 net/batman-adv/translation-table.c | 35 +++++++++++++++++++++++++++++++----
 1 file changed, 31 insertions(+), 4 deletions(-)

diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 63adb97..c8fc303 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1506,6 +1506,24 @@ out:
  * batadv_tt_global_crc - calculates the checksum of the local table belonging
  *  to the given orig_node
  * @bat_priv: the bat priv with all the soft interface information
+ * @orig_node: originator for which the CRC should be computed
+ *
+ * This function computes the checksum for the global table corresponding to a
+ * specific originator. In particular, the checksum is computed as follows: For
+ * each client connected to the originator the CRC32C of the MAC address and the
+ * VID is computed and then all the CRC32Cs of the various clients are xor'ed
+ * together.
+ *
+ * The idea behind is that CRC32C should be used as much as possible in order to
+ * produce a unique hash of the table, but since the order which is used to feed
+ * the CRC32C function affects the result and since every node in the network
+ * probably sorts the clients differently, the hash function cannot be directly
+ * computed over the entire table. Hence the CRC32C is used only on
+ * the single client entry, while all the results are then xor'ed together
+ * because the XOR operation can combine them all while trying to reduce the
+ * noise as much as possible.
+ *
+ * Returns the checksum of the global table of a given originator.
  */
 static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
 				     struct batadv_orig_node *orig_node)
@@ -1514,7 +1532,7 @@ static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
 	struct batadv_tt_common_entry *tt_common;
 	struct batadv_tt_global_entry *tt_global;
 	struct hlist_head *head;
-	uint32_t i, crc = 0;
+	uint32_t i, crc_tmp, crc = 0;
 
 	for (i = 0; i < hash->size; i++) {
 		head = &hash->table[i];
@@ -1545,7 +1563,9 @@ static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
 							     orig_node))
 				continue;
 
-			crc ^= crc32c(0, tt_common->addr, ETH_ALEN);
+			crc_tmp = crc32c(0, &tt_common->vid,
+					 sizeof(tt_common->vid));
+			crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN);
 		}
 		rcu_read_unlock();
 	}
@@ -1556,13 +1576,18 @@ static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
 /**
  * batadv_tt_local_crc - calculates the checksum of the local table
  * @bat_priv: the bat priv with all the soft interface information
+ *
+ * For details about the computation, please refer to the documentation for
+ * batadv_tt_global_crc().
+ *
+ * Returns the checksum of the local table
  */
 static uint32_t batadv_tt_local_crc(struct batadv_priv *bat_priv)
 {
 	struct batadv_hashtable *hash = bat_priv->tt.local_hash;
 	struct batadv_tt_common_entry *tt_common;
 	struct hlist_head *head;
-	uint32_t i, crc = 0;
+	uint32_t i, crc_tmp, crc = 0;
 
 	for (i = 0; i < hash->size; i++) {
 		head = &hash->table[i];
@@ -1575,7 +1600,9 @@ static uint32_t batadv_tt_local_crc(struct batadv_priv *bat_priv)
 			if (tt_common->flags & BATADV_TT_CLIENT_NEW)
 				continue;
 
-			crc ^= crc32c(0, tt_common->addr, ETH_ALEN);
+			crc_tmp = crc32c(0, &tt_common->vid,
+					 sizeof(tt_common->vid));
+			crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN);
 		}
 		rcu_read_unlock();
 	}
-- 
1.8.4

  parent reply	other threads:[~2013-10-19 22:21 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-19 22:21 [B.A.T.M.A.N.] (no subject) Antonio Quartulli
2013-10-19 22:21 ` (unknown), Antonio Quartulli
2013-10-19 22:21 ` [B.A.T.M.A.N.] [PATCH 01/18] batman-adv: check skb preparation return value Antonio Quartulli
2013-10-19 22:21   ` Antonio Quartulli
2013-10-19 22:21 ` [B.A.T.M.A.N.] [PATCH 02/18] batman-adv: update email address for Simon Wunderlich Antonio Quartulli
2013-10-19 22:21   ` Antonio Quartulli
2013-10-19 22:21 ` [B.A.T.M.A.N.] [PATCH 03/18] batman-adv: update email address for Antonio Quartulli Antonio Quartulli
2013-10-19 22:21   ` Antonio Quartulli
2013-10-19 22:21 ` [B.A.T.M.A.N.] [PATCH 04/18] batman-adv: update email address for Marek Lindner Antonio Quartulli
2013-10-19 22:21   ` Antonio Quartulli
2013-10-19 22:21 ` [B.A.T.M.A.N.] [PATCH 05/18] batman-adv: add the VLAN ID attribute to the TT entry Antonio Quartulli
2013-10-19 22:21   ` Antonio Quartulli
2013-10-19 22:21 ` Antonio Quartulli [this message]
2013-10-19 22:21   ` [PATCH 06/18] batman-adv: use vid when computing local and global TT CRC Antonio Quartulli
2013-10-19 22:21 ` [B.A.T.M.A.N.] [PATCH 07/18] batman-adv: print the VID together with the TT entries Antonio Quartulli
2013-10-19 22:21   ` Antonio Quartulli
2013-10-19 22:22 ` [B.A.T.M.A.N.] [PATCH 08/18] batman-adv: make the GW module correctly talk to the new VLAN-TT Antonio Quartulli
2013-10-19 22:22   ` Antonio Quartulli
2013-10-19 22:22 ` [B.A.T.M.A.N.] [PATCH 09/18] batman-adv: make the Distributed ARP Table vlan aware Antonio Quartulli
2013-10-19 22:22   ` Antonio Quartulli
2013-10-19 22:22 ` [B.A.T.M.A.N.] [PATCH 10/18] batman-adv: add per VLAN interface attribute framework Antonio Quartulli
2013-10-19 22:22   ` Antonio Quartulli
2013-10-19 22:22 ` [B.A.T.M.A.N.] [PATCH 11/18] batman-adv: add sysfs framework for VLAN Antonio Quartulli
2013-10-19 22:22   ` Antonio Quartulli
2013-10-19 22:22 ` [B.A.T.M.A.N.] [PATCH 12/18] batman-adv: make the AP isolation attribute VLAN specific Antonio Quartulli
2013-10-19 22:22   ` Antonio Quartulli
2013-10-19 22:22 ` [B.A.T.M.A.N.] [PATCH 13/18] batman-adv: refine API calls for unicast transmissions of SKBs Antonio Quartulli
2013-10-19 22:22   ` Antonio Quartulli
2013-10-19 22:22 ` [B.A.T.M.A.N.] [PATCH 14/18] batman-adv: remove bogus comment Antonio Quartulli
2013-10-19 22:22   ` Antonio Quartulli
2013-10-19 22:22 ` [B.A.T.M.A.N.] [PATCH 15/18] batman-adv: lock around TT operations to avoid sending inconsistent data Antonio Quartulli
2013-10-19 22:22   ` Antonio Quartulli
2013-10-19 22:22 ` [B.A.T.M.A.N.] [PATCH 16/18] batman-adv: make the TT CRC logic VLAN specific Antonio Quartulli
2013-10-19 22:22   ` Antonio Quartulli
2013-10-19 22:22 ` [B.A.T.M.A.N.] [PATCH 17/18] batman-adv: make the TT global purge routine " Antonio Quartulli
2013-10-19 22:22   ` Antonio Quartulli
2013-10-19 22:22 ` [B.A.T.M.A.N.] [PATCH 18/18] batman-adv: make the backbone gw check " Antonio Quartulli
2013-10-19 22:22   ` Antonio Quartulli
2013-10-20  0:15 ` [B.A.T.M.A.N.] (no subject) David Miller
2013-10-20  0:15   ` (unknown) David Miller
2013-10-20  7:57   ` [B.A.T.M.A.N.] your mail Antonio Quartulli
2013-10-20  7:57     ` 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=1382221330-3769-7-git-send-email-antonio@meshcoding.com \
    --to=antonio@meshcoding.com \
    --cc=antonio@open-mesh.com \
    --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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.