diff options
Diffstat (limited to 'drivers/net/bonding/bonding.h')
| -rw-r--r-- | drivers/net/bonding/bonding.h | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 86ccfb9f71cc..2b0fdec695f7 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
| @@ -195,7 +195,8 @@ struct slave { | |||
| 195 | s8 new_link; | 195 | s8 new_link; |
| 196 | u8 backup:1, /* indicates backup slave. Value corresponds with | 196 | u8 backup:1, /* indicates backup slave. Value corresponds with |
| 197 | BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ | 197 | BOND_STATE_ACTIVE and BOND_STATE_BACKUP */ |
| 198 | inactive:1; /* indicates inactive slave */ | 198 | inactive:1, /* indicates inactive slave */ |
| 199 | should_notify:1; /* indicateds whether the state changed */ | ||
| 199 | u8 duplex; | 200 | u8 duplex; |
| 200 | u32 original_mtu; | 201 | u32 original_mtu; |
| 201 | u32 link_failure_count; | 202 | u32 link_failure_count; |
| @@ -303,6 +304,24 @@ static inline void bond_set_backup_slave(struct slave *slave) | |||
| 303 | } | 304 | } |
| 304 | } | 305 | } |
| 305 | 306 | ||
| 307 | static inline void bond_set_slave_state(struct slave *slave, | ||
| 308 | int slave_state, bool notify) | ||
| 309 | { | ||
| 310 | if (slave->backup == slave_state) | ||
| 311 | return; | ||
| 312 | |||
| 313 | slave->backup = slave_state; | ||
| 314 | if (notify) { | ||
| 315 | rtmsg_ifinfo(RTM_NEWLINK, slave->dev, 0, GFP_KERNEL); | ||
| 316 | slave->should_notify = 0; | ||
| 317 | } else { | ||
| 318 | if (slave->should_notify) | ||
| 319 | slave->should_notify = 0; | ||
| 320 | else | ||
| 321 | slave->should_notify = 1; | ||
| 322 | } | ||
| 323 | } | ||
| 324 | |||
| 306 | static inline void bond_slave_state_change(struct bonding *bond) | 325 | static inline void bond_slave_state_change(struct bonding *bond) |
| 307 | { | 326 | { |
| 308 | struct list_head *iter; | 327 | struct list_head *iter; |
| @@ -316,6 +335,19 @@ static inline void bond_slave_state_change(struct bonding *bond) | |||
| 316 | } | 335 | } |
| 317 | } | 336 | } |
| 318 | 337 | ||
| 338 | static inline void bond_slave_state_notify(struct bonding *bond) | ||
| 339 | { | ||
| 340 | struct list_head *iter; | ||
| 341 | struct slave *tmp; | ||
| 342 | |||
| 343 | bond_for_each_slave(bond, tmp, iter) { | ||
| 344 | if (tmp->should_notify) { | ||
| 345 | rtmsg_ifinfo(RTM_NEWLINK, tmp->dev, 0, GFP_KERNEL); | ||
| 346 | tmp->should_notify = 0; | ||
| 347 | } | ||
| 348 | } | ||
| 349 | } | ||
| 350 | |||
| 319 | static inline int bond_slave_state(struct slave *slave) | 351 | static inline int bond_slave_state(struct slave *slave) |
| 320 | { | 352 | { |
| 321 | return slave->backup; | 353 | return slave->backup; |
| @@ -343,6 +375,9 @@ static inline bool bond_is_active_slave(struct slave *slave) | |||
| 343 | #define BOND_ARP_VALIDATE_ALL (BOND_ARP_VALIDATE_ACTIVE | \ | 375 | #define BOND_ARP_VALIDATE_ALL (BOND_ARP_VALIDATE_ACTIVE | \ |
| 344 | BOND_ARP_VALIDATE_BACKUP) | 376 | BOND_ARP_VALIDATE_BACKUP) |
| 345 | 377 | ||
| 378 | #define BOND_SLAVE_NOTIFY_NOW true | ||
| 379 | #define BOND_SLAVE_NOTIFY_LATER false | ||
| 380 | |||
| 346 | static inline int slave_do_arp_validate(struct bonding *bond, | 381 | static inline int slave_do_arp_validate(struct bonding *bond, |
| 347 | struct slave *slave) | 382 | struct slave *slave) |
| 348 | { | 383 | { |
| @@ -394,17 +429,19 @@ static inline void bond_netpoll_send_skb(const struct slave *slave, | |||
| 394 | } | 429 | } |
| 395 | #endif | 430 | #endif |
| 396 | 431 | ||
| 397 | static inline void bond_set_slave_inactive_flags(struct slave *slave) | 432 | static inline void bond_set_slave_inactive_flags(struct slave *slave, |
| 433 | bool notify) | ||
| 398 | { | 434 | { |
| 399 | if (!bond_is_lb(slave->bond)) | 435 | if (!bond_is_lb(slave->bond)) |
| 400 | bond_set_backup_slave(slave); | 436 | bond_set_slave_state(slave, BOND_STATE_BACKUP, notify); |
| 401 | if (!slave->bond->params.all_slaves_active) | 437 | if (!slave->bond->params.all_slaves_active) |
| 402 | slave->inactive = 1; | 438 | slave->inactive = 1; |
| 403 | } | 439 | } |
| 404 | 440 | ||
| 405 | static inline void bond_set_slave_active_flags(struct slave *slave) | 441 | static inline void bond_set_slave_active_flags(struct slave *slave, |
| 442 | bool notify) | ||
| 406 | { | 443 | { |
| 407 | bond_set_active_slave(slave); | 444 | bond_set_slave_state(slave, BOND_STATE_ACTIVE, notify); |
| 408 | slave->inactive = 0; | 445 | slave->inactive = 0; |
| 409 | } | 446 | } |
| 410 | 447 | ||
