Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 4b47b3c

Browse files
committed
some debugging from Eric Dumazet
should drop a BUG_ON if refcount goes weird.
1 parent 13339c1 commit 4b47b3c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

include/net/dst.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,14 @@ dst_metric_locked(const struct dst_entry *dst, int metric)
234234

235235
static inline void dst_hold(struct dst_entry *dst)
236236
{
237+
int newrefcnt;
237238
/*
238239
* If your kernel compilation stops here, please check
239240
* __pad_to_align_refcnt declaration in struct dst_entry
240241
*/
241242
BUILD_BUG_ON(offsetof(struct dst_entry, __refcnt) & 63);
242-
atomic_inc(&dst->__refcnt);
243+
newrefcnt = atomic_inc_return(&dst->__refcnt);
244+
BUG_ON(newrefcnt <= 1 && (dst->flags & DST_NOCACHE));
243245
}
244246

245247
static inline void dst_use(struct dst_entry *dst, unsigned long time)
@@ -258,7 +260,7 @@ static inline void dst_use_noref(struct dst_entry *dst, unsigned long time)
258260
static inline struct dst_entry *dst_clone(struct dst_entry *dst)
259261
{
260262
if (dst)
261-
atomic_inc(&dst->__refcnt);
263+
dst_hold(dst);
262264
return dst;
263265
}
264266

0 commit comments

Comments
 (0)