]> git.karo-electronics.de Git - karo-tx-linux.git/commit
tools lib bpf: Add BPF program pinning APIs
authorJoe Stringer <joe@ovn.org>
Thu, 26 Jan 2017 21:19:56 +0000 (13:19 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 31 Jan 2017 19:20:05 +0000 (16:20 -0300)
commitf367540c8c13d65603c431e29a0b87a7db893d6c
tree7a5556430a8d34e5a0ba7accbcfcdfcc206a5fb1
parent9c68ae98c6f714ef573826cfc9055af1bd5e97b1
tools lib bpf: Add BPF program pinning APIs

Add new APIs to pin a BPF program (or specific instances) to the
filesystem.  The user can specify the path full path within a BPF
filesystem to pin the program.

bpf_program__pin_instance(prog, path, n) will pin the nth instance of
'prog' to the specified path.

bpf_program__pin(prog, path) will create the directory 'path' (if it
does not exist) and pin each instance within that directory. For
instance, path/0, path/1, path/2.

Committer notes:

- Add missing headers for mkdir()

- Check strdup() for failure

- Check snprintf >= size, not >, as == also means truncated, see 'man
  snprintf', return value.

- Conditionally define BPF_FS_MAGIC, as it isn't in magic.h in older
  systems and we're not yet having a tools/include/uapi/linux/magic.h
  copy.

- Do not include linux/magic.h, not present in older distros.

Signed-off-by: Joe Stringer <joe@ovn.org>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: netdev@vger.kernel.org
Link: http://lkml.kernel.org/r/20170126212001.14103-2-joe@ovn.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf.h