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 /include/linux/netdevice.h | |
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 'include/linux/netdevice.h')
-rw-r--r-- | include/linux/netdevice.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 4428f1c3c13c..30446222b396 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -304,7 +304,7 @@ struct net_device | |||
304 | 304 | ||
305 | unsigned long state; | 305 | unsigned long state; |
306 | 306 | ||
307 | struct net_device *next; | 307 | struct list_head dev_list; |
308 | 308 | ||
309 | /* The device initialization function. Called only once. */ | 309 | /* The device initialization function. Called only once. */ |
310 | int (*init)(struct net_device *dev); | 310 | int (*init)(struct net_device *dev); |
@@ -575,9 +575,31 @@ struct packet_type { | |||
575 | #include <linux/notifier.h> | 575 | #include <linux/notifier.h> |
576 | 576 | ||
577 | extern struct net_device loopback_dev; /* The loopback */ | 577 | extern struct net_device loopback_dev; /* The loopback */ |
578 | extern struct net_device *dev_base; /* All devices */ | 578 | extern struct list_head dev_base_head; /* All devices */ |
579 | extern rwlock_t dev_base_lock; /* Device list lock */ | 579 | extern rwlock_t dev_base_lock; /* Device list lock */ |
580 | 580 | ||
581 | #define for_each_netdev(d) \ | ||
582 | list_for_each_entry(d, &dev_base_head, dev_list) | ||
583 | #define for_each_netdev_safe(d, n) \ | ||
584 | list_for_each_entry_safe(d, n, &dev_base_head, dev_list) | ||
585 | #define for_each_netdev_continue(d) \ | ||
586 | list_for_each_entry_continue(d, &dev_base_head, dev_list) | ||
587 | #define net_device_entry(lh) list_entry(lh, struct net_device, dev_list) | ||
588 | |||
589 | static inline struct net_device *next_net_device(struct net_device *dev) | ||
590 | { | ||
591 | struct list_head *lh; | ||
592 | |||
593 | lh = dev->dev_list.next; | ||
594 | return lh == &dev_base_head ? NULL : net_device_entry(lh); | ||
595 | } | ||
596 | |||
597 | static inline struct net_device *first_net_device(void) | ||
598 | { | ||
599 | return list_empty(&dev_base_head) ? NULL : | ||
600 | net_device_entry(dev_base_head.next); | ||
601 | } | ||
602 | |||
581 | extern int netdev_boot_setup_check(struct net_device *dev); | 603 | extern int netdev_boot_setup_check(struct net_device *dev); |
582 | extern unsigned long netdev_boot_base(const char *prefix, int unit); | 604 | extern unsigned long netdev_boot_base(const char *prefix, int unit); |
583 | extern struct net_device *dev_getbyhwaddr(unsigned short type, char *hwaddr); | 605 | extern struct net_device *dev_getbyhwaddr(unsigned short type, char *hwaddr); |