From: David Ahern <dsahern@kernel.org>
To: netdev@vger.kernel.org
Cc: stephen@networkplumber.org, David Ahern <dsahern@kernel.org>
Subject: [PATCH iproute2-next 1/3] bpf_glue: Remove use of bpf_load_program from libbpf
Date: Sun, 27 Feb 2022 18:58:38 -0700 [thread overview]
Message-ID: <20220228015840.1413-2-dsahern@kernel.org> (raw)
In-Reply-To: <20220228015840.1413-1-dsahern@kernel.org>
bpf_load_program is deprecated starting in v0.7. The preferred
bpf_prog_load requires bpf_prog_load_opts from v0.6. This creates an
ugly scenario for iproute2 to work across libbpf versions from v0.1
and up.
Since bpf_program_load is only used to load the builtin vrf program,
just remove the libbpf call and use the legacy code.
Signed-off-by: David Ahern <dsahern@kernel.org>
---
lib/bpf_glue.c | 12 ------------
lib/bpf_legacy.c | 7 +++++++
2 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/lib/bpf_glue.c b/lib/bpf_glue.c
index 70d001840f7b..cc3015487c68 100644
--- a/lib/bpf_glue.c
+++ b/lib/bpf_glue.c
@@ -11,18 +11,6 @@
#include <bpf/bpf.h>
#endif
-int bpf_program_load(enum bpf_prog_type type, const struct bpf_insn *insns,
- size_t size_insns, const char *license, char *log,
- size_t size_log)
-{
-#ifdef HAVE_LIBBPF
- return bpf_load_program(type, insns, size_insns / sizeof(struct bpf_insn),
- license, 0, log, size_log);
-#else
- return bpf_prog_load_dev(type, insns, size_insns, license, 0, log, size_log);
-#endif
-}
-
int bpf_program_attach(int prog_fd, int target_fd, enum bpf_attach_type type)
{
#ifdef HAVE_LIBBPF
diff --git a/lib/bpf_legacy.c b/lib/bpf_legacy.c
index 6e3891c9f1f1..3779ae90cc1c 100644
--- a/lib/bpf_legacy.c
+++ b/lib/bpf_legacy.c
@@ -1126,6 +1126,13 @@ int bpf_prog_load_dev(enum bpf_prog_type type, const struct bpf_insn *insns,
return bpf(BPF_PROG_LOAD, &attr, sizeof(attr));
}
+int bpf_program_load(enum bpf_prog_type type, const struct bpf_insn *insns,
+ size_t size_insns, const char *license, char *log,
+ size_t size_log)
+{
+ return bpf_prog_load_dev(type, insns, size_insns, license, 0, log, size_log);
+}
+
#ifdef HAVE_ELF
struct bpf_elf_prog {
enum bpf_prog_type type;
--
2.24.3 (Apple Git-128)
next prev parent reply other threads:[~2022-02-28 1:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-28 1:58 [PATCH iproute2-next 0/3] bpf: Work around libbpf deprecations David Ahern
2022-02-28 1:58 ` David Ahern [this message]
2022-02-28 1:58 ` [PATCH iproute2-next 2/3] bpf: Export bpf syscall wrapper David Ahern
2022-02-28 1:58 ` [PATCH iproute2-next 3/3] bpf: Remove use of bpf_create_map_xattr David Ahern
2022-03-07 16:10 ` [PATCH iproute2-next 0/3] bpf: Work around libbpf deprecations patchwork-bot+netdevbpf
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=20220228015840.1413-2-dsahern@kernel.org \
--to=dsahern@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.