vserver 1.9.3
[linux-2.6.git] / net / ipv6 / xfrm6_input.c
index 0791594..28c29d7 100644 (file)
@@ -9,7 +9,9 @@
  *             IPv6 support
  */
 
+#include <linux/module.h>
 #include <linux/string.h>
+#include <net/dsfield.h>
 #include <net/inet_ecn.h>
 #include <net/ip.h>
 #include <net/ipv6.h>
@@ -20,16 +22,15 @@ static inline void ipip6_ecn_decapsulate(struct sk_buff *skb)
        struct ipv6hdr *outer_iph = skb->nh.ipv6h;
        struct ipv6hdr *inner_iph = skb->h.ipv6h;
 
-       if (INET_ECN_is_ce(ip6_get_dsfield(outer_iph)) &&
-           INET_ECN_is_not_ce(ip6_get_dsfield(inner_iph)))
+       if (INET_ECN_is_ce(ipv6_get_dsfield(outer_iph)))
                IP6_ECN_set_ce(inner_iph);
 }
 
-int xfrm6_rcv(struct sk_buff **pskb, unsigned int *nhoffp)
+int xfrm6_rcv_spi(struct sk_buff **pskb, unsigned int *nhoffp, u32 spi)
 {
        struct sk_buff *skb = *pskb;
        int err;
-       u32 spi, seq;
+       u32 seq;
        struct sec_decap_state xfrm_vec[XFRM_MAX_DEPTH];
        struct xfrm_state *x;
        int xfrm_nr = 0;
@@ -40,7 +41,8 @@ int xfrm6_rcv(struct sk_buff **pskb, unsigned int *nhoffp)
        nhoff = *nhoffp;
        nexthdr = skb->nh.raw[nhoff];
 
-       if ((err = xfrm_parse_spi(skb, nexthdr, &spi, &seq)) != 0)
+       seq = 0;
+       if (!spi && (err = xfrm_parse_spi(skb, nexthdr, &spi, &seq)) != 0)
                goto drop;
        
        do {
@@ -86,6 +88,8 @@ int xfrm6_rcv(struct sk_buff **pskb, unsigned int *nhoffp)
                        if (skb_cloned(skb) &&
                            pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
                                goto drop;
+                       if (x->props.flags & XFRM_STATE_DECAP_DSCP)
+                               ipv6_copy_dscp(skb->nh.ipv6h, skb->h.ipv6h);
                        if (!(x->props.flags & XFRM_STATE_NOECN))
                                ipip6_ecn_decapsulate(skb);
                        skb->mac.raw = memmove(skb->data - skb->mac_len,
@@ -137,3 +141,10 @@ drop:
        kfree_skb(skb);
        return -1;
 }
+
+EXPORT_SYMBOL(xfrm6_rcv_spi);
+
+int xfrm6_rcv(struct sk_buff **pskb, unsigned int *nhoffp)
+{
+       return xfrm6_rcv_spi(pskb, nhoffp, 0);
+}