Commit be65de71 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'filter-next'

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 76fcee24 2e8a83c5
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -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
descends all possible paths. It simulates execution of every insn and observes
the state change of registers and stack.
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
Misc
----
----


+2 −2
Original line number Original line Diff line number Diff line
@@ -634,7 +634,7 @@ isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg)
#ifdef CONFIG_IPPP_FILTER
#ifdef CONFIG_IPPP_FILTER
	case PPPIOCSPASS:
	case PPPIOCSPASS:
	{
	{
		struct sock_fprog fprog;
		struct sock_fprog_kern fprog;
		struct sock_filter *code;
		struct sock_filter *code;
		int err, len = get_filter(argp, &code);
		int err, len = get_filter(argp, &code);


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


+2 −2
Original line number Original line Diff line number Diff line
@@ -757,7 +757,7 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)


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


		err = get_filter(argp, &code);
		err = get_filter(argp, &code);
		if (err >= 0) {
		if (err >= 0) {
			struct sock_fprog fprog = {
			struct sock_fprog_kern fprog = {
				.len = err,
				.len = err,
				.filter = code,
				.filter = code,
			};
			};
+5 −5
Original line number Original line Diff line number Diff line
@@ -49,7 +49,7 @@ struct lb_port_mapping {
struct lb_priv_ex {
struct lb_priv_ex {
	struct team *team;
	struct team *team;
	struct lb_port_mapping tx_hash_to_port_mapping[LB_TX_HASHTABLE_SIZE];
	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 {
	struct {
		unsigned int refresh_interval; /* in tenths of second */
		unsigned int refresh_interval; /* in tenths of second */
		struct delayed_work refresh_dw;
		struct delayed_work refresh_dw;
@@ -241,10 +241,10 @@ static int lb_bpf_func_get(struct team *team, struct team_gsetter_ctx *ctx)
	return 0;
	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)
			  const void *data)
{
{
	struct sock_fprog *fprog;
	struct sock_fprog_kern *fprog;
	struct sock_filter *filter = (struct sock_filter *) data;
	struct sock_filter *filter = (struct sock_filter *) data;


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


static void __fprog_destroy(struct sock_fprog *fprog)
static void __fprog_destroy(struct sock_fprog_kern *fprog)
{
{
	kfree(fprog->filter);
	kfree(fprog->filter);
	kfree(fprog);
	kfree(fprog);
@@ -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 lb_priv *lb_priv = get_lb_priv(team);
	struct sk_filter *fp = NULL;
	struct sk_filter *fp = NULL;
	struct sk_filter *orig_fp;
	struct sk_filter *orig_fp;
	struct sock_fprog *fprog = NULL;
	struct sock_fprog_kern *fprog = NULL;
	int err;
	int err;


	if (ctx->data.bin_val.len) {
	if (ctx->data.bin_val.len) {
+1 −4
Original line number Original line Diff line number Diff line
@@ -37,9 +37,6 @@
#define BPF_CALL	0x80	/* function call */
#define BPF_CALL	0x80	/* function call */
#define BPF_EXIT	0x90	/* function return */
#define BPF_EXIT	0x90	/* function return */


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

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


int sk_unattached_filter_create(struct sk_filter **pfp,
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);
void sk_unattached_filter_destroy(struct sk_filter *fp);


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