diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/filter.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/include/linux/filter.h b/include/linux/filter.h index a6ac84871d6d..ff4e40cd45b1 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <linux/atomic.h> | 7 | #include <linux/atomic.h> |
| 8 | #include <linux/compat.h> | 8 | #include <linux/compat.h> |
| 9 | #include <linux/workqueue.h> | ||
| 9 | #include <uapi/linux/filter.h> | 10 | #include <uapi/linux/filter.h> |
| 10 | 11 | ||
| 11 | #ifdef CONFIG_COMPAT | 12 | #ifdef CONFIG_COMPAT |
| @@ -25,15 +26,19 @@ struct sk_filter | |||
| 25 | { | 26 | { |
| 26 | atomic_t refcnt; | 27 | atomic_t refcnt; |
| 27 | unsigned int len; /* Number of filter blocks */ | 28 | unsigned int len; /* Number of filter blocks */ |
| 29 | struct rcu_head rcu; | ||
| 28 | unsigned int (*bpf_func)(const struct sk_buff *skb, | 30 | unsigned int (*bpf_func)(const struct sk_buff *skb, |
| 29 | const struct sock_filter *filter); | 31 | const struct sock_filter *filter); |
| 30 | struct rcu_head rcu; | 32 | union { |
| 31 | struct sock_filter insns[0]; | 33 | struct sock_filter insns[0]; |
| 34 | struct work_struct work; | ||
| 35 | }; | ||
| 32 | }; | 36 | }; |
| 33 | 37 | ||
| 34 | static inline unsigned int sk_filter_len(const struct sk_filter *fp) | 38 | static inline unsigned int sk_filter_size(unsigned int proglen) |
| 35 | { | 39 | { |
| 36 | return fp->len * sizeof(struct sock_filter) + sizeof(*fp); | 40 | return max(sizeof(struct sk_filter), |
| 41 | offsetof(struct sk_filter, insns[proglen])); | ||
| 37 | } | 42 | } |
| 38 | 43 | ||
| 39 | extern int sk_filter(struct sock *sk, struct sk_buff *skb); | 44 | extern int sk_filter(struct sock *sk, struct sk_buff *skb); |
| @@ -67,11 +72,13 @@ static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen, | |||
| 67 | } | 72 | } |
| 68 | #define SK_RUN_FILTER(FILTER, SKB) (*FILTER->bpf_func)(SKB, FILTER->insns) | 73 | #define SK_RUN_FILTER(FILTER, SKB) (*FILTER->bpf_func)(SKB, FILTER->insns) |
| 69 | #else | 74 | #else |
| 75 | #include <linux/slab.h> | ||
| 70 | static inline void bpf_jit_compile(struct sk_filter *fp) | 76 | static inline void bpf_jit_compile(struct sk_filter *fp) |
| 71 | { | 77 | { |
| 72 | } | 78 | } |
| 73 | static inline void bpf_jit_free(struct sk_filter *fp) | 79 | static inline void bpf_jit_free(struct sk_filter *fp) |
| 74 | { | 80 | { |
| 81 | kfree(fp); | ||
| 75 | } | 82 | } |
| 76 | #define SK_RUN_FILTER(FILTER, SKB) sk_run_filter(SKB, FILTER->insns) | 83 | #define SK_RUN_FILTER(FILTER, SKB) sk_run_filter(SKB, FILTER->insns) |
| 77 | #endif | 84 | #endif |
