Skip to content

Commit

Permalink
[NEIGH]: Add debugging check when adding timers.
Browse files Browse the repository at this point in the history
If we double-add a neighbour entry timer, which should be
impossible but has been reported, dump the current state of
the entry so that we can debug this.

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Sep 27, 2005
1 parent 56e9b26 commit 667347f
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions net/core/neighbour.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,13 @@ static __inline__ int neigh_max_probes(struct neighbour *n)
p->ucast_probes + p->app_probes + p->mcast_probes);
}

static inline void neigh_add_timer(struct neighbour *n, unsigned long when)
{
if (unlikely(mod_timer(&n->timer, when))) {
printk("NEIGH: BUG, double timer add, state is %x\n",
n->nud_state);
}
}

/* Called when a timer expires for a neighbour entry. */

Expand Down Expand Up @@ -811,8 +818,7 @@ static void neigh_timer_handler(unsigned long arg)
neigh_hold(neigh);
if (time_before(next, jiffies + HZ/2))
next = jiffies + HZ/2;
neigh->timer.expires = next;
add_timer(&neigh->timer);
neigh_add_timer(neigh, next);
}
if (neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) {
struct sk_buff *skb = skb_peek(&neigh->arp_queue);
Expand Down Expand Up @@ -854,8 +860,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
atomic_set(&neigh->probes, neigh->parms->ucast_probes);
neigh->nud_state = NUD_INCOMPLETE;
neigh_hold(neigh);
neigh->timer.expires = now + 1;
add_timer(&neigh->timer);
neigh_add_timer(neigh, now + 1);
} else {
neigh->nud_state = NUD_FAILED;
write_unlock_bh(&neigh->lock);
Expand All @@ -868,8 +873,8 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
NEIGH_PRINTK2("neigh %p is delayed.\n", neigh);
neigh_hold(neigh);
neigh->nud_state = NUD_DELAY;
neigh->timer.expires = jiffies + neigh->parms->delay_probe_time;
add_timer(&neigh->timer);
neigh_add_timer(neigh,
jiffies + neigh->parms->delay_probe_time);
}

if (neigh->nud_state == NUD_INCOMPLETE) {
Expand Down Expand Up @@ -1015,10 +1020,10 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
neigh_del_timer(neigh);
if (new & NUD_IN_TIMER) {
neigh_hold(neigh);
neigh->timer.expires = jiffies +
neigh_add_timer(neigh, (jiffies +
((new & NUD_REACHABLE) ?
neigh->parms->reachable_time : 0);
add_timer(&neigh->timer);
neigh->parms->reachable_time :
0)));
}
neigh->nud_state = new;
}
Expand Down

0 comments on commit 667347f

Please sign in to comment.