aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorPavel Emelianov <xemul@openvz.org>2007-05-03 18:13:45 -0400
committerDavid S. Miller <davem@davemloft.net>2007-05-03 18:13:45 -0400
commit7562f876cd93800f2f8c89445f2a563590b24e09 (patch)
tree78a34c011af275efa0d55ba59c3bd49b771dd533 /net/ipv4
parent03fba0479600114f32d29eee74ca3eaa364606bf (diff)
[NET]: Rework dev_base via list_head (v3)
Cleanup of dev_base list use, with the aim to simplify making device list per-namespace. In almost every occasion, use of dev_base variable and dev->next pointer could be easily replaced by for_each_netdev loop. A few most complicated places were converted to using first_netdev()/next_netdev(). Signed-off-by: Pavel Emelianov <xemul@openvz.org> Acked-by: Kirill Korotaev <dev@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/devinet.c17
-rw-r--r--net/ipv4/igmp.c15
-rw-r--r--net/ipv4/ipconfig.c2
3 files changed, 18 insertions, 16 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 088888db8b3d..7f95e6e9beeb 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -910,7 +910,7 @@ no_in_dev:
910 */ 910 */
911 read_lock(&dev_base_lock); 911 read_lock(&dev_base_lock);
912 rcu_read_lock(); 912 rcu_read_lock();
913 for (dev = dev_base; dev; dev = dev->next) { 913 for_each_netdev(dev) {
914 if ((in_dev = __in_dev_get_rcu(dev)) == NULL) 914 if ((in_dev = __in_dev_get_rcu(dev)) == NULL)
915 continue; 915 continue;
916 916
@@ -989,7 +989,7 @@ __be32 inet_confirm_addr(const struct net_device *dev, __be32 dst, __be32 local,
989 989
990 read_lock(&dev_base_lock); 990 read_lock(&dev_base_lock);
991 rcu_read_lock(); 991 rcu_read_lock();
992 for (dev = dev_base; dev; dev = dev->next) { 992 for_each_netdev(dev) {
993 if ((in_dev = __in_dev_get_rcu(dev))) { 993 if ((in_dev = __in_dev_get_rcu(dev))) {
994 addr = confirm_addr_indev(in_dev, dst, local, scope); 994 addr = confirm_addr_indev(in_dev, dst, local, scope);
995 if (addr) 995 if (addr)
@@ -1182,23 +1182,26 @@ 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 for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) { 1185 idx = 0;
1186 for_each_netdev(dev) {
1186 if (idx < s_idx) 1187 if (idx < s_idx)
1187 continue; 1188 goto cont;
1188 if (idx > s_idx) 1189 if (idx > s_idx)
1189 s_ip_idx = 0; 1190 s_ip_idx = 0;
1190 if ((in_dev = __in_dev_get_rtnl(dev)) == NULL) 1191 if ((in_dev = __in_dev_get_rtnl(dev)) == NULL)
1191 continue; 1192 goto cont;
1192 1193
1193 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa; 1194 for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
1194 ifa = ifa->ifa_next, ip_idx++) { 1195 ifa = ifa->ifa_next, ip_idx++) {
1195 if (ip_idx < s_ip_idx) 1196 if (ip_idx < s_ip_idx)
1196 continue; 1197 goto cont;
1197 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid, 1198 if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
1198 cb->nlh->nlmsg_seq, 1199 cb->nlh->nlmsg_seq,
1199 RTM_NEWADDR, NLM_F_MULTI) <= 0) 1200 RTM_NEWADDR, NLM_F_MULTI) <= 0)
1200 goto done; 1201 goto done;
1201 } 1202 }
1203cont:
1204 idx++;
1202 } 1205 }
1203 1206
1204done: 1207done:
@@ -1243,7 +1246,7 @@ void inet_forward_change(void)
1243 ipv4_devconf_dflt.forwarding = on; 1246 ipv4_devconf_dflt.forwarding = on;
1244 1247
1245 read_lock(&dev_base_lock); 1248 read_lock(&dev_base_lock);
1246 for (dev = dev_base; dev; dev = dev->next) { 1249 for_each_netdev(dev) {
1247 struct in_device *in_dev; 1250 struct in_device *in_dev;
1248 rcu_read_lock(); 1251 rcu_read_lock();
1249 in_dev = __in_dev_get_rcu(dev); 1252 in_dev = __in_dev_get_rcu(dev);
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 2506021c2935..f4dd47453108 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -2288,9 +2288,8 @@ static inline struct ip_mc_list *igmp_mc_get_first(struct seq_file *seq)
2288 struct ip_mc_list *im = NULL; 2288 struct ip_mc_list *im = NULL;
2289 struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq); 2289 struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq);
2290 2290
2291 for (state->dev = dev_base, state->in_dev = NULL; 2291 state->in_dev = NULL;
2292 state->dev; 2292 for_each_netdev(state->dev) {
2293 state->dev = state->dev->next) {
2294 struct in_device *in_dev; 2293 struct in_device *in_dev;
2295 in_dev = in_dev_get(state->dev); 2294 in_dev = in_dev_get(state->dev);
2296 if (!in_dev) 2295 if (!in_dev)
@@ -2316,7 +2315,7 @@ static struct ip_mc_list *igmp_mc_get_next(struct seq_file *seq, struct ip_mc_li
2316 read_unlock(&state->in_dev->mc_list_lock); 2315 read_unlock(&state->in_dev->mc_list_lock);
2317 in_dev_put(state->in_dev); 2316 in_dev_put(state->in_dev);
2318 } 2317 }
2319 state->dev = state->dev->next; 2318 state->dev = next_net_device(state->dev);
2320 if (!state->dev) { 2319 if (!state->dev) {
2321 state->in_dev = NULL; 2320 state->in_dev = NULL;
2322 break; 2321 break;
@@ -2450,9 +2449,9 @@ static inline struct ip_sf_list *igmp_mcf_get_first(struct seq_file *seq)
2450 struct ip_mc_list *im = NULL; 2449 struct ip_mc_list *im = NULL;
2451 struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq); 2450 struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
2452 2451
2453 for (state->dev = dev_base, state->idev = NULL, state->im = NULL; 2452 state->idev = NULL;
2454 state->dev; 2453 state->im = NULL;
2455 state->dev = state->dev->next) { 2454 for_each_netdev(state->dev) {
2456 struct in_device *idev; 2455 struct in_device *idev;
2457 idev = in_dev_get(state->dev); 2456 idev = in_dev_get(state->dev);
2458 if (unlikely(idev == NULL)) 2457 if (unlikely(idev == NULL))
@@ -2488,7 +2487,7 @@ static struct ip_sf_list *igmp_mcf_get_next(struct seq_file *seq, struct ip_sf_l
2488 read_unlock(&state->idev->mc_list_lock); 2487 read_unlock(&state->idev->mc_list_lock);
2489 in_dev_put(state->idev); 2488 in_dev_put(state->idev);
2490 } 2489 }
2491 state->dev = state->dev->next; 2490 state->dev = next_net_device(state->dev);
2492 if (!state->dev) { 2491 if (!state->dev) {
2493 state->idev = NULL; 2492 state->idev = NULL;
2494 goto out; 2493 goto out;
diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 597c800b2fdc..342ca8d89458 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -192,7 +192,7 @@ static int __init ic_open_devs(void)
192 if (dev_change_flags(&loopback_dev, loopback_dev.flags | IFF_UP) < 0) 192 if (dev_change_flags(&loopback_dev, loopback_dev.flags | IFF_UP) < 0)
193 printk(KERN_ERR "IP-Config: Failed to open %s\n", loopback_dev.name); 193 printk(KERN_ERR "IP-Config: Failed to open %s\n", loopback_dev.name);
194 194
195 for (dev = dev_base; dev; dev = dev->next) { 195 for_each_netdev(dev) {
196 if (dev == &loopback_dev) 196 if (dev == &loopback_dev)
197 continue; 197 continue;
198 if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) : 198 if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :