[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AE90C24D6B3A694183C094C60CF0A2F6026B7384@saturn3.aculab.com>
Date: Wed, 9 Oct 2013 15:11:08 +0100
From: "David Laight" <David.Laight@...LAB.COM>
To: "Antonio Quartulli" <antonio@...hcoding.com>, <davem@...emloft.net>
Cc: <netdev@...r.kernel.org>, <b.a.t.m.a.n@...ts.open-mesh.org>,
"Antonio Quartulli" <ordex@...istici.org>,
"Marek Lindner" <lindner_marek@...oo.de>
Subject: RE: [PATCH 10/16] batman-adv: use CRC32C instead of CRC16 in TT code
> CRC32C has to be preferred to CRC16 because of its possible
> HW native support and because of the reduced collision
> probability. With this change the Translation Table
> component now uses CRC32C to compute the local and global
> table checksum.
...
> -/* Calculates the checksum of the local table of a given orig_node */
> -static uint16_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
> +/**
> + * 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
> + */
> +static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
> struct batadv_orig_node *orig_node)
...
> for (i = 0; i < hash->size; i++) {
> head = &hash->table[i];
> @@ -1435,27 +1437,24 @@ static uint16_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
> orig_node))
> continue;
>
...
> + crc ^= crc32c(0, tt_common->addr, ETH_ALEN);
> }
Are you really generating CRC32 of a pile of ethernet MAC addresses
and the XORing the CRC together?
That gives the same answer as XORing together the MAC addresses and
then doing a CRC of the final value.
So it gives you almost no protection against corruption at all.
...
> -/* Calculates the checksum of the local table */
> -static uint16_t batadv_tt_local_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
> + */
> +static uint32_t batadv_tt_local_crc(struct batadv_priv *bat_priv)
> {
...
This looks like a clone of the previous routine.
Surely you can avoid the code duplication.
David
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists