Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1563208
| From | Joe Stringer <joe@ovn.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH perf/core 6/6] tools lib bpf: Add bpf_object__pin() |
| Date | 2017-01-20 01:00 +0100 |
| Message-ID | <t1uMx-8aL-1@gated-at.bofh.it> (permalink) |
| References | <t18iZ-2h7-1@gated-at.bofh.it> <t18sG-2zw-19@gated-at.bofh.it> <t1i8F-jB-17@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 19 January 2017 at 02:22, Wangnan (F) <wangnan0@huawei.com> wrote:
>
>
> On 2017/1/19 7:57, Joe Stringer wrote:
>>
>> Add a new API to pin a BPF object to the filesystem. The user can
>> specify a subdirectory under the BPF filesystem to pin these programs.
>>
>> For example, with the subdirectory 'foo', programs and maps are pinned:
>> /sys/fs/bpf/foo/progs/PROG_NAME
>> /sys/fs/bpf/foo/maps/MAP_NAME
>>
>> If the user has specified an alternative BPF filesystem mountpoint via
>> /proc/mounts, that will be read and used instead.
>>
>> Signed-off-by: Joe Stringer <joe@ovn.org>
>> ---
>> tools/lib/bpf/libbpf.c | 136
>> +++++++++++++++++++++++++++++++++++++++++++++++++
>> tools/lib/bpf/libbpf.h | 1 +
>> 2 files changed, 137 insertions(+)
>>
>> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
>> index 6b651c19870d..181dca0bdacb 100644
>> --- a/tools/lib/bpf/libbpf.c
>> +++ b/tools/lib/bpf/libbpf.c
>> @@ -4,6 +4,7 @@
>> * Copyright (C) 2013-2015 Alexei Starovoitov <ast@kernel.org>
>> * Copyright (C) 2015 Wang Nan <wangnan0@huawei.com>
>> * Copyright (C) 2015 Huawei Inc.
>> + * Copyright (C) 2016 Nicira, Inc.
>> *
>> * This program is free software; you can redistribute it and/or
>> * modify it under the terms of the GNU Lesser General Public
>> @@ -31,7 +32,12 @@
>> #include <linux/err.h>
>> #include <linux/kernel.h>
>> #include <linux/bpf.h>
>> +#include <linux/magic.h>
>> #include <linux/list.h>
>> +#include <linux/limits.h>
>> +#include <sys/mount.h>
>> +#include <sys/stat.h>
>> +#include <sys/vfs.h>
>> #include <libelf.h>
>> #include <gelf.h>
>> @@ -1231,6 +1237,136 @@ int bpf_object__load(struct bpf_object *obj)
>> return err;
>> }
>> +#define stringize(x) #x
>> +
>> +static int mount_bpf(char *path)
>
>
> We can use tools/lib/api/fs/fs.c to help us mounting filesystems.
> Try not reinventing it.
libbpf is LGPL2.1 and libapi doesn't state a license.
Instead, maybe I'll just drop this piece - libbpf user can mount the
filesystem (using libapi or something else) and provide fully
qualified path to bpf_{map,program}__pin().
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH perf/core 0/6] Libbpf improvements Joe Stringer <joe@ovn.org> - 2017-01-19 01:00 +0100
[PATCH perf/core 2/6] tools lib bpf: Fix grammar in map_idx warning Joe Stringer <joe@ovn.org> - 2017-01-19 01:00 +0100
Re: [PATCH perf/core 2/6] tools lib bpf: Fix grammar in map_idx warning "Wangnan (F)" <wangnan0@huawei.com> - 2017-01-19 11:20 +0100
[PATCH perf/core 4/6] tools lib bpf: Add set/is helpers for all prog types Joe Stringer <joe@ovn.org> - 2017-01-19 01:00 +0100
[PATCH perf/core 5/6] tools lib bpf: Add libbpf_get_error() Joe Stringer <joe@ovn.org> - 2017-01-19 01:10 +0100
[PATCH perf/core 1/6] tools lib bpf: Fix map offsets in relocation Joe Stringer <joe@ovn.org> - 2017-01-19 01:10 +0100
Re: [PATCH perf/core 1/6] tools lib bpf: Fix map offsets in relocation "Wangnan (F)" <wangnan0@huawei.com> - 2017-01-19 07:10 +0100
[PATCH -improve] tools lib bpf: Fix map offsets in relocation Wang Nan <wangnan0@huawei.com> - 2017-01-19 11:00 +0100
[PATCH perf/core 3/6] tools lib bpf: Define prog_type fns with macro Joe Stringer <joe@ovn.org> - 2017-01-19 01:10 +0100
[PATCH perf/core 6/6] tools lib bpf: Add bpf_object__pin() Joe Stringer <joe@ovn.org> - 2017-01-19 01:10 +0100
Re: [PATCH perf/core 6/6] tools lib bpf: Add bpf_object__pin() "Wangnan (F)" <wangnan0@huawei.com> - 2017-01-19 11:30 +0100
Re: [PATCH perf/core 6/6] tools lib bpf: Add bpf_object__pin() Joe Stringer <joe@ovn.org> - 2017-01-20 01:00 +0100
Re: [PATCH perf/core 0/6] Libbpf improvements "Wangnan (F)" <wangnan0@huawei.com> - 2017-01-19 11:30 +0100
Re: [PATCH perf/core 0/6] Libbpf improvements Joe Stringer <joe@ovn.org> - 2017-01-23 02:20 +0100
csiph-web