]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv6/xfrm6_policy.c
[IPSEC]: Use crypto_aead and authenc in ESP
[linux-2.6-omap-h63xx.git] / net / ipv6 / xfrm6_policy.c
index 181cf91538f1c16ae4db7cccaa1e77b5cd85848d..c25a6b527fc4e083184e718720f184a752625bc6 100644 (file)
@@ -98,6 +98,20 @@ static int xfrm6_get_tos(struct flowi *fl)
        return 0;
 }
 
+static int xfrm6_init_path(struct xfrm_dst *path, struct dst_entry *dst,
+                          int nfheader_len)
+{
+       if (dst->ops->family == AF_INET6) {
+               struct rt6_info *rt = (struct rt6_info*)dst;
+               if (rt->rt6i_node)
+                       path->path_cookie = rt->rt6i_node->fn_sernum;
+       }
+
+       path->u.rt6.rt6i_nfheader_len = nfheader_len;
+
+       return 0;
+}
+
 static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev)
 {
        struct rt6_info *rt = (struct rt6_info*)xdst->route;
@@ -115,6 +129,8 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev)
                                                   RTF_LOCAL);
        xdst->u.rt6.rt6i_metric = rt->rt6i_metric;
        xdst->u.rt6.rt6i_node = rt->rt6i_node;
+       if (rt->rt6i_node)
+               xdst->route_cookie = rt->rt6i_node->fn_sernum;
        xdst->u.rt6.rt6i_gateway = rt->rt6i_gateway;
        xdst->u.rt6.rt6i_dst = rt->rt6i_dst;
        xdst->u.rt6.rt6i_src = rt->rt6i_src;
@@ -123,7 +139,7 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev)
 }
 
 static inline void
-_decode_session6(struct sk_buff *skb, struct flowi *fl)
+_decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
 {
        u16 offset = skb_network_header_len(skb);
        struct ipv6hdr *hdr = ipv6_hdr(skb);
@@ -132,8 +148,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl)
        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);
+       ipv6_addr_copy(&fl->fl6_dst, reverse ? &hdr->saddr : &hdr->daddr);
+       ipv6_addr_copy(&fl->fl6_src, reverse ? &hdr->daddr : &hdr->saddr);
 
        while (pskb_may_pull(skb, nh + offset + 1 - skb->data)) {
                nh = skb_network_header(skb);
@@ -156,8 +172,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl)
                        if (pskb_may_pull(skb, nh + offset + 4 - skb->data)) {
                                __be16 *ports = (__be16 *)exthdr;
 
-                               fl->fl_ip_sport = ports[0];
-                               fl->fl_ip_dport = ports[1];
+                               fl->fl_ip_sport = ports[!!reverse];
+                               fl->fl_ip_dport = ports[!reverse];
                        }
                        fl->proto = nexthdr;
                        return;
@@ -196,7 +212,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl)
        }
 }
 
-static inline int xfrm6_garbage_collect(void)
+static inline int xfrm6_garbage_collect(struct dst_ops *ops)
 {
        xfrm6_policy_afinfo.garbage_collect();
        return (atomic_read(&xfrm6_dst_ops.entries) > xfrm6_dst_ops.gc_thresh*2);
@@ -266,6 +282,7 @@ static struct xfrm_policy_afinfo xfrm6_policy_afinfo = {
        .find_bundle =          __xfrm6_find_bundle,
        .decode_session =       _decode_session6,
        .get_tos =              xfrm6_get_tos,
+       .init_path =            xfrm6_init_path,
        .fill_dst =             xfrm6_fill_dst,
 };