netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Stringer <joe@wand.net.nz>
To: daniel@iogearbox.net
Cc: netdev@vger.kernel.org, ast@kernel.org, john.fastabend@gmail.com,
	tgraf@suug.ch, kafai@fb.com, nitin.hande@gmail.com,
	mauricio.vasquez@polito.it
Subject: [PATCHv4 bpf-next 11/13] libbpf: Support loading individual progs
Date: Tue,  2 Oct 2018 13:35:39 -0700	[thread overview]
Message-ID: <20181002203541.26599-12-joe@wand.net.nz> (raw)
In-Reply-To: <20181002203541.26599-1-joe@wand.net.nz>

Allow the individual program load to be invoked. This will help with
testing, where a single ELF may contain several sections, some of which
denote subprograms that are expected to fail verification, along with
some which are expected to pass verification. By allowing programs to be
iterated and individually loaded, each program can be independently
checked against its expected verification result.

Signed-off-by: Joe Stringer <joe@wand.net.nz>
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
 tools/lib/bpf/libbpf.c | 4 ++--
 tools/lib/bpf/libbpf.h | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 425d5ca45c97..9e68fd9fcfca 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -228,7 +228,7 @@ struct bpf_object {
 };
 #define obj_elf_valid(o)	((o)->efile.elf)
 
-static void bpf_program__unload(struct bpf_program *prog)
+void bpf_program__unload(struct bpf_program *prog)
 {
 	int i;
 
@@ -1375,7 +1375,7 @@ load_program(enum bpf_prog_type type, enum bpf_attach_type expected_attach_type,
 	return ret;
 }
 
-static int
+int
 bpf_program__load(struct bpf_program *prog,
 		  char *license, u32 kern_version)
 {
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 511c1294dcbf..2ed24d3f80b3 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -128,10 +128,13 @@ void bpf_program__set_ifindex(struct bpf_program *prog, __u32 ifindex);
 
 const char *bpf_program__title(struct bpf_program *prog, bool needs_copy);
 
+int bpf_program__load(struct bpf_program *prog, char *license,
+		      u32 kern_version);
 int bpf_program__fd(struct bpf_program *prog);
 int bpf_program__pin_instance(struct bpf_program *prog, const char *path,
 			      int instance);
 int bpf_program__pin(struct bpf_program *prog, const char *path);
+void bpf_program__unload(struct bpf_program *prog);
 
 struct bpf_insn;
 
-- 
2.17.1

  parent reply	other threads:[~2018-10-03  3:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-02 20:35 [PATCHv4 bpf-next 00/13] Add socket lookup support Joe Stringer
2018-10-02 20:35 ` [PATCHv4 bpf-next 01/13] bpf: Add iterator for spilled registers Joe Stringer
2018-10-02 20:35 ` [PATCHv4 bpf-next 02/13] bpf: Simplify ptr_min_max_vals adjustment Joe Stringer
2018-10-02 20:35 ` [PATCHv4 bpf-next 03/13] bpf: Reuse canonical string formatter for ctx errs Joe Stringer
2018-10-02 20:35 ` [PATCHv4 bpf-next 04/13] bpf: Generalize ptr_or_null regs check Joe Stringer
2018-10-02 20:35 ` [PATCHv4 bpf-next 05/13] bpf: Add PTR_TO_SOCKET verifier type Joe Stringer
2018-10-02 20:35 ` [PATCHv4 bpf-next 06/13] bpf: Macrofy stack state copy Joe Stringer
2018-10-02 20:35 ` [PATCHv4 bpf-next 07/13] bpf: Add reference tracking to verifier Joe Stringer
2019-01-09  5:27   ` Alexei Starovoitov
2019-01-10 19:26     ` Joe Stringer
2018-10-02 20:35 ` [PATCHv4 bpf-next 08/13] bpf: Add helper to retrieve socket in BPF Joe Stringer
2018-10-02 20:35 ` [PATCHv4 bpf-next 09/13] selftests/bpf: Generalize dummy program types Joe Stringer
2018-10-02 20:35 ` [PATCHv4 bpf-next 10/13] selftests/bpf: Add tests for reference tracking Joe Stringer
2018-10-02 20:35 ` Joe Stringer [this message]
2018-10-02 20:35 ` [PATCHv4 bpf-next 12/13] selftests/bpf: Add C " Joe Stringer
2018-10-02 20:35 ` [PATCHv4 bpf-next 13/13] Documentation: Describe bpf " Joe Stringer
2018-10-03  1:08 ` [PATCHv4 bpf-next 00/13] Add socket lookup support Daniel Borkmann

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=20181002203541.26599-12-joe@wand.net.nz \
    --to=joe@wand.net.nz \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=mauricio.vasquez@polito.it \
    --cc=netdev@vger.kernel.org \
    --cc=nitin.hande@gmail.com \
    --cc=tgraf@suug.ch \
    /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).