From: "Martin Hundebøll" <martin@hundeboll.net>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [B.A.T.M.A.N.] [RFC] batman-adv: Add function to calculate crc32c for the skb payload
Date: Wed, 17 Oct 2012 18:11:56 +0200 [thread overview]
Message-ID: <507ED8CC.1060901@hundeboll.net> (raw)
In-Reply-To: <1350489584-10428-1-git-send-email-sven@narfation.org>
On 2012-10-17 17:59, Sven Eckelmann wrote:
> +__be32 batadv_crc32(const struct sk_buff *skb, u8 *payload_ptr)
> +{
> + u32 crc = 0;
> + struct sk_buff *iter;
> + size_t skip_len, read_len;
> + const skb_frag_t *f;
> + int i;
> +
> + skip_len = payload_ptr - skb->data;
> + read_len = skb_headlen(skb) - skip_len;
> + if (read_len)
> + crc = crc32c(crc, payload_ptr, read_len);
> +
> + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
> + f = &skb_shinfo(skb)->frags[i];
> + crc = crc32c(crc, skb_frag_address(f), skb_frag_size(f));
> + }
> +
> + skb_walk_frags(skb, iter)
> + crc = crc32c(crc, iter->data, skb_headlen(iter));
> +
> + return htonl(crc);
> +}
I tested the crc'ing of non-linear skb buffers and can confirm that it
works as expected, so:
Tested-by: Martin Hundebøll <martin@hundeboll.net>
... at least for batadv_crc32() :)
--
Kind Regards
Martin Hundebøll
Frederiks Allé 99, 1.th
8000 Aarhus C
Denmark
+45 61 65 54 61
martin@hundeboll.net
next prev parent reply other threads:[~2012-10-17 16:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-17 15:59 [B.A.T.M.A.N.] [RFC] batman-adv: Add function to calculate crc32c for the skb payload Sven Eckelmann
2012-10-17 16:11 ` Martin Hundebøll [this message]
2012-10-17 17:18 ` [B.A.T.M.A.N.] [RFCv2] " Sven Eckelmann
2012-10-17 19:10 ` [B.A.T.M.A.N.] [RFCv3] " Sven Eckelmann
2012-10-17 19:57 ` Marek Lindner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=507ED8CC.1060901@hundeboll.net \
--to=martin@hundeboll.net \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox