]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv6/xfrm6_policy.c
Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
[linux-2.6-omap-h63xx.git] / net / ipv6 / xfrm6_policy.c
index 8dffd4daae9ce4dbeb3ab8a7cc1f9887f495b669..82e27b80d07d3d060112eb873d7b0a9774853cba 100644 (file)
@@ -8,7 +8,7 @@
  *             IPv6 support
  *     YOSHIFUJI Hideaki
  *             Split up af-specific portion
- * 
+ *
  */
 
 #include <linux/compiler.h>
@@ -18,7 +18,7 @@
 #include <net/ip.h>
 #include <net/ipv6.h>
 #include <net/ip6_route.h>
-#ifdef CONFIG_IPV6_MIP6
+#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
 #include <net/mip6.h>
 #endif
 
@@ -131,13 +131,11 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
        struct dst_entry *dst, *dst_prev;
        struct rt6_info *rt0 = (struct rt6_info*)(*dst_p);
        struct rt6_info *rt  = rt0;
-       struct in6_addr *remote = &fl->fl6_dst;
-       struct in6_addr *local  = &fl->fl6_src;
        struct flowi fl_tunnel = {
                .nl_u = {
                        .ip6_u = {
-                               .saddr = *local,
-                               .daddr = *remote
+                               .saddr = fl->fl6_src,
+                               .daddr = fl->fl6_dst,
                        }
                }
        };
@@ -153,7 +151,6 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
        for (i = 0; i < nx; i++) {
                struct dst_entry *dst1 = dst_alloc(&xfrm6_dst_ops);
                struct xfrm_dst *xdst;
-               int tunnel = 0;
 
                if (unlikely(dst1 == NULL)) {
                        err = -ENOBUFS;
@@ -177,19 +174,28 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
 
                dst1->next = dst_prev;
                dst_prev = dst1;
-               if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) {
-                       remote = __xfrm6_bundle_addr_remote(xfrm[i], remote);
-                       local  = __xfrm6_bundle_addr_local(xfrm[i], local);
-                       tunnel = 1;
-               }
+
                __xfrm6_bundle_len_inc(&header_len, &nfheader_len, xfrm[i]);
                trailer_len += xfrm[i]->props.trailer_len;
 
-               if (tunnel) {
-                       ipv6_addr_copy(&fl_tunnel.fl6_dst, remote);
-                       ipv6_addr_copy(&fl_tunnel.fl6_src, local);
+               if (xfrm[i]->props.mode != XFRM_MODE_TRANSPORT) {
+                       unsigned short encap_family = xfrm[i]->props.family;
+                       switch(encap_family) {
+                       case AF_INET:
+                               fl_tunnel.fl4_dst = xfrm[i]->id.daddr.a4;
+                               fl_tunnel.fl4_src = xfrm[i]->props.saddr.a4;
+                               break;
+                       case AF_INET6:
+                               ipv6_addr_copy(&fl_tunnel.fl6_dst, __xfrm6_bundle_addr_remote(xfrm[i], &fl->fl6_dst));
+
+                               ipv6_addr_copy(&fl_tunnel.fl6_src, __xfrm6_bundle_addr_local(xfrm[i], &fl->fl6_src));
+                               break;
+                       default:
+                               BUG_ON(1);
+                       }
+
                        err = xfrm_dst_lookup((struct xfrm_dst **) &rt,
-                                             &fl_tunnel, AF_INET6);
+                                             &fl_tunnel, encap_family);
                        if (err)
                                goto error;
                } else
@@ -224,16 +230,16 @@ __xfrm6_bundle_create(struct xfrm_policy *policy, struct xfrm_state **xfrm, int
                /* Copy neighbour for reachability confirmation */
                dst_prev->neighbour     = neigh_clone(rt->u.dst.neighbour);
                dst_prev->input         = rt->u.dst.input;
-               dst_prev->output        = xfrm6_output;
+               dst_prev->output = dst_prev->xfrm->outer_mode->afinfo->output;
                /* Sheit... I remember I did this right. Apparently,
                 * it was magically lost, so this code needs audit */
                x->u.rt6.rt6i_flags    = rt0->rt6i_flags&(RTCF_BROADCAST|RTCF_MULTICAST|RTCF_LOCAL);
                x->u.rt6.rt6i_metric   = rt0->rt6i_metric;
                x->u.rt6.rt6i_node     = rt0->rt6i_node;
                x->u.rt6.rt6i_gateway  = rt0->rt6i_gateway;
-               memcpy(&x->u.rt6.rt6i_gateway, &rt0->rt6i_gateway, sizeof(x->u.rt6.rt6i_gateway)); 
+               memcpy(&x->u.rt6.rt6i_gateway, &rt0->rt6i_gateway, sizeof(x->u.rt6.rt6i_gateway));
                x->u.rt6.rt6i_dst      = rt0->rt6i_dst;
-               x->u.rt6.rt6i_src      = rt0->rt6i_src; 
+               x->u.rt6.rt6i_src      = rt0->rt6i_src;
                x->u.rt6.rt6i_idev     = rt0->rt6i_idev;
                in6_dev_hold(rt0->rt6i_idev);
                __xfrm6_bundle_len_dec(&header_len, &nfheader_len, x->u.dst.xfrm);
@@ -252,17 +258,19 @@ error:
 static inline void
 _decode_session6(struct sk_buff *skb, struct flowi *fl)
 {
-       u16 offset = skb->h.raw - skb->nh.raw;
-       struct ipv6hdr *hdr = skb->nh.ipv6h;
+       u16 offset = skb_network_header_len(skb);
+       struct ipv6hdr *hdr = ipv6_hdr(skb);
        struct ipv6_opt_hdr *exthdr;
-       u8 nexthdr = skb->nh.raw[IP6CB(skb)->nhoff];
+       const unsigned char *nh = skb_network_header(skb);
+       u8 nexthdr = nh[IP6CB(skb)->nhoff];
 
        memset(fl, 0, sizeof(struct flowi));
        ipv6_addr_copy(&fl->fl6_dst, &hdr->daddr);
        ipv6_addr_copy(&fl->fl6_src, &hdr->saddr);
 
-       while (pskb_may_pull(skb, skb->nh.raw + offset + 1 - skb->data)) {
-               exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset);
+       while (pskb_may_pull(skb, nh + offset + 1 - skb->data)) {
+               nh = skb_network_header(skb);
+               exthdr = (struct ipv6_opt_hdr *)(nh + offset);
 
                switch (nexthdr) {
                case NEXTHDR_ROUTING:
@@ -270,7 +278,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl)
                case NEXTHDR_DEST:
                        offset += ipv6_optlen(exthdr);
                        nexthdr = exthdr->nexthdr;
-                       exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset);
+                       exthdr = (struct ipv6_opt_hdr *)(nh + offset);
                        break;
 
                case IPPROTO_UDP:
@@ -278,7 +286,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl)
                case IPPROTO_TCP:
                case IPPROTO_SCTP:
                case IPPROTO_DCCP:
-                       if (pskb_may_pull(skb, skb->nh.raw + offset + 4 - skb->data)) {
+                       if (pskb_may_pull(skb, nh + offset + 4 - skb->data)) {
                                __be16 *ports = (__be16 *)exthdr;
 
                                fl->fl_ip_sport = ports[0];
@@ -288,7 +296,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl)
                        return;
 
                case IPPROTO_ICMPV6:
-                       if (pskb_may_pull(skb, skb->nh.raw + offset + 2 - skb->data)) {
+                       if (pskb_may_pull(skb, nh + offset + 2 - skb->data)) {
                                u8 *icmp = (u8 *)exthdr;
 
                                fl->fl_icmp_type = icmp[0];
@@ -297,9 +305,9 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl)
                        fl->proto = nexthdr;
                        return;
 
-#ifdef CONFIG_IPV6_MIP6
+#if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE)
                case IPPROTO_MH:
-                       if (pskb_may_pull(skb, skb->nh.raw + offset + 3 - skb->data)) {
+                       if (pskb_may_pull(skb, nh + offset + 3 - skb->data)) {
                                struct ip6_mh *mh;
                                mh = (struct ip6_mh *)exthdr;
 
@@ -317,7 +325,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl)
                        fl->fl_ipsec_spi = 0;
                        fl->proto = nexthdr;
                        return;
-               };
+               }
        }
 }
 
@@ -354,7 +362,7 @@ static void xfrm6_dst_ifdown(struct dst_entry *dst, struct net_device *dev,
 
        xdst = (struct xfrm_dst *)dst;
        if (xdst->u.rt6.rt6i_idev->dev == dev) {
-               struct inet6_dev *loopback_idev = in6_dev_get(&loopback_dev);
+               struct inet6_dev *loopback_idev = in6_dev_get(init_net.loopback_dev);
                BUG_ON(!loopback_idev);
 
                do {