Linux Kernel
3.7.1
|
Go to the source code of this file.
Data Structures | |
struct | sk_filter |
Macros | |
#define | SK_RUN_FILTER(FILTER, SKB) sk_run_filter(SKB, FILTER->insns) |
Functions | |
int | sk_filter (struct sock *sk, struct sk_buff *skb) |
unsigned int | sk_run_filter (const struct sk_buff *skb, const struct sock_filter *filter) |
int | sk_unattached_filter_create (struct sk_filter **pfp, struct sock_fprog *fprog) |
void | sk_unattached_filter_destroy (struct sk_filter *fp) |
int | sk_attach_filter (struct sock_fprog *fprog, struct sock *sk) |
int | sk_detach_filter (struct sock *sk) |
int | sk_chk_filter (struct sock_filter *filter, unsigned int flen) |
#define SK_RUN_FILTER | ( | FILTER, | |
SKB | |||
) | sk_run_filter(SKB, FILTER->insns) |
anonymous enum |
int sk_attach_filter | ( | struct sock_fprog * | fprog, |
struct sock * | sk | ||
) |
sk_attach_filter - attach a socket filter : the filter program : the socket to use
Attach the user's filter code. We first run some sanity checks on it to make sure it does not explode on us later. If an error occurs or there is insufficient memory for the filter a negative errno code is returned. On success the return is zero.
int sk_chk_filter | ( | struct sock_filter * | filter, |
unsigned int | flen | ||
) |
sk_chk_filter - verify socket filter code : filter to verify : length of filter
Check the user's filter code. If we let some ugly filter code slip through kaboom! The filter must contain no references or jumps that are out of range, no illegal instructions, and must end with a RET instruction.
All jumps are forward as they are not signed.
Returns 0 if the rule set is legal or -EINVAL if not.
sk_filter - run a packet through a socket filter : sock associated with &sk_buff : buffer to filter
Run the filter code and then cut skb->data to correct size returned by sk_run_filter. If pkt_len is 0 we toss packet. If skb->len is smaller than pkt_len we keep whole skb->data. This is the socket level wrapper to sk_run_filter. It returns 0 if the packet should be accepted or -EPERM if the packet should be tossed.
sk_run_filter - run a filter on a socket : buffer to run the filter on : filter to apply
Decode and apply filter instructions to the skb->data. Return length to keep, 0 for none. is the data we are filtering, is the array of filter instructions. Because all jumps are guaranteed to be before last instruction, and last instruction guaranteed to be a RET, we dont need to check flen. (We used to pass to this function the length of filter)
int sk_unattached_filter_create | ( | struct sk_filter ** | pfp, |
struct sock_fprog * | fprog | ||
) |
sk_unattached_filter_create - create an unattached filter : the filter program : the unattached filter that is created
Create a filter independent of any socket. We first run some sanity checks on it to make sure it does not explode on us later. If an error occurs or there is insufficient memory for the filter a negative errno code is returned. On success the return is zero.