diff options
author | Antonio Quartulli <antonio@open-mesh.com> | 2013-06-04 06:11:40 -0400 |
---|---|---|
committer | Antonio Quartulli <antonio@meshcoding.com> | 2013-10-19 09:11:24 -0400 |
commit | 0ffa9e8d86d665f0f29343e45ecc09e2772ac646 (patch) | |
tree | 248c061f5579912a7db367ce151869cd95341f12 /net | |
parent | c018ad3de61a1dc4194879a53e5559e094aa7b1a (diff) |
batman-adv: use vid when computing local and global TT CRC
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/batman-adv/translation-table.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 63adb97a7677..c8fc303ae71e 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -1506,6 +1506,24 @@ out: | |||
1506 | * batadv_tt_global_crc - calculates the checksum of the local table belonging | 1506 | * batadv_tt_global_crc - calculates the checksum of the local table belonging |
1507 | * to the given orig_node | 1507 | * to the given orig_node |
1508 | * @bat_priv: the bat priv with all the soft interface information | 1508 | * @bat_priv: the bat priv with all the soft interface information |
1509 | * @orig_node: originator for which the CRC should be computed | ||
1510 | * | ||
1511 | * This function computes the checksum for the global table corresponding to a | ||
1512 | * specific originator. In particular, the checksum is computed as follows: For | ||
1513 | * each client connected to the originator the CRC32C of the MAC address and the | ||
1514 | * VID is computed and then all the CRC32Cs of the various clients are xor'ed | ||
1515 | * together. | ||
1516 | * | ||
1517 | * The idea behind is that CRC32C should be used as much as possible in order to | ||
1518 | * produce a unique hash of the table, but since the order which is used to feed | ||
1519 | * the CRC32C function affects the result and since every node in the network | ||
1520 | * probably sorts the clients differently, the hash function cannot be directly | ||
1521 | * computed over the entire table. Hence the CRC32C is used only on | ||
1522 | * the single client entry, while all the results are then xor'ed together | ||
1523 | * because the XOR operation can combine them all while trying to reduce the | ||
1524 | * noise as much as possible. | ||
1525 | * | ||
1526 | * Returns the checksum of the global table of a given originator. | ||
1509 | */ | 1527 | */ |
1510 | static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv, | 1528 | static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv, |
1511 | struct batadv_orig_node *orig_node) | 1529 | struct batadv_orig_node *orig_node) |
@@ -1514,7 +1532,7 @@ static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv, | |||
1514 | struct batadv_tt_common_entry *tt_common; | 1532 | struct batadv_tt_common_entry *tt_common; |
1515 | struct batadv_tt_global_entry *tt_global; | 1533 | struct batadv_tt_global_entry *tt_global; |
1516 | struct hlist_head *head; | 1534 | struct hlist_head *head; |
1517 | uint32_t i, crc = 0; | 1535 | uint32_t i, crc_tmp, crc = 0; |
1518 | 1536 | ||
1519 | for (i = 0; i < hash->size; i++) { | 1537 | for (i = 0; i < hash->size; i++) { |
1520 | head = &hash->table[i]; | 1538 | head = &hash->table[i]; |
@@ -1545,7 +1563,9 @@ static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv, | |||
1545 | orig_node)) | 1563 | orig_node)) |
1546 | continue; | 1564 | continue; |
1547 | 1565 | ||
1548 | crc ^= crc32c(0, tt_common->addr, ETH_ALEN); | 1566 | crc_tmp = crc32c(0, &tt_common->vid, |
1567 | sizeof(tt_common->vid)); | ||
1568 | crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN); | ||
1549 | } | 1569 | } |
1550 | rcu_read_unlock(); | 1570 | rcu_read_unlock(); |
1551 | } | 1571 | } |
@@ -1556,13 +1576,18 @@ static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv, | |||
1556 | /** | 1576 | /** |
1557 | * batadv_tt_local_crc - calculates the checksum of the local table | 1577 | * batadv_tt_local_crc - calculates the checksum of the local table |
1558 | * @bat_priv: the bat priv with all the soft interface information | 1578 | * @bat_priv: the bat priv with all the soft interface information |
1579 | * | ||
1580 | * For details about the computation, please refer to the documentation for | ||
1581 | * batadv_tt_global_crc(). | ||
1582 | * | ||
1583 | * Returns the checksum of the local table | ||
1559 | */ | 1584 | */ |
1560 | static uint32_t batadv_tt_local_crc(struct batadv_priv *bat_priv) | 1585 | static uint32_t batadv_tt_local_crc(struct batadv_priv *bat_priv) |
1561 | { | 1586 | { |
1562 | struct batadv_hashtable *hash = bat_priv->tt.local_hash; | 1587 | struct batadv_hashtable *hash = bat_priv->tt.local_hash; |
1563 | struct batadv_tt_common_entry *tt_common; | 1588 | struct batadv_tt_common_entry *tt_common; |
1564 | struct hlist_head *head; | 1589 | struct hlist_head *head; |
1565 | uint32_t i, crc = 0; | 1590 | uint32_t i, crc_tmp, crc = 0; |
1566 | 1591 | ||
1567 | for (i = 0; i < hash->size; i++) { | 1592 | for (i = 0; i < hash->size; i++) { |
1568 | head = &hash->table[i]; | 1593 | head = &hash->table[i]; |
@@ -1575,7 +1600,9 @@ static uint32_t batadv_tt_local_crc(struct batadv_priv *bat_priv) | |||
1575 | if (tt_common->flags & BATADV_TT_CLIENT_NEW) | 1600 | if (tt_common->flags & BATADV_TT_CLIENT_NEW) |
1576 | continue; | 1601 | continue; |
1577 | 1602 | ||
1578 | crc ^= crc32c(0, tt_common->addr, ETH_ALEN); | 1603 | crc_tmp = crc32c(0, &tt_common->vid, |
1604 | sizeof(tt_common->vid)); | ||
1605 | crc ^= crc32c(crc_tmp, tt_common->addr, ETH_ALEN); | ||
1579 | } | 1606 | } |
1580 | rcu_read_unlock(); | 1607 | rcu_read_unlock(); |
1581 | } | 1608 | } |