diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2014-03-28 13:58:20 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-03-31 00:45:09 -0400 |
commit | fbc907f0b1386c02e00516aa78a0fa6b0454fd0b (patch) | |
tree | a747b5bb1dec44ce93e0924e4ea2de3411417b2c /include/net | |
parent | a3ea269b8bcdbb0c5fa2fd449a436e7987446975 (diff) |
net: filter: move filter accounting to filter core
This patch basically does two things, i) removes the extern keyword
from the include/linux/filter.h file to be more consistent with the
rest of Joe's changes, and ii) moves filter accounting into the filter
core framework.
Filter accounting mainly done through sk_filter_{un,}charge() take
care of the case when sockets are being cloned through sk_clone_lock()
so that removal of the filter on one socket won't result in eviction
as it's still referenced by the other.
These functions actually belong to net/core/filter.c and not
include/net/sock.h as we want to keep all that in a central place.
It's also not in fast-path so uninlining them is fine and even allows
us to get rd of sk_filter_release_rcu()'s EXPORT_SYMBOL and a forward
declaration.
Joint work with Alexei Starovoitov.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Cc: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/sock.h | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 8d7c431a0660..06a5668f05c9 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -1621,33 +1621,6 @@ void sk_common_release(struct sock *sk); | |||
1621 | /* Initialise core socket variables */ | 1621 | /* Initialise core socket variables */ |
1622 | void sock_init_data(struct socket *sock, struct sock *sk); | 1622 | void sock_init_data(struct socket *sock, struct sock *sk); |
1623 | 1623 | ||
1624 | void sk_filter_release_rcu(struct rcu_head *rcu); | ||
1625 | |||
1626 | /** | ||
1627 | * sk_filter_release - release a socket filter | ||
1628 | * @fp: filter to remove | ||
1629 | * | ||
1630 | * Remove a filter from a socket and release its resources. | ||
1631 | */ | ||
1632 | |||
1633 | static inline void sk_filter_release(struct sk_filter *fp) | ||
1634 | { | ||
1635 | if (atomic_dec_and_test(&fp->refcnt)) | ||
1636 | call_rcu(&fp->rcu, sk_filter_release_rcu); | ||
1637 | } | ||
1638 | |||
1639 | static inline void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp) | ||
1640 | { | ||
1641 | atomic_sub(sk_filter_size(fp->len), &sk->sk_omem_alloc); | ||
1642 | sk_filter_release(fp); | ||
1643 | } | ||
1644 | |||
1645 | static inline void sk_filter_charge(struct sock *sk, struct sk_filter *fp) | ||
1646 | { | ||
1647 | atomic_inc(&fp->refcnt); | ||
1648 | atomic_add(sk_filter_size(fp->len), &sk->sk_omem_alloc); | ||
1649 | } | ||
1650 | |||
1651 | /* | 1624 | /* |
1652 | * Socket reference counting postulates. | 1625 | * Socket reference counting postulates. |
1653 | * | 1626 | * |