Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7562f876 authored by Pavel Emelianov's avatar Pavel Emelianov Committed by David S. Miller
Browse files

[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: default avatarPavel Emelianov <xemul@openvz.org>
Acked-by: default avatarKirill Korotaev <dev@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 03fba047
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ static void appldata_get_net_sum_data(void *data)
	tx_dropped = 0;
	collisions = 0;
	read_lock(&dev_base_lock);
	for (dev = dev_base; dev != NULL; dev = dev->next) {
	for_each_netdev(dev) {
		stats = dev->get_stats(dev);
		rx_packets += stats->rx_packets;
		tx_packets += stats->tx_packets;
+2 −1
Original line number Diff line number Diff line
@@ -686,7 +686,8 @@ static inline int solaris_i(unsigned int fd, unsigned int cmd, u32 arg)
			int i = 0;
			
			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);

			if (put_user (i, (int __user *)A(arg)))
+5 −3
Original line number Diff line number Diff line
@@ -194,15 +194,15 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
	sl = sl_tail = NULL;

	read_lock(&dev_base_lock);
	for (ifp = dev_base; ifp; dev_put(ifp), ifp = ifp->next) {
	for_each_netdev(ifp) {
		dev_hold(ifp);
		if (!is_aoe_netif(ifp))
			continue;
			goto cont;

		skb = new_skb(sizeof *h + sizeof *ch);
		if (skb == NULL) {
			printk(KERN_INFO "aoe: skb alloc failure\n");
			continue;
			goto cont;
		}
		skb_put(skb, sizeof *h + sizeof *ch);
		skb->dev = ifp;
@@ -221,6 +221,8 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)

		skb->next = sl;
		sl = skb;
cont:
		dev_put(ifp);
	}
	read_unlock(&dev_base_lock);

+1 −3
Original line number Diff line number Diff line
@@ -1971,8 +1971,7 @@ static struct net_device *get_strip_dev(struct strip *strip_info)
		      sizeof(zero_address))) {
		struct net_device *dev;
		read_lock_bh(&dev_base_lock);
		dev = dev_base;
		while (dev) {
		for_each_netdev(dev) {
			if (dev->type == strip_info->dev->type &&
			    !memcmp(dev->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);
				return (dev);
			}
			dev = dev->next;
		}
		read_unlock_bh(&dev_base_lock);
	}
+1 −1
Original line number Diff line number Diff line
@@ -365,7 +365,7 @@ static __inline__ int led_get_net_activity(void)
	 * for reading should be OK */
	read_lock(&dev_base_lock);
	rcu_read_lock();
	for (dev = dev_base; dev; dev = dev->next) {
	for_each_netdev(dev) {
	    struct net_device_stats *stats;
	    struct in_device *in_dev = __in_dev_get_rcu(dev);
	    if (!in_dev || !in_dev->ifa_list)
Loading