Merge to Fedora kernel-2.6.6-1.422
[linux-2.6.git] / net / ipv4 / route.c
index 5bdc280..6e7cbd3 100644 (file)
@@ -1040,6 +1040,8 @@ void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw,
                                rt->u.dst.child         = NULL;
                                if (rt->u.dst.dev)
                                        dev_hold(rt->u.dst.dev);
+                               if (rt->idev)
+                                       in_dev_hold(rt->idev);
                                rt->u.dst.obsolete      = 0;
                                rt->u.dst.lastuse       = jiffies;
                                rt->u.dst.path          = &rt->u.dst;
@@ -1321,11 +1323,17 @@ static void ipv4_dst_destroy(struct dst_entry *dst)
 {
        struct rtable *rt = (struct rtable *) dst;
        struct inet_peer *peer = rt->peer;
+       struct in_device *idev = rt->idev;
 
        if (peer) {
                rt->peer = NULL;
                inet_putpeer(peer);
        }
+
+       if (idev) {
+               rt->idev = NULL;
+               in_dev_put(idev);
+       }
 }
 
 static void ipv4_link_failure(struct sk_buff *skb)
@@ -1486,6 +1494,7 @@ static int ip_route_input_mc(struct sk_buff *skb, u32 daddr, u32 saddr,
        rth->fl.iif     = dev->ifindex;
        rth->u.dst.dev  = &loopback_dev;
        dev_hold(rth->u.dst.dev);
+       rth->idev       = in_dev_get(rth->u.dst.dev);
        rth->fl.oif     = 0;
        rth->rt_gateway = daddr;
        rth->rt_spec_dst= spec_dst;
@@ -1695,6 +1704,7 @@ static int ip_route_input_slow(struct sk_buff *skb, u32 daddr, u32 saddr,
        rth->fl.iif     = dev->ifindex;
        rth->u.dst.dev  = out_dev->dev;
        dev_hold(rth->u.dst.dev);
+       rth->idev       = in_dev_get(rth->u.dst.dev);
        rth->fl.oif     = 0;
        rth->rt_spec_dst= spec_dst;
 
@@ -1774,6 +1784,7 @@ local_input:
        rth->fl.iif     = dev->ifindex;
        rth->u.dst.dev  = &loopback_dev;
        dev_hold(rth->u.dst.dev);
+       rth->idev       = in_dev_get(rth->u.dst.dev);
        rth->rt_gateway = daddr;
        rth->rt_spec_dst= spec_dst;
        rth->u.dst.input= ip_local_deliver;
@@ -2157,6 +2168,7 @@ make_route:
        rth->rt_iif     = oldflp->oif ? : dev_out->ifindex;
        rth->u.dst.dev  = dev_out;
        dev_hold(dev_out);
+       rth->idev       = in_dev_get(dev_out);
        rth->rt_gateway = fl.fl4_dst;
        rth->rt_spec_dst= fl.fl4_src;