netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bpf: add mod default A and X test cases
@ 2015-11-04 19:36 Yang Shi
  2015-11-04 20:15 ` Daniel Borkmann
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Yang Shi @ 2015-11-04 19:36 UTC (permalink / raw)
  To: ast, daniel
  Cc: zlim.lnx, xi.wang, linux-kernel, netdev, linaro-kernel, yang.shi

When running "mod X" operation, if X is 0 the filter has to be halt.
Add new test cases to cover A = A mod X if X is 0, and A = A mod 1.

CC: Xi Wang <xi.wang@gmail.com>
CC: Zi Shen Lim <zlim.lnx@gmail.com>
Signed-off-by: Yang Shi <yang.shi@linaro.org>
---
 lib/test_bpf.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index d137739..10cd186 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -5056,6 +5056,36 @@ static struct bpf_test tests[] = {
 		{ {0x1, 0x0 } },
 	},
 	{
+		"MOD default X",
+		.u.insns = {
+			/*
+			 * A = 0x42
+			 * A = A mod X ; this halt the filter execution if X is 0
+			 * ret 0x42
+			 */
+			BPF_STMT(BPF_LD | BPF_IMM, 0x42),
+			BPF_STMT(BPF_ALU | BPF_MOD | BPF_X, 0),
+			BPF_STMT(BPF_RET | BPF_K, 0x42),
+		},
+		CLASSIC | FLAG_NO_DATA,
+		{},
+		{ {0x1, 0x0 } },
+	},
+	{
+		"MOD default A",
+		.u.insns = {
+			/*
+			 * A = A mod 1
+			 * ret A
+			 */
+			BPF_STMT(BPF_ALU | BPF_MOD | BPF_K, 0x1),
+			BPF_STMT(BPF_RET | BPF_A, 0x0),
+		},
+		CLASSIC | FLAG_NO_DATA,
+		{},
+		{ {0x1, 0x0 } },
+	},
+	{
 		"JMP EQ default A",
 		.u.insns = {
 			/*
-- 
2.0.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpf: add mod default A and X test cases
  2015-11-04 19:36 [PATCH] bpf: add mod default A and X test cases Yang Shi
@ 2015-11-04 20:15 ` Daniel Borkmann
  2015-11-04 20:25 ` Alexei Starovoitov
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Daniel Borkmann @ 2015-11-04 20:15 UTC (permalink / raw)
  To: Yang Shi, ast; +Cc: zlim.lnx, xi.wang, linux-kernel, netdev, linaro-kernel

On 11/04/2015 08:36 PM, Yang Shi wrote:
> When running "mod X" operation, if X is 0 the filter has to be halt.
> Add new test cases to cover A = A mod X if X is 0, and A = A mod 1.
>
> CC: Xi Wang <xi.wang@gmail.com>
> CC: Zi Shen Lim <zlim.lnx@gmail.com>
> Signed-off-by: Yang Shi <yang.shi@linaro.org>

LGTM!

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpf: add mod default A and X test cases
  2015-11-04 19:36 [PATCH] bpf: add mod default A and X test cases Yang Shi
  2015-11-04 20:15 ` Daniel Borkmann
@ 2015-11-04 20:25 ` Alexei Starovoitov
  2015-11-04 22:05 ` Z Lim
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Alexei Starovoitov @ 2015-11-04 20:25 UTC (permalink / raw)
  To: Yang Shi
  Cc: ast, daniel, zlim.lnx, xi.wang, linux-kernel, netdev, linaro-kernel

On Wed, Nov 04, 2015 at 11:36:37AM -0800, Yang Shi wrote:
> When running "mod X" operation, if X is 0 the filter has to be halt.
> Add new test cases to cover A = A mod X if X is 0, and A = A mod 1.
> 
> CC: Xi Wang <xi.wang@gmail.com>
> CC: Zi Shen Lim <zlim.lnx@gmail.com>
> Signed-off-by: Yang Shi <yang.shi@linaro.org>

Acked-by: Alexei Starovoitov <ast@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpf: add mod default A and X test cases
  2015-11-04 19:36 [PATCH] bpf: add mod default A and X test cases Yang Shi
  2015-11-04 20:15 ` Daniel Borkmann
  2015-11-04 20:25 ` Alexei Starovoitov
@ 2015-11-04 22:05 ` Z Lim
  2015-11-04 22:43 ` Xi Wang
  2015-11-05  5:06 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Z Lim @ 2015-11-04 22:05 UTC (permalink / raw)
  To: Yang Shi
  Cc: Alexei Starovoitov, daniel, Xi Wang, LKML, Network Development,
	linaro-kernel

On Wed, Nov 4, 2015 at 11:36 AM, Yang Shi <yang.shi@linaro.org> wrote:
> When running "mod X" operation, if X is 0 the filter has to be halt.
> Add new test cases to cover A = A mod X if X is 0, and A = A mod 1.
>
> CC: Xi Wang <xi.wang@gmail.com>
> CC: Zi Shen Lim <zlim.lnx@gmail.com>
> Signed-off-by: Yang Shi <yang.shi@linaro.org>
> ---

Acked-by: Zi Shen Lim <zlim.lnx@gmail.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpf: add mod default A and X test cases
  2015-11-04 19:36 [PATCH] bpf: add mod default A and X test cases Yang Shi
                   ` (2 preceding siblings ...)
  2015-11-04 22:05 ` Z Lim
@ 2015-11-04 22:43 ` Xi Wang
  2015-11-05  5:06 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Xi Wang @ 2015-11-04 22:43 UTC (permalink / raw)
  To: Yang Shi
  Cc: Alexei Starovoitov, Daniel Borkmann, Z Lim, linux-kernel, netdev,
	linaro-kernel

On Wed, Nov 4, 2015 at 11:36 AM, Yang Shi <yang.shi@linaro.org> wrote:
> When running "mod X" operation, if X is 0 the filter has to be halt.
> Add new test cases to cover A = A mod X if X is 0, and A = A mod 1.
>
> CC: Xi Wang <xi.wang@gmail.com>
> CC: Zi Shen Lim <zlim.lnx@gmail.com>
> Signed-off-by: Yang Shi <yang.shi@linaro.org>

Acked-by: Xi Wang <xi.wang@gmail.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpf: add mod default A and X test cases
  2015-11-04 19:36 [PATCH] bpf: add mod default A and X test cases Yang Shi
                   ` (3 preceding siblings ...)
  2015-11-04 22:43 ` Xi Wang
@ 2015-11-05  5:06 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2015-11-05  5:06 UTC (permalink / raw)
  To: yang.shi
  Cc: ast, daniel, zlim.lnx, xi.wang, linux-kernel, netdev, linaro-kernel

From: Yang Shi <yang.shi@linaro.org>
Date: Wed,  4 Nov 2015 11:36:37 -0800

> When running "mod X" operation, if X is 0 the filter has to be halt.
> Add new test cases to cover A = A mod X if X is 0, and A = A mod 1.
> 
> CC: Xi Wang <xi.wang@gmail.com>
> CC: Zi Shen Lim <zlim.lnx@gmail.com>
> Signed-off-by: Yang Shi <yang.shi@linaro.org>

Applied, thank you.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-11-05  5:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-04 19:36 [PATCH] bpf: add mod default A and X test cases Yang Shi
2015-11-04 20:15 ` Daniel Borkmann
2015-11-04 20:25 ` Alexei Starovoitov
2015-11-04 22:05 ` Z Lim
2015-11-04 22:43 ` Xi Wang
2015-11-05  5:06 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).