Subject: Re: [PATCH 10/16] batman-adv: use CRC32C instead of CRC16 in TT code

From: Antonio Quartulli <[email-masked]>
Date: Wed, 9 Oct 2013 18:10:28 +0200

On Wed, Oct 09, 2013 at 04:49:53PM +0100, David Laight wrote:
> > > 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.
> > 
> > I was not sure about this since the CRC32 is not a linear operation. However
> > this routine is not on the fast path, so we can also live with this order.
> 
> All CRC are linear.
> Because '(a + b) mod c' is the same as '((a mod c) + (b mod c)) mod c'.
> 
> The CRC of a buffer is the XOR of the CRCs generated for each '1' bit.
> The CRC for each bit depends on how far it is from the end of the buffer.

In our tables we cannot make any assumption about the order of the entries: the
node whom generated the table may store the entries in a different order from
what we have got.
This is why I did not implemented it as a simple CRC of the
whole the GlobalTable/buffer but I CRC'd each MAC+VID on its own.

> Presetting the CRC to all-ones generates a value that is dependent on
> the length of the buffer - otherwise missing/extra leading zeros are
> not detected.

Assuming what I said above (that we cannot make assumptions on the order of the
entries), what is your suggestion?

Regards,

-- 
Antonio Quartulli