diff options
author | Holger Eitzenberger <holger@eitzenberger.org> | 2008-12-10 02:07:13 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-12-10 02:07:13 -0500 |
commit | 58402054264fa33b405d1abcbcd8e528507aac1a (patch) | |
tree | a3e4ce7ecdb33402d0810113e339d517b609e0b8 /drivers | |
parent | 512bb43eb5422ee69a1be05ea0d89dc074fac9a2 (diff) |
bonding: add and use bond_is_lb()
Introduce and use bond_is_lb(), it is usefull to shorten the repetitive
check for either ALB or TLB mode.
Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 29 | ||||
-rw-r--r-- | drivers/net/bonding/bonding.h | 6 |
2 files changed, 15 insertions, 20 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index e422dbaa25b4..16cfe9efee7c 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -294,10 +294,8 @@ static int bond_del_vlan(struct bonding *bond, unsigned short vlan_id) | |||
294 | if (vlan->vlan_id == vlan_id) { | 294 | if (vlan->vlan_id == vlan_id) { |
295 | list_del(&vlan->vlan_list); | 295 | list_del(&vlan->vlan_list); |
296 | 296 | ||
297 | if ((bond->params.mode == BOND_MODE_TLB) || | 297 | if (bond_is_lb(bond)) |
298 | (bond->params.mode == BOND_MODE_ALB)) { | ||
299 | bond_alb_clear_vlan(bond, vlan_id); | 298 | bond_alb_clear_vlan(bond, vlan_id); |
300 | } | ||
301 | 299 | ||
302 | dprintk("removed VLAN ID %d from bond %s\n", vlan_id, | 300 | dprintk("removed VLAN ID %d from bond %s\n", vlan_id, |
303 | bond->dev->name); | 301 | bond->dev->name); |
@@ -1174,10 +1172,8 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active) | |||
1174 | bond_3ad_handle_link_change(new_active, BOND_LINK_UP); | 1172 | bond_3ad_handle_link_change(new_active, BOND_LINK_UP); |
1175 | } | 1173 | } |
1176 | 1174 | ||
1177 | if ((bond->params.mode == BOND_MODE_TLB) || | 1175 | if (bond_is_lb(bond)) |
1178 | (bond->params.mode == BOND_MODE_ALB)) { | ||
1179 | bond_alb_handle_link_change(bond, new_active, BOND_LINK_UP); | 1176 | bond_alb_handle_link_change(bond, new_active, BOND_LINK_UP); |
1180 | } | ||
1181 | } else { | 1177 | } else { |
1182 | if (USES_PRIMARY(bond->params.mode)) { | 1178 | if (USES_PRIMARY(bond->params.mode)) { |
1183 | printk(KERN_INFO DRV_NAME | 1179 | printk(KERN_INFO DRV_NAME |
@@ -1192,8 +1188,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active) | |||
1192 | bond_mc_swap(bond, new_active, old_active); | 1188 | bond_mc_swap(bond, new_active, old_active); |
1193 | } | 1189 | } |
1194 | 1190 | ||
1195 | if ((bond->params.mode == BOND_MODE_TLB) || | 1191 | if (bond_is_lb(bond)) { |
1196 | (bond->params.mode == BOND_MODE_ALB)) { | ||
1197 | bond_alb_handle_active_change(bond, new_active); | 1192 | bond_alb_handle_active_change(bond, new_active); |
1198 | if (old_active) | 1193 | if (old_active) |
1199 | bond_set_slave_inactive_flags(old_active); | 1194 | bond_set_slave_inactive_flags(old_active); |
@@ -1554,8 +1549,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1554 | new_slave->dev = slave_dev; | 1549 | new_slave->dev = slave_dev; |
1555 | slave_dev->priv_flags |= IFF_BONDING; | 1550 | slave_dev->priv_flags |= IFF_BONDING; |
1556 | 1551 | ||
1557 | if ((bond->params.mode == BOND_MODE_TLB) || | 1552 | if (bond_is_lb(bond)) { |
1558 | (bond->params.mode == BOND_MODE_ALB)) { | ||
1559 | /* bond_alb_init_slave() must be called before all other stages since | 1553 | /* bond_alb_init_slave() must be called before all other stages since |
1560 | * it might fail and we do not want to have to undo everything | 1554 | * it might fail and we do not want to have to undo everything |
1561 | */ | 1555 | */ |
@@ -1871,8 +1865,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1871 | bond_change_active_slave(bond, NULL); | 1865 | bond_change_active_slave(bond, NULL); |
1872 | } | 1866 | } |
1873 | 1867 | ||
1874 | if ((bond->params.mode == BOND_MODE_TLB) || | 1868 | if (bond_is_lb(bond)) { |
1875 | (bond->params.mode == BOND_MODE_ALB)) { | ||
1876 | /* Must be called only after the slave has been | 1869 | /* Must be called only after the slave has been |
1877 | * detached from the list and the curr_active_slave | 1870 | * detached from the list and the curr_active_slave |
1878 | * has been cleared (if our_slave == old_current), | 1871 | * has been cleared (if our_slave == old_current), |
@@ -2061,8 +2054,7 @@ static int bond_release_all(struct net_device *bond_dev) | |||
2061 | */ | 2054 | */ |
2062 | write_unlock_bh(&bond->lock); | 2055 | write_unlock_bh(&bond->lock); |
2063 | 2056 | ||
2064 | if ((bond->params.mode == BOND_MODE_TLB) || | 2057 | if (bond_is_lb(bond)) { |
2065 | (bond->params.mode == BOND_MODE_ALB)) { | ||
2066 | /* must be called only after the slave | 2058 | /* must be called only after the slave |
2067 | * has been detached from the list | 2059 | * has been detached from the list |
2068 | */ | 2060 | */ |
@@ -2389,8 +2381,7 @@ static void bond_miimon_commit(struct bonding *bond) | |||
2389 | if (bond->params.mode == BOND_MODE_8023AD) | 2381 | if (bond->params.mode == BOND_MODE_8023AD) |
2390 | bond_3ad_handle_link_change(slave, BOND_LINK_UP); | 2382 | bond_3ad_handle_link_change(slave, BOND_LINK_UP); |
2391 | 2383 | ||
2392 | if ((bond->params.mode == BOND_MODE_TLB) || | 2384 | if (bond_is_lb(bond)) |
2393 | (bond->params.mode == BOND_MODE_ALB)) | ||
2394 | bond_alb_handle_link_change(bond, slave, | 2385 | bond_alb_handle_link_change(bond, slave, |
2395 | BOND_LINK_UP); | 2386 | BOND_LINK_UP); |
2396 | 2387 | ||
@@ -3796,8 +3787,7 @@ static int bond_open(struct net_device *bond_dev) | |||
3796 | 3787 | ||
3797 | bond->kill_timers = 0; | 3788 | bond->kill_timers = 0; |
3798 | 3789 | ||
3799 | if ((bond->params.mode == BOND_MODE_TLB) || | 3790 | if (bond_is_lb(bond)) { |
3800 | (bond->params.mode == BOND_MODE_ALB)) { | ||
3801 | /* bond_alb_initialize must be called before the timer | 3791 | /* bond_alb_initialize must be called before the timer |
3802 | * is started. | 3792 | * is started. |
3803 | */ | 3793 | */ |
@@ -3882,8 +3872,7 @@ static int bond_close(struct net_device *bond_dev) | |||
3882 | } | 3872 | } |
3883 | 3873 | ||
3884 | 3874 | ||
3885 | if ((bond->params.mode == BOND_MODE_TLB) || | 3875 | if (bond_is_lb(bond)) { |
3886 | (bond->params.mode == BOND_MODE_ALB)) { | ||
3887 | /* Must be called only after all | 3876 | /* Must be called only after all |
3888 | * slaves have been released | 3877 | * slaves have been released |
3889 | */ | 3878 | */ |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 921abacc6074..b8c2462577b7 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -260,6 +260,12 @@ static inline struct bonding *bond_get_bond_by_slave(struct slave *slave) | |||
260 | return (struct bonding *)netdev_priv(slave->dev->master); | 260 | return (struct bonding *)netdev_priv(slave->dev->master); |
261 | } | 261 | } |
262 | 262 | ||
263 | static inline bool bond_is_lb(const struct bonding *bond) | ||
264 | { | ||
265 | return bond->params.mode == BOND_MODE_TLB | ||
266 | || bond->params.mode == BOND_MODE_ALB; | ||
267 | } | ||
268 | |||
263 | #define BOND_FOM_NONE 0 | 269 | #define BOND_FOM_NONE 0 |
264 | #define BOND_FOM_ACTIVE 1 | 270 | #define BOND_FOM_ACTIVE 1 |
265 | #define BOND_FOM_FOLLOW 2 | 271 | #define BOND_FOM_FOLLOW 2 |