]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - net/ipv4/xfrm4_policy.c
ipv4: Remove flowi from struct rtable.
[mv-sheeva.git] / net / ipv4 / xfrm4_policy.c
index b057d40addec3ef2ffab44413421e502894fe60e..c70c42e7e77b8cb95a1be26deab0116f904f5fd9 100644 (file)
 static struct xfrm_policy_afinfo xfrm4_policy_afinfo;
 
 static struct dst_entry *xfrm4_dst_lookup(struct net *net, int tos,
-                                         xfrm_address_t *saddr,
-                                         xfrm_address_t *daddr)
+                                         const xfrm_address_t *saddr,
+                                         const xfrm_address_t *daddr)
 {
        struct flowi fl = {
                .fl4_dst = daddr->a4,
                .fl4_tos = tos,
        };
-       struct dst_entry *dst;
        struct rtable *rt;
-       int err;
 
        if (saddr)
                fl.fl4_src = saddr->a4;
 
-       err = __ip_route_output_key(net, &rt, &fl);
-       dst = &rt->dst;
-       if (err)
-               dst = ERR_PTR(err);
-       return dst;
+       rt = __ip_route_output_key(net, &fl);
+       if (!IS_ERR(rt))
+               return &rt->dst;
+
+       return ERR_CAST(rt);
 }
 
 static int xfrm4_get_saddr(struct net *net,
@@ -56,7 +54,7 @@ static int xfrm4_get_saddr(struct net *net,
        return 0;
 }
 
-static int xfrm4_get_tos(struct flowi *fl)
+static int xfrm4_get_tos(const struct flowi *fl)
 {
        return IPTOS_RT_MASK & fl->fl4_tos; /* Strip ECN bits */
 }
@@ -68,11 +66,16 @@ static int xfrm4_init_path(struct xfrm_dst *path, struct dst_entry *dst,
 }
 
 static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
-                         struct flowi *fl)
+                         const struct flowi *fl)
 {
        struct rtable *rt = (struct rtable *)xdst->route;
 
-       xdst->u.rt.fl = *fl;
+       rt->rt_key_dst = fl->fl4_dst;
+       rt->rt_key_src = fl->fl4_src;
+       rt->rt_tos = fl->fl4_tos;
+       rt->rt_iif = fl->iif;
+       rt->rt_oif = fl->oif;
+       rt->rt_mark = fl->mark;
 
        xdst->u.dst.dev = dev;
        dev_hold(dev);
@@ -196,8 +199,11 @@ static void xfrm4_dst_destroy(struct dst_entry *dst)
 {
        struct xfrm_dst *xdst = (struct xfrm_dst *)dst;
 
+       dst_destroy_metrics_generic(dst);
+
        if (likely(xdst->u.rt.peer))
                inet_putpeer(xdst->u.rt.peer);
+
        xfrm_dst_destroy(xdst);
 }
 
@@ -215,6 +221,7 @@ static struct dst_ops xfrm4_dst_ops = {
        .protocol =             cpu_to_be16(ETH_P_IP),
        .gc =                   xfrm4_garbage_collect,
        .update_pmtu =          xfrm4_update_pmtu,
+       .cow_metrics =          dst_cow_metrics_generic,
        .destroy =              xfrm4_dst_destroy,
        .ifdown =               xfrm4_dst_ifdown,
        .local_out =            __ip_local_out,
@@ -230,6 +237,7 @@ static struct xfrm_policy_afinfo xfrm4_policy_afinfo = {
        .get_tos =              xfrm4_get_tos,
        .init_path =            xfrm4_init_path,
        .fill_dst =             xfrm4_fill_dst,
+       .blackhole_route =      ipv4_blackhole_route,
 };
 
 #ifdef CONFIG_SYSCTL