On Tue, 29 Aug 2006 19:28:16 +0400
Alexey Kuznetsov <[EMAIL PROTECTED]> wrote:

> Hello!
> 
> > @@ -346,8 +354,8 @@ struct neighbour *neigh_lookup(struct ne
> >     
> >     NEIGH_CACHE_STAT_INC(tbl, lookups);
> >  
> > -   read_lock_bh(&tbl->lock);
> > -   hlist_for_each_entry(n, tmp, &tbl->hash_buckets[hash_val], hlist) {
> > +   rcu_read_lock();
> > +   hlist_for_each_entry_rcu(n, tmp, &tbl->hash_buckets[hash_val], hlist) {
> >             if (dev == n->dev && !memcmp(n->primary_key, pkey, key_len)) {
> >                     neigh_hold(n);
> >                     NEIGH_CACHE_STAT_INC(tbl, hits);
> 
> Sure? Seems, you cannot grab refcnt here, the entry can be already
> released.
> 
> Probably, you should do atomic_inc_and_test() here and restart lookup,
> if it fails.
> 
> Alexey

atomic_inc_and_test is true iff result is zero, so that won't work.
But the following should work:

        hlist_for_each_entry_rcu(n, tmp, &tbl->hash_buckets[hash_val], hlist) {
                if (dev == n->dev && !memcmp(n->primary_key, pkey, key_len)) {
                        if (unlikely(&atomic_inc_return(&n->refcnt) == 1)) {
                                neigh_release(n);
                                continue;
                        }
                        NEIGH_CACHE_STAT_INC(tbl, hits);

I'll wrap the atomic_inc_return inside neigh_hold_return()


-- 
Stephen Hemminger <[EMAIL PROTECTED]>
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to