summaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/bpf.c
diff options
context:
space:
mode:
authorStanislav Fomichev <sdf@google.com>2018-11-20 17:11:20 -0800
committerDaniel Borkmann <daniel@iogearbox.net>2018-11-21 23:26:04 +0100
commit94cb310cfaa16582cd49ebbeea5925e8f49324a1 (patch)
tree0e274f0cd618cb816e0432d048d1ce67cca498f8 /tools/lib/bpf/bpf.c
parent47eff61777c7b2db58805f974994713c8acbe9a6 (diff)
downloadlinux-94cb310cfaa16582cd49ebbeea5925e8f49324a1.tar.gz
linux-94cb310cfaa16582cd49ebbeea5925e8f49324a1.tar.bz2
linux-94cb310cfaa16582cd49ebbeea5925e8f49324a1.zip
bpf: libbpf: remove map name retry from bpf_create_map_xattr
Instead, check for a newly created caps.name bpf_object capability. If kernel doesn't support names, don't specify the attribute. See commit 23499442c319 ("bpf: libbpf: retry map creation without the name") for rationale. Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/lib/bpf/bpf.c')
-rw-r--r--tools/lib/bpf/bpf.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 836447bb4f14..ce1822194590 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -69,7 +69,6 @@ int bpf_create_map_xattr(const struct bpf_create_map_attr *create_attr)
{
__u32 name_len = create_attr->name ? strlen(create_attr->name) : 0;
union bpf_attr attr;
- int ret;
memset(&attr, '\0', sizeof(attr));
@@ -87,15 +86,7 @@ int bpf_create_map_xattr(const struct bpf_create_map_attr *create_attr)
attr.map_ifindex = create_attr->map_ifindex;
attr.inner_map_fd = create_attr->inner_map_fd;
- ret = sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
- if (ret < 0 && errno == EINVAL && create_attr->name) {
- /* Retry the same syscall, but without the name.
- * Pre v4.14 kernels don't support map names.
- */
- memset(attr.map_name, 0, sizeof(attr.map_name));
- return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
- }
- return ret;
+ return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
}
int bpf_create_map_node(enum bpf_map_type map_type, const char *name,