linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* how to use skb_postpush_rcsum()?
@ 2020-04-21 15:20 Johannes Berg
  2020-04-21 16:54 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Berg @ 2020-04-21 15:20 UTC (permalink / raw)
  To: netdev; +Cc: linux-wireless

Hi,

This is probably a stupid question but I'm hitting my head against the
wall ...

I have an skb. I have this:


        if (skb->ip_summed == CHECKSUM_COMPLETE) {
                printk(KERN_DEBUG "csum before\n");
                printk(KERN_DEBUG "  hw = 0x%.4x\n", skb->csum);
                printk(KERN_DEBUG "  sw = 0x%.4x\n", csum_fold(skb_checksum(skb, 0, skb->len, 0)));
        }

	ehdr = skb_push(skb, ETH_HLEN);
	memcpy(ehdr, &tmp, ETH_HLEN);
	skb_postpush_rcsum(skb, &tmp, ETH_HLEN);

        if (skb->ip_summed == CHECKSUM_COMPLETE) {
                printk(KERN_DEBUG "csum after\n");
                printk(KERN_DEBUG "  hw = 0x%.4x\n", csum_fold(skb->csum));
                printk(KERN_DEBUG "  sw = 0x%.4x\n", csum_fold(skb_checksum(skb, 0, skb->len, 0)));
        }

Why does this print, for example:

csum before
  hw = 0xce81
  sw = 0xce81
csum after
  hw = 0x5f36
  sw = 0xfc39


I'm clearly doing something wrong, but most of the examples seem to do
things this way, so what I'm I doing wrong?

johannes


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: how to use skb_postpush_rcsum()?
  2020-04-21 15:20 how to use skb_postpush_rcsum()? Johannes Berg
@ 2020-04-21 16:54 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2020-04-21 16:54 UTC (permalink / raw)
  To: netdev; +Cc: linux-wireless

On Tue, 2020-04-21 at 17:20 +0200, Johannes Berg wrote:
> Hi,
> 
> This is probably a stupid question but I'm hitting my head against the
> wall ...
> 
> I have an skb. I have this:
> 
> 
>         if (skb->ip_summed == CHECKSUM_COMPLETE) {
>                 printk(KERN_DEBUG "csum before\n");
>                 printk(KERN_DEBUG "  hw = 0x%.4x\n", skb->csum);
>                 printk(KERN_DEBUG "  sw = 0x%.4x\n", csum_fold(skb_checksum(skb, 0, skb->len, 0)));

Never mind. The csum_fold() there is obviously the problem - that
shouldn't match, it should match the folded skb->csum. I have a missing
~ basically.

johannes


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-21 16:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-21 15:20 how to use skb_postpush_rcsum()? Johannes Berg
2020-04-21 16:54 ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).