netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Lemon <jonathan.lemon@gmail.com>
To: <bjorn.topel@intel.com>, <magnus.karlsson@intel.com>,
	<toke@redhat.com>, <brouer@redhat.com>, <daniel@iogearbox.net>,
	<ast@kernel.org>
Cc: <kernel-team@fb.com>, <netdev@vger.kernel.org>
Subject: [PATCH v5 3/4] tools/bpf: Add bpf_map_lookup_elem selftest for xskmap
Date: Thu, 6 Jun 2019 13:59:42 -0700	[thread overview]
Message-ID: <20190606205943.818795-4-jonathan.lemon@gmail.com> (raw)
In-Reply-To: <20190606205943.818795-1-jonathan.lemon@gmail.com>

Check that bpf_map_lookup_elem lookup and structure
access operats correctly.

Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
---
 tools/testing/selftests/bpf/verifier/sock.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/tools/testing/selftests/bpf/verifier/sock.c b/tools/testing/selftests/bpf/verifier/sock.c
index b31cd2cf50d0..9ed192e14f5f 100644
--- a/tools/testing/selftests/bpf/verifier/sock.c
+++ b/tools/testing/selftests/bpf/verifier/sock.c
@@ -498,3 +498,21 @@
 	.result = REJECT,
 	.errstr = "cannot pass map_type 24 into func bpf_map_lookup_elem",
 },
+{
+	"bpf_map_lookup_elem(xskmap, &key); xs->queue_id",
+	.insns = {
+	BPF_ST_MEM(BPF_W, BPF_REG_10, -8, 0),
+	BPF_MOV64_REG(BPF_REG_2, BPF_REG_10),
+	BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8),
+	BPF_LD_MAP_FD(BPF_REG_1, 0),
+	BPF_EMIT_CALL(BPF_FUNC_map_lookup_elem),
+	BPF_JMP_IMM(BPF_JNE, BPF_REG_0, 0, 1),
+	BPF_EXIT_INSN(),
+	BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_0, offsetof(struct bpf_xdp_sock, queue_id)),
+	BPF_MOV64_IMM(BPF_REG_0, 0),
+	BPF_EXIT_INSN(),
+	},
+	.fixup_map_xskmap = { 3 },
+	.prog_type = BPF_PROG_TYPE_XDP,
+	.result = ACCEPT,
+},
-- 
2.17.1


  parent reply	other threads:[~2019-06-06 20:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-06 20:59 [PATCH v5 bpf-next 0/4] Better handling of xskmap entries Jonathan Lemon
2019-06-06 20:59 ` [PATCH v5 bpf-next 1/4] bpf: Allow bpf_map_lookup_elem() on an xskmap Jonathan Lemon
2019-06-06 20:59 ` [PATCH v5 bpf-next 2/4] bpf/tools: sync bpf.h Jonathan Lemon
2019-06-07  6:17   ` Martin Lau
2019-06-06 20:59 ` Jonathan Lemon [this message]
2019-06-07  6:18   ` [PATCH v5 3/4] tools/bpf: Add bpf_map_lookup_elem selftest for xskmap Martin Lau
2019-06-06 20:59 ` [PATCH v5 4/4] libbpf: remove qidconf and better support external bpf programs Jonathan Lemon
2019-06-09  6:52 ` [PATCH v5 bpf-next 0/4] Better handling of xskmap entries Björn Töpel
2019-06-11  6:36 ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190606205943.818795-4-jonathan.lemon@gmail.com \
    --to=jonathan.lemon@gmail.com \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@intel.com \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=toke@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).