Skip to contentSkip to conversation

: Fix HW checksum handling in ip_queue/ip6_queue

PATCH In review Patrick McHardy 3 participants 5 messages Aug 22, 2005 – Aug 26, 2005

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

PATCH 1/4 : Fix HW checksum handling in ip_queue/ip6_queue

Hi Dave,

following are a fix for ip_queue and HW checksums, Pablo's string match and two new targets. Please apply to your net-2.6.14 tree (the ip_queue fix could also go directly in 2.6.13 IMO).

[NETFILTER]: Fix HW checksum handling in ip_queue/ip6_queue [NETFILTER]: Add string match
[NETFILTER]: Add IPv6 REJECT target
[NETFILTER]: Add goto target

[NETFILTER]: Fix HW checksum handling in ip_queue/ip6_queue

The checksum needs to be filled in on output, after mangling a packet ip_summed needs to be reset.

---
commit 8cf07748b0be017ee9776fa5cb25b7d07e771e37
tree 07e5170035c471f59c866d9df4453a2dad6dd667
parent 01d727422b4153699009a711905e86741f9080e4
author Patrick McHardy <[email protected]> Sun, 21 Aug 2005 21:54:12 +0200 committer Patrick McHardy <[email protected]> Sun, 21 Aug 2005 21:54:12 +0200

 net/ipv4/netfilter/ip_queue.c  |    7 +++++++
 net/ipv6/netfilter/ip6_queue.c |    7 +++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
net/ipv4/netfilter/ip_queue.c +7 -0
@@ -207,6 +207,12 @@ ipq_build_packet_message(struct ipq_queu
 		break;
 	
 	case IPQ_COPY_PACKET:
+		if (entry->skb->ip_summed == CHECKSUM_HW &&
+		    (*errp = skb_checksum_help(entry->skb,
+		                               entry->info->outdev == NULL))) {
+			read_unlock_bh(&queue_lock);
+			return NULL;
+		}
 		if (copy_range == 0 || copy_range > entry->skb->len)
 			data_len = entry->skb->len;
 		else
@@ -371,6 +377,7 @@ ipq_mangle_ipv4(ipq_verdict_msg_t *v, st
 	if (!skb_make_writable(&e->skb, v->data_len))
 		return -ENOMEM;
 	memcpy(e->skb->data, v->payload, v->data_len);
+	e->skb->ip_summed = CHECKSUM_NONE;
 
 	return 0;
 }
net/ipv6/netfilter/ip6_queue.c +7 -0
@@ -205,6 +205,12 @@ ipq_build_packet_message(struct ipq_queu
 		break;
 	
 	case IPQ_COPY_PACKET:
+		if (entry->skb->ip_summed == CHECKSUM_HW &&
+		    (*errp = skb_checksum_help(entry->skb,
+		                               entry->info->outdev == NULL))) {
+			read_unlock_bh(&queue_lock);
+			return NULL;
+		}
 		if (copy_range == 0 || copy_range > entry->skb->len)
 			data_len = entry->skb->len;
 		else
@@ -369,6 +375,7 @@ ipq_mangle_ipv6(ipq_verdict_msg_t *v, st
 	if (!skb_make_writable(&e->skb, v->data_len))
 		return -ENOMEM;
 	memcpy(e->skb->data, v->payload, v->data_len);
+	e->skb->ip_summed = CHECKSUM_NONE;
 
 	return 0;
 }
maintainer
#1 lore raw

From: Patrick McHardy <[email protected]>
Date: Mon, 22 Aug 2005 02:03:57 +0200

Quoted 3 lines

following are a fix for ip_queue and HW checksums, Pablo's string match and two new targets. Please apply to your net-2.6.14 tree (the ip_queue fix could also go directly in 2.6.13 IMO).

All applied to net-2.6.14 and I will push the ip_queue CHECKSUM_HW fix into 2.6.13 if possible.

Thanks a lot Patrick.

maintainer
#2 lore raw
In reply to Patrick McHardy

From: Patrick McHardy <[email protected]>
Date: Mon, 22 Aug 2005 02:03:57 +0200

Quoted 1 line

(the ip_queue fix could also go directly in 2.6.13 IMO).

I had to munge the patch a lot to get it to apply to 2.6.13 (too many 2.6.14 dependencies in the patch hunks :-), but I did add it to my 2.6.13 tree.

Thanks.

#3 lore raw
In reply to Patrick McHardy
Quoted 4 lines · Patrick McHardy

[NETFILTER]: Fix HW checksum handling in ip_queue/ip6_queue

The checksum needs to be filled in on output, after mangling a packet ip_summed needs to be reset.

I think we're going to need the same fix for nfnetlink_queue, too. I'm not sure whether I could just copy+paste your code into the respective section of the code, or whether there are some other issues that need to be thought of, like "Is skb->ip_summed valid for non-ip-packets?".

Please advise or propose a patch, thanks!

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie
#4 lore raw
Quoted 6 lines · Harald Welte

I think we're going to need the same fix for nfnetlink_queue, too. I'm not sure whether I could just copy+paste your code into the respective section of the code, or whether there are some other issues that need to be thought of, like "Is skb->ip_summed valid for non-ip-packets?".

Please advise or propose a patch, thanks!

The same fix is fine for nfnetlink_queue, protocols that don't support HW checksumming ip_summed is set to CHECKSUM_NONE and the fix does nothing.

[NETFILTER]: Fix HW checksum handling in nfnetlink_queue

---
commit fd32f6a1bad85e74e72ac603bce19da767b5928f
tree c69f2224f141fbb6085f9576a7b67a833f9a3d80
parent c233e993bb49e007b667659243f344172768a6c8
author Patrick McHardy <[email protected]> Fri, 26 Aug 2005 18:43:17 +0200 committer Patrick McHardy <[email protected]> Fri, 26 Aug 2005 18:43:17 +0200

 net/netfilter/nfnetlink_queue.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
net/netfilter/nfnetlink_queue.c +7 -1
@@ -382,6 +382,12 @@ nfqnl_build_packet_message(struct nfqnl_
 		break;
 	
 	case NFQNL_COPY_PACKET:
+		if (entry->skb->ip_summed == CHECKSUM_HW &&
+		    (*errp = skb_checksum_help(entry->skb,
+		                               entry->info->outdev == NULL))) {
+			spin_unlock_bh(&queue->lock);
+			return NULL;
+		}
 		if (queue->copy_range == 0 
 		    || queue->copy_range > entry->skb->len)
 			data_len = entry->skb->len;
@@ -647,7 +653,7 @@ nfqnl_mangle(void *data, int data_len, s
 	if (!skb_make_writable(&e->skb, data_len))
 		return -ENOMEM;
 	memcpy(e->skb->data, data, data_len);
-
+	e->skb->ip_summed = CHECKSUM_NONE;
 	return 0;
 }