0

sctp uses crc32c to calculate the checksum,but I don't know how to implement incremental updates。 code is in /include/net/sctp/checksum.h:

static inline __wsum sctp_csum_update(const void *buff, int len, __wsum sum)
{
    /* This uses the crypto implementation of crc32c, which is either
     * implemented w/ hardware support or resolves to __crc32c_le().
     */
    return (__force __wsum)crc32c((__force __u32)sum, buff, len);
}

crc32c code is: (/lib/libcrc32c.c)

u32 crc32c(u32 crc, const void *address, unsigned int length)
{
    SHASH_DESC_ON_STACK(shash, tfm);
    u32 ret, *ctx = (u32 *)shash_desc_ctx(shash);
    int err;

    shash->tfm = tfm;
    *ctx = crc;

    err = crypto_shash_update(shash, address, length);
    BUG_ON(err);

    ret = *ctx;
    barrier_data(ctx);
    return ret;
}
Progman
  • 16,827
  • 6
  • 33
  • 48

0 Answers0