Skip to contentSkip to conversation

fragment locally generated tunnel-mode IPSec6 packets as needed

PATCH In review David L Stevens 3 participants 6 messages Dec 17, 2010 – Dec 20, 2010

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

PATCH v4 1/1 fragment locally generated tunnel-mode IPSec6 packets as needed

This patch modifies IPsec6 to fragment IPv6 packets that are locally generated as needed.

This version of the patch only fragments in tunnel mode, so that fragment headers will not be obscured by ESP in transport mode.

include/net/ip6_route.h +10 -0
diff -ruNp linux-2.6.36-rc8/include/net/ip6_route.h linux-2.6.36-rc8DLS/include/net/ip6_route.h
@@ -164,5 +164,15 @@ static inline int ipv6_unicast_destinati
 	return rt->rt6i_flags & RTF_LOCAL;
 }
 
+int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *));
+
+static inline int ip6_skb_dst_mtu(struct sk_buff *skb)
+{
+	struct ipv6_pinfo *np = skb->sk ? inet6_sk(skb->sk) : NULL;
+
+	return (np && np->pmtudisc == IPV6_PMTUDISC_PROBE) ?
+	       skb_dst(skb)->dev->mtu : dst_mtu(skb_dst(skb));
+}
+
 #endif
 #endif
net/ipv6/ip6_output.c +2 -10
diff -ruNp linux-2.6.36-rc8/net/ipv6/ip6_output.c linux-2.6.36-rc8DLS/net/ipv6/ip6_output.c
@@ -56,7 +56,7 @@
 #include <net/checksum.h>
 #include <linux/mroute6.h>
 
-static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *));
+int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *));
 
 int __ip6_local_out(struct sk_buff *skb)
 {
@@ -145,14 +145,6 @@ static int ip6_finish_output2(struct sk_
 	return -EINVAL;
 }
 
-static inline int ip6_skb_dst_mtu(struct sk_buff *skb)
-{
-	struct ipv6_pinfo *np = skb->sk ? inet6_sk(skb->sk) : NULL;
-
-	return (np && np->pmtudisc == IPV6_PMTUDISC_PROBE) ?
-	       skb_dst(skb)->dev->mtu : dst_mtu(skb_dst(skb));
-}
-
 static int ip6_finish_output(struct sk_buff *skb)
 {
 	if ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) ||
@@ -601,7 +593,7 @@ int ip6_find_1stfragopt(struct sk_buff *
 	return offset;
 }
 
-static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
+int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
 {
 	struct sk_buff *frag;
 	struct rt6_info *rt = (struct rt6_info*)skb_dst(skb);
net/ipv6/xfrm6_output.c +15 -1
diff -ruNp linux-2.6.36-rc8/net/ipv6/xfrm6_output.c linux-2.6.36-rc8DLS/net/ipv6/xfrm6_output.c
@@ -17,6 +17,7 @@
 #include <linux/netfilter_ipv6.h>
 #include <net/dst.h>
 #include <net/ipv6.h>
+#include <net/ip6_route.h>
 #include <net/xfrm.h>
 
 int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb,
@@ -88,8 +89,21 @@ static int xfrm6_output_finish(struct sk
 	return xfrm_output(skb);
 }
 
+static int __xfrm6_output(struct sk_buff *skb)
+{
+	struct dst_entry *dst = skb_dst(skb);
+	struct xfrm_state *x = dst->xfrm;
+
+	if ((x && x->props.mode == XFRM_MODE_TUNNEL) &&
+	    ((skb->len > ip6_skb_dst_mtu(skb) && !skb_is_gso(skb)) ||
+		dst_allfrag(skb_dst(skb)))) {
+			return ip6_fragment(skb, xfrm6_output_finish);
+	}
+	return xfrm6_output_finish(skb);
+}
+
 int xfrm6_output(struct sk_buff *skb)
 {
 	return NF_HOOK(NFPROTO_IPV6, NF_INET_POST_ROUTING, skb, NULL,
-		       skb_dst(skb)->dev, xfrm6_output_finish);
+		       skb_dst(skb)->dev, __xfrm6_output);
 }
maintainer Acked-by on v4 1/1
#1 lore raw
Quoted 7 lines · David L Stevens

This patch modifies IPsec6 to fragment IPv6 packets that are locally generated as needed.

This version of the patch only fragments in tunnel mode, so that fragment headers will not be obscured by ESP in transport mode.

Thanks,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer
#2 lore raw

From: Herbert Xu <[email protected]>
Date: Sat, 18 Dec 2010 10:16:06 +0800

Quoted 10 lines · David L Stevens
Quoted 7 lines

This patch modifies IPsec6 to fragment IPv6 packets that are locally generated as needed.

This version of the patch only fragments in tunnel mode, so that fragment headers will not be obscured by ESP in transport mode.

So is the TAHI test regression caused by v3 fixed here in v4?

maintainer
#3 lore raw
Quoted 7 lines · David Miller

From: Herbert Xu <[email protected]>
Date: Sat, 18 Dec 2010 10:16:06 +0800

Quoted 4 lines · David L Stevens
Quoted 3 lines

This patch modifies IPsec6 to fragment IPv6 packets that are locally generated as needed.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

This version of the patch only fragments in tunnel mode, so that fragment headers will not be obscured by ESP in transport mode.

So is the TAHI test regression caused by v3 fixed here in v4?

I think so since that was probably caused by the incorrect fragmentation of transport-mode packets before encapsulation.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer
#5 lore raw

From: David Stevens <[email protected]>
Date: Sun, 19 Dec 2010 08:07:06 -0800

Quoted 5 lines

David Miller <[email protected]> wrote on 12/18/2010 02:34:23 PM:

Quoted 1 line

So is the TAHI test regression caused by v3 fixed here in v4?

Yes.

Great, applied, thanks.