netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [NET]: Allow forwarding of ip_summed except CHECKSUM_COMPLETE
@ 2007-03-27  5:38 Herbert Xu
  2007-03-27  6:23 ` David Miller
  2007-03-27 20:51 ` Patrick McHardy
  0 siblings, 2 replies; 4+ messages in thread
From: Herbert Xu @ 2007-03-27  5:38 UTC (permalink / raw)
  To: David S. Miller, Stephen Hemminger, netdev

Hi Dave:

[NET]: Allow forwarding of ip_summed except CHECKSUM_COMPLETE

Right now Xen has a horrible hack that lets it forward packets with
partial checksums.  One of the reasons that CHECKSUM_PARTIAL and
CHECKSUM_COMPLETE were added is so that we can get rid of this hack
(where it creates two extra bits in the skbuff to essentially mirror
ip_summed without being destroyed by the forwarding code).

I had forgotten that I've already gone through all the deivce drivers
last time around to make sure that they're looking at ip_summed ==
CHECKSUM_PARTIAL rather than ip_summed != 0 on transmit.  In any case,
I've now done that again so it should definitely be safe.

Unfortunately nobody has yet added any code to update CHECKSUM_COMPLETE
values on forward so we I'm setting that to CHECKSUM_NONE.  This should
be safe to remove for bridging but I'd like to check that code path
first.

So here is the patch that lets us get rid of the hack by preserving
ip_summed (mostly) on forwarded packets.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 4ff3940..6d4243d 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1481,5 +1481,12 @@ static inline int skb_is_gso(const struct sk_buff *skb)
 	return skb_shinfo(skb)->gso_size;
 }
 
+static inline void skb_forward_csum(struct sk_buff *skb)
+{
+	/* Unfortunately we don't support this one.  Any brave souls? */
+	if (skb->ip_summed == CHECKSUM_COMPLETE)
+		skb->ip_summed = CHECKSUM_NONE;
+}
+
 #endif	/* __KERNEL__ */
 #endif	/* _LINUX_SKBUFF_H */
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index 3e45c1a..ada7f49 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -71,7 +71,7 @@ static void __br_forward(const struct net_bridge_port *to, struct sk_buff *skb)
 
 	indev = skb->dev;
 	skb->dev = to->dev;
-	skb->ip_summed = CHECKSUM_NONE;
+	skb_forward_csum(skb);
 
 	NF_HOOK(PF_BRIDGE, NF_BR_FORWARD, skb, indev, skb->dev,
 			br_forward_finish);
diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
index 369e721..a38037b 100644
--- a/net/ipv4/ip_forward.c
+++ b/net/ipv4/ip_forward.c
@@ -67,7 +67,7 @@ int ip_forward(struct sk_buff *skb)
 	if (skb->pkt_type != PACKET_HOST)
 		goto drop;
 
-	skb->ip_summed = CHECKSUM_NONE;
+	skb_forward_csum(skb);
 
 	/*
 	 *	According to the RFC, we must first decrease the TTL field. If
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 3055169..ba0143c 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -372,7 +372,7 @@ int ip6_forward(struct sk_buff *skb)
 		goto drop;
 	}
 
-	skb->ip_summed = CHECKSUM_NONE;
+	skb_forward_csum(skb);
 
 	/*
 	 *	We DO NOT make any processing on

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

* Re: [NET]: Allow forwarding of ip_summed except CHECKSUM_COMPLETE
  2007-03-27  5:38 [NET]: Allow forwarding of ip_summed except CHECKSUM_COMPLETE Herbert Xu
@ 2007-03-27  6:23 ` David Miller
  2007-03-27 20:51 ` Patrick McHardy
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2007-03-27  6:23 UTC (permalink / raw)
  To: herbert; +Cc: shemminger, netdev

From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Tue, 27 Mar 2007 15:38:21 +1000

> [NET]: Allow forwarding of ip_summed except CHECKSUM_COMPLETE
> 
> Right now Xen has a horrible hack that lets it forward packets with
> partial checksums.  One of the reasons that CHECKSUM_PARTIAL and
> CHECKSUM_COMPLETE were added is so that we can get rid of this hack
> (where it creates two extra bits in the skbuff to essentially mirror
> ip_summed without being destroyed by the forwarding code).
> 
> I had forgotten that I've already gone through all the deivce drivers
> last time around to make sure that they're looking at ip_summed ==
> CHECKSUM_PARTIAL rather than ip_summed != 0 on transmit.  In any case,
> I've now done that again so it should definitely be safe.
> 
> Unfortunately nobody has yet added any code to update CHECKSUM_COMPLETE
> values on forward so we I'm setting that to CHECKSUM_NONE.  This should
> be safe to remove for bridging but I'd like to check that code path
> first.
> 
> So here is the patch that lets us get rid of the hack by preserving
> ip_summed (mostly) on forwarded packets.
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Applied to net-2.6.22, thanks Herbert.

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

* Re: [NET]: Allow forwarding of ip_summed except CHECKSUM_COMPLETE
  2007-03-27  5:38 [NET]: Allow forwarding of ip_summed except CHECKSUM_COMPLETE Herbert Xu
  2007-03-27  6:23 ` David Miller
@ 2007-03-27 20:51 ` Patrick McHardy
  2007-03-27 21:20   ` Herbert Xu
  1 sibling, 1 reply; 4+ messages in thread
From: Patrick McHardy @ 2007-03-27 20:51 UTC (permalink / raw)
  To: Herbert Xu; +Cc: David S. Miller, Stephen Hemminger, netdev

Herbert Xu wrote:
> Hi Dave:
> 
> [NET]: Allow forwarding of ip_summed except CHECKSUM_COMPLETE
> 
> Right now Xen has a horrible hack that lets it forward packets with
> partial checksums.  One of the reasons that CHECKSUM_PARTIAL and
> CHECKSUM_COMPLETE were added is so that we can get rid of this hack
> (where it creates two extra bits in the skbuff to essentially mirror
> ip_summed without being destroyed by the forwarding code).
> 
> I had forgotten that I've already gone through all the deivce drivers
> last time around to make sure that they're looking at ip_summed ==
> CHECKSUM_PARTIAL rather than ip_summed != 0 on transmit.  In any case,
> I've now done that again so it should definitely be safe.
> 
> Unfortunately nobody has yet added any code to update CHECKSUM_COMPLETE
> values on forward so we I'm setting that to CHECKSUM_NONE.  This should
> be safe to remove for bridging but I'd like to check that code path
> first.
> 
> So here is the patch that lets us get rid of the hack by preserving
> ip_summed (mostly) on forwarded packets.


Just wondering, how does Xen know whether a packet will be forwarded?
The input path doesn't seem to deal with CHECKSUM_PARTIAL correctly,
ip_defrag for example resets them to CHECKSUM_NONE, so further checks
will fail, others seem to either ignore them or handle them together
with CHECKSUM_NONE.


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

* Re: [NET]: Allow forwarding of ip_summed except CHECKSUM_COMPLETE
  2007-03-27 20:51 ` Patrick McHardy
@ 2007-03-27 21:20   ` Herbert Xu
  0 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2007-03-27 21:20 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: David S. Miller, Stephen Hemminger, netdev

On Tue, Mar 27, 2007 at 10:51:53PM +0200, Patrick McHardy wrote:
> 
> Just wondering, how does Xen know whether a packet will be forwarded?

It's up to Linux to handle it correctly.

> The input path doesn't seem to deal with CHECKSUM_PARTIAL correctly,
> ip_defrag for example resets them to CHECKSUM_NONE, so further checks
> will fail, others seem to either ignore them or handle them together
> with CHECKSUM_NONE.

That's OK, Linux/Xen never generates any CHECKSUM_PARTIAL fragments.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2007-03-27 21:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-27  5:38 [NET]: Allow forwarding of ip_summed except CHECKSUM_COMPLETE Herbert Xu
2007-03-27  6:23 ` David Miller
2007-03-27 20:51 ` Patrick McHardy
2007-03-27 21:20   ` Herbert Xu

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