ipv6: xfrm: Handle errors reported by xfrm6_find_1stfragopt()
[pandora-kernel.git] / net / ipv6 / xfrm6_mode_ro.c
index 2575804..bc75be1 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/skbuff.h>
+#include <linux/spinlock.h>
 #include <linux/stringify.h>
 #include <linux/time.h>
 #include <net/ipv6.h>
  *
  * The IP header and mutable extension headers will be moved forward to make
  * space for the route optimization header.
- *
- * On exit, skb->h will be set to the start of the encapsulation header to be
- * filled in by x->type->output and the mac header will be set to the
- * nextheader field of the extension header directly preceding the
- * encapsulation header, or in its absence, that of the top IP header.
- * The value of skb->data and the network header will always point to the
- * top IP header.
  */
 static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb)
 {
@@ -51,30 +45,23 @@ static int xfrm6_ro_output(struct xfrm_state *x, struct sk_buff *skb)
        u8 *prevhdr;
        int hdr_len;
 
-       skb_push(skb, x->props.header_len);
        iph = ipv6_hdr(skb);
 
        hdr_len = x->type->hdr_offset(x, skb, &prevhdr);
+       if (hdr_len < 0)
+               return hdr_len;
        skb_set_mac_header(skb, (prevhdr - x->props.header_len) - skb->data);
-       skb_reset_network_header(skb);
-       skb_set_transport_header(skb, hdr_len);
-       memmove(skb->data, iph, hdr_len);
+       skb_set_network_header(skb, -x->props.header_len);
+       skb->transport_header = skb->network_header + hdr_len;
+       __skb_pull(skb, hdr_len);
+       memmove(ipv6_hdr(skb), iph, hdr_len);
 
        x->lastused = get_seconds();
 
        return 0;
 }
 
-/*
- * Do nothing about routing optimization header unlike IPsec.
- */
-static int xfrm6_ro_input(struct xfrm_state *x, struct sk_buff *skb)
-{
-       return 0;
-}
-
 static struct xfrm_mode xfrm6_ro_mode = {
-       .input = xfrm6_ro_input,
        .output = xfrm6_ro_output,
        .owner = THIS_MODULE,
        .encap = XFRM_MODE_ROUTEOPTIMIZATION,