VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / net / ipv4 / xfrm4_output.c
index f65ec86..191cec7 100644 (file)
@@ -13,6 +13,7 @@
 #include <net/inet_ecn.h>
 #include <net/ip.h>
 #include <net/xfrm.h>
+#include <net/icmp.h>
 
 /* Add encapsulation header.
  *
@@ -67,6 +68,30 @@ static void xfrm4_encap(struct sk_buff *skb)
        memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));
 }
 
+static int xfrm4_tunnel_check_size(struct sk_buff *skb)
+{
+       int mtu, ret = 0;
+       struct dst_entry *dst;
+       struct iphdr *iph = skb->nh.iph;
+
+       if (IPCB(skb)->flags & IPSKB_XFRM_TUNNEL_SIZE)
+               goto out;
+
+       IPCB(skb)->flags |= IPSKB_XFRM_TUNNEL_SIZE;
+       
+       if (!(iph->frag_off & htons(IP_DF)))
+               goto out;
+
+       dst = skb->dst;
+       mtu = dst_pmtu(dst) - dst->header_len - dst->trailer_len;
+       if (skb->len > mtu) {
+               icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu));
+               ret = -EMSGSIZE;
+       }
+out:
+       return ret;
+}
+
 int xfrm4_output(struct sk_buff **pskb)
 {
        struct sk_buff *skb = *pskb;