[NEIGH] Fix add_timer race in neigh_add_timer
[linux-2.6-block.git] / net / core / neighbour.c
index 4128fc76ac3a2906bc586c1f5b05ae670cdca686..37d8d8c295226b214c95de9134317391886e387e 100644 (file)
@@ -732,6 +732,7 @@ 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);
+               dump_stack();
        }
 }
 
@@ -815,10 +816,10 @@ static void neigh_timer_handler(unsigned long arg)
        }
 
        if (neigh->nud_state & NUD_IN_TIMER) {
-               neigh_hold(neigh);
                if (time_before(next, jiffies + HZ/2))
                        next = jiffies + HZ/2;
-               neigh_add_timer(neigh, next);
+               if (!mod_timer(&neigh->timer, next))
+                       neigh_hold(neigh);
        }
        if (neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) {
                struct sk_buff *skb = skb_peek(&neigh->arp_queue);