]> err.no Git - linux-2.6/commitdiff
[NET]: Move the filter releasing into a separate call
authorPavel Emelyanov <xemul@openvz.org>
Thu, 18 Oct 2007 04:21:51 +0000 (21:21 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 18 Oct 2007 04:21:51 +0000 (21:21 -0700)
This is done merely as a preparation for the fix.

The sk_filter_uncharge() unaccounts the filter memory and calls
the sk_filter_release(), which in turn decrements the refcount
anf frees the filter.

The latter function will be required separately.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/sock.h
net/core/filter.c
net/core/sock.c

index 453c79d0915ba00ca8b33ff160ba64cb7c58a521..b9cfe125c9e68e56ed4768552280e71cb894ba16 100644 (file)
@@ -922,14 +922,18 @@ static inline void sk_filter_rcu_free(struct rcu_head *rcu)
  *     Remove a filter from a socket and release its resources.
  */
 
-static inline void sk_filter_release(struct sock *sk, struct sk_filter *fp)
+static inline void sk_filter_release(struct sk_filter *fp)
+{
+       if (atomic_dec_and_test(&fp->refcnt))
+               call_rcu_bh(&fp->rcu, sk_filter_rcu_free);
+}
+
+static inline void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp)
 {
        unsigned int size = sk_filter_len(fp);
 
        atomic_sub(size, &sk->sk_omem_alloc);
-
-       if (atomic_dec_and_test(&fp->refcnt))
-               call_rcu_bh(&fp->rcu, sk_filter_rcu_free);
+       sk_filter_release(fp);
 }
 
 static inline void sk_filter_charge(struct sock *sk, struct sk_filter *fp)
index fd607581ab503bb69043cbbc154265c3799baf05..2be1830d3c35183d033ecc9108f98ae58d204c0a 100644 (file)
@@ -429,7 +429,7 @@ int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk)
        }
 
        if (fp)
-               sk_filter_release(sk, fp);
+               sk_filter_uncharge(sk, fp);
        return err;
 }
 
@@ -442,7 +442,7 @@ int sk_detach_filter(struct sock *sk)
        filter = rcu_dereference(sk->sk_filter);
        if (filter) {
                rcu_assign_pointer(sk->sk_filter, NULL);
-               sk_filter_release(sk, filter);
+               sk_filter_uncharge(sk, filter);
                ret = 0;
        }
        rcu_read_unlock_bh();
index 07101381b8b78df697987325a421d37dd308537f..d292b4113d6e240829c48cbd84e24ab5da660764 100644 (file)
@@ -915,7 +915,7 @@ void sk_free(struct sock *sk)
 
        filter = rcu_dereference(sk->sk_filter);
        if (filter) {
-               sk_filter_release(sk, filter);
+               sk_filter_uncharge(sk, filter);
                rcu_assign_pointer(sk->sk_filter, NULL);
        }