and changed files
[powerpc.git] / net / ipv6 / xfrm6_input.c
index a40a057..d7ed8aa 100644 (file)
 #include <net/ipv6.h>
 #include <net/xfrm.h>
 
-int xfrm6_rcv_spi(struct sk_buff *skb, u32 spi)
+int xfrm6_rcv_spi(struct sk_buff *skb, __be32 spi)
 {
        int err;
-       u32 seq;
+       __be32 seq;
        struct xfrm_state *xfrm_vec[XFRM_MAX_DEPTH];
        struct xfrm_state *x;
        int xfrm_nr = 0;
@@ -28,19 +28,20 @@ int xfrm6_rcv_spi(struct sk_buff *skb, u32 spi)
        unsigned int nhoff;
 
        nhoff = IP6CB(skb)->nhoff;
-       nexthdr = skb->nh.raw[nhoff];
+       nexthdr = skb_network_header(skb)[nhoff];
 
        seq = 0;
        if (!spi && (err = xfrm_parse_spi(skb, nexthdr, &spi, &seq)) != 0)
                goto drop;
-       
+
        do {
-               struct ipv6hdr *iph = skb->nh.ipv6h;
+               struct ipv6hdr *iph = ipv6_hdr(skb);
 
                if (xfrm_nr == XFRM_MAX_DEPTH)
                        goto drop;
 
-               x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, spi, nexthdr, AF_INET6);
+               x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, spi,
+                               nexthdr != IPPROTO_IPIP ? nexthdr : IPPROTO_IPV6, AF_INET6);
                if (x == NULL)
                        goto drop;
                spin_lock(&x->lock);
@@ -57,7 +58,7 @@ int xfrm6_rcv_spi(struct sk_buff *skb, u32 spi)
                if (nexthdr <= 0)
                        goto drop_unlock;
 
-               skb->nh.raw[nhoff] = nexthdr;
+               skb_network_header(skb)[nhoff] = nexthdr;
 
                if (x->props.replay_window)
                        xfrm_replay_advance(x, seq);
@@ -111,11 +112,11 @@ int xfrm6_rcv_spi(struct sk_buff *skb, u32 spi)
                return -1;
        } else {
 #ifdef CONFIG_NETFILTER
-               skb->nh.ipv6h->payload_len = htons(skb->len);
-               __skb_push(skb, skb->data - skb->nh.raw);
+               ipv6_hdr(skb)->payload_len = htons(skb->len);
+               __skb_push(skb, skb->data - skb_network_header(skb));
 
                NF_HOOK(PF_INET6, NF_IP6_PRE_ROUTING, skb, skb->dev, NULL,
-                       ip6_rcv_finish);
+                       ip6_rcv_finish);
                return -1;
 #else
                return 1;
@@ -139,19 +140,19 @@ int xfrm6_rcv(struct sk_buff **pskb)
        return xfrm6_rcv_spi(*pskb, 0);
 }
 
+EXPORT_SYMBOL(xfrm6_rcv);
+
 int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
                     xfrm_address_t *saddr, u8 proto)
 {
-       struct xfrm_state *x = NULL;
-       int wildcard = 0;
-       struct in6_addr any;
+       struct xfrm_state *x = NULL;
+       int wildcard = 0;
        xfrm_address_t *xany;
        struct xfrm_state *xfrm_vec_one = NULL;
-       int nh = 0;
+       int nh = 0;
        int i = 0;
 
-       ipv6_addr_set(&any, 0, 0, 0, 0);
-       xany = (xfrm_address_t *)&any;
+       xany = (xfrm_address_t *)&in6addr_any;
 
        for (i = 0; i < 3; i++) {
                xfrm_address_t *dst, *src;
@@ -168,12 +169,12 @@ int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
                        break;
                case 2:
                default:
-                       /* lookup state with wild-card addresses */
+                       /* lookup state with wild-card addresses */
                        wildcard = 1; /* XXX */
                        dst = xany;
                        src = xany;
                        break;
-               }
+               }
 
                x = xfrm_state_lookup_byaddr(dst, src, proto, AF_INET6);
                if (!x)
@@ -193,8 +194,8 @@ int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
                if (unlikely(x->km.state != XFRM_STATE_VALID)) {
                        spin_unlock(&x->lock);
                        xfrm_state_put(x);
-                       x = NULL;
-                       continue;
+                       x = NULL;
+                       continue;
                }
                if (xfrm_state_check_expire(x)) {
                        spin_unlock(&x->lock);
@@ -246,3 +247,5 @@ drop:
                xfrm_state_put(xfrm_vec_one);
        return -1;
 }
+
+EXPORT_SYMBOL(xfrm6_input_addr);