Skip to contentSkip to conversation

r8169: fix checksum broken

PATCH Applied Shan Wei 3 participants 8 messages Nov 12, 2010 – Nov 17, 2010

Subsystems (2)
lore
Share & tools
lore

Shan Wei

author
#0 lore raw

PATCH 1/1 r8169: fix checksum broken

If r8196 received packets with invalid sctp/igmp(not tcp, udp) checksum, r8196 set skb->ip_summed wit CHECKSUM_UNNECESSARY. This cause that upper protocol don't check checksum field.

I am not family with r8196 driver. I try to guess the meaning of RxProtoIP and IPFail. RxProtoIP stands for received IPv4 packet that upper protocol is not tcp and udp. !(opts1 & IPFail) is true means that driver correctly to check checksum in IPv4 header.

If it's right, I think we should not set ip_summed wit CHECKSUM_UNNECESSARY for my sctp packets with invalid checksum.

If it's not right, please tell me.

---
 drivers/net/r8169.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/r8169.c +1 -2
index d88ce9f..2cf6c2e 100644
@@ -4440,8 +4440,7 @@ static inline void rtl8169_rx_csum(struct sk_buff *skb, u32 opts1)
 	u32 status = opts1 & RxProtoMask;
 
 	if (((status == RxProtoTCP) && !(opts1 & TCPFail)) ||
-	    ((status == RxProtoUDP) && !(opts1 & UDPFail)) ||
-	    ((status == RxProtoIP) && !(opts1 & IPFail)))
+	    ((status == RxProtoUDP) && !(opts1 & UDPFail)))
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 	else
 		skb_checksum_none_assert(skb);
Signature · 1 line
1.6.3.3
maintainer
#1 lore raw

From: Shan Wei <[email protected]>
Date: Fri, 12 Nov 2010 18:15:25 +0800

Quoted 7 lines

If r8196 received packets with invalid sctp/igmp(not tcp, udp) checksum, r8196 set skb->ip_summed wit CHECKSUM_UNNECESSARY. This cause that upper protocol don't check checksum field.

I am not family with r8196 driver. I try to guess the meaning of RxProtoIP and IPFail. RxProtoIP stands for received IPv4 packet that upper protocol is not tcp and udp. !(opts1 & IPFail) is true means that driver correctly to check checksum in IPv4 header.

Quoted 7 lines

If it's right, I think we should not set ip_summed wit CHECKSUM_UNNECESSARY for my sctp packets with invalid checksum.

If it's not right, please tell me.

Francois, please review, it looks correct to my eyes.

#2 lore raw
In reply to Shan Wei

Shan Wei <[email protected]> :

Quoted 2 lines

If r8196 received packets with invalid sctp/igmp(not tcp, udp) checksum, r8196 set skb->ip_summed wit CHECKSUM_UNNECESSARY. This cause that upper protocol don't check checksum field.

...

Which kind of device do you use : PCI-E 8168 / 810x or PCI 8169 ?

Have a nice night.

Signature · 1 line
Ueimor
author
#4 lore raw

Francois Romieu wrote, at 11/13/2010 07:13 AM:

Quoted 7 lines

Francois Romieu <[email protected]> :
[...]

Quoted 1 line

Which kind of device do you use : PCI-E 8168 / 810x or PCI 8169 ?

Wrong page. Forget it.

While grepping IPFail variable, maybe cp_rx_csum_ok() in 8139cp driver also has same bug. There is no NIC on hand using RealTek RTL-8139C+ series 10/100 PCI Ethernet driver, So don't confirm it.

===
[PATCH] 8139cp: fix checksum broken

I am not family with RealTek RTL-8139C+ series 10/100 PCI Ethernet driver. I try to guess the meaning of RxProtoIP and IPFail.
RxProtoIP stands for received IPv4 packet that upper protocol is not tcp and udp. !(status & IPFail) is true means that driver correctly to check checksum in IPv4 header.

If these are right, driver will set ip_summed with CHECKSUM_UNNECESSARY for other upper protocol, e.g. sctp, igmp protocol. This will cause protocol stack ignores checksum check for packets with invalid checksum.

This patch is only compile-test.

---
 drivers/net/8139cp.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
drivers/net/8139cp.c +4 -6
index ac422cd..dd16e83 100644
@@ -490,13 +490,11 @@ static inline unsigned int cp_rx_csum_ok (u32 status)
 {
 	unsigned int protocol = (status >> 16) & 0x3;
 
-	if (likely((protocol == RxProtoTCP) && (!(status & TCPFail))))
+	if (((protocol == RxProtoTCP) && !(status & TCPFail)) ||
+	    ((protocol == RxProtoUDP) && !(status & UDPFail)))
 		return 1;
-	else if ((protocol == RxProtoUDP) && (!(status & UDPFail)))
-		return 1;
-	else if ((protocol == RxProtoIP) && (!(status & IPFail)))
-		return 1;
-	return 0;
+	else
+		return 0;
 }
 
 static int cp_rx_poll(struct napi_struct *napi, int budget)
Signature · 1 line
1.6.3.3
#5 lore raw

Shan Wei <[email protected]> :
[...]

Quoted 3 lines

If these are right, driver will set ip_summed with CHECKSUM_UNNECESSARY for other upper protocol, e.g. sctp, igmp protocol. This will cause protocol stack ignores checksum check for packets with invalid checksum.

The documentation of these bits is identical for the 8139c+ and the 8169.

Signature · 1 line
Ueimor
maintainer
#6 lore raw

From: Francois Romieu <[email protected]>
Date: Mon, 15 Nov 2010 22:01:23 +0100

Quoted 7 lines

Shan Wei <[email protected]> :
[...]

Quoted 3 lines

If these are right, driver will set ip_summed with CHECKSUM_UNNECESSARY for other upper protocol, e.g. sctp, igmp protocol. This will cause protocol stack ignores checksum check for packets with invalid checksum.

The documentation of these bits is identical for the 8139c+ and the 8169.

Also applied, thank you.