From: David Ahern <dsahern@kernel.org>
To: netdev@vger.kernel.org
Cc: stephen@networkplumber.org, David Ahern <dsahern@kernel.org>
Subject: [PATCH iproute2-next 3/3] bpf: Remove use of bpf_create_map_xattr
Date: Sun, 27 Feb 2022 18:58:40 -0700 [thread overview]
Message-ID: <20220228015840.1413-4-dsahern@kernel.org> (raw)
In-Reply-To: <20220228015840.1413-1-dsahern@kernel.org>
bpf_create_map_xattr is deprecated in v0.7 in favor of bpf_map_create.
bpf_map_create and its bpf_map_create_opts are not available across the
range of v0.1 and up versions of libbpf, so change create_map to use
the bpf syscall directly.
Signed-off-by: David Ahern <dsahern@kernel.org>
---
lib/bpf_libbpf.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/lib/bpf_libbpf.c b/lib/bpf_libbpf.c
index 921716aec8c6..f4f98caa1e58 100644
--- a/lib/bpf_libbpf.c
+++ b/lib/bpf_libbpf.c
@@ -54,18 +54,18 @@ static const char *get_bpf_program__section_name(const struct bpf_program *prog)
static int create_map(const char *name, struct bpf_elf_map *map,
__u32 ifindex, int inner_fd)
{
- struct bpf_create_map_attr map_attr = {};
-
- map_attr.name = name;
- map_attr.map_type = map->type;
- map_attr.map_flags = map->flags;
- map_attr.key_size = map->size_key;
- map_attr.value_size = map->size_value;
- map_attr.max_entries = map->max_elem;
- map_attr.map_ifindex = ifindex;
- map_attr.inner_map_fd = inner_fd;
-
- return bpf_create_map_xattr(&map_attr);
+ union bpf_attr attr = {};
+
+ attr.map_type = map->type;
+ strlcpy(attr.map_name, name, sizeof(attr.map_name));
+ attr.map_flags = map->flags;
+ attr.key_size = map->size_key;
+ attr.value_size = map->size_value;
+ attr.max_entries = map->max_elem;
+ attr.map_ifindex = ifindex;
+ attr.inner_map_fd = inner_fd;
+
+ return bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
}
static int create_map_in_map(struct bpf_object *obj, struct bpf_map *map,
--
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 ` [PATCH iproute2-next 1/3] bpf_glue: Remove use of bpf_load_program from libbpf David Ahern
2022-02-28 1:58 ` [PATCH iproute2-next 2/3] bpf: Export bpf syscall wrapper David Ahern
2022-02-28 1:58 ` David Ahern [this message]
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-4-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.