]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[RTNETLINK]: Remove unnecessary locking in dump callbacks
authorPatrick McHardy <kaber@trash.net>
Tue, 17 Apr 2007 00:00:53 +0000 (17:00 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Thu, 26 Apr 2007 05:29:05 +0000 (22:29 -0700)
Since we're now holding the rtnl during the entire dump operation, we can
remove additional locking for rtnl protected data. This patch does that
for all simple cases (dev_base_lock for dev_base walking, RCU protection
for FIB rule dumping).

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_netlink.c
net/core/fib_rules.c
net/core/rtnetlink.c
net/decnet/dn_dev.c
net/ipv4/devinet.c
net/ipv6/addrconf.c

index 5e84ade129caa260a130c4dca843df0fae7deb49..35facc0c11c24368f51c555be6bb13f072394c60 100644 (file)
@@ -109,7 +109,6 @@ static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
        struct net_device *dev;
        int idx;
 
-       read_lock(&dev_base_lock);
        for (dev = dev_base, idx = 0; dev; dev = dev->next) {
                /* not a bridge port */
                if (dev->br_port == NULL || idx < cb->args[0])
@@ -122,7 +121,6 @@ static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
 skip:
                ++idx;
        }
-       read_unlock(&dev_base_lock);
 
        cb->args[0] = idx;
 
index cb2dae19531b49cdf66b95b23f268b7de2de596a..8c5474e16683aa22971b1bed0390354b728a0f64 100644 (file)
@@ -495,8 +495,7 @@ static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb,
        int idx = 0;
        struct fib_rule *rule;
 
-       rcu_read_lock();
-       list_for_each_entry_rcu(rule, ops->rules_list, list) {
+       list_for_each_entry(rule, ops->rules_list, list) {
                if (idx < cb->args[1])
                        goto skip;
 
@@ -507,7 +506,6 @@ static int dump_rules(struct sk_buff *skb, struct netlink_callback *cb,
 skip:
                idx++;
        }
-       rcu_read_unlock();
        cb->args[1] = idx;
        rules_ops_put(ops);
 
index 62f5c7f98d17b93b52c44d02f80a42a842aec088..bc95fab0b0ceb35a1f92db14e81b1989b965e967 100644 (file)
@@ -543,7 +543,6 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
        int s_idx = cb->args[0];
        struct net_device *dev;
 
-       read_lock(&dev_base_lock);
        for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
                if (idx < s_idx)
                        continue;
@@ -552,7 +551,6 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
                                     cb->nlh->nlmsg_seq, 0, NLM_F_MULTI) <= 0)
                        break;
        }
-       read_unlock(&dev_base_lock);
        cb->args[0] = idx;
 
        return skb->len;
index 61be2caddc576936585ab35030397f268b704280..5c2a9951b638346691b4801d27be5d036018c155 100644 (file)
@@ -799,7 +799,6 @@ static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
        skip_ndevs = cb->args[0];
        skip_naddr = cb->args[1];
 
-       read_lock(&dev_base_lock);
        for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) {
                if (idx < skip_ndevs)
                        continue;
@@ -824,8 +823,6 @@ static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
                }
        }
 done:
-       read_unlock(&dev_base_lock);
-
        cb->args[0] = idx;
        cb->args[1] = dn_idx;
 
index 9bdc79564cc65767c4e540017683fb99b509f14c..088888db8b3db18f4a02319e8041638a248fd30f 100644 (file)
@@ -1182,17 +1182,13 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
        int s_ip_idx, s_idx = cb->args[0];
 
        s_ip_idx = ip_idx = cb->args[1];
-       read_lock(&dev_base_lock);
        for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) {
                if (idx < s_idx)
                        continue;
                if (idx > s_idx)
                        s_ip_idx = 0;
-               rcu_read_lock();
-               if ((in_dev = __in_dev_get_rcu(dev)) == NULL) {
-                       rcu_read_unlock();
+               if ((in_dev = __in_dev_get_rtnl(dev)) == NULL)
                        continue;
-               }
 
                for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
                     ifa = ifa->ifa_next, ip_idx++) {
@@ -1200,16 +1196,12 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
                                continue;
                        if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
                                             cb->nlh->nlmsg_seq,
-                                            RTM_NEWADDR, NLM_F_MULTI) <= 0) {
-                               rcu_read_unlock();
+                                            RTM_NEWADDR, NLM_F_MULTI) <= 0)
                                goto done;
-                       }
                }
-               rcu_read_unlock();
        }
 
 done:
-       read_unlock(&dev_base_lock);
        cb->args[0] = idx;
        cb->args[1] = ip_idx;
 
index eecba1886b497c872a4fc8f69a75efc948bb865a..1486f76f7878fe423c7f265e48f33570195fd8ee 100644 (file)
@@ -3224,7 +3224,6 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
 
        s_idx = cb->args[0];
        s_ip_idx = ip_idx = cb->args[1];
-       read_lock(&dev_base_lock);
 
        for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) {
                if (idx < s_idx)
@@ -3286,7 +3285,6 @@ done:
                read_unlock_bh(&idev->lock);
                in6_dev_put(idev);
        }
-       read_unlock(&dev_base_lock);
        cb->args[0] = idx;
        cb->args[1] = ip_idx;
        return skb->len;