Commit b63bb739 authored by David Sterba's avatar David Sterba Committed by Jeff Garzik

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: default avatarDavid Sterba <dsterba@suse.cz>
Acked-by: default avatarJay Vosburgh <fubar@us.ibm.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 8e4b9329
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
#include <linux/if_bonding.h> #include <linux/if_bonding.h>
#include <linux/jiffies.h>
#include <net/route.h> #include <net/route.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include "bonding.h" #include "bonding.h"
...@@ -2722,8 +2723,8 @@ void bond_loadbalance_arp_mon(struct work_struct *work) ...@@ -2722,8 +2723,8 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
*/ */
bond_for_each_slave(bond, slave, i) { bond_for_each_slave(bond, slave, i) {
if (slave->link != BOND_LINK_UP) { if (slave->link != BOND_LINK_UP) {
if (((jiffies - slave->dev->trans_start) <= delta_in_ticks) && if (time_before_eq(jiffies, slave->dev->trans_start + delta_in_ticks) &&
((jiffies - slave->dev->last_rx) <= delta_in_ticks)) { time_before_eq(jiffies, slave->dev->last_rx + delta_in_ticks)) {
slave->link = BOND_LINK_UP; slave->link = BOND_LINK_UP;
slave->state = BOND_STATE_ACTIVE; slave->state = BOND_STATE_ACTIVE;
...@@ -2754,8 +2755,8 @@ void bond_loadbalance_arp_mon(struct work_struct *work) ...@@ -2754,8 +2755,8 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
* when the source ip is 0, so don't take the link down * when the source ip is 0, so don't take the link down
* if we don't know our ip yet * if we don't know our ip yet
*/ */
if (((jiffies - slave->dev->trans_start) >= (2*delta_in_ticks)) || if (time_after_eq(jiffies, slave->dev->trans_start + 2*delta_in_ticks) ||
(((jiffies - slave->dev->last_rx) >= (2*delta_in_ticks)) && (time_after_eq(jiffies, slave->dev->last_rx + 2*delta_in_ticks) &&
bond_has_ip(bond))) { bond_has_ip(bond))) {
slave->link = BOND_LINK_DOWN; slave->link = BOND_LINK_DOWN;
...@@ -2848,8 +2849,8 @@ void bond_activebackup_arp_mon(struct work_struct *work) ...@@ -2848,8 +2849,8 @@ void bond_activebackup_arp_mon(struct work_struct *work)
*/ */
bond_for_each_slave(bond, slave, i) { bond_for_each_slave(bond, slave, i) {
if (slave->link != BOND_LINK_UP) { if (slave->link != BOND_LINK_UP) {
if ((jiffies - slave_last_rx(bond, slave)) <= if (time_before_eq(jiffies,
delta_in_ticks) { slave_last_rx(bond, slave) + delta_in_ticks)) {
slave->link = BOND_LINK_UP; slave->link = BOND_LINK_UP;
...@@ -2858,7 +2859,7 @@ void bond_activebackup_arp_mon(struct work_struct *work) ...@@ -2858,7 +2859,7 @@ void bond_activebackup_arp_mon(struct work_struct *work)
write_lock_bh(&bond->curr_slave_lock); write_lock_bh(&bond->curr_slave_lock);
if ((!bond->curr_active_slave) && if ((!bond->curr_active_slave) &&
((jiffies - slave->dev->trans_start) <= delta_in_ticks)) { time_before_eq(jiffies, slave->dev->trans_start + delta_in_ticks)) {
bond_change_active_slave(bond, slave); bond_change_active_slave(bond, slave);
bond->current_arp_slave = NULL; bond->current_arp_slave = NULL;
} else if (bond->curr_active_slave != slave) { } else if (bond->curr_active_slave != slave) {
...@@ -2897,7 +2898,7 @@ void bond_activebackup_arp_mon(struct work_struct *work) ...@@ -2897,7 +2898,7 @@ void bond_activebackup_arp_mon(struct work_struct *work)
if ((slave != bond->curr_active_slave) && if ((slave != bond->curr_active_slave) &&
(!bond->current_arp_slave) && (!bond->current_arp_slave) &&
(((jiffies - slave_last_rx(bond, slave)) >= 3*delta_in_ticks) && (time_after_eq(jiffies, slave_last_rx(bond, slave) + 3*delta_in_ticks) &&
bond_has_ip(bond))) { bond_has_ip(bond))) {
/* a backup slave has gone down; three times /* a backup slave has gone down; three times
* the delta allows the current slave to be * the delta allows the current slave to be
...@@ -2943,10 +2944,10 @@ void bond_activebackup_arp_mon(struct work_struct *work) ...@@ -2943,10 +2944,10 @@ void bond_activebackup_arp_mon(struct work_struct *work)
* before being taken out. if a primary is being used, check * before being taken out. if a primary is being used, check
* if it is up and needs to take over as the curr_active_slave * if it is up and needs to take over as the curr_active_slave
*/ */
if ((((jiffies - slave->dev->trans_start) >= (2*delta_in_ticks)) || if ((time_after_eq(jiffies, slave->dev->trans_start + 2*delta_in_ticks) ||
(((jiffies - slave_last_rx(bond, slave)) >= (2*delta_in_ticks)) && (time_after_eq(jiffies, slave_last_rx(bond, slave) + 2*delta_in_ticks) &&
bond_has_ip(bond))) && bond_has_ip(bond))) &&
((jiffies - slave->jiffies) >= 2*delta_in_ticks)) { time_after_eq(jiffies, slave->jiffies + 2*delta_in_ticks)) {
slave->link = BOND_LINK_DOWN; slave->link = BOND_LINK_DOWN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment