lkml.org 
[lkml]   [2016]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [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@huawei.com>
    > Cc: Alexei Starovoitov <ast@fb.com>
    > Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
    > Cc: Joe Stringer <joe@ovn.org>
    > Cc: Li Zefan <lizefan@huawei.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@kernel.org>

    \
     
     \ /
      Last update: 2016-11-26 18:11    [W:4.418 / U:1.096 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site