diff options
author | Pavel Emelianov <xemul@openvz.org> | 2007-05-03 18:13:45 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-05-03 18:13:45 -0400 |
commit | 7562f876cd93800f2f8c89445f2a563590b24e09 (patch) | |
tree | 78a34c011af275efa0d55ba59c3bd49b771dd533 /net/8021q | |
parent | 03fba0479600114f32d29eee74ca3eaa364606bf (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/8021q')
-rw-r--r-- | net/8021q/vlan.c | 3 | ||||
-rw-r--r-- | net/8021q/vlanproc.c | 36 |
2 files changed, 25 insertions, 14 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index c0c7bb8e9f07..bd93c45778d4 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c | |||
@@ -117,8 +117,7 @@ static void __exit vlan_cleanup_devices(void) | |||
117 | struct net_device *dev, *nxt; | 117 | struct net_device *dev, *nxt; |
118 | 118 | ||
119 | rtnl_lock(); | 119 | rtnl_lock(); |
120 | for (dev = dev_base; dev; dev = nxt) { | 120 | for_each_netdev_safe(dev, nxt) { |
121 | nxt = dev->next; | ||
122 | if (dev->priv_flags & IFF_802_1Q_VLAN) { | 121 | if (dev->priv_flags & IFF_802_1Q_VLAN) { |
123 | unregister_vlan_dev(VLAN_DEV_INFO(dev)->real_dev, | 122 | unregister_vlan_dev(VLAN_DEV_INFO(dev)->real_dev, |
124 | VLAN_DEV_INFO(dev)->vlan_id); | 123 | VLAN_DEV_INFO(dev)->vlan_id); |
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c index 5e24f72602a1..d216a64421cd 100644 --- a/net/8021q/vlanproc.c +++ b/net/8021q/vlanproc.c | |||
@@ -237,13 +237,9 @@ int vlan_proc_rem_dev(struct net_device *vlandev) | |||
237 | * The following few functions build the content of /proc/net/vlan/config | 237 | * The following few functions build the content of /proc/net/vlan/config |
238 | */ | 238 | */ |
239 | 239 | ||
240 | /* starting at dev, find a VLAN device */ | 240 | static inline int is_vlan_dev(struct net_device *dev) |
241 | static struct net_device *vlan_skip(struct net_device *dev) | ||
242 | { | 241 | { |
243 | while (dev && !(dev->priv_flags & IFF_802_1Q_VLAN)) | 242 | return dev->priv_flags & IFF_802_1Q_VLAN; |
244 | dev = dev->next; | ||
245 | |||
246 | return dev; | ||
247 | } | 243 | } |
248 | 244 | ||
249 | /* start read of /proc/net/vlan/config */ | 245 | /* start read of /proc/net/vlan/config */ |
@@ -257,19 +253,35 @@ static void *vlan_seq_start(struct seq_file *seq, loff_t *pos) | |||
257 | if (*pos == 0) | 253 | if (*pos == 0) |
258 | return SEQ_START_TOKEN; | 254 | return SEQ_START_TOKEN; |
259 | 255 | ||
260 | for (dev = vlan_skip(dev_base); dev && i < *pos; | 256 | for_each_netdev(dev) { |
261 | dev = vlan_skip(dev->next), ++i); | 257 | if (!is_vlan_dev(dev)) |
258 | continue; | ||
259 | |||
260 | if (i++ == *pos) | ||
261 | return dev; | ||
262 | } | ||
262 | 263 | ||
263 | return (i == *pos) ? dev : NULL; | 264 | return NULL; |
264 | } | 265 | } |
265 | 266 | ||
266 | static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 267 | static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
267 | { | 268 | { |
269 | struct net_device *dev; | ||
270 | |||
268 | ++*pos; | 271 | ++*pos; |
269 | 272 | ||
270 | return vlan_skip((v == SEQ_START_TOKEN) | 273 | dev = (struct net_device *)v; |
271 | ? dev_base | 274 | if (v == SEQ_START_TOKEN) |
272 | : ((struct net_device *)v)->next); | 275 | dev = net_device_entry(&dev_base_head); |
276 | |||
277 | for_each_netdev_continue(dev) { | ||
278 | if (!is_vlan_dev(dev)) | ||
279 | continue; | ||
280 | |||
281 | return dev; | ||
282 | } | ||
283 | |||
284 | return NULL; | ||
273 | } | 285 | } |
274 | 286 | ||
275 | static void vlan_seq_stop(struct seq_file *seq, void *v) | 287 | static void vlan_seq_stop(struct seq_file *seq, void *v) |