aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2014-03-28 13:58:20 -0400
committerDavid S. Miller <davem@davemloft.net>2014-03-31 00:45:09 -0400
commitfbc907f0b1386c02e00516aa78a0fa6b0454fd0b (patch)
treea747b5bb1dec44ce93e0924e4ea2de3411417b2c /include/linux
parenta3ea269b8bcdbb0c5fa2fd449a436e7987446975 (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.h30
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
53extern int sk_filter(struct sock *sk, struct sk_buff *skb); 53int sk_filter(struct sock *sk, struct sk_buff *skb);
54extern unsigned int sk_run_filter(const struct sk_buff *skb, 54unsigned int sk_run_filter(const struct sk_buff *skb,
55 const struct sock_filter *filter); 55 const struct sock_filter *filter);
56 56
57extern int sk_unattached_filter_create(struct sk_filter **pfp, 57int sk_unattached_filter_create(struct sk_filter **pfp,
58 struct sock_fprog *fprog); 58 struct sock_fprog *fprog);
59extern void sk_unattached_filter_destroy(struct sk_filter *fp); 59void sk_unattached_filter_destroy(struct sk_filter *fp);
60 60
61extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk); 61int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
62extern int sk_detach_filter(struct sock *sk); 62int sk_detach_filter(struct sock *sk);
63 63
64extern int sk_chk_filter(struct sock_filter *filter, unsigned int flen); 64int sk_chk_filter(struct sock_filter *filter, unsigned int flen);
65extern int sk_get_filter(struct sock *sk, struct sock_filter __user *filter, unsigned len); 65int sk_get_filter(struct sock *sk, struct sock_filter __user *filter,
66extern void sk_decode_filter(struct sock_filter *filt, struct sock_filter *to); 66 unsigned int len);
67void sk_decode_filter(struct sock_filter *filt, struct sock_filter *to);
68
69void sk_filter_charge(struct sock *sk, struct sk_filter *fp);
70void 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
73extern void bpf_jit_compile(struct sk_filter *fp); 77void bpf_jit_compile(struct sk_filter *fp);
74extern void bpf_jit_free(struct sk_filter *fp); 78void bpf_jit_free(struct sk_filter *fp);
75 79
76static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen, 80static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen,
77 u32 pass, void *image) 81 u32 pass, void *image)