diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2008-04-10 04:33:47 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-04-10 04:33:47 -0400 |
commit | b715631fad3ed320b85d386a84a6fb0b3f86b0b9 (patch) | |
tree | 3f7f84419a7ab76f78516abbbba929e1c19c2f7c | |
parent | d9c58f30b08bfe1e689537af5bc855a76d0fae25 (diff) |
socket: sk_filter minor cleanups
Some minor style cleanups:
* Move __KERNEL__ definitions to one place in filter.h
* Use const for sk_filter_len
* Line wrapping
* Put EXPORT_SYMBOL next to function definition
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/filter.h | 31 | ||||
-rw-r--r-- | net/core/filter.c | 5 |
2 files changed, 17 insertions, 19 deletions
diff --git a/include/linux/filter.h b/include/linux/filter.h index ddfa0372a3b7..bfc5d319b946 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h | |||
@@ -37,21 +37,6 @@ struct sock_fprog /* Required for SO_ATTACH_FILTER. */ | |||
37 | struct sock_filter __user *filter; | 37 | struct sock_filter __user *filter; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | #ifdef __KERNEL__ | ||
41 | struct sk_filter | ||
42 | { | ||
43 | atomic_t refcnt; | ||
44 | unsigned int len; /* Number of filter blocks */ | ||
45 | struct rcu_head rcu; | ||
46 | struct sock_filter insns[0]; | ||
47 | }; | ||
48 | |||
49 | static inline unsigned int sk_filter_len(struct sk_filter *fp) | ||
50 | { | ||
51 | return fp->len*sizeof(struct sock_filter) + sizeof(*fp); | ||
52 | } | ||
53 | #endif | ||
54 | |||
55 | /* | 40 | /* |
56 | * Instruction classes | 41 | * Instruction classes |
57 | */ | 42 | */ |
@@ -141,10 +126,24 @@ static inline unsigned int sk_filter_len(struct sk_filter *fp) | |||
141 | #define SKF_LL_OFF (-0x200000) | 126 | #define SKF_LL_OFF (-0x200000) |
142 | 127 | ||
143 | #ifdef __KERNEL__ | 128 | #ifdef __KERNEL__ |
129 | struct sk_filter | ||
130 | { | ||
131 | atomic_t refcnt; | ||
132 | unsigned int len; /* Number of filter blocks */ | ||
133 | struct rcu_head rcu; | ||
134 | struct sock_filter insns[0]; | ||
135 | }; | ||
136 | |||
137 | static inline unsigned int sk_filter_len(const struct sk_filter *fp) | ||
138 | { | ||
139 | return fp->len * sizeof(struct sock_filter) + sizeof(*fp); | ||
140 | } | ||
141 | |||
144 | struct sk_buff; | 142 | struct sk_buff; |
145 | struct sock; | 143 | struct sock; |
146 | 144 | ||
147 | extern unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen); | 145 | extern unsigned int sk_run_filter(struct sk_buff *skb, |
146 | struct sock_filter *filter, int flen); | ||
148 | extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk); | 147 | extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk); |
149 | extern int sk_detach_filter(struct sock *sk); | 148 | extern int sk_detach_filter(struct sock *sk); |
150 | extern int sk_chk_filter(struct sock_filter *filter, int flen); | 149 | extern int sk_chk_filter(struct sock_filter *filter, int flen); |
diff --git a/net/core/filter.c b/net/core/filter.c index e0a06942c025..85a5febab567 100644 --- a/net/core/filter.c +++ b/net/core/filter.c | |||
@@ -275,6 +275,7 @@ load_b: | |||
275 | 275 | ||
276 | return 0; | 276 | return 0; |
277 | } | 277 | } |
278 | EXPORT_SYMBOL(sk_run_filter); | ||
278 | 279 | ||
279 | /** | 280 | /** |
280 | * sk_chk_filter - verify socket filter code | 281 | * sk_chk_filter - verify socket filter code |
@@ -385,6 +386,7 @@ int sk_chk_filter(struct sock_filter *filter, int flen) | |||
385 | 386 | ||
386 | return (BPF_CLASS(filter[flen - 1].code) == BPF_RET) ? 0 : -EINVAL; | 387 | return (BPF_CLASS(filter[flen - 1].code) == BPF_RET) ? 0 : -EINVAL; |
387 | } | 388 | } |
389 | EXPORT_SYMBOL(sk_chk_filter); | ||
388 | 390 | ||
389 | /** | 391 | /** |
390 | * sk_filter_rcu_release: Release a socket filter by rcu_head | 392 | * sk_filter_rcu_release: Release a socket filter by rcu_head |
@@ -467,6 +469,3 @@ int sk_detach_filter(struct sock *sk) | |||
467 | rcu_read_unlock_bh(); | 469 | rcu_read_unlock_bh(); |
468 | return ret; | 470 | return ret; |
469 | } | 471 | } |
470 | |||
471 | EXPORT_SYMBOL(sk_chk_filter); | ||
472 | EXPORT_SYMBOL(sk_run_filter); | ||