Commit a15d408b authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Alexei Starovoitov

bpftool: Migrate off of deprecated bpf_create_map_xattr() API

Switch to bpf_map_create() API instead.
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20211201232824.3166325-4-andrii@kernel.org
parent dbdd2c7f
...@@ -1261,7 +1261,10 @@ static int do_pin(int argc, char **argv) ...@@ -1261,7 +1261,10 @@ static int do_pin(int argc, char **argv)
static int do_create(int argc, char **argv) static int do_create(int argc, char **argv)
{ {
struct bpf_create_map_attr attr = { NULL, }; LIBBPF_OPTS(bpf_map_create_opts, attr);
enum bpf_map_type map_type = BPF_MAP_TYPE_UNSPEC;
__u32 key_size = 0, value_size = 0, max_entries = 0;
const char *map_name = NULL;
const char *pinfile; const char *pinfile;
int err = -1, fd; int err = -1, fd;
...@@ -1276,30 +1279,30 @@ static int do_create(int argc, char **argv) ...@@ -1276,30 +1279,30 @@ static int do_create(int argc, char **argv)
if (is_prefix(*argv, "type")) { if (is_prefix(*argv, "type")) {
NEXT_ARG(); NEXT_ARG();
if (attr.map_type) { if (map_type) {
p_err("map type already specified"); p_err("map type already specified");
goto exit; goto exit;
} }
attr.map_type = map_type_from_str(*argv); map_type = map_type_from_str(*argv);
if ((int)attr.map_type < 0) { if ((int)map_type < 0) {
p_err("unrecognized map type: %s", *argv); p_err("unrecognized map type: %s", *argv);
goto exit; goto exit;
} }
NEXT_ARG(); NEXT_ARG();
} else if (is_prefix(*argv, "name")) { } else if (is_prefix(*argv, "name")) {
NEXT_ARG(); NEXT_ARG();
attr.name = GET_ARG(); map_name = GET_ARG();
} else if (is_prefix(*argv, "key")) { } else if (is_prefix(*argv, "key")) {
if (parse_u32_arg(&argc, &argv, &attr.key_size, if (parse_u32_arg(&argc, &argv, &key_size,
"key size")) "key size"))
goto exit; goto exit;
} else if (is_prefix(*argv, "value")) { } else if (is_prefix(*argv, "value")) {
if (parse_u32_arg(&argc, &argv, &attr.value_size, if (parse_u32_arg(&argc, &argv, &value_size,
"value size")) "value size"))
goto exit; goto exit;
} else if (is_prefix(*argv, "entries")) { } else if (is_prefix(*argv, "entries")) {
if (parse_u32_arg(&argc, &argv, &attr.max_entries, if (parse_u32_arg(&argc, &argv, &max_entries,
"max entries")) "max entries"))
goto exit; goto exit;
} else if (is_prefix(*argv, "flags")) { } else if (is_prefix(*argv, "flags")) {
...@@ -1340,14 +1343,14 @@ static int do_create(int argc, char **argv) ...@@ -1340,14 +1343,14 @@ static int do_create(int argc, char **argv)
} }
} }
if (!attr.name) { if (!map_name) {
p_err("map name not specified"); p_err("map name not specified");
goto exit; goto exit;
} }
set_max_rlimit(); set_max_rlimit();
fd = bpf_create_map_xattr(&attr); fd = bpf_map_create(map_type, map_name, key_size, value_size, max_entries, &attr);
if (fd < 0) { if (fd < 0) {
p_err("map create failed: %s", strerror(errno)); p_err("map create failed: %s", strerror(errno));
goto exit; goto exit;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment