Skip to content

Commit

Permalink
Merge branch 'filter-next'
Browse files Browse the repository at this point in the history
Daniel Borkmann says:

====================
BPF updates

These were still in my queue. Please see individual patches for
details.

I have rebased these on top of current net-next with Andrew's
gcc union fixup [1] applied to avoid dealing with an unnecessary
merge conflict.

 [1] http://patchwork.ozlabs.org/patch/351577/
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed May 23, 2014
2 parents 76fcee2 + 2e8a83c commit be65de7
Show file tree
Hide file tree
Showing 10 changed files with 457 additions and 268 deletions.
14 changes: 14 additions & 0 deletions Documentation/networking/filter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,20 @@ loops and other CFG validation; second step starts from the first insn and
descends all possible paths. It simulates execution of every insn and observes
the state change of registers and stack.

Testing
-------

Next to the BPF toolchain, the kernel also ships a test module that contains
various test cases for classic and internal BPF that can be executed against
the BPF interpreter and JIT compiler. It can be found in lib/test_bpf.c and
enabled via Kconfig:

CONFIG_TEST_BPF=m

After the module has been built and installed, the test suite can be executed
via insmod or modprobe against 'test_bpf' module. Results of the test cases
including timings in nsec can be found in the kernel log (dmesg).

Misc
----

Expand Down
4 changes: 2 additions & 2 deletions drivers/isdn/i4l/isdn_ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg)
#ifdef CONFIG_IPPP_FILTER
case PPPIOCSPASS:
{
struct sock_fprog fprog;
struct sock_fprog_kern fprog;
struct sock_filter *code;
int err, len = get_filter(argp, &code);

Expand All @@ -653,7 +653,7 @@ isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg)
}
case PPPIOCSACTIVE:
{
struct sock_fprog fprog;
struct sock_fprog_kern fprog;
struct sock_filter *code;
int err, len = get_filter(argp, &code);

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ppp/ppp_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)

err = get_filter(argp, &code);
if (err >= 0) {
struct sock_fprog fprog = {
struct sock_fprog_kern fprog = {
.len = err,
.filter = code,
};
Expand All @@ -778,7 +778,7 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)

err = get_filter(argp, &code);
if (err >= 0) {
struct sock_fprog fprog = {
struct sock_fprog_kern fprog = {
.len = err,
.filter = code,
};
Expand Down
10 changes: 5 additions & 5 deletions drivers/net/team/team_mode_loadbalance.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct lb_port_mapping {
struct lb_priv_ex {
struct team *team;
struct lb_port_mapping tx_hash_to_port_mapping[LB_TX_HASHTABLE_SIZE];
struct sock_fprog *orig_fprog;
struct sock_fprog_kern *orig_fprog;
struct {
unsigned int refresh_interval; /* in tenths of second */
struct delayed_work refresh_dw;
Expand Down Expand Up @@ -241,10 +241,10 @@ static int lb_bpf_func_get(struct team *team, struct team_gsetter_ctx *ctx)
return 0;
}

static int __fprog_create(struct sock_fprog **pfprog, u32 data_len,
static int __fprog_create(struct sock_fprog_kern **pfprog, u32 data_len,
const void *data)
{
struct sock_fprog *fprog;
struct sock_fprog_kern *fprog;
struct sock_filter *filter = (struct sock_filter *) data;

if (data_len % sizeof(struct sock_filter))
Expand All @@ -262,7 +262,7 @@ static int __fprog_create(struct sock_fprog **pfprog, u32 data_len,
return 0;
}

static void __fprog_destroy(struct sock_fprog *fprog)
static void __fprog_destroy(struct sock_fprog_kern *fprog)
{
kfree(fprog->filter);
kfree(fprog);
Expand All @@ -273,7 +273,7 @@ static int lb_bpf_func_set(struct team *team, struct team_gsetter_ctx *ctx)
struct lb_priv *lb_priv = get_lb_priv(team);
struct sk_filter *fp = NULL;
struct sk_filter *orig_fp;
struct sock_fprog *fprog = NULL;
struct sock_fprog_kern *fprog = NULL;
int err;

if (ctx->data.bin_val.len) {
Expand Down
5 changes: 1 addition & 4 deletions include/linux/filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@
#define BPF_CALL 0x80 /* function call */
#define BPF_EXIT 0x90 /* function return */

/* Placeholder/dummy for 0 */
#define BPF_0 0

/* Register numbers */
enum {
BPF_REG_0 = 0,
Expand Down Expand Up @@ -191,7 +188,7 @@ int sk_convert_filter(struct sock_filter *prog, int len,
struct sock_filter_int *new_prog, int *new_len);

int sk_unattached_filter_create(struct sk_filter **pfp,
struct sock_fprog *fprog);
struct sock_fprog_kern *fprog);
void sk_unattached_filter_destroy(struct sk_filter *fp);

int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
Expand Down
Loading

0 comments on commit be65de7

Please sign in to comment.