mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
[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>
This commit is contained in:
parent
03fba04796
commit
7562f876cd
31 changed files with 253 additions and 198 deletions
|
@ -304,7 +304,7 @@ struct net_device
|
|||
|
||||
unsigned long state;
|
||||
|
||||
struct net_device *next;
|
||||
struct list_head dev_list;
|
||||
|
||||
/* The device initialization function. Called only once. */
|
||||
int (*init)(struct net_device *dev);
|
||||
|
@ -575,9 +575,31 @@ struct packet_type {
|
|||
#include <linux/notifier.h>
|
||||
|
||||
extern struct net_device loopback_dev; /* The loopback */
|
||||
extern struct net_device *dev_base; /* All devices */
|
||||
extern struct list_head dev_base_head; /* All devices */
|
||||
extern rwlock_t dev_base_lock; /* Device list lock */
|
||||
|
||||
#define for_each_netdev(d) \
|
||||
list_for_each_entry(d, &dev_base_head, dev_list)
|
||||
#define for_each_netdev_safe(d, n) \
|
||||
list_for_each_entry_safe(d, n, &dev_base_head, dev_list)
|
||||
#define for_each_netdev_continue(d) \
|
||||
list_for_each_entry_continue(d, &dev_base_head, dev_list)
|
||||
#define net_device_entry(lh) list_entry(lh, struct net_device, dev_list)
|
||||
|
||||
static inline struct net_device *next_net_device(struct net_device *dev)
|
||||
{
|
||||
struct list_head *lh;
|
||||
|
||||
lh = dev->dev_list.next;
|
||||
return lh == &dev_base_head ? NULL : net_device_entry(lh);
|
||||
}
|
||||
|
||||
static inline struct net_device *first_net_device(void)
|
||||
{
|
||||
return list_empty(&dev_base_head) ? NULL :
|
||||
net_device_entry(dev_base_head.next);
|
||||
}
|
||||
|
||||
extern int netdev_boot_setup_check(struct net_device *dev);
|
||||
extern unsigned long netdev_boot_base(const char *prefix, int unit);
|
||||
extern struct net_device *dev_getbyhwaddr(unsigned short type, char *hwaddr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue