>From c61f1fd27e19d6614dcb381b4d8e7bac0429e412 Mon Sep 17 00:00:00 2001 From: Joern Engel Date: Thu, 2 Apr 2015 15:19:57 -0700 Subject: [PATCH] net: Check for neighbor refcount bugs Debugging why we crash in the timer softirq without this is pretty painful. Should be low-overhead and give a more meaningful backtrace. Signed-off-by: Joern Engel --- include/net/neighbour.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 7e748ad8b50c..a19d02bb336c 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h @@ -297,8 +297,10 @@ static inline struct neigh_parms *neigh_parms_clone(struct neigh_parms *parms) static inline void neigh_release(struct neighbour *neigh) { - if (atomic_dec_and_test(&neigh->refcnt)) + if (atomic_dec_and_test(&neigh->refcnt)) { + WARN_ON_ONCE(timer_pending(&neigh->timer)); neigh_destroy(neigh); + } } static inline struct neighbour * neigh_clone(struct neighbour *neigh) @@ -308,7 +310,10 @@ static inline struct neighbour * neigh_clone(struct neighbour *neigh) return neigh; } -#define neigh_hold(n) atomic_inc(&(n)->refcnt) +static inline void neigh_hold(struct neighbour *neigh) +{ + WARN_ON_ONCE(atomic_inc_return(&neigh->refcnt) == 1); +} static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) { -- 2.1.4