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/linux | |
| 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/linux')
| -rw-r--r-- | include/linux/filter.h | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/include/linux/filter.h b/include/linux/filter.h index 93a9792e27bc..9bde3ed19fe6 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h | |||
| @@ -50,28 +50,32 @@ static inline unsigned int sk_filter_size(unsigned int proglen) | |||
| 50 | #define sk_filter_proglen(fprog) \ | 50 | #define sk_filter_proglen(fprog) \ |
| 51 | (fprog->len * sizeof(fprog->filter[0])) | 51 | (fprog->len * sizeof(fprog->filter[0])) |
| 52 | 52 | ||
| 53 | extern int sk_filter(struct sock *sk, struct sk_buff *skb); | 53 | int sk_filter(struct sock *sk, struct sk_buff *skb); |
| 54 | extern unsigned int sk_run_filter(const struct sk_buff *skb, | 54 | unsigned int sk_run_filter(const struct sk_buff *skb, |
| 55 | const struct sock_filter *filter); | 55 | const struct sock_filter *filter); |
| 56 | 56 | ||
| 57 | extern int sk_unattached_filter_create(struct sk_filter **pfp, | 57 | int sk_unattached_filter_create(struct sk_filter **pfp, |
| 58 | struct sock_fprog *fprog); | 58 | struct sock_fprog *fprog); |
| 59 | extern void sk_unattached_filter_destroy(struct sk_filter *fp); | 59 | void sk_unattached_filter_destroy(struct sk_filter *fp); |
| 60 | 60 | ||
| 61 | extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk); | 61 | int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk); |
| 62 | extern int sk_detach_filter(struct sock *sk); | 62 | int sk_detach_filter(struct sock *sk); |
| 63 | 63 | ||
| 64 | extern int sk_chk_filter(struct sock_filter *filter, unsigned int flen); | 64 | int sk_chk_filter(struct sock_filter *filter, unsigned int flen); |
| 65 | extern int sk_get_filter(struct sock *sk, struct sock_filter __user *filter, unsigned len); | 65 | int sk_get_filter(struct sock *sk, struct sock_filter __user *filter, |
| 66 | extern void sk_decode_filter(struct sock_filter *filt, struct sock_filter *to); | 66 | unsigned int len); |
| 67 | void sk_decode_filter(struct sock_filter *filt, struct sock_filter *to); | ||
| 68 | |||
| 69 | void sk_filter_charge(struct sock *sk, struct sk_filter *fp); | ||
| 70 | void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp); | ||
| 67 | 71 | ||
| 68 | #ifdef CONFIG_BPF_JIT | 72 | #ifdef CONFIG_BPF_JIT |
| 69 | #include <stdarg.h> | 73 | #include <stdarg.h> |
| 70 | #include <linux/linkage.h> | 74 | #include <linux/linkage.h> |
| 71 | #include <linux/printk.h> | 75 | #include <linux/printk.h> |
| 72 | 76 | ||
| 73 | extern void bpf_jit_compile(struct sk_filter *fp); | 77 | void bpf_jit_compile(struct sk_filter *fp); |
| 74 | extern void bpf_jit_free(struct sk_filter *fp); | 78 | void bpf_jit_free(struct sk_filter *fp); |
| 75 | 79 | ||
| 76 | static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen, | 80 | static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen, |
| 77 | u32 pass, void *image) | 81 | u32 pass, void *image) |
