aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-12-20 18:49:05 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:59:28 -0500
commita43d8994b959a6daeeadcd1be6d4a9045b7029ac (patch)
tree0262e3391f3b445e34e9ace4d48449d7d53d5aa5
parent7054fb9376e111d0edc06efcedbac6930a6caf76 (diff)
[NEIGH]: Make neigh_add_timer symmetrical to neigh_del_timer.
The neigh_del_timer() looks sane - it removes the timer and (conditionally) puts the neighbor. I expected, that the neigh_add_timer() is symmetrical to the del one - i.e. it holds the neighbor and arms the timer - but it turned out that it was not so. I think, that making them look symmetrical makes the code more readable. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/core/neighbour.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 4b6dd1e66f10..9a283fcde9a6 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -165,6 +165,16 @@ static int neigh_forced_gc(struct neigh_table *tbl)
165 return shrunk; 165 return shrunk;
166} 166}
167 167
168static void neigh_add_timer(struct neighbour *n, unsigned long when)
169{
170 neigh_hold(n);
171 if (unlikely(mod_timer(&n->timer, when))) {
172 printk("NEIGH: BUG, double timer add, state is %x\n",
173 n->nud_state);
174 dump_stack();
175 }
176}
177
168static int neigh_del_timer(struct neighbour *n) 178static int neigh_del_timer(struct neighbour *n)
169{ 179{
170 if ((n->nud_state & NUD_IN_TIMER) && 180 if ((n->nud_state & NUD_IN_TIMER) &&
@@ -716,15 +726,6 @@ static __inline__ int neigh_max_probes(struct neighbour *n)
716 p->ucast_probes + p->app_probes + p->mcast_probes); 726 p->ucast_probes + p->app_probes + p->mcast_probes);
717} 727}
718 728
719static inline void neigh_add_timer(struct neighbour *n, unsigned long when)
720{
721 if (unlikely(mod_timer(&n->timer, when))) {
722 printk("NEIGH: BUG, double timer add, state is %x\n",
723 n->nud_state);
724 dump_stack();
725 }
726}
727
728/* Called when a timer expires for a neighbour entry. */ 729/* Called when a timer expires for a neighbour entry. */
729 730
730static void neigh_timer_handler(unsigned long arg) 731static void neigh_timer_handler(unsigned long arg)
@@ -856,7 +857,6 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
856 atomic_set(&neigh->probes, neigh->parms->ucast_probes); 857 atomic_set(&neigh->probes, neigh->parms->ucast_probes);
857 neigh->nud_state = NUD_INCOMPLETE; 858 neigh->nud_state = NUD_INCOMPLETE;
858 neigh->updated = jiffies; 859 neigh->updated = jiffies;
859 neigh_hold(neigh);
860 neigh_add_timer(neigh, now + 1); 860 neigh_add_timer(neigh, now + 1);
861 } else { 861 } else {
862 neigh->nud_state = NUD_FAILED; 862 neigh->nud_state = NUD_FAILED;
@@ -869,7 +869,6 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb)
869 } 869 }
870 } else if (neigh->nud_state & NUD_STALE) { 870 } else if (neigh->nud_state & NUD_STALE) {
871 NEIGH_PRINTK2("neigh %p is delayed.\n", neigh); 871 NEIGH_PRINTK2("neigh %p is delayed.\n", neigh);
872 neigh_hold(neigh);
873 neigh->nud_state = NUD_DELAY; 872 neigh->nud_state = NUD_DELAY;
874 neigh->updated = jiffies; 873 neigh->updated = jiffies;
875 neigh_add_timer(neigh, 874 neigh_add_timer(neigh,
@@ -1013,13 +1012,11 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new,
1013 1012
1014 if (new != old) { 1013 if (new != old) {
1015 neigh_del_timer(neigh); 1014 neigh_del_timer(neigh);
1016 if (new & NUD_IN_TIMER) { 1015 if (new & NUD_IN_TIMER)
1017 neigh_hold(neigh);
1018 neigh_add_timer(neigh, (jiffies + 1016 neigh_add_timer(neigh, (jiffies +
1019 ((new & NUD_REACHABLE) ? 1017 ((new & NUD_REACHABLE) ?
1020 neigh->parms->reachable_time : 1018 neigh->parms->reachable_time :
1021 0))); 1019 0)));
1022 }
1023 neigh->nud_state = new; 1020 neigh->nud_state = new;
1024 } 1021 }
1025 1022