@@ -173,14 +173,18 @@ static void neigh_add_timer(struct neighbour *n, unsigned long when)
}
}
-static int neigh_del_timer(struct neighbour *n)
+/* Ungrab neigh in the context, which assumes that neigh refcnt
+ * cannot hit zero.
+ */
+static void __neigh_release(struct neighbour *n)
{
- if ((n->nud_state & NUD_IN_TIMER) &&
- del_timer(&n->timer)) {
- neigh_release(n);
- return 1;
- }
- return 0;
+ atomic_dec(&n->refcnt);
+}
+
+static void neigh_del_timer(struct neighbour *n)
+{
+ if ((n->nud_state & NUD_IN_TIMER) && del_timer(&n->timer))
+ __neigh_release(n);
}
static void pneigh_queue_purge(struct sk_buff_head *list)
Keep the usage of neigh timer aligned with one of sock timer, making the usage of neigh timer more understandable. To reach the goal, a new function - __neigh_release() is introduced in neigh_del_timer(), and it just decreases neigh refcount but doesn't call neigh_destroy(). This makes sense because neigh recount has been taken when its timer is added, and it cannot hit zero when the timer is deleted. Signed-off-by: Ying Xue <ying.xue@windriver.com> --- net/core/neighbour.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)