[NET]: Add barriers for dst refcnt.
Linux Kernel Mailing List <[email protected]>
| Newsgroups | gmane.linux.kernel.commits.2-4 |
|---|---|
| Message-ID | <[email protected]> |
ChangeSet 1.1539.1.5, 2005/02/05 17:09:11-08:00, [email protected] [NET]: Add barriers for dst refcnt. In light of the recent discussion about sk_buff, I think we need the following patch for dst_entry. This adds a memory barrier before dst_release drops the refcnt, and a read memory barrier before dst_destroy starts destroying the entry. Signed-off-by: Herbert Xu <[email protected]> Signed-off-by: David S. Miller <[email protected]> include/net/dst.h | 4 +++- net/core/dst.c | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff -Nru a/include/net/dst.h b/include/net/dst.h --- a/include/net/dst.h 2005-02-09 09:06:27 -08:00 +++ b/include/net/dst.h 2005-02-09 09:06:27 -08:00 @@ -104,8 +104,10 @@ static inline void dst_release(struct dst_entry * dst) { - if (dst) + if (dst) { + smp_mb__before_atomic_dec(); atomic_dec(&dst->__refcnt); + } } extern void * dst_alloc(struct dst_ops * ops); diff -Nru a/net/core/dst.c b/net/core/dst.c --- a/net/core/dst.c 2005-02-09 09:06:27 -08:00 +++ b/net/core/dst.c 2005-02-09 09:06:27 -08:00 @@ -142,8 +142,13 @@ void dst_destroy(struct dst_entry * dst) { - struct neighbour *neigh = dst->neighbour; - struct hh_cache *hh = dst->hh; + struct neighbour *neigh; + struct hh_cache *hh; + + smp_rmb(); + + neigh = dst->neighbour; + hh = dst->hh; dst->hh = NULL; if (hh && atomic_dec_and_test(&hh->hh_refcnt))