[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20161126171043.GB83987@ast-mbp.thefacebook.com>
Date: Sat, 26 Nov 2016 09:10:44 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Wang Nan <wangnan0@...wei.com>
Cc: acme@...hat.com, ast@...com, lizefan@...wei.com,
hekuang@...wei.com, linux-kernel@...r.kernel.org, pi3orama@....com,
joe@....org
Subject: Re: [PATCH v3 01/30] tools lib bpf: Add missing BPF functions
On Sat, Nov 26, 2016 at 07:03:25AM +0000, Wang Nan wrote:
> Add more BPF map operations to libbpf. Also add bpf_obj_{pin,get}(). They
> can be used on not only BPF maps but also BPF programs.
>
> Signed-off-by: Wang Nan <wangnan0@...wei.com>
> Cc: Alexei Starovoitov <ast@...com>
> Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
> Cc: Joe Stringer <joe@....org>
> Cc: Li Zefan <lizefan@...wei.com>
> ---
> tools/lib/bpf/bpf.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> tools/lib/bpf/bpf.h | 7 +++++++
> 2 files changed, 63 insertions(+)
>
> diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> index 4212ed6..8143536 100644
> --- a/tools/lib/bpf/bpf.c
> +++ b/tools/lib/bpf/bpf.c
> @@ -110,3 +110,59 @@ int bpf_map_update_elem(int fd, void *key, void *value,
>
> return sys_bpf(BPF_MAP_UPDATE_ELEM, &attr, sizeof(attr));
> }
> +
> +int bpf_map_lookup_elem(int fd, void *key, void *value)
> +{
> + union bpf_attr attr;
> +
> + bzero(&attr, sizeof(attr));
> + attr.map_fd = fd;
> + attr.key = ptr_to_u64(key);
> + attr.value = ptr_to_u64(value);
> +
> + return sys_bpf(BPF_MAP_LOOKUP_ELEM, &attr, sizeof(attr));
> +}
Acked-by: Alexei Starovoitov <ast@...nel.org>
Powered by blists - more mailing lists