Commit b715631f authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

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: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d9c58f30
...@@ -37,21 +37,6 @@ struct sock_fprog /* Required for SO_ATTACH_FILTER. */ ...@@ -37,21 +37,6 @@ struct sock_fprog /* Required for SO_ATTACH_FILTER. */
struct sock_filter __user *filter; struct sock_filter __user *filter;
}; };
#ifdef __KERNEL__
struct sk_filter
{
atomic_t refcnt;
unsigned int len; /* Number of filter blocks */
struct rcu_head rcu;
struct sock_filter insns[0];
};
static inline unsigned int sk_filter_len(struct sk_filter *fp)
{
return fp->len*sizeof(struct sock_filter) + sizeof(*fp);
}
#endif
/* /*
* Instruction classes * Instruction classes
*/ */
...@@ -141,10 +126,24 @@ static inline unsigned int sk_filter_len(struct sk_filter *fp) ...@@ -141,10 +126,24 @@ static inline unsigned int sk_filter_len(struct sk_filter *fp)
#define SKF_LL_OFF (-0x200000) #define SKF_LL_OFF (-0x200000)
#ifdef __KERNEL__ #ifdef __KERNEL__
struct sk_filter
{
atomic_t refcnt;
unsigned int len; /* Number of filter blocks */
struct rcu_head rcu;
struct sock_filter insns[0];
};
static inline unsigned int sk_filter_len(const struct sk_filter *fp)
{
return fp->len * sizeof(struct sock_filter) + sizeof(*fp);
}
struct sk_buff; struct sk_buff;
struct sock; struct sock;
extern unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int flen); extern unsigned int sk_run_filter(struct sk_buff *skb,
struct sock_filter *filter, int flen);
extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk); extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
extern int sk_detach_filter(struct sock *sk); extern int sk_detach_filter(struct sock *sk);
extern int sk_chk_filter(struct sock_filter *filter, int flen); extern int sk_chk_filter(struct sock_filter *filter, int flen);
......
...@@ -275,6 +275,7 @@ unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int ...@@ -275,6 +275,7 @@ unsigned int sk_run_filter(struct sk_buff *skb, struct sock_filter *filter, int
return 0; return 0;
} }
EXPORT_SYMBOL(sk_run_filter);
/** /**
* sk_chk_filter - verify socket filter code * sk_chk_filter - verify socket filter code
...@@ -385,6 +386,7 @@ int sk_chk_filter(struct sock_filter *filter, int flen) ...@@ -385,6 +386,7 @@ int sk_chk_filter(struct sock_filter *filter, int flen)
return (BPF_CLASS(filter[flen - 1].code) == BPF_RET) ? 0 : -EINVAL; return (BPF_CLASS(filter[flen - 1].code) == BPF_RET) ? 0 : -EINVAL;
} }
EXPORT_SYMBOL(sk_chk_filter);
/** /**
* sk_filter_rcu_release: Release a socket filter by rcu_head * sk_filter_rcu_release: Release a socket filter by rcu_head
...@@ -467,6 +469,3 @@ int sk_detach_filter(struct sock *sk) ...@@ -467,6 +469,3 @@ int sk_detach_filter(struct sock *sk)
rcu_read_unlock_bh(); rcu_read_unlock_bh();
return ret; return ret;
} }
EXPORT_SYMBOL(sk_chk_filter);
EXPORT_SYMBOL(sk_run_filter);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment