aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_main.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-05-18 00:10:10 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-05-22 06:34:22 -0400
commit0883beca7f39ab0c6447af35080e5caaa07418e3 (patch)
tree160996e2c3483095ec5a1b88cfa975a6f1982533 /drivers/net/bonding/bond_main.c
parent0dd646fe0549251e79d6fb03e6773bcc6ccea61f (diff)
bonding: Relax unneeded _safe lists iterations.
Many places either do not modify the list under the list_for_each_xxx, or break out of the loop as soon as the first element is removed. Thus, this _safe iteration just occupies some unneeded .text space and requires an additional variable. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Acked-by: Jay Vosburgh <fubar@us.ibm.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/bonding/bond_main.c')
-rw-r--r--drivers/net/bonding/bond_main.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 6b1216455bc9..5e3b942fb515 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -261,14 +261,14 @@ static int bond_add_vlan(struct bonding *bond, unsigned short vlan_id)
261 */ 261 */
262static int bond_del_vlan(struct bonding *bond, unsigned short vlan_id) 262static int bond_del_vlan(struct bonding *bond, unsigned short vlan_id)
263{ 263{
264 struct vlan_entry *vlan, *next; 264 struct vlan_entry *vlan;
265 int res = -ENODEV; 265 int res = -ENODEV;
266 266
267 dprintk("bond: %s, vlan id %d\n", bond->dev->name, vlan_id); 267 dprintk("bond: %s, vlan id %d\n", bond->dev->name, vlan_id);
268 268
269 write_lock_bh(&bond->lock); 269 write_lock_bh(&bond->lock);
270 270
271 list_for_each_entry_safe(vlan, next, &bond->vlan_list, vlan_list) { 271 list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
272 if (vlan->vlan_id == vlan_id) { 272 if (vlan->vlan_id == vlan_id) {
273 list_del(&vlan->vlan_list); 273 list_del(&vlan->vlan_list);
274 274
@@ -2428,7 +2428,7 @@ out:
2428 2428
2429static int bond_has_this_ip(struct bonding *bond, __be32 ip) 2429static int bond_has_this_ip(struct bonding *bond, __be32 ip)
2430{ 2430{
2431 struct vlan_entry *vlan, *vlan_next; 2431 struct vlan_entry *vlan;
2432 2432
2433 if (ip == bond->master_ip) 2433 if (ip == bond->master_ip)
2434 return 1; 2434 return 1;
@@ -2436,8 +2436,7 @@ static int bond_has_this_ip(struct bonding *bond, __be32 ip)
2436 if (list_empty(&bond->vlan_list)) 2436 if (list_empty(&bond->vlan_list))
2437 return 0; 2437 return 0;
2438 2438
2439 list_for_each_entry_safe(vlan, vlan_next, &bond->vlan_list, 2439 list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
2440 vlan_list) {
2441 if (ip == vlan->vlan_ip) 2440 if (ip == vlan->vlan_ip)
2442 return 1; 2441 return 1;
2443 } 2442 }
@@ -2479,7 +2478,7 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
2479{ 2478{
2480 int i, vlan_id, rv; 2479 int i, vlan_id, rv;
2481 __be32 *targets = bond->params.arp_targets; 2480 __be32 *targets = bond->params.arp_targets;
2482 struct vlan_entry *vlan, *vlan_next; 2481 struct vlan_entry *vlan;
2483 struct net_device *vlan_dev; 2482 struct net_device *vlan_dev;
2484 struct flowi fl; 2483 struct flowi fl;
2485 struct rtable *rt; 2484 struct rtable *rt;
@@ -2526,8 +2525,7 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
2526 } 2525 }
2527 2526
2528 vlan_id = 0; 2527 vlan_id = 0;
2529 list_for_each_entry_safe(vlan, vlan_next, &bond->vlan_list, 2528 list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
2530 vlan_list) {
2531 vlan_dev = vlan_group_get_device(bond->vlgrp, vlan->vlan_id); 2529 vlan_dev = vlan_group_get_device(bond->vlgrp, vlan->vlan_id);
2532 if (vlan_dev == rt->u.dst.dev) { 2530 if (vlan_dev == rt->u.dst.dev) {
2533 vlan_id = vlan->vlan_id; 2531 vlan_id = vlan->vlan_id;
@@ -3477,13 +3475,13 @@ static int bond_inetaddr_event(struct notifier_block *this, unsigned long event,
3477{ 3475{
3478 struct in_ifaddr *ifa = ptr; 3476 struct in_ifaddr *ifa = ptr;
3479 struct net_device *vlan_dev, *event_dev = ifa->ifa_dev->dev; 3477 struct net_device *vlan_dev, *event_dev = ifa->ifa_dev->dev;
3480 struct bonding *bond, *bond_next; 3478 struct bonding *bond;
3481 struct vlan_entry *vlan, *vlan_next; 3479 struct vlan_entry *vlan;
3482 3480
3483 if (dev_net(ifa->ifa_dev->dev) != &init_net) 3481 if (dev_net(ifa->ifa_dev->dev) != &init_net)
3484 return NOTIFY_DONE; 3482 return NOTIFY_DONE;
3485 3483
3486 list_for_each_entry_safe(bond, bond_next, &bond_dev_list, bond_list) { 3484 list_for_each_entry(bond, &bond_dev_list, bond_list) {
3487 if (bond->dev == event_dev) { 3485 if (bond->dev == event_dev) {
3488 switch (event) { 3486 switch (event) {
3489 case NETDEV_UP: 3487 case NETDEV_UP:
@@ -3500,8 +3498,7 @@ static int bond_inetaddr_event(struct notifier_block *this, unsigned long event,
3500 if (list_empty(&bond->vlan_list)) 3498 if (list_empty(&bond->vlan_list))
3501 continue; 3499 continue;
3502 3500
3503 list_for_each_entry_safe(vlan, vlan_next, &bond->vlan_list, 3501 list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
3504 vlan_list) {
3505 vlan_dev = vlan_group_get_device(bond->vlgrp, vlan->vlan_id); 3502 vlan_dev = vlan_group_get_device(bond->vlgrp, vlan->vlan_id);
3506 if (vlan_dev == event_dev) { 3503 if (vlan_dev == event_dev) {
3507 switch (event) { 3504 switch (event) {
@@ -4851,7 +4848,7 @@ static struct lock_class_key bonding_netdev_xmit_lock_key;
4851int bond_create(char *name, struct bond_params *params) 4848int bond_create(char *name, struct bond_params *params)
4852{ 4849{
4853 struct net_device *bond_dev; 4850 struct net_device *bond_dev;
4854 struct bonding *bond, *nxt; 4851 struct bonding *bond;
4855 int res; 4852 int res;
4856 4853
4857 rtnl_lock(); 4854 rtnl_lock();
@@ -4859,7 +4856,7 @@ int bond_create(char *name, struct bond_params *params)
4859 4856
4860 /* Check to see if the bond already exists. */ 4857 /* Check to see if the bond already exists. */
4861 if (name) { 4858 if (name) {
4862 list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) 4859 list_for_each_entry(bond, &bond_dev_list, bond_list)
4863 if (strnicmp(bond->dev->name, name, IFNAMSIZ) == 0) { 4860 if (strnicmp(bond->dev->name, name, IFNAMSIZ) == 0) {
4864 printk(KERN_ERR DRV_NAME 4861 printk(KERN_ERR DRV_NAME
4865 ": cannot add bond %s; it already exists\n", 4862 ": cannot add bond %s; it already exists\n",
@@ -4931,7 +4928,7 @@ static int __init bonding_init(void)
4931{ 4928{
4932 int i; 4929 int i;
4933 int res; 4930 int res;
4934 struct bonding *bond, *nxt; 4931 struct bonding *bond;
4935 4932
4936 printk(KERN_INFO "%s", version); 4933 printk(KERN_INFO "%s", version);
4937 4934
@@ -4961,7 +4958,7 @@ static int __init bonding_init(void)
4961 4958
4962 goto out; 4959 goto out;
4963err: 4960err:
4964 list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) { 4961 list_for_each_entry(bond, &bond_dev_list, bond_list) {
4965 bond_work_cancel_all(bond); 4962 bond_work_cancel_all(bond);
4966 destroy_workqueue(bond->wq); 4963 destroy_workqueue(bond->wq);
4967 } 4964 }