netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bug in pskb_trim_rcsum()
@ 2006-07-17  3:53 Wei Yongjun
  2006-07-17 12:17 ` Herbert Xu
  0 siblings, 1 reply; 7+ messages in thread
From: Wei Yongjun @ 2006-07-17  3:53 UTC (permalink / raw)
  To: netdev

  Since network device can auto calculate and verify the checksum of a
packet, for example: some e1000 interface. Different device will set
different value of skb->ip_summed.
  a) If device do nothing to checksum, skb->ip_summed would be set to
CHECKSUM_NONE.
  b) If device can only calculate a checksum, and the checksum is
correct, skb->ip_summed would be set to CHECKSUM_HW.
  c) If device can verify the checksum, and the checksum is correct,
skb->ip_summed would be set to CHECKSUM_UNNECESSARY.
  So if I want to trim a skb, I think I must do a checksum even if the
skb->ip_summed is CHECKSUM_UNNECESSARY.

Following is the comment about CHECKSUM_UNNECESSARY in
include/linux/skbuff.h:
 *	UNNECESSARY: device parsed packet and wouldbe verified checksum.
 *		skb->csum is undefined.
 *	      It is bad option, but, unfortunately, many of vendors do this.
 *	      Apparently with secret goal to sell you new device, when you
 *	      will add new protocol to your host. F.e. IPv6. 8)

Signed-off-by: Wei Yongjun <weiyj@soft.fujitsu.com>


--- a/include/linux/skbuff.h	2006-07-17 10:14:23.175070472 -0400
+++ b/include/linux/skbuff.h	2006-07-17 10:18:31.762279472 -0400
@@ -1208,8 +1208,8 @@ static inline int pskb_trim_rcsum(struct
 {
 	if (likely(len >= skb->len))
 		return 0;
-	if (skb->ip_summed == CHECKSUM_HW)
-		skb->ip_summed = CHECKSUM_NONE;
+
+	skb->ip_summed = CHECKSUM_NONE;
 	return __pskb_trim(skb, len);
 }
 



^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [PATCH] Bug in pskb_trim_rcsum()
@ 2006-07-18  2:26 Wei Yongjun
  0 siblings, 0 replies; 7+ messages in thread
From: Wei Yongjun @ 2006-07-18  2:26 UTC (permalink / raw)
  To: Herbert Xu; +Cc: netdev

On Monday 17 July 2006 08:17, Herbert Xu wrote:
> Wei Yongjun <yjwei@nanjing-fnst.com> wrote:
> >  So if I want to trim a skb, I think I must do a checksum even if
the
> > skb->ip_summed is CHECKSUM_UNNECESSARY.
>
> Nope.  CHECKSUM_UNNECESSARY means that the hardware has already
> verified the checksum to be correct for the given protocol.
> Trimming a packet does not affect it.

Yes, you are right. hardware has already verified the checksum to be
correct.
But I think hardware do this:
  1) calculate a checksum for the given protocol.(as the same as the
hardware which does not support verified the checksum)
  2) verified the checksum.(compare protocol checksum of packet with
calculated checksum)
If that is true, Trimming a packet also affect CHECKSUM_UNNECESSARY.

And in my test, UDP under IPv4 maybe do that.
My UDP packet is:

packet1:
 ___________________________________
| Source Port     | Dest Port       |
|_________________|_________________|
| Length = 16     | Checksum(*1)    |
|_________________|_________________|
|             payload24             |
|___________________________________|

correct is :
 ___________________________________
| Source Port     | Dest Port       |
|_________________|_________________|
| Length = 32     | Checksum        |
|_________________|_________________|
|             payload24             |
|___________________________________|

  Checksum(*1)  is the checksum of payload24, not only the first 8 byte
of payload24.

  When I send packet1 to echo-udp(target used e1000 inferface), echo-
reply can be reply. When I send packet1 to echo-udp(target used e100
inferface), echo-reply can not be reply.

  In e1000, when packet1 with checksum(*1) ,  skb->ip_summed is set to
CHECKSUM_UNNECESSARY. And when other, skb->ip_summed is set to
CHECKSUM_HW. So I think my guess is correct. Patch is necessary.


Regards


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

end of thread, other threads:[~2006-07-25  6:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-17  3:53 [PATCH] Bug in pskb_trim_rcsum() Wei Yongjun
2006-07-17 12:17 ` Herbert Xu
     [not found]   ` <006201c6aa06$d51581c0$6004a8c0@WeiYongjun>
2006-07-18 11:32     ` Herbert Xu
2006-07-18 12:54       ` Alexey Kuznetsov
2006-07-18 13:04         ` Herbert Xu
2006-07-25  6:36           ` David Miller
  -- strict thread matches above, loose matches on Subject: below --
2006-07-18  2:26 Wei Yongjun

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).