libbpf: introduce bpf_map_lookup_elem_flags()
authorAlexei Starovoitov <ast@kernel.org>
Thu, 31 Jan 2019 23:40:11 +0000 (15:40 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 1 Feb 2019 19:55:39 +0000 (20:55 +0100)
Introduce
int bpf_map_lookup_elem_flags(int fd, const void *key, void *value, __u64 flags)
helper to lookup array/hash/cgroup_local_storage elements with BPF_F_LOCK flag.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/lib/bpf/bpf.c
tools/lib/bpf/bpf.h
tools/lib/bpf/libbpf.map

index 88cbd110ae5807091b2a1c7b5227abd1940d996f..3defad77dc7aca37e7496e2aee6e6b386f44a802 100644 (file)
@@ -368,6 +368,19 @@ int bpf_map_lookup_elem(int fd, const void *key, void *value)
        return sys_bpf(BPF_MAP_LOOKUP_ELEM, &attr, sizeof(attr));
 }
 
+int bpf_map_lookup_elem_flags(int fd, const void *key, void *value, __u64 flags)
+{
+       union bpf_attr attr;
+
+       bzero(&attr, sizeof(attr));
+       attr.map_fd = fd;
+       attr.key = ptr_to_u64(key);
+       attr.value = ptr_to_u64(value);
+       attr.flags = flags;
+
+       return sys_bpf(BPF_MAP_LOOKUP_ELEM, &attr, sizeof(attr));
+}
+
 int bpf_map_lookup_and_delete_elem(int fd, const void *key, void *value)
 {
        union bpf_attr attr;
index 8f09de482839e289ff1b203d105eae26b52d2de6..ed09eed2dc3ba6e6a3b2ebf0d4241066e2d04447 100644 (file)
@@ -110,6 +110,8 @@ LIBBPF_API int bpf_map_update_elem(int fd, const void *key, const void *value,
                                   __u64 flags);
 
 LIBBPF_API int bpf_map_lookup_elem(int fd, const void *key, void *value);
+LIBBPF_API int bpf_map_lookup_elem_flags(int fd, const void *key, void *value,
+                                        __u64 flags);
 LIBBPF_API int bpf_map_lookup_and_delete_elem(int fd, const void *key,
                                              void *value);
 LIBBPF_API int bpf_map_delete_elem(int fd, const void *key);
index 266bc95d0142698539dd5586af2112581397ac61..f6f96fc38c504380306ce98e0db69622e3fa1051 100644 (file)
@@ -130,4 +130,5 @@ LIBBPF_0.0.2 {
                bpf_probe_helper;
                bpf_probe_map_type;
                bpf_probe_prog_type;
+               bpf_map_lookup_elem_flags;
 } LIBBPF_0.0.1;