From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: alexei.starovoitov@gmail.com, daniel@iogearbox.net
Cc: oss-drivers@netronome.com, netdev@vger.kernel.org,
Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH bpf-next 3/8] tools: libbpf: allow setting ifindex for programs and maps
Date: Thu, 28 Jun 2018 14:41:37 -0700 [thread overview]
Message-ID: <20180628214142.11268-4-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20180628214142.11268-1-jakub.kicinski@netronome.com>
Users of bpf_object__open()/bpf_object__load() APIs may want to
load the programs and maps onto a device for offload. Allow
setting ifindex on those sub-objects.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
---
tools/lib/bpf/libbpf.c | 10 ++++++++++
tools/lib/bpf/libbpf.h | 2 ++
2 files changed, 12 insertions(+)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index a1491e95edd0..7bc02d93e277 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1896,6 +1896,11 @@ void *bpf_program__priv(struct bpf_program *prog)
return prog ? prog->priv : ERR_PTR(-EINVAL);
}
+void bpf_program__set_ifindex(struct bpf_program *prog, __u32 ifindex)
+{
+ prog->prog_ifindex = ifindex;
+}
+
const char *bpf_program__title(struct bpf_program *prog, bool needs_copy)
{
const char *title;
@@ -2122,6 +2127,11 @@ void *bpf_map__priv(struct bpf_map *map)
return map ? map->priv : ERR_PTR(-EINVAL);
}
+void bpf_map__set_ifindex(struct bpf_map *map, __u32 ifindex)
+{
+ map->map_ifindex = ifindex;
+}
+
struct bpf_map *
bpf_map__next(struct bpf_map *prev, struct bpf_object *obj)
{
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 09976531aa74..564f4be9bae0 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -109,6 +109,7 @@ int bpf_program__set_priv(struct bpf_program *prog, void *priv,
bpf_program_clear_priv_t clear_priv);
void *bpf_program__priv(struct bpf_program *prog);
+void bpf_program__set_ifindex(struct bpf_program *prog, __u32 ifindex);
const char *bpf_program__title(struct bpf_program *prog, bool needs_copy);
@@ -251,6 +252,7 @@ typedef void (*bpf_map_clear_priv_t)(struct bpf_map *, void *);
int bpf_map__set_priv(struct bpf_map *map, void *priv,
bpf_map_clear_priv_t clear_priv);
void *bpf_map__priv(struct bpf_map *map);
+void bpf_map__set_ifindex(struct bpf_map *map, __u32 ifindex);
int bpf_map__pin(struct bpf_map *map, const char *path);
long libbpf_get_error(const void *ptr);
--
2.17.1
next prev parent reply other threads:[~2018-06-28 21:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-28 21:41 [PATCH bpf-next 0/8] tools: bpf: updates to bpftool and libbpf Jakub Kicinski
2018-06-28 21:41 ` [PATCH bpf-next 1/8] tools: bpftool: use correct make variable type to improve compilation time Jakub Kicinski
2018-06-28 21:41 ` [PATCH bpf-next 2/8] tools: libbpf: add section names for missing program types Jakub Kicinski
2018-06-28 21:41 ` Jakub Kicinski [this message]
2018-06-28 21:41 ` [PATCH bpf-next 4/8] tools: libbpf: restore the ability to load programs from .text section Jakub Kicinski
2018-06-28 21:41 ` [PATCH bpf-next 5/8] tools: libbpf: don't return '.text' as a program for multi-function programs Jakub Kicinski
2018-06-28 21:41 ` [PATCH bpf-next 6/8] tools: bpftool: drop unnecessary Author comments Jakub Kicinski
2018-06-28 21:41 ` [PATCH bpf-next 7/8] tools: bpftool: add missing --bpffs to completions Jakub Kicinski
2018-06-28 21:41 ` [PATCH bpf-next 8/8] tools: bpftool: deal with options upfront Jakub Kicinski
2018-06-30 23:03 ` [PATCH bpf-next 0/8] tools: bpf: updates to bpftool and libbpf 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=20180628214142.11268-4-jakub.kicinski@netronome.com \
--to=jakub.kicinski@netronome.com \
--cc=alexei.starovoitov@gmail.com \
--cc=daniel@iogearbox.net \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.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