]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv6/xfrm6_mode_beet.c
[IPSEC]: Rename mode to outer_mode and add inner_mode
[linux-2.6-omap-h63xx.git] / net / ipv6 / xfrm6_mode_beet.c
index edcfffa9e87b1395723cbf5e07df05ed3bca43ee..2bfb4f05c14cdffec7f7c455e5ecf43f34acd4c9 100644 (file)
 /* Add encapsulation header.
  *
  * The top IP header will be constructed per draft-nikander-esp-beet-mode-06.txt.
- * The following fields in it shall be filled in by x->type->output:
- *     payload_len
- *
- * On exit, skb->h will be set to the start of the encapsulation header to be
- * filled in by x->type->output and skb->nh 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 will always
- * point to the top IP header.
  */
 static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
 {
@@ -37,18 +29,17 @@ static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
        u8 *prevhdr;
        int hdr_len;
 
-       skb_push(skb, x->props.header_len);
-       iph = skb->nh.ipv6h;
+       iph = ipv6_hdr(skb);
 
        hdr_len = ip6_find_1stfragopt(skb, &prevhdr);
-       skb->nh.raw = prevhdr - x->props.header_len;
-       skb->h.raw = skb->data + hdr_len;
-       memmove(skb->data, iph, hdr_len);
 
-       skb->nh.raw = skb->data;
-       top_iph = skb->nh.ipv6h;
-       skb->nh.raw = &top_iph->nexthdr;
-       skb->h.ipv6h = top_iph + 1;
+       skb_set_mac_header(skb, (prevhdr - x->props.header_len) - skb->data);
+       skb_set_network_header(skb, -x->props.header_len);
+       skb->transport_header = skb->network_header + hdr_len;
+       __skb_pull(skb, hdr_len);
+
+       top_iph = ipv6_hdr(skb);
+       memmove(top_iph, iph, hdr_len);
 
        ipv6_addr_copy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr);
        ipv6_addr_copy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr);
@@ -59,6 +50,7 @@ static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
 static int xfrm6_beet_input(struct xfrm_state *x, struct sk_buff *skb)
 {
        struct ipv6hdr *ip6h;
+       const unsigned char *old_mac;
        int size = sizeof(struct ipv6hdr);
        int err = -EINVAL;
 
@@ -66,13 +58,14 @@ static int xfrm6_beet_input(struct xfrm_state *x, struct sk_buff *skb)
                goto out;
 
        skb_push(skb, size);
-       memmove(skb->data, skb->nh.raw, size);
-       skb->nh.raw = skb->data;
+       memmove(skb->data, skb_network_header(skb), size);
+       skb_reset_network_header(skb);
 
-       skb->mac.raw = memmove(skb->data - skb->mac_len,
-                              skb->mac.raw, skb->mac_len);
+       old_mac = skb_mac_header(skb);
+       skb_set_mac_header(skb, -skb->mac_len);
+       memmove(skb_mac_header(skb), old_mac, skb->mac_len);
 
-       ip6h = skb->nh.ipv6h;
+       ip6h = ipv6_hdr(skb);
        ip6h->payload_len = htons(skb->len - size);
        ipv6_addr_copy(&ip6h->daddr, (struct in6_addr *) &x->sel.daddr.a6);
        ipv6_addr_copy(&ip6h->saddr, (struct in6_addr *) &x->sel.saddr.a6);
@@ -86,6 +79,7 @@ static struct xfrm_mode xfrm6_beet_mode = {
        .output = xfrm6_beet_output,
        .owner = THIS_MODULE,
        .encap = XFRM_MODE_BEET,
+       .flags = XFRM_MODE_FLAG_TUNNEL,
 };
 
 static int __init xfrm6_beet_init(void)