Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1198875
| From | Nicolas Schichan <nschichan@freebox.fr> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 3/6] test_bpf: test LD_ABS and LD_IND instructions on fragmented skbs. |
| Date | 2015-08-03 16:10 +0200 |
| Message-ID | <pToBc-5iK-25@gated-at.bofh.it> (permalink) |
| References | <pToBb-5iK-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
These new tests exercise various load sizes and offsets crossing the
head/fragment boundary.
Signed-off-by: Nicolas Schichan <nschichan@freebox.fr>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
---
lib/test_bpf.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 142 insertions(+)
diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index acef1e9..f5606fb 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -4493,6 +4493,148 @@ static struct bpf_test tests[] = {
{ { 1, 0xbef } },
.fill_helper = bpf_fill_ld_abs_vlan_push_pop,
},
+ /*
+ * LD_IND / LD_ABS on fragmented SKBs
+ */
+ {
+ "LD_IND byte frag",
+ .u.insns = {
+ BPF_STMT(BPF_LDX | BPF_IMM, 0x40),
+ BPF_STMT(BPF_LD | BPF_IND | BPF_B, 0x0),
+ BPF_STMT(BPF_RET | BPF_A, 0x0),
+ },
+ CLASSIC | FLAG_SKB_FRAG,
+ { },
+ { {0x40, 0x42} },
+ .frag_data = {
+ 0x42, 0x00, 0x00, 0x00,
+ 0x43, 0x44, 0x00, 0x00,
+ 0x21, 0x07, 0x19, 0x83,
+ },
+ },
+ {
+ "LD_IND halfword frag",
+ .u.insns = {
+ BPF_STMT(BPF_LDX | BPF_IMM, 0x40),
+ BPF_STMT(BPF_LD | BPF_IND | BPF_H, 0x4),
+ BPF_STMT(BPF_RET | BPF_A, 0x0),
+ },
+ CLASSIC | FLAG_SKB_FRAG,
+ { },
+ { {0x40, 0x4344} },
+ .frag_data = {
+ 0x42, 0x00, 0x00, 0x00,
+ 0x43, 0x44, 0x00, 0x00,
+ 0x21, 0x07, 0x19, 0x83,
+ },
+ },
+ {
+ "LD_IND word frag",
+ .u.insns = {
+ BPF_STMT(BPF_LDX | BPF_IMM, 0x40),
+ BPF_STMT(BPF_LD | BPF_IND | BPF_W, 0x8),
+ BPF_STMT(BPF_RET | BPF_A, 0x0),
+ },
+ CLASSIC | FLAG_SKB_FRAG,
+ { },
+ { {0x40, 0x21071983} },
+ .frag_data = {
+ 0x42, 0x00, 0x00, 0x00,
+ 0x43, 0x44, 0x00, 0x00,
+ 0x21, 0x07, 0x19, 0x83,
+ },
+ },
+ {
+ "LD_IND halfword mixed head/frag",
+ .u.insns = {
+ BPF_STMT(BPF_LDX | BPF_IMM, 0x40),
+ BPF_STMT(BPF_LD | BPF_IND | BPF_H, -0x1),
+ BPF_STMT(BPF_RET | BPF_A, 0x0),
+ },
+ CLASSIC | FLAG_SKB_FRAG,
+ { [0x3e] = 0x25, [0x3f] = 0x05, },
+ { {0x40, 0x0519} },
+ .frag_data = { 0x19, 0x82 },
+ },
+ {
+ "LD_IND word mixed head/frag",
+ .u.insns = {
+ BPF_STMT(BPF_LDX | BPF_IMM, 0x40),
+ BPF_STMT(BPF_LD | BPF_IND | BPF_W, -0x2),
+ BPF_STMT(BPF_RET | BPF_A, 0x0),
+ },
+ CLASSIC | FLAG_SKB_FRAG,
+ { [0x3e] = 0x25, [0x3f] = 0x05, },
+ { {0x40, 0x25051982} },
+ .frag_data = { 0x19, 0x82 },
+ },
+ {
+ "LD_ABS byte frag",
+ .u.insns = {
+ BPF_STMT(BPF_LD | BPF_ABS | BPF_B, 0x40),
+ BPF_STMT(BPF_RET | BPF_A, 0x0),
+ },
+ CLASSIC | FLAG_SKB_FRAG,
+ { },
+ { {0x40, 0x42} },
+ .frag_data = {
+ 0x42, 0x00, 0x00, 0x00,
+ 0x43, 0x44, 0x00, 0x00,
+ 0x21, 0x07, 0x19, 0x83,
+ },
+ },
+ {
+ "LD_ABS halfword frag",
+ .u.insns = {
+ BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x44),
+ BPF_STMT(BPF_RET | BPF_A, 0x0),
+ },
+ CLASSIC | FLAG_SKB_FRAG,
+ { },
+ { {0x40, 0x4344} },
+ .frag_data = {
+ 0x42, 0x00, 0x00, 0x00,
+ 0x43, 0x44, 0x00, 0x00,
+ 0x21, 0x07, 0x19, 0x83,
+ },
+ },
+ {
+ "LD_ABS word frag",
+ .u.insns = {
+ BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x48),
+ BPF_STMT(BPF_RET | BPF_A, 0x0),
+ },
+ CLASSIC | FLAG_SKB_FRAG,
+ { },
+ { {0x40, 0x21071983} },
+ .frag_data = {
+ 0x42, 0x00, 0x00, 0x00,
+ 0x43, 0x44, 0x00, 0x00,
+ 0x21, 0x07, 0x19, 0x83,
+ },
+ },
+ {
+ "LD_ABS halfword mixed head/frag",
+ .u.insns = {
+ BPF_STMT(BPF_LD | BPF_ABS | BPF_H, 0x3f),
+ BPF_STMT(BPF_RET | BPF_A, 0x0),
+ },
+ CLASSIC | FLAG_SKB_FRAG,
+ { [0x3e] = 0x25, [0x3f] = 0x05, },
+ { {0x40, 0x0519} },
+ .frag_data = { 0x19, 0x82 },
+ },
+ {
+ "LD_ABS word mixed head/frag",
+ .u.insns = {
+ BPF_STMT(BPF_LD | BPF_ABS | BPF_W, 0x3e),
+ BPF_STMT(BPF_RET | BPF_A, 0x0),
+ },
+ CLASSIC | FLAG_SKB_FRAG,
+ { [0x3e] = 0x25, [0x3f] = 0x05, },
+ { {0x40, 0x25051982} },
+ .frag_data = { 0x19, 0x82 },
+ },
};
static struct net_device dev;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 0/6] test_bpf improvements Nicolas Schichan <nschichan@freebox.fr> - 2015-08-03 16:10 +0200
[PATCH 4/6] test_bpf: add module parameters to filter the tests to run. Nicolas Schichan <nschichan@freebox.fr> - 2015-08-03 16:10 +0200
Re: [PATCH 4/6] test_bpf: add module parameters to filter the tests to run. Daniel Borkmann <daniel@iogearbox.net> - 2015-08-03 18:00 +0200
Re: [PATCH 4/6] test_bpf: add module parameters to filter the tests to run. Daniel Borkmann <daniel@iogearbox.net> - 2015-08-03 18:40 +0200
Re: [PATCH 4/6] test_bpf: add module parameters to filter the tests to run. Nicolas Schichan <nschichan@freebox.fr> - 2015-08-03 18:40 +0200
[PATCH 3/6] test_bpf: test LD_ABS and LD_IND instructions on fragmented skbs. Nicolas Schichan <nschichan@freebox.fr> - 2015-08-03 16:10 +0200
Re: [PATCH 3/6] test_bpf: test LD_ABS and LD_IND instructions on fragmented skbs. Daniel Borkmann <daniel@iogearbox.net> - 2015-08-03 17:10 +0200
[PATCH 6/6] test_bpf: add tests checking that JIT/interpreter sets A and X to 0. Nicolas Schichan <nschichan@freebox.fr> - 2015-08-03 16:10 +0200
Re: [PATCH 6/6] test_bpf: add tests checking that JIT/interpreter sets A and X to 0. Daniel Borkmann <daniel@iogearbox.net> - 2015-08-03 17:10 +0200
[PATCH 5/6] test_bpf: add more tests for LD_ABS and LD_IND. Nicolas Schichan <nschichan@freebox.fr> - 2015-08-03 16:10 +0200
Re: [PATCH 5/6] test_bpf: add more tests for LD_ABS and LD_IND. Daniel Borkmann <daniel@iogearbox.net> - 2015-08-03 17:10 +0200
[PATCH 1/6] test_bpf: avoid oopsing the kernel when generate_test_data() fails. Nicolas Schichan <nschichan@freebox.fr> - 2015-08-03 16:10 +0200
Re: [PATCH 1/6] test_bpf: avoid oopsing the kernel when generate_test_data() fails. Daniel Borkmann <daniel@iogearbox.net> - 2015-08-03 16:50 +0200
csiph-web