forked from Minki/linux
[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
@ -107,7 +107,7 @@ static void appldata_get_net_sum_data(void *data)
|
|||||||
tx_dropped = 0;
|
tx_dropped = 0;
|
||||||
collisions = 0;
|
collisions = 0;
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for (dev = dev_base; dev != NULL; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
stats = dev->get_stats(dev);
|
stats = dev->get_stats(dev);
|
||||||
rx_packets += stats->rx_packets;
|
rx_packets += stats->rx_packets;
|
||||||
tx_packets += stats->tx_packets;
|
tx_packets += stats->tx_packets;
|
||||||
|
@ -686,7 +686,8 @@ static inline int solaris_i(unsigned int fd, unsigned int cmd, u32 arg)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
read_lock_bh(&dev_base_lock);
|
read_lock_bh(&dev_base_lock);
|
||||||
for (d = dev_base; d; d = d->next) i++;
|
for_each_netdev(d)
|
||||||
|
i++;
|
||||||
read_unlock_bh(&dev_base_lock);
|
read_unlock_bh(&dev_base_lock);
|
||||||
|
|
||||||
if (put_user (i, (int __user *)A(arg)))
|
if (put_user (i, (int __user *)A(arg)))
|
||||||
|
@ -194,15 +194,15 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
|
|||||||
sl = sl_tail = NULL;
|
sl = sl_tail = NULL;
|
||||||
|
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for (ifp = dev_base; ifp; dev_put(ifp), ifp = ifp->next) {
|
for_each_netdev(ifp) {
|
||||||
dev_hold(ifp);
|
dev_hold(ifp);
|
||||||
if (!is_aoe_netif(ifp))
|
if (!is_aoe_netif(ifp))
|
||||||
continue;
|
goto cont;
|
||||||
|
|
||||||
skb = new_skb(sizeof *h + sizeof *ch);
|
skb = new_skb(sizeof *h + sizeof *ch);
|
||||||
if (skb == NULL) {
|
if (skb == NULL) {
|
||||||
printk(KERN_INFO "aoe: skb alloc failure\n");
|
printk(KERN_INFO "aoe: skb alloc failure\n");
|
||||||
continue;
|
goto cont;
|
||||||
}
|
}
|
||||||
skb_put(skb, sizeof *h + sizeof *ch);
|
skb_put(skb, sizeof *h + sizeof *ch);
|
||||||
skb->dev = ifp;
|
skb->dev = ifp;
|
||||||
@ -221,6 +221,8 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
|
|||||||
|
|
||||||
skb->next = sl;
|
skb->next = sl;
|
||||||
sl = skb;
|
sl = skb;
|
||||||
|
cont:
|
||||||
|
dev_put(ifp);
|
||||||
}
|
}
|
||||||
read_unlock(&dev_base_lock);
|
read_unlock(&dev_base_lock);
|
||||||
|
|
||||||
|
@ -1971,8 +1971,7 @@ static struct net_device *get_strip_dev(struct strip *strip_info)
|
|||||||
sizeof(zero_address))) {
|
sizeof(zero_address))) {
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
read_lock_bh(&dev_base_lock);
|
read_lock_bh(&dev_base_lock);
|
||||||
dev = dev_base;
|
for_each_netdev(dev) {
|
||||||
while (dev) {
|
|
||||||
if (dev->type == strip_info->dev->type &&
|
if (dev->type == strip_info->dev->type &&
|
||||||
!memcmp(dev->dev_addr,
|
!memcmp(dev->dev_addr,
|
||||||
&strip_info->true_dev_addr,
|
&strip_info->true_dev_addr,
|
||||||
@ -1983,7 +1982,6 @@ static struct net_device *get_strip_dev(struct strip *strip_info)
|
|||||||
read_unlock_bh(&dev_base_lock);
|
read_unlock_bh(&dev_base_lock);
|
||||||
return (dev);
|
return (dev);
|
||||||
}
|
}
|
||||||
dev = dev->next;
|
|
||||||
}
|
}
|
||||||
read_unlock_bh(&dev_base_lock);
|
read_unlock_bh(&dev_base_lock);
|
||||||
}
|
}
|
||||||
|
@ -365,7 +365,7 @@ static __inline__ int led_get_net_activity(void)
|
|||||||
* for reading should be OK */
|
* for reading should be OK */
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
for (dev = dev_base; dev; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
struct net_device_stats *stats;
|
struct net_device_stats *stats;
|
||||||
struct in_device *in_dev = __in_dev_get_rcu(dev);
|
struct in_device *in_dev = __in_dev_get_rcu(dev);
|
||||||
if (!in_dev || !in_dev->ifa_list)
|
if (!in_dev || !in_dev->ifa_list)
|
||||||
|
@ -47,7 +47,7 @@ int afs_get_ipv4_interfaces(struct afs_interface *bufs, size_t maxbufs,
|
|||||||
ASSERT(maxbufs > 0);
|
ASSERT(maxbufs > 0);
|
||||||
|
|
||||||
rtnl_lock();
|
rtnl_lock();
|
||||||
for (dev = dev_base; dev; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
if (dev->type == ARPHRD_LOOPBACK && !wantloopback)
|
if (dev->type == ARPHRD_LOOPBACK && !wantloopback)
|
||||||
continue;
|
continue;
|
||||||
idev = __in_dev_get_rtnl(dev);
|
idev = __in_dev_get_rtnl(dev);
|
||||||
|
@ -304,7 +304,7 @@ struct net_device
|
|||||||
|
|
||||||
unsigned long state;
|
unsigned long state;
|
||||||
|
|
||||||
struct net_device *next;
|
struct list_head dev_list;
|
||||||
|
|
||||||
/* The device initialization function. Called only once. */
|
/* The device initialization function. Called only once. */
|
||||||
int (*init)(struct net_device *dev);
|
int (*init)(struct net_device *dev);
|
||||||
@ -575,9 +575,31 @@ struct packet_type {
|
|||||||
#include <linux/notifier.h>
|
#include <linux/notifier.h>
|
||||||
|
|
||||||
extern struct net_device loopback_dev; /* The loopback */
|
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 */
|
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 int netdev_boot_setup_check(struct net_device *dev);
|
||||||
extern unsigned long netdev_boot_base(const char *prefix, int unit);
|
extern unsigned long netdev_boot_base(const char *prefix, int unit);
|
||||||
extern struct net_device *dev_getbyhwaddr(unsigned short type, char *hwaddr);
|
extern struct net_device *dev_getbyhwaddr(unsigned short type, char *hwaddr);
|
||||||
|
@ -117,8 +117,7 @@ static void __exit vlan_cleanup_devices(void)
|
|||||||
struct net_device *dev, *nxt;
|
struct net_device *dev, *nxt;
|
||||||
|
|
||||||
rtnl_lock();
|
rtnl_lock();
|
||||||
for (dev = dev_base; dev; dev = nxt) {
|
for_each_netdev_safe(dev, nxt) {
|
||||||
nxt = dev->next;
|
|
||||||
if (dev->priv_flags & IFF_802_1Q_VLAN) {
|
if (dev->priv_flags & IFF_802_1Q_VLAN) {
|
||||||
unregister_vlan_dev(VLAN_DEV_INFO(dev)->real_dev,
|
unregister_vlan_dev(VLAN_DEV_INFO(dev)->real_dev,
|
||||||
VLAN_DEV_INFO(dev)->vlan_id);
|
VLAN_DEV_INFO(dev)->vlan_id);
|
||||||
|
@ -237,13 +237,9 @@ int vlan_proc_rem_dev(struct net_device *vlandev)
|
|||||||
* The following few functions build the content of /proc/net/vlan/config
|
* The following few functions build the content of /proc/net/vlan/config
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* starting at dev, find a VLAN device */
|
static inline int is_vlan_dev(struct net_device *dev)
|
||||||
static struct net_device *vlan_skip(struct net_device *dev)
|
|
||||||
{
|
{
|
||||||
while (dev && !(dev->priv_flags & IFF_802_1Q_VLAN))
|
return dev->priv_flags & IFF_802_1Q_VLAN;
|
||||||
dev = dev->next;
|
|
||||||
|
|
||||||
return dev;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* start read of /proc/net/vlan/config */
|
/* start read of /proc/net/vlan/config */
|
||||||
@ -257,19 +253,35 @@ static void *vlan_seq_start(struct seq_file *seq, loff_t *pos)
|
|||||||
if (*pos == 0)
|
if (*pos == 0)
|
||||||
return SEQ_START_TOKEN;
|
return SEQ_START_TOKEN;
|
||||||
|
|
||||||
for (dev = vlan_skip(dev_base); dev && i < *pos;
|
for_each_netdev(dev) {
|
||||||
dev = vlan_skip(dev->next), ++i);
|
if (!is_vlan_dev(dev))
|
||||||
|
continue;
|
||||||
|
|
||||||
return (i == *pos) ? dev : NULL;
|
if (i++ == *pos)
|
||||||
|
return dev;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
static void *vlan_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
||||||
{
|
{
|
||||||
|
struct net_device *dev;
|
||||||
|
|
||||||
++*pos;
|
++*pos;
|
||||||
|
|
||||||
return vlan_skip((v == SEQ_START_TOKEN)
|
dev = (struct net_device *)v;
|
||||||
? dev_base
|
if (v == SEQ_START_TOKEN)
|
||||||
: ((struct net_device *)v)->next);
|
dev = net_device_entry(&dev_base_head);
|
||||||
|
|
||||||
|
for_each_netdev_continue(dev) {
|
||||||
|
if (!is_vlan_dev(dev))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return dev;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vlan_seq_stop(struct seq_file *seq, void *v)
|
static void vlan_seq_stop(struct seq_file *seq, void *v)
|
||||||
|
@ -475,11 +475,9 @@ void __exit br_cleanup_bridges(void)
|
|||||||
struct net_device *dev, *nxt;
|
struct net_device *dev, *nxt;
|
||||||
|
|
||||||
rtnl_lock();
|
rtnl_lock();
|
||||||
for (dev = dev_base; dev; dev = nxt) {
|
for_each_netdev_safe(dev, nxt)
|
||||||
nxt = dev->next;
|
|
||||||
if (dev->priv_flags & IFF_EBRIDGE)
|
if (dev->priv_flags & IFF_EBRIDGE)
|
||||||
del_br(dev->priv);
|
del_br(dev->priv);
|
||||||
}
|
|
||||||
rtnl_unlock();
|
rtnl_unlock();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,9 @@ static int get_bridge_ifindices(int *indices, int num)
|
|||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (dev = dev_base; dev && i < num; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
|
if (i >= num)
|
||||||
|
break;
|
||||||
if (dev->priv_flags & IFF_EBRIDGE)
|
if (dev->priv_flags & IFF_EBRIDGE)
|
||||||
indices[i++] = dev->ifindex;
|
indices[i++] = dev->ifindex;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,8 @@ static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
for (dev = dev_base, idx = 0; dev; dev = dev->next) {
|
idx = 0;
|
||||||
|
for_each_netdev(dev) {
|
||||||
/* not a bridge port */
|
/* not a bridge port */
|
||||||
if (dev->br_port == NULL || idx < cb->args[0])
|
if (dev->br_port == NULL || idx < cb->args[0])
|
||||||
goto skip;
|
goto skip;
|
||||||
|
@ -156,13 +156,13 @@ static spinlock_t net_dma_event_lock;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The @dev_base list is protected by @dev_base_lock and the rtnl
|
* The @dev_base_head list is protected by @dev_base_lock and the rtnl
|
||||||
* semaphore.
|
* semaphore.
|
||||||
*
|
*
|
||||||
* Pure readers hold dev_base_lock for reading.
|
* Pure readers hold dev_base_lock for reading.
|
||||||
*
|
*
|
||||||
* Writers must hold the rtnl semaphore while they loop through the
|
* Writers must hold the rtnl semaphore while they loop through the
|
||||||
* dev_base list, and hold dev_base_lock for writing when they do the
|
* dev_base_head list, and hold dev_base_lock for writing when they do the
|
||||||
* actual updates. This allows pure readers to access the list even
|
* actual updates. This allows pure readers to access the list even
|
||||||
* while a writer is preparing to update it.
|
* while a writer is preparing to update it.
|
||||||
*
|
*
|
||||||
@ -174,11 +174,10 @@ static spinlock_t net_dma_event_lock;
|
|||||||
* unregister_netdevice(), which must be called with the rtnl
|
* unregister_netdevice(), which must be called with the rtnl
|
||||||
* semaphore held.
|
* semaphore held.
|
||||||
*/
|
*/
|
||||||
struct net_device *dev_base;
|
LIST_HEAD(dev_base_head);
|
||||||
static struct net_device **dev_tail = &dev_base;
|
|
||||||
DEFINE_RWLOCK(dev_base_lock);
|
DEFINE_RWLOCK(dev_base_lock);
|
||||||
|
|
||||||
EXPORT_SYMBOL(dev_base);
|
EXPORT_SYMBOL(dev_base_head);
|
||||||
EXPORT_SYMBOL(dev_base_lock);
|
EXPORT_SYMBOL(dev_base_lock);
|
||||||
|
|
||||||
#define NETDEV_HASHBITS 8
|
#define NETDEV_HASHBITS 8
|
||||||
@ -567,11 +566,12 @@ struct net_device *dev_getbyhwaddr(unsigned short type, char *ha)
|
|||||||
|
|
||||||
ASSERT_RTNL();
|
ASSERT_RTNL();
|
||||||
|
|
||||||
for (dev = dev_base; dev; dev = dev->next)
|
for_each_netdev(dev)
|
||||||
if (dev->type == type &&
|
if (dev->type == type &&
|
||||||
!memcmp(dev->dev_addr, ha, dev->addr_len))
|
!memcmp(dev->dev_addr, ha, dev->addr_len))
|
||||||
break;
|
|
||||||
return dev;
|
return dev;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(dev_getbyhwaddr);
|
EXPORT_SYMBOL(dev_getbyhwaddr);
|
||||||
@ -581,11 +581,11 @@ struct net_device *__dev_getfirstbyhwtype(unsigned short type)
|
|||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
|
|
||||||
ASSERT_RTNL();
|
ASSERT_RTNL();
|
||||||
for (dev = dev_base; dev; dev = dev->next) {
|
for_each_netdev(dev)
|
||||||
if (dev->type == type)
|
if (dev->type == type)
|
||||||
break;
|
|
||||||
}
|
|
||||||
return dev;
|
return dev;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(__dev_getfirstbyhwtype);
|
EXPORT_SYMBOL(__dev_getfirstbyhwtype);
|
||||||
@ -617,17 +617,19 @@ EXPORT_SYMBOL(dev_getfirstbyhwtype);
|
|||||||
|
|
||||||
struct net_device * dev_get_by_flags(unsigned short if_flags, unsigned short mask)
|
struct net_device * dev_get_by_flags(unsigned short if_flags, unsigned short mask)
|
||||||
{
|
{
|
||||||
struct net_device *dev;
|
struct net_device *dev, *ret;
|
||||||
|
|
||||||
|
ret = NULL;
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for (dev = dev_base; dev != NULL; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
if (((dev->flags ^ if_flags) & mask) == 0) {
|
if (((dev->flags ^ if_flags) & mask) == 0) {
|
||||||
dev_hold(dev);
|
dev_hold(dev);
|
||||||
|
ret = dev;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
read_unlock(&dev_base_lock);
|
read_unlock(&dev_base_lock);
|
||||||
return dev;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -693,7 +695,7 @@ int dev_alloc_name(struct net_device *dev, const char *name)
|
|||||||
if (!inuse)
|
if (!inuse)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
for (d = dev_base; d; d = d->next) {
|
for_each_netdev(d) {
|
||||||
if (!sscanf(d->name, name, &i))
|
if (!sscanf(d->name, name, &i))
|
||||||
continue;
|
continue;
|
||||||
if (i < 0 || i >= max_netdevices)
|
if (i < 0 || i >= max_netdevices)
|
||||||
@ -975,7 +977,7 @@ int register_netdevice_notifier(struct notifier_block *nb)
|
|||||||
rtnl_lock();
|
rtnl_lock();
|
||||||
err = raw_notifier_chain_register(&netdev_chain, nb);
|
err = raw_notifier_chain_register(&netdev_chain, nb);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
for (dev = dev_base; dev; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
nb->notifier_call(nb, NETDEV_REGISTER, dev);
|
nb->notifier_call(nb, NETDEV_REGISTER, dev);
|
||||||
|
|
||||||
if (dev->flags & IFF_UP)
|
if (dev->flags & IFF_UP)
|
||||||
@ -2049,7 +2051,7 @@ static int dev_ifconf(char __user *arg)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
total = 0;
|
total = 0;
|
||||||
for (dev = dev_base; dev; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
for (i = 0; i < NPROTO; i++) {
|
for (i = 0; i < NPROTO; i++) {
|
||||||
if (gifconf_list[i]) {
|
if (gifconf_list[i]) {
|
||||||
int done;
|
int done;
|
||||||
@ -2081,26 +2083,28 @@ static int dev_ifconf(char __user *arg)
|
|||||||
* This is invoked by the /proc filesystem handler to display a device
|
* This is invoked by the /proc filesystem handler to display a device
|
||||||
* in detail.
|
* in detail.
|
||||||
*/
|
*/
|
||||||
static struct net_device *dev_get_idx(loff_t pos)
|
|
||||||
{
|
|
||||||
struct net_device *dev;
|
|
||||||
loff_t i;
|
|
||||||
|
|
||||||
for (i = 0, dev = dev_base; dev && i < pos; ++i, dev = dev->next);
|
|
||||||
|
|
||||||
return i == pos ? dev : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *dev_seq_start(struct seq_file *seq, loff_t *pos)
|
void *dev_seq_start(struct seq_file *seq, loff_t *pos)
|
||||||
{
|
{
|
||||||
|
loff_t off;
|
||||||
|
struct net_device *dev;
|
||||||
|
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
return *pos ? dev_get_idx(*pos - 1) : SEQ_START_TOKEN;
|
if (!*pos)
|
||||||
|
return SEQ_START_TOKEN;
|
||||||
|
|
||||||
|
off = 1;
|
||||||
|
for_each_netdev(dev)
|
||||||
|
if (off++ == *pos)
|
||||||
|
return dev;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
void *dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
||||||
{
|
{
|
||||||
++*pos;
|
++*pos;
|
||||||
return v == SEQ_START_TOKEN ? dev_base : ((struct net_device *)v)->next;
|
return v == SEQ_START_TOKEN ?
|
||||||
|
first_net_device() : next_net_device((struct net_device *)v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dev_seq_stop(struct seq_file *seq, void *v)
|
void dev_seq_stop(struct seq_file *seq, void *v)
|
||||||
@ -3082,11 +3086,9 @@ int register_netdevice(struct net_device *dev)
|
|||||||
|
|
||||||
set_bit(__LINK_STATE_PRESENT, &dev->state);
|
set_bit(__LINK_STATE_PRESENT, &dev->state);
|
||||||
|
|
||||||
dev->next = NULL;
|
|
||||||
dev_init_scheduler(dev);
|
dev_init_scheduler(dev);
|
||||||
write_lock_bh(&dev_base_lock);
|
write_lock_bh(&dev_base_lock);
|
||||||
*dev_tail = dev;
|
list_add_tail(&dev->dev_list, &dev_base_head);
|
||||||
dev_tail = &dev->next;
|
|
||||||
hlist_add_head(&dev->name_hlist, head);
|
hlist_add_head(&dev->name_hlist, head);
|
||||||
hlist_add_head(&dev->index_hlist, dev_index_hash(dev->ifindex));
|
hlist_add_head(&dev->index_hlist, dev_index_hash(dev->ifindex));
|
||||||
dev_hold(dev);
|
dev_hold(dev);
|
||||||
@ -3360,8 +3362,6 @@ void synchronize_net(void)
|
|||||||
|
|
||||||
void unregister_netdevice(struct net_device *dev)
|
void unregister_netdevice(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct net_device *d, **dp;
|
|
||||||
|
|
||||||
BUG_ON(dev_boot_phase);
|
BUG_ON(dev_boot_phase);
|
||||||
ASSERT_RTNL();
|
ASSERT_RTNL();
|
||||||
|
|
||||||
@ -3381,19 +3381,11 @@ void unregister_netdevice(struct net_device *dev)
|
|||||||
dev_close(dev);
|
dev_close(dev);
|
||||||
|
|
||||||
/* And unlink it from device chain. */
|
/* And unlink it from device chain. */
|
||||||
for (dp = &dev_base; (d = *dp) != NULL; dp = &d->next) {
|
|
||||||
if (d == dev) {
|
|
||||||
write_lock_bh(&dev_base_lock);
|
write_lock_bh(&dev_base_lock);
|
||||||
|
list_del(&dev->dev_list);
|
||||||
hlist_del(&dev->name_hlist);
|
hlist_del(&dev->name_hlist);
|
||||||
hlist_del(&dev->index_hlist);
|
hlist_del(&dev->index_hlist);
|
||||||
if (dev_tail == &dev->next)
|
|
||||||
dev_tail = dp;
|
|
||||||
*dp = d->next;
|
|
||||||
write_unlock_bh(&dev_base_lock);
|
write_unlock_bh(&dev_base_lock);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BUG_ON(!d);
|
|
||||||
|
|
||||||
dev->reg_state = NETREG_UNREGISTERING;
|
dev->reg_state = NETREG_UNREGISTERING;
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos)
|
|||||||
loff_t off = 0;
|
loff_t off = 0;
|
||||||
|
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for (dev = dev_base; dev; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
if (off++ == *pos)
|
if (off++ == *pos)
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
@ -232,9 +232,8 @@ static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos)
|
|||||||
|
|
||||||
static void *dev_mc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
static void *dev_mc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
||||||
{
|
{
|
||||||
struct net_device *dev = v;
|
|
||||||
++*pos;
|
++*pos;
|
||||||
return dev->next;
|
return next_net_device((struct net_device *)v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dev_mc_seq_stop(struct seq_file *seq, void *v)
|
static void dev_mc_seq_stop(struct seq_file *seq, void *v)
|
||||||
|
@ -539,13 +539,16 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
int s_idx = cb->args[0];
|
int s_idx = cb->args[0];
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
|
|
||||||
for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
|
idx = 0;
|
||||||
|
for_each_netdev(dev) {
|
||||||
if (idx < s_idx)
|
if (idx < s_idx)
|
||||||
continue;
|
goto cont;
|
||||||
if (rtnl_fill_ifinfo(skb, dev, NULL, 0, RTM_NEWLINK,
|
if (rtnl_fill_ifinfo(skb, dev, NULL, 0, RTM_NEWLINK,
|
||||||
NETLINK_CB(cb->skb).pid,
|
NETLINK_CB(cb->skb).pid,
|
||||||
cb->nlh->nlmsg_seq, 0, NLM_F_MULTI) <= 0)
|
cb->nlh->nlmsg_seq, 0, NLM_F_MULTI) <= 0)
|
||||||
break;
|
break;
|
||||||
|
cont:
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
cb->args[0] = idx;
|
cb->args[0] = idx;
|
||||||
|
|
||||||
|
@ -721,7 +721,7 @@ static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
|
|||||||
struct sock *sk = sock->sk;
|
struct sock *sk = sock->sk;
|
||||||
struct dn_scp *scp = DN_SK(sk);
|
struct dn_scp *scp = DN_SK(sk);
|
||||||
struct sockaddr_dn *saddr = (struct sockaddr_dn *)uaddr;
|
struct sockaddr_dn *saddr = (struct sockaddr_dn *)uaddr;
|
||||||
struct net_device *dev;
|
struct net_device *dev, *ldev;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
if (addr_len != sizeof(struct sockaddr_dn))
|
if (addr_len != sizeof(struct sockaddr_dn))
|
||||||
@ -746,14 +746,17 @@ static int dn_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
|
|||||||
if (!(saddr->sdn_flags & SDF_WILD)) {
|
if (!(saddr->sdn_flags & SDF_WILD)) {
|
||||||
if (dn_ntohs(saddr->sdn_nodeaddrl)) {
|
if (dn_ntohs(saddr->sdn_nodeaddrl)) {
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for(dev = dev_base; dev; dev = dev->next) {
|
ldev = NULL;
|
||||||
|
for_each_netdev(dev) {
|
||||||
if (!dev->dn_ptr)
|
if (!dev->dn_ptr)
|
||||||
continue;
|
continue;
|
||||||
if (dn_dev_islocal(dev, dn_saddr2dn(saddr)))
|
if (dn_dev_islocal(dev, dn_saddr2dn(saddr))) {
|
||||||
|
ldev = dev;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
read_unlock(&dev_base_lock);
|
read_unlock(&dev_base_lock);
|
||||||
if (dev == NULL)
|
if (ldev == NULL)
|
||||||
return -EADDRNOTAVAIL;
|
return -EADDRNOTAVAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -799,9 +799,10 @@ static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
skip_ndevs = cb->args[0];
|
skip_ndevs = cb->args[0];
|
||||||
skip_naddr = cb->args[1];
|
skip_naddr = cb->args[1];
|
||||||
|
|
||||||
for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) {
|
idx = 0;
|
||||||
|
for_each_netdev(dev) {
|
||||||
if (idx < skip_ndevs)
|
if (idx < skip_ndevs)
|
||||||
continue;
|
goto cont;
|
||||||
else if (idx > skip_ndevs) {
|
else if (idx > skip_ndevs) {
|
||||||
/* Only skip over addresses for first dev dumped
|
/* Only skip over addresses for first dev dumped
|
||||||
* in this iteration (idx == skip_ndevs) */
|
* in this iteration (idx == skip_ndevs) */
|
||||||
@ -809,18 +810,20 @@ static int dn_nl_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((dn_db = dev->dn_ptr) == NULL)
|
if ((dn_db = dev->dn_ptr) == NULL)
|
||||||
continue;
|
goto cont;
|
||||||
|
|
||||||
for (ifa = dn_db->ifa_list, dn_idx = 0; ifa;
|
for (ifa = dn_db->ifa_list, dn_idx = 0; ifa;
|
||||||
ifa = ifa->ifa_next, dn_idx++) {
|
ifa = ifa->ifa_next, dn_idx++) {
|
||||||
if (dn_idx < skip_naddr)
|
if (dn_idx < skip_naddr)
|
||||||
continue;
|
goto cont;
|
||||||
|
|
||||||
if (dn_nl_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
|
if (dn_nl_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
|
||||||
cb->nlh->nlmsg_seq, RTM_NEWADDR,
|
cb->nlh->nlmsg_seq, RTM_NEWADDR,
|
||||||
NLM_F_MULTI) < 0)
|
NLM_F_MULTI) < 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
cont:
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
cb->args[0] = idx;
|
cb->args[0] = idx;
|
||||||
@ -1296,7 +1299,7 @@ void dn_dev_devices_off(void)
|
|||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
|
|
||||||
rtnl_lock();
|
rtnl_lock();
|
||||||
for(dev = dev_base; dev; dev = dev->next)
|
for_each_netdev(dev)
|
||||||
dn_dev_down(dev);
|
dn_dev_down(dev);
|
||||||
rtnl_unlock();
|
rtnl_unlock();
|
||||||
|
|
||||||
@ -1307,7 +1310,7 @@ void dn_dev_devices_on(void)
|
|||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
|
|
||||||
rtnl_lock();
|
rtnl_lock();
|
||||||
for(dev = dev_base; dev; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
if (dev->flags & IFF_UP)
|
if (dev->flags & IFF_UP)
|
||||||
dn_dev_up(dev);
|
dn_dev_up(dev);
|
||||||
}
|
}
|
||||||
@ -1325,61 +1328,55 @@ int unregister_dnaddr_notifier(struct notifier_block *nb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
static inline struct net_device *dn_dev_get_next(struct seq_file *seq, struct net_device *dev)
|
static inline int is_dn_dev(struct net_device *dev)
|
||||||
{
|
{
|
||||||
do {
|
return dev->dn_ptr != NULL;
|
||||||
dev = dev->next;
|
|
||||||
} while(dev && !dev->dn_ptr);
|
|
||||||
|
|
||||||
return dev;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct net_device *dn_dev_get_idx(struct seq_file *seq, loff_t pos)
|
|
||||||
{
|
|
||||||
struct net_device *dev;
|
|
||||||
|
|
||||||
dev = dev_base;
|
|
||||||
if (dev && !dev->dn_ptr)
|
|
||||||
dev = dn_dev_get_next(seq, dev);
|
|
||||||
if (pos) {
|
|
||||||
while(dev && (dev = dn_dev_get_next(seq, dev)))
|
|
||||||
--pos;
|
|
||||||
}
|
|
||||||
return dev;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *dn_dev_seq_start(struct seq_file *seq, loff_t *pos)
|
static void *dn_dev_seq_start(struct seq_file *seq, loff_t *pos)
|
||||||
{
|
{
|
||||||
if (*pos) {
|
int i;
|
||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
|
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
dev = dn_dev_get_idx(seq, *pos - 1);
|
|
||||||
if (dev == NULL)
|
if (*pos == 0)
|
||||||
read_unlock(&dev_base_lock);
|
return SEQ_START_TOKEN;
|
||||||
|
|
||||||
|
i = 1;
|
||||||
|
for_each_netdev(dev) {
|
||||||
|
if (!is_dn_dev(dev))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (i++ == *pos)
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
return SEQ_START_TOKEN;
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *dn_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
static void *dn_dev_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
||||||
{
|
{
|
||||||
struct net_device *dev = v;
|
struct net_device *dev;
|
||||||
loff_t one = 1;
|
|
||||||
|
|
||||||
if (v == SEQ_START_TOKEN) {
|
|
||||||
dev = dn_dev_seq_start(seq, &one);
|
|
||||||
} else {
|
|
||||||
dev = dn_dev_get_next(seq, dev);
|
|
||||||
if (dev == NULL)
|
|
||||||
read_unlock(&dev_base_lock);
|
|
||||||
}
|
|
||||||
++*pos;
|
++*pos;
|
||||||
|
|
||||||
|
dev = (struct net_device *)v;
|
||||||
|
if (v == SEQ_START_TOKEN)
|
||||||
|
dev = net_device_entry(&dev_base_head);
|
||||||
|
|
||||||
|
for_each_netdev_continue(dev) {
|
||||||
|
if (!is_dn_dev(dev))
|
||||||
|
continue;
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dn_dev_seq_stop(struct seq_file *seq, void *v)
|
static void dn_dev_seq_stop(struct seq_file *seq, void *v)
|
||||||
{
|
{
|
||||||
if (v && v != SEQ_START_TOKEN)
|
|
||||||
read_unlock(&dev_base_lock);
|
read_unlock(&dev_base_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,7 +602,7 @@ static void dn_fib_del_ifaddr(struct dn_ifaddr *ifa)
|
|||||||
|
|
||||||
/* Scan device list */
|
/* Scan device list */
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for(dev = dev_base; dev; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
dn_db = dev->dn_ptr;
|
dn_db = dev->dn_ptr;
|
||||||
if (dn_db == NULL)
|
if (dn_db == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
@ -886,7 +886,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
|
|||||||
.iif = loopback_dev.ifindex,
|
.iif = loopback_dev.ifindex,
|
||||||
.oif = oldflp->oif };
|
.oif = oldflp->oif };
|
||||||
struct dn_route *rt = NULL;
|
struct dn_route *rt = NULL;
|
||||||
struct net_device *dev_out = NULL;
|
struct net_device *dev_out = NULL, *dev;
|
||||||
struct neighbour *neigh = NULL;
|
struct neighbour *neigh = NULL;
|
||||||
unsigned hash;
|
unsigned hash;
|
||||||
unsigned flags = 0;
|
unsigned flags = 0;
|
||||||
@ -925,15 +925,17 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowi *old
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for(dev_out = dev_base; dev_out; dev_out = dev_out->next) {
|
for_each_netdev(dev) {
|
||||||
if (!dev_out->dn_ptr)
|
if (!dev->dn_ptr)
|
||||||
continue;
|
continue;
|
||||||
if (!dn_dev_islocal(dev_out, oldflp->fld_src))
|
if (!dn_dev_islocal(dev, oldflp->fld_src))
|
||||||
continue;
|
continue;
|
||||||
if ((dev_out->flags & IFF_LOOPBACK) &&
|
if ((dev->flags & IFF_LOOPBACK) &&
|
||||||
oldflp->fld_dst &&
|
oldflp->fld_dst &&
|
||||||
!dn_dev_islocal(dev_out, oldflp->fld_dst))
|
!dn_dev_islocal(dev, oldflp->fld_dst))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
dev_out = dev;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
read_unlock(&dev_base_lock);
|
read_unlock(&dev_base_lock);
|
||||||
|
@ -910,7 +910,7 @@ no_in_dev:
|
|||||||
*/
|
*/
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
for (dev = dev_base; dev; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
if ((in_dev = __in_dev_get_rcu(dev)) == NULL)
|
if ((in_dev = __in_dev_get_rcu(dev)) == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -989,7 +989,7 @@ __be32 inet_confirm_addr(const struct net_device *dev, __be32 dst, __be32 local,
|
|||||||
|
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
for (dev = dev_base; dev; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
if ((in_dev = __in_dev_get_rcu(dev))) {
|
if ((in_dev = __in_dev_get_rcu(dev))) {
|
||||||
addr = confirm_addr_indev(in_dev, dst, local, scope);
|
addr = confirm_addr_indev(in_dev, dst, local, scope);
|
||||||
if (addr)
|
if (addr)
|
||||||
@ -1182,23 +1182,26 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
int s_ip_idx, s_idx = cb->args[0];
|
int s_ip_idx, s_idx = cb->args[0];
|
||||||
|
|
||||||
s_ip_idx = ip_idx = cb->args[1];
|
s_ip_idx = ip_idx = cb->args[1];
|
||||||
for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) {
|
idx = 0;
|
||||||
|
for_each_netdev(dev) {
|
||||||
if (idx < s_idx)
|
if (idx < s_idx)
|
||||||
continue;
|
goto cont;
|
||||||
if (idx > s_idx)
|
if (idx > s_idx)
|
||||||
s_ip_idx = 0;
|
s_ip_idx = 0;
|
||||||
if ((in_dev = __in_dev_get_rtnl(dev)) == NULL)
|
if ((in_dev = __in_dev_get_rtnl(dev)) == NULL)
|
||||||
continue;
|
goto cont;
|
||||||
|
|
||||||
for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
|
for (ifa = in_dev->ifa_list, ip_idx = 0; ifa;
|
||||||
ifa = ifa->ifa_next, ip_idx++) {
|
ifa = ifa->ifa_next, ip_idx++) {
|
||||||
if (ip_idx < s_ip_idx)
|
if (ip_idx < s_ip_idx)
|
||||||
continue;
|
goto cont;
|
||||||
if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
|
if (inet_fill_ifaddr(skb, ifa, NETLINK_CB(cb->skb).pid,
|
||||||
cb->nlh->nlmsg_seq,
|
cb->nlh->nlmsg_seq,
|
||||||
RTM_NEWADDR, NLM_F_MULTI) <= 0)
|
RTM_NEWADDR, NLM_F_MULTI) <= 0)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
cont:
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
@ -1243,7 +1246,7 @@ void inet_forward_change(void)
|
|||||||
ipv4_devconf_dflt.forwarding = on;
|
ipv4_devconf_dflt.forwarding = on;
|
||||||
|
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for (dev = dev_base; dev; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
struct in_device *in_dev;
|
struct in_device *in_dev;
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
in_dev = __in_dev_get_rcu(dev);
|
in_dev = __in_dev_get_rcu(dev);
|
||||||
|
@ -2288,9 +2288,8 @@ static inline struct ip_mc_list *igmp_mc_get_first(struct seq_file *seq)
|
|||||||
struct ip_mc_list *im = NULL;
|
struct ip_mc_list *im = NULL;
|
||||||
struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq);
|
struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq);
|
||||||
|
|
||||||
for (state->dev = dev_base, state->in_dev = NULL;
|
state->in_dev = NULL;
|
||||||
state->dev;
|
for_each_netdev(state->dev) {
|
||||||
state->dev = state->dev->next) {
|
|
||||||
struct in_device *in_dev;
|
struct in_device *in_dev;
|
||||||
in_dev = in_dev_get(state->dev);
|
in_dev = in_dev_get(state->dev);
|
||||||
if (!in_dev)
|
if (!in_dev)
|
||||||
@ -2316,7 +2315,7 @@ static struct ip_mc_list *igmp_mc_get_next(struct seq_file *seq, struct ip_mc_li
|
|||||||
read_unlock(&state->in_dev->mc_list_lock);
|
read_unlock(&state->in_dev->mc_list_lock);
|
||||||
in_dev_put(state->in_dev);
|
in_dev_put(state->in_dev);
|
||||||
}
|
}
|
||||||
state->dev = state->dev->next;
|
state->dev = next_net_device(state->dev);
|
||||||
if (!state->dev) {
|
if (!state->dev) {
|
||||||
state->in_dev = NULL;
|
state->in_dev = NULL;
|
||||||
break;
|
break;
|
||||||
@ -2450,9 +2449,9 @@ static inline struct ip_sf_list *igmp_mcf_get_first(struct seq_file *seq)
|
|||||||
struct ip_mc_list *im = NULL;
|
struct ip_mc_list *im = NULL;
|
||||||
struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
|
struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
|
||||||
|
|
||||||
for (state->dev = dev_base, state->idev = NULL, state->im = NULL;
|
state->idev = NULL;
|
||||||
state->dev;
|
state->im = NULL;
|
||||||
state->dev = state->dev->next) {
|
for_each_netdev(state->dev) {
|
||||||
struct in_device *idev;
|
struct in_device *idev;
|
||||||
idev = in_dev_get(state->dev);
|
idev = in_dev_get(state->dev);
|
||||||
if (unlikely(idev == NULL))
|
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
|
|||||||
read_unlock(&state->idev->mc_list_lock);
|
read_unlock(&state->idev->mc_list_lock);
|
||||||
in_dev_put(state->idev);
|
in_dev_put(state->idev);
|
||||||
}
|
}
|
||||||
state->dev = state->dev->next;
|
state->dev = next_net_device(state->dev);
|
||||||
if (!state->dev) {
|
if (!state->dev) {
|
||||||
state->idev = NULL;
|
state->idev = NULL;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -192,7 +192,7 @@ static int __init ic_open_devs(void)
|
|||||||
if (dev_change_flags(&loopback_dev, loopback_dev.flags | IFF_UP) < 0)
|
if (dev_change_flags(&loopback_dev, loopback_dev.flags | IFF_UP) < 0)
|
||||||
printk(KERN_ERR "IP-Config: Failed to open %s\n", loopback_dev.name);
|
printk(KERN_ERR "IP-Config: Failed to open %s\n", loopback_dev.name);
|
||||||
|
|
||||||
for (dev = dev_base; dev; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
if (dev == &loopback_dev)
|
if (dev == &loopback_dev)
|
||||||
continue;
|
continue;
|
||||||
if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
|
if (user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
|
||||||
|
@ -449,7 +449,7 @@ static void addrconf_forward_change(void)
|
|||||||
struct inet6_dev *idev;
|
struct inet6_dev *idev;
|
||||||
|
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for (dev=dev_base; dev; dev=dev->next) {
|
for_each_netdev(dev) {
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
idev = __in6_dev_get(dev);
|
idev = __in6_dev_get(dev);
|
||||||
if (idev) {
|
if (idev) {
|
||||||
@ -911,7 +911,7 @@ int ipv6_dev_get_saddr(struct net_device *daddr_dev,
|
|||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
|
|
||||||
for (dev = dev_base; dev; dev=dev->next) {
|
for_each_netdev(dev) {
|
||||||
struct inet6_dev *idev;
|
struct inet6_dev *idev;
|
||||||
struct inet6_ifaddr *ifa;
|
struct inet6_ifaddr *ifa;
|
||||||
|
|
||||||
@ -2064,7 +2064,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (dev = dev_base; dev != NULL; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
struct in_device * in_dev = __in_dev_get_rtnl(dev);
|
struct in_device * in_dev = __in_dev_get_rtnl(dev);
|
||||||
if (in_dev && (dev->flags & IFF_UP)) {
|
if (in_dev && (dev->flags & IFF_UP)) {
|
||||||
struct in_ifaddr * ifa;
|
struct in_ifaddr * ifa;
|
||||||
@ -2225,7 +2225,7 @@ static void ip6_tnl_add_linklocal(struct inet6_dev *idev)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* then try to inherit it from any device */
|
/* then try to inherit it from any device */
|
||||||
for (link_dev = dev_base; link_dev; link_dev = link_dev->next) {
|
for_each_netdev(link_dev) {
|
||||||
if (!ipv6_inherit_linklocal(idev, link_dev))
|
if (!ipv6_inherit_linklocal(idev, link_dev))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -3257,14 +3257,15 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
|
|||||||
s_idx = cb->args[0];
|
s_idx = cb->args[0];
|
||||||
s_ip_idx = ip_idx = cb->args[1];
|
s_ip_idx = ip_idx = cb->args[1];
|
||||||
|
|
||||||
for (dev = dev_base, idx = 0; dev; dev = dev->next, idx++) {
|
idx = 0;
|
||||||
|
for_each_netdev(dev) {
|
||||||
if (idx < s_idx)
|
if (idx < s_idx)
|
||||||
continue;
|
goto cont;
|
||||||
if (idx > s_idx)
|
if (idx > s_idx)
|
||||||
s_ip_idx = 0;
|
s_ip_idx = 0;
|
||||||
ip_idx = 0;
|
ip_idx = 0;
|
||||||
if ((idev = in6_dev_get(dev)) == NULL)
|
if ((idev = in6_dev_get(dev)) == NULL)
|
||||||
continue;
|
goto cont;
|
||||||
read_lock_bh(&idev->lock);
|
read_lock_bh(&idev->lock);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case UNICAST_ADDR:
|
case UNICAST_ADDR:
|
||||||
@ -3311,6 +3312,8 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
|
|||||||
}
|
}
|
||||||
read_unlock_bh(&idev->lock);
|
read_unlock_bh(&idev->lock);
|
||||||
in6_dev_put(idev);
|
in6_dev_put(idev);
|
||||||
|
cont:
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
if (err <= 0) {
|
if (err <= 0) {
|
||||||
@ -3575,16 +3578,19 @@ static int inet6_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
struct inet6_dev *idev;
|
struct inet6_dev *idev;
|
||||||
|
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
|
idx = 0;
|
||||||
|
for_each_netdev(dev) {
|
||||||
if (idx < s_idx)
|
if (idx < s_idx)
|
||||||
continue;
|
goto cont;
|
||||||
if ((idev = in6_dev_get(dev)) == NULL)
|
if ((idev = in6_dev_get(dev)) == NULL)
|
||||||
continue;
|
goto cont;
|
||||||
err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
|
err = inet6_fill_ifinfo(skb, idev, NETLINK_CB(cb->skb).pid,
|
||||||
cb->nlh->nlmsg_seq, RTM_NEWLINK, NLM_F_MULTI);
|
cb->nlh->nlmsg_seq, RTM_NEWLINK, NLM_F_MULTI);
|
||||||
in6_dev_put(idev);
|
in6_dev_put(idev);
|
||||||
if (err <= 0)
|
if (err <= 0)
|
||||||
break;
|
break;
|
||||||
|
cont:
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
read_unlock(&dev_base_lock);
|
read_unlock(&dev_base_lock);
|
||||||
cb->args[0] = idx;
|
cb->args[0] = idx;
|
||||||
@ -4247,7 +4253,7 @@ void __exit addrconf_cleanup(void)
|
|||||||
* clean dev list.
|
* clean dev list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (dev=dev_base; dev; dev=dev->next) {
|
for_each_netdev(dev) {
|
||||||
if ((idev = __in6_dev_get(dev)) == NULL)
|
if ((idev = __in6_dev_get(dev)) == NULL)
|
||||||
continue;
|
continue;
|
||||||
addrconf_ifdown(dev, 1);
|
addrconf_ifdown(dev, 1);
|
||||||
|
@ -423,14 +423,18 @@ static int ipv6_chk_acast_dev(struct net_device *dev, struct in6_addr *addr)
|
|||||||
*/
|
*/
|
||||||
int ipv6_chk_acast_addr(struct net_device *dev, struct in6_addr *addr)
|
int ipv6_chk_acast_addr(struct net_device *dev, struct in6_addr *addr)
|
||||||
{
|
{
|
||||||
|
int found = 0;
|
||||||
|
|
||||||
if (dev)
|
if (dev)
|
||||||
return ipv6_chk_acast_dev(dev, addr);
|
return ipv6_chk_acast_dev(dev, addr);
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for (dev=dev_base; dev; dev=dev->next)
|
for_each_netdev(dev)
|
||||||
if (ipv6_chk_acast_dev(dev, addr))
|
if (ipv6_chk_acast_dev(dev, addr)) {
|
||||||
|
found = 1;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
read_unlock(&dev_base_lock);
|
read_unlock(&dev_base_lock);
|
||||||
return dev != 0;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -447,9 +451,8 @@ static inline struct ifacaddr6 *ac6_get_first(struct seq_file *seq)
|
|||||||
struct ifacaddr6 *im = NULL;
|
struct ifacaddr6 *im = NULL;
|
||||||
struct ac6_iter_state *state = ac6_seq_private(seq);
|
struct ac6_iter_state *state = ac6_seq_private(seq);
|
||||||
|
|
||||||
for (state->dev = dev_base, state->idev = NULL;
|
state->idev = NULL;
|
||||||
state->dev;
|
for_each_netdev(state->dev) {
|
||||||
state->dev = state->dev->next) {
|
|
||||||
struct inet6_dev *idev;
|
struct inet6_dev *idev;
|
||||||
idev = in6_dev_get(state->dev);
|
idev = in6_dev_get(state->dev);
|
||||||
if (!idev)
|
if (!idev)
|
||||||
@ -476,7 +479,7 @@ static struct ifacaddr6 *ac6_get_next(struct seq_file *seq, struct ifacaddr6 *im
|
|||||||
read_unlock_bh(&state->idev->lock);
|
read_unlock_bh(&state->idev->lock);
|
||||||
in6_dev_put(state->idev);
|
in6_dev_put(state->idev);
|
||||||
}
|
}
|
||||||
state->dev = state->dev->next;
|
state->dev = next_net_device(state->dev);
|
||||||
if (!state->dev) {
|
if (!state->dev) {
|
||||||
state->idev = NULL;
|
state->idev = NULL;
|
||||||
break;
|
break;
|
||||||
|
@ -2331,9 +2331,8 @@ static inline struct ifmcaddr6 *igmp6_mc_get_first(struct seq_file *seq)
|
|||||||
struct ifmcaddr6 *im = NULL;
|
struct ifmcaddr6 *im = NULL;
|
||||||
struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq);
|
struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq);
|
||||||
|
|
||||||
for (state->dev = dev_base, state->idev = NULL;
|
state->idev = NULL;
|
||||||
state->dev;
|
for_each_netdev(state->dev) {
|
||||||
state->dev = state->dev->next) {
|
|
||||||
struct inet6_dev *idev;
|
struct inet6_dev *idev;
|
||||||
idev = in6_dev_get(state->dev);
|
idev = in6_dev_get(state->dev);
|
||||||
if (!idev)
|
if (!idev)
|
||||||
@ -2360,7 +2359,7 @@ static struct ifmcaddr6 *igmp6_mc_get_next(struct seq_file *seq, struct ifmcaddr
|
|||||||
read_unlock_bh(&state->idev->lock);
|
read_unlock_bh(&state->idev->lock);
|
||||||
in6_dev_put(state->idev);
|
in6_dev_put(state->idev);
|
||||||
}
|
}
|
||||||
state->dev = state->dev->next;
|
state->dev = next_net_device(state->dev);
|
||||||
if (!state->dev) {
|
if (!state->dev) {
|
||||||
state->idev = NULL;
|
state->idev = NULL;
|
||||||
break;
|
break;
|
||||||
@ -2475,9 +2474,9 @@ static inline struct ip6_sf_list *igmp6_mcf_get_first(struct seq_file *seq)
|
|||||||
struct ifmcaddr6 *im = NULL;
|
struct ifmcaddr6 *im = NULL;
|
||||||
struct igmp6_mcf_iter_state *state = igmp6_mcf_seq_private(seq);
|
struct igmp6_mcf_iter_state *state = igmp6_mcf_seq_private(seq);
|
||||||
|
|
||||||
for (state->dev = dev_base, state->idev = NULL, state->im = NULL;
|
state->idev = NULL;
|
||||||
state->dev;
|
state->im = NULL;
|
||||||
state->dev = state->dev->next) {
|
for_each_netdev(state->dev) {
|
||||||
struct inet6_dev *idev;
|
struct inet6_dev *idev;
|
||||||
idev = in6_dev_get(state->dev);
|
idev = in6_dev_get(state->dev);
|
||||||
if (unlikely(idev == NULL))
|
if (unlikely(idev == NULL))
|
||||||
@ -2513,7 +2512,7 @@ static struct ip6_sf_list *igmp6_mcf_get_next(struct seq_file *seq, struct ip6_s
|
|||||||
read_unlock_bh(&state->idev->lock);
|
read_unlock_bh(&state->idev->lock);
|
||||||
in6_dev_put(state->idev);
|
in6_dev_put(state->idev);
|
||||||
}
|
}
|
||||||
state->dev = state->dev->next;
|
state->dev = next_net_device(state->dev);
|
||||||
if (!state->dev) {
|
if (!state->dev) {
|
||||||
state->idev = NULL;
|
state->idev = NULL;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -160,8 +160,14 @@ static struct packet_type llc_tr_packet_type = {
|
|||||||
|
|
||||||
static int __init llc_init(void)
|
static int __init llc_init(void)
|
||||||
{
|
{
|
||||||
if (dev_base->next)
|
struct net_device *dev;
|
||||||
memcpy(llc_station_mac_sa, dev_base->next->dev_addr, ETH_ALEN);
|
|
||||||
|
dev = first_net_device();
|
||||||
|
if (dev != NULL)
|
||||||
|
dev = next_net_device(dev);
|
||||||
|
|
||||||
|
if (dev != NULL)
|
||||||
|
memcpy(llc_station_mac_sa, dev->dev_addr, ETH_ALEN);
|
||||||
else
|
else
|
||||||
memset(llc_station_mac_sa, 0, ETH_ALEN);
|
memset(llc_station_mac_sa, 0, ETH_ALEN);
|
||||||
dev_add_pack(&llc_packet_type);
|
dev_add_pack(&llc_packet_type);
|
||||||
|
@ -598,7 +598,7 @@ struct net_device *nr_dev_first(void)
|
|||||||
struct net_device *dev, *first = NULL;
|
struct net_device *dev, *first = NULL;
|
||||||
|
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for (dev = dev_base; dev != NULL; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
if ((dev->flags & IFF_UP) && dev->type == ARPHRD_NETROM)
|
if ((dev->flags & IFF_UP) && dev->type == ARPHRD_NETROM)
|
||||||
if (first == NULL || strncmp(dev->name, first->name, 3) < 0)
|
if (first == NULL || strncmp(dev->name, first->name, 3) < 0)
|
||||||
first = dev;
|
first = dev;
|
||||||
@ -618,12 +618,13 @@ struct net_device *nr_dev_get(ax25_address *addr)
|
|||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
|
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for (dev = dev_base; dev != NULL; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
if ((dev->flags & IFF_UP) && dev->type == ARPHRD_NETROM && ax25cmp(addr, (ax25_address *)dev->dev_addr) == 0) {
|
if ((dev->flags & IFF_UP) && dev->type == ARPHRD_NETROM && ax25cmp(addr, (ax25_address *)dev->dev_addr) == 0) {
|
||||||
dev_hold(dev);
|
dev_hold(dev);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dev = NULL;
|
||||||
out:
|
out:
|
||||||
read_unlock(&dev_base_lock);
|
read_unlock(&dev_base_lock);
|
||||||
return dev;
|
return dev;
|
||||||
|
@ -596,7 +596,7 @@ struct net_device *rose_dev_first(void)
|
|||||||
struct net_device *dev, *first = NULL;
|
struct net_device *dev, *first = NULL;
|
||||||
|
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for (dev = dev_base; dev != NULL; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE)
|
if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE)
|
||||||
if (first == NULL || strncmp(dev->name, first->name, 3) < 0)
|
if (first == NULL || strncmp(dev->name, first->name, 3) < 0)
|
||||||
first = dev;
|
first = dev;
|
||||||
@ -614,12 +614,13 @@ struct net_device *rose_dev_get(rose_address *addr)
|
|||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
|
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for (dev = dev_base; dev != NULL; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0) {
|
if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0) {
|
||||||
dev_hold(dev);
|
dev_hold(dev);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dev = NULL;
|
||||||
out:
|
out:
|
||||||
read_unlock(&dev_base_lock);
|
read_unlock(&dev_base_lock);
|
||||||
return dev;
|
return dev;
|
||||||
@ -630,10 +631,11 @@ static int rose_dev_exists(rose_address *addr)
|
|||||||
struct net_device *dev;
|
struct net_device *dev;
|
||||||
|
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for (dev = dev_base; dev != NULL; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0)
|
if ((dev->flags & IFF_UP) && dev->type == ARPHRD_ROSE && rosecmp(addr, (rose_address *)dev->dev_addr) == 0)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
dev = NULL;
|
||||||
out:
|
out:
|
||||||
read_unlock(&dev_base_lock);
|
read_unlock(&dev_base_lock);
|
||||||
return dev != NULL;
|
return dev != NULL;
|
||||||
|
@ -894,9 +894,10 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
s_idx = cb->args[0];
|
s_idx = cb->args[0];
|
||||||
s_q_idx = q_idx = cb->args[1];
|
s_q_idx = q_idx = cb->args[1];
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for (dev=dev_base, idx=0; dev; dev = dev->next, idx++) {
|
idx = 0;
|
||||||
|
for_each_netdev(dev) {
|
||||||
if (idx < s_idx)
|
if (idx < s_idx)
|
||||||
continue;
|
goto cont;
|
||||||
if (idx > s_idx)
|
if (idx > s_idx)
|
||||||
s_q_idx = 0;
|
s_q_idx = 0;
|
||||||
q_idx = 0;
|
q_idx = 0;
|
||||||
@ -910,6 +911,8 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb)
|
|||||||
goto done;
|
goto done;
|
||||||
q_idx++;
|
q_idx++;
|
||||||
}
|
}
|
||||||
|
cont:
|
||||||
|
idx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
@ -170,7 +170,7 @@ static void sctp_get_local_addr_list(void)
|
|||||||
struct sctp_af *af;
|
struct sctp_af *af;
|
||||||
|
|
||||||
read_lock(&dev_base_lock);
|
read_lock(&dev_base_lock);
|
||||||
for (dev = dev_base; dev; dev = dev->next) {
|
for_each_netdev(dev) {
|
||||||
__list_for_each(pos, &sctp_address_families) {
|
__list_for_each(pos, &sctp_address_families) {
|
||||||
af = list_entry(pos, struct sctp_af, list);
|
af = list_entry(pos, struct sctp_af, list);
|
||||||
af->copy_addrlist(&sctp_local_addr_list, dev);
|
af->copy_addrlist(&sctp_local_addr_list, dev);
|
||||||
|
@ -120,15 +120,17 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev,
|
|||||||
|
|
||||||
static int enable_bearer(struct tipc_bearer *tb_ptr)
|
static int enable_bearer(struct tipc_bearer *tb_ptr)
|
||||||
{
|
{
|
||||||
struct net_device *dev = dev_base;
|
struct net_device *dev, *pdev;
|
||||||
struct eth_bearer *eb_ptr = ð_bearers[0];
|
struct eth_bearer *eb_ptr = ð_bearers[0];
|
||||||
struct eth_bearer *stop = ð_bearers[MAX_ETH_BEARERS];
|
struct eth_bearer *stop = ð_bearers[MAX_ETH_BEARERS];
|
||||||
char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1;
|
char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1;
|
||||||
|
|
||||||
/* Find device with specified name */
|
/* Find device with specified name */
|
||||||
|
dev = NULL;
|
||||||
while (dev && dev->name && strncmp(dev->name, driver_name, IFNAMSIZ)) {
|
for_each_netdev(pdev)
|
||||||
dev = dev->next;
|
if (!strncmp(dev->name, driver_name, IFNAMSIZ)) {
|
||||||
|
dev = pdev;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!dev)
|
if (!dev)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
Loading…
Reference in New Issue
Block a user