Skip to contentSkip to conversation

Fix UDP filter condition when do checksum

PATCH In review Wei Yongjun 3 participants 3 messages Jul 31, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix UDP filter condition when do checksum

In udp_queue_rcv_skb(), checksum condition is error. When UDP filter is set, checksum is be done, but if UDP filter is not set, checksum will not be done. So I think this is a BUG. Following is my patch:

net/ipv4/udp.c +1 -1
@@ -1018,7 +1018,7 @@ static int udp_queue_rcv_skb(struct sock
 		/* FALLTHROUGH -- it's a UDP Packet */
 	}
 
-	if (sk->sk_filter && skb->ip_summed != CHECKSUM_UNNECESSARY) {
+	if (!sk->sk_filter && skb->ip_summed != CHECKSUM_UNNECESSARY) {
 		if (__udp_checksum_complete(skb)) {
 			UDP_INC_STATS_BH(UDP_MIB_INERRORS);
 			kfree_skb(skb);

`�' 

' c link

Quoted 1 line
#1 lore raw
Quoted 7 lines · Wei Yongjun

In udp_queue_rcv_skb(), checksum condition is error. When UDP filter is set, checksum is be done, but if UDP filter is not set, checksum will not be done. So I think this is a BUG. Following is my patch:

net/ipv4/udp.c 2006-07-31 17:10:41.271632200 -0400 static int udp_queue_rcv_skb(struct sock · line 1024

Quoted 8 lines
net/ipv4/udp.c 2006-07-31 17:10:41.271632200 -0400 renamed from net/ipv4/udp.c 2006-07-31 09:33:45.392479344 -0400 +1 -1
@@ -1018,7 +1018,7 @@ static int udp_queue_rcv_skb(struct sock
               /* FALLTHROUGH -- it's a UDP Packet */
       }
 
-       if (sk->sk_filter && skb->ip_summed != CHECKSUM_UNNECESSARY) {
+       if (!sk->sk_filter && skb->ip_summed != CHECKSUM_UNNECESSARY) {
               if (__udp_checksum_complete(skb)) {
                       UDP_INC_STATS_BH(UDP_MIB_INERRORS);
                       kfree_skb(skb);

For the record, this isn't correct since the only reason we're computing a checksum here rather than recv(2) time is if we have a filter attached.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer
#2 lore raw
In reply to Wei Yongjun

From: Wei Yongjun <[email protected]>
Date: Mon, 31 Jul 2006 06:33:42 -0400

Quoted 3 lines

In udp_queue_rcv_skb(), checksum condition is error. When UDP filter is set, checksum is be done, but if UDP filter is not set, checksum will not be done. So I think this is a BUG.

It is not a bug, we defer the checksum, when we can, to sys_recvmsg() where we can combine the copy into userspace and the checksum calculation into one operation.

We cannot do this deferral when there is a filter attached, and that is why the check is the way it is.