aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/devinet.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2007-04-16 20:00:53 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:29:05 -0400
commit6313c1e0992feaee56bc09b85042b3186041fa3c (patch)
treef75cda674d8f2b62bcdb09e59f8bc7010003a91f /net/ipv4/devinet.c
parent1c2d670f3660e9103fdcdca702f6dbf8ea7d6afb (diff)
[RTNETLINK]: Remove unnecessary locking in dump callbacks
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>
Diffstat (limited to 'net/ipv4/devinet.c')
-rw-r--r--net/ipv4/devinet.c12
1 files changed, 2 insertions, 10 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 9bdc79564cc6..088888db8b3d 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1182,17 +1182,13 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
1182 int s_ip_idx, s_idx = cb->args[0]; 1182 int s_ip_idx, s_idx = cb->args[0];
1183 1183
1184 s_ip_idx = ip_idx = cb->args[1]; 1184 s_ip_idx = ip_idx = cb->args[1];
1185 read_lock(&dev_base_lock);
1186 for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) { 1185 for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) {
1187 if (idx < s_idx) 1186 if (idx < s_idx)
1188 continue; 1187 continue;
1189 if (idx > s_idx) 1188 if (idx > s_idx)
1190 s_ip_idx = 0; 1189 s_ip_idx = 0;
1191 rcu_read_lock(); 1190 if ((in_dev = __in_dev_get_rtnl(dev)) == NULL)
1192 if ((in_dev = __in_dev_get_rcu(dev)) == NULL) {
1193 rcu_read_unlock();
1194 continue; 1191 continue;
1195 }
1196 1192
1197 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa; 1193 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
1198 ifa = ifa->ifa_next, ip_idx++) { 1194 ifa = ifa->ifa_next, ip_idx++) {
@@ -1200,16 +1196,12 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
1200 continue; 1196 continue;
1201 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid, 1197 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
1202 cb->nlh->nlmsg_seq, 1198 cb->nlh->nlmsg_seq,
1203 RTM_NEWADDR, NLM_F_MULTI) <= 0) { 1199 RTM_NEWADDR, NLM_F_MULTI) <= 0)
1204 rcu_read_unlock();
1205 goto done; 1200 goto done;
1206 }
1207 } 1201 }
1208 rcu_read_unlock();
1209 } 1202 }
1210 1203
1211done: 1204done:
1212 read_unlock(&dev_base_lock);
1213 cb->args[0] = idx; 1205 cb->args[0] = idx;
1214 cb->args[1] = ip_idx; 1206 cb->args[1] = ip_idx;
1215 1207