diff options
author | David Sterba <dsterba@suse.cz> | 2007-12-07 02:40:33 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-12-07 15:00:30 -0500 |
commit | b63bb739a1d24f395c09f88ff43c54c736a60453 (patch) | |
tree | 27aec1b4779f6bfd9c6d4c393ae037c665069220 /drivers/net/bonding | |
parent | 8e4b9329080b7c37e3dcf4a7c435657d4d0f4816 (diff) |
bonding: Fix time comparison
From: David Sterba <dsterba@suse.cz>
Use macros for comparing jiffies. Jiffies' wrap caused missed events and hangs.
Module reinsert was needed to make bonding work again.
Signed-off-by: David Sterba <dsterba@suse.cz>
Acked-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 423298c84a1d..e4a47149735f 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -74,6 +74,7 @@ | |||
74 | #include <linux/ethtool.h> | 74 | #include <linux/ethtool.h> |
75 | #include <linux/if_vlan.h> | 75 | #include <linux/if_vlan.h> |
76 | #include <linux/if_bonding.h> | 76 | #include <linux/if_bonding.h> |
77 | #include <linux/jiffies.h> | ||
77 | #include <net/route.h> | 78 | #include <net/route.h> |
78 | #include <net/net_namespace.h> | 79 | #include <net/net_namespace.h> |
79 | #include "bonding.h" | 80 | #include "bonding.h" |
@@ -2722,8 +2723,8 @@ void bond_loadbalance_arp_mon(struct work_struct *work) | |||
2722 | */ | 2723 | */ |
2723 | bond_for_each_slave(bond, slave, i) { | 2724 | bond_for_each_slave(bond, slave, i) { |
2724 | if (slave->link != BOND_LINK_UP) { | 2725 | if (slave->link != BOND_LINK_UP) { |
2725 | if (((jiffies - slave->dev->trans_start) <= delta_in_ticks) && | 2726 | if (time_before_eq(jiffies, slave->dev->trans_start + delta_in_ticks) && |
2726 | ((jiffies - slave->dev->last_rx) <= delta_in_ticks)) { | 2727 | time_before_eq(jiffies, slave->dev->last_rx + delta_in_ticks)) { |
2727 | 2728 | ||
2728 | slave->link = BOND_LINK_UP; | 2729 | slave->link = BOND_LINK_UP; |
2729 | slave->state = BOND_STATE_ACTIVE; | 2730 | slave->state = BOND_STATE_ACTIVE; |
@@ -2754,8 +2755,8 @@ void bond_loadbalance_arp_mon(struct work_struct *work) | |||
2754 | * when the source ip is 0, so don't take the link down | 2755 | * when the source ip is 0, so don't take the link down |
2755 | * if we don't know our ip yet | 2756 | * if we don't know our ip yet |
2756 | */ | 2757 | */ |
2757 | if (((jiffies - slave->dev->trans_start) >= (2*delta_in_ticks)) || | 2758 | if (time_after_eq(jiffies, slave->dev->trans_start + 2*delta_in_ticks) || |
2758 | (((jiffies - slave->dev->last_rx) >= (2*delta_in_ticks)) && | 2759 | (time_after_eq(jiffies, slave->dev->last_rx + 2*delta_in_ticks) && |
2759 | bond_has_ip(bond))) { | 2760 | bond_has_ip(bond))) { |
2760 | 2761 | ||
2761 | slave->link = BOND_LINK_DOWN; | 2762 | slave->link = BOND_LINK_DOWN; |
@@ -2848,8 +2849,8 @@ void bond_activebackup_arp_mon(struct work_struct *work) | |||
2848 | */ | 2849 | */ |
2849 | bond_for_each_slave(bond, slave, i) { | 2850 | bond_for_each_slave(bond, slave, i) { |
2850 | if (slave->link != BOND_LINK_UP) { | 2851 | if (slave->link != BOND_LINK_UP) { |
2851 | if ((jiffies - slave_last_rx(bond, slave)) <= | 2852 | if (time_before_eq(jiffies, |
2852 | delta_in_ticks) { | 2853 | slave_last_rx(bond, slave) + delta_in_ticks)) { |
2853 | 2854 | ||
2854 | slave->link = BOND_LINK_UP; | 2855 | slave->link = BOND_LINK_UP; |
2855 | 2856 | ||
@@ -2858,7 +2859,7 @@ void bond_activebackup_arp_mon(struct work_struct *work) | |||
2858 | write_lock_bh(&bond->curr_slave_lock); | 2859 | write_lock_bh(&bond->curr_slave_lock); |
2859 | 2860 | ||
2860 | if ((!bond->curr_active_slave) && | 2861 | if ((!bond->curr_active_slave) && |
2861 | ((jiffies - slave->dev->trans_start) <= delta_in_ticks)) { | 2862 | time_before_eq(jiffies, slave->dev->trans_start + delta_in_ticks)) { |
2862 | bond_change_active_slave(bond, slave); | 2863 | bond_change_active_slave(bond, slave); |
2863 | bond->current_arp_slave = NULL; | 2864 | bond->current_arp_slave = NULL; |
2864 | } else if (bond->curr_active_slave != slave) { | 2865 | } else if (bond->curr_active_slave != slave) { |
@@ -2897,7 +2898,7 @@ void bond_activebackup_arp_mon(struct work_struct *work) | |||
2897 | 2898 | ||
2898 | if ((slave != bond->curr_active_slave) && | 2899 | if ((slave != bond->curr_active_slave) && |
2899 | (!bond->current_arp_slave) && | 2900 | (!bond->current_arp_slave) && |
2900 | (((jiffies - slave_last_rx(bond, slave)) >= 3*delta_in_ticks) && | 2901 | (time_after_eq(jiffies, slave_last_rx(bond, slave) + 3*delta_in_ticks) && |
2901 | bond_has_ip(bond))) { | 2902 | bond_has_ip(bond))) { |
2902 | /* a backup slave has gone down; three times | 2903 | /* a backup slave has gone down; three times |
2903 | * the delta allows the current slave to be | 2904 | * the delta allows the current slave to be |
@@ -2943,10 +2944,10 @@ void bond_activebackup_arp_mon(struct work_struct *work) | |||
2943 | * before being taken out. if a primary is being used, check | 2944 | * before being taken out. if a primary is being used, check |
2944 | * if it is up and needs to take over as the curr_active_slave | 2945 | * if it is up and needs to take over as the curr_active_slave |
2945 | */ | 2946 | */ |
2946 | if ((((jiffies - slave->dev->trans_start) >= (2*delta_in_ticks)) || | 2947 | if ((time_after_eq(jiffies, slave->dev->trans_start + 2*delta_in_ticks) || |
2947 | (((jiffies - slave_last_rx(bond, slave)) >= (2*delta_in_ticks)) && | 2948 | (time_after_eq(jiffies, slave_last_rx(bond, slave) + 2*delta_in_ticks) && |
2948 | bond_has_ip(bond))) && | 2949 | bond_has_ip(bond))) && |
2949 | ((jiffies - slave->jiffies) >= 2*delta_in_ticks)) { | 2950 | time_after_eq(jiffies, slave->jiffies + 2*delta_in_ticks)) { |
2950 | 2951 | ||
2951 | slave->link = BOND_LINK_DOWN; | 2952 | slave->link = BOND_LINK_DOWN; |
2952 | 2953 | ||