]> err.no Git - linux-2.6/commitdiff
[XFRM]: Eliminate refcounting confusion by creating __xfrm_state_put().
authorHerbert Xu <herbert@gondor.apana.org.au>
Wed, 22 Feb 2006 22:47:13 +0000 (14:47 -0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Fri, 24 Feb 2006 00:10:53 +0000 (16:10 -0800)
We often just do an atomic_dec(&x->refcnt) on an xfrm_state object
because we know there is more than 1 reference remaining and thus
we can elide the heavier xfrm_state_put() call.

Do this behind an inline function called __xfrm_state_put() so that is
more obvious and also to allow us to more cleanly add refcount
debugging later.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/xfrm.h
net/key/af_key.c
net/xfrm/xfrm_state.c
net/xfrm/xfrm_user.c

index d6111a2f0a23d07bb25afe53e3806594f538f02d..004e645f3e1829a81b39ed67918a243f66ef049e 100644 (file)
@@ -403,6 +403,11 @@ unsigned xfrm_spi_hash(xfrm_address_t *addr, u32 spi, u8 proto, unsigned short f
 
 extern void __xfrm_state_destroy(struct xfrm_state *);
 
+static inline void __xfrm_state_put(struct xfrm_state *x)
+{
+       atomic_dec(&x->refcnt);
+}
+
 static inline void xfrm_state_put(struct xfrm_state *x)
 {
        if (atomic_dec_and_test(&x->refcnt))
index ae86d237a4569b47e764db78ebe359390bc63359..b2d4d1dd2116fb64212b2c4d33f1d8a2196b42e6 100644 (file)
@@ -1423,7 +1423,7 @@ static int pfkey_add(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr,
 
        if (err < 0) {
                x->km.state = XFRM_STATE_DEAD;
-               xfrm_state_put(x);
+               __xfrm_state_put(x);
                goto out;
        }
 
index e12d0be5f9762f7fe595c6645a1d1f34dffeaac8..c656cbaf35e8453d36441db9665feb54493515c9 100644 (file)
@@ -220,14 +220,14 @@ static int __xfrm_state_delete(struct xfrm_state *x)
                x->km.state = XFRM_STATE_DEAD;
                spin_lock(&xfrm_state_lock);
                list_del(&x->bydst);
-               atomic_dec(&x->refcnt);
+               __xfrm_state_put(x);
                if (x->id.spi) {
                        list_del(&x->byspi);
-                       atomic_dec(&x->refcnt);
+                       __xfrm_state_put(x);
                }
                spin_unlock(&xfrm_state_lock);
                if (del_timer(&x->timer))
-                       atomic_dec(&x->refcnt);
+                       __xfrm_state_put(x);
 
                /* The number two in this test is the reference
                 * mentioned in the comment below plus the reference
@@ -243,7 +243,7 @@ static int __xfrm_state_delete(struct xfrm_state *x)
                 * The xfrm_state_alloc call gives a reference, and that
                 * is what we are dropping here.
                 */
-               atomic_dec(&x->refcnt);
+               __xfrm_state_put(x);
                err = 0;
        }
 
index ac87a09ba83ed47dd03df3993eca7a108b33d016..7de17559249a28e30f25dbd21a0ff1d408060661 100644 (file)
@@ -345,7 +345,7 @@ static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma)
 
        if (err < 0) {
                x->km.state = XFRM_STATE_DEAD;
-               xfrm_state_put(x);
+               __xfrm_state_put(x);
                goto out;
        }