Skip to contentSkip to conversation

batman-adv: use CRC32C instead of CRC16 in TT code

PATCH Superseded Antonio Quartulli 2 participants 2 messages Apr 18, 2013 – Apr 19, 2013

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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 its less likely probability of collision. With this change the Translation Table component now uses CRC32C to compute the Local and Global Table checksum.

---

v2:
- added kernel doc and fixed return type for global/local_crc

 packet.h            |  4 ++--
 translation-table.c | 60 ++++++++++++++++++++++++++---------------------------
 types.h             |  4 ++--
 3 files changed, 33 insertions(+), 35 deletions(-)
packet.h +2 -2
index 27424e1..e24daa6 100644
@@ -360,12 +360,12 @@ struct batadv_tvlv_long {
  * struct tvlv_tt_data - tt data propagated through the tt tvlv container
  * @flags: translation table flags (see batadv_tt_data_flags)
  * @ttvn: translation table version number
- * @crc: crc16 checksum of the local translation table
+ * @crc: crc32 checksum of the local translation table
  */
 struct batadv_tvlv_tt_data {
 	uint8_t flags;
 	uint8_t ttvn;
-	__be16  crc;
+	__be32  crc;
 };
 
 /**
translation-table.c +29 -31

167 lines not on this page · raw message

types.h +2 -2
index 1548372..0c77d67 100644
@@ -152,7 +152,7 @@ struct batadv_orig_node {
 	uint8_t flags;
 	uint8_t capabilities;
 	atomic_t last_ttvn;
-	uint16_t tt_crc;
+	uint32_t tt_crc;
 	unsigned char *tt_buff;
 	int16_t tt_buff_len;
 	spinlock_t tt_buff_lock; /* protects tt_buff & tt_buff_len */
@@ -375,7 +375,7 @@ struct batadv_priv_tt {
 	spinlock_t req_list_lock; /* protects req_list */
 	spinlock_t roam_list_lock; /* protects roam_list */
 	atomic_t local_entry_num;
-	uint16_t local_crc;
+	uint32_t local_crc;
 	unsigned char *last_changeset;
 	int16_t last_changeset_len;
 	/* protects last_changeset & last_changeset_len */
Signature · 1 line
1.8.1.5
#1 lore raw

translation-table.c out: · line 1383

Quoted 6 lines · On Thursday, April 18, 2013 21:10:04 Antonio Quartulli wrote:
translation-table.c +1 -1
@@ -1380,16 +1380,14 @@ out:
 }
 
 /* Calculates the checksum of the local table of a given orig_node */
-static uint16_t batadv_tt_global_crc(struct batadv_priv *bat_priv,
+static uint32_t batadv_tt_global_crc(struct batadv_priv *bat_priv,

Don't forget the kernel doc here.

Cheers,
Marek