]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv4/devinet.c
inet: RCU changes in inetdev_by_index()
[net-next-2.6.git] / net / ipv4 / devinet.c
index c2ff48fa18c723ff110b4ada4e49461225ee8098..dc94b0316b783fd1c1985e407fb0339782c66df5 100644 (file)
@@ -403,6 +403,9 @@ static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa)
        return inet_insert_ifa(ifa);
 }
 
+/* Caller must hold RCU or RTNL :
+ * We dont take a reference on found in_device
+ */
 struct in_device *inetdev_by_index(struct net *net, int ifindex)
 {
        struct net_device *dev;
@@ -411,7 +414,7 @@ struct in_device *inetdev_by_index(struct net *net, int ifindex)
        rcu_read_lock();
        dev = dev_get_by_index_rcu(net, ifindex);
        if (dev)
-               in_dev = in_dev_get(dev);
+               in_dev = rcu_dereference_rtnl(dev->ip_ptr);
        rcu_read_unlock();
        return in_dev;
 }
@@ -453,8 +456,6 @@ static int inet_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
                goto errout;
        }
 
-       __in_dev_put(in_dev);
-
        for (ifap = &in_dev->ifa_list; (ifa = *ifap) != NULL;
             ifap = &ifa->ifa_next) {
                if (tb[IFA_LOCAL] &&