From: Ralf Baechle <ralf@linux-mips.org>
To: Ben Hutchings <ben@decadent.org.uk>
Cc: Lino Sanfilippo <LinoSanfilippo@gmx.de>,
linux-mips@linux-mips.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ioc3: fix incorrect use of htons/ntohs
Date: Mon, 15 Dec 2014 19:14:44 +0100 [thread overview]
Message-ID: <20141215181444.GD26674@linux-mips.org> (raw)
In-Reply-To: <1417406976.7215.126.camel@decadent.org.uk>
On Mon, Dec 01, 2014 at 04:09:36AM +0000, Ben Hutchings wrote:
> > /* Same as tx - compute csum of pseudo header */
> > csum = hwsum +
> > - (ih->tot_len - (ih->ihl << 2)) +
> > - htons((uint16_t)ih->protocol) +
> > + (ih->tot_len - (ih->ihl << 2)) + ih->protocol +
> > (ih->saddr >> 16) + (ih->saddr & 0xffff) +
> > (ih->daddr >> 16) + (ih->daddr & 0xffff);
> >
>
> The pseudo-header is specified as:
>
> +--------+--------+--------+--------+
> | Source Address |
> +--------+--------+--------+--------+
> | Destination Address |
> +--------+--------+--------+--------+
> | zero | PTCL | TCP Length |
> +--------+--------+--------+--------+
>
> The current code zero-extends the protocol number to produce the 5th
> 16-bit word of the pseudo-header, then uses htons() to put it in
> big-endian order, consistent with the other fields. (Yes, it's doing
> addition on big-endian words; this works even on little-endian machines
> due to the way the checksum is specified.)
>
> The driver should not be doing this at all, though. It should set
> skb->csum = hwsum; skb->ip_summed = CHECKSUM_COMPLETE; and let the
> network stack adjust the hardware checksum.
Really? The IOC3 isn't the exactly the smartest NIC around; it does add up
everything and the kitchen sink, that is ethernet headers, IP headers and
on RX the frame's trailing CRC. All that needs to be subtracted in software
which is what this does. I think others NICs are all smarted and don't
need this particular piece of magic.
I agree with your other comment wrt. to htons().
Ralf
next prev parent reply other threads:[~2014-12-15 18:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-30 10:40 [PATCH] ioc3: fix incorrect use of htons/ntohs Lino Sanfilippo
2014-12-01 4:09 ` Ben Hutchings
2014-12-02 1:31 ` Lino Sanfilippo
2014-12-15 18:14 ` Ralf Baechle [this message]
2014-12-15 21:09 ` Ben Hutchings
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=20141215181444.GD26674@linux-mips.org \
--to=ralf@linux-mips.org \
--cc=LinoSanfilippo@gmx.de \
--cc=ben@decadent.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).