[SNIP]
On 2015/12/18 14:19, Alexei Starovoitov wrote:
On Fri, Dec 18, 2015 at 09:47:11AM +0800, Wangnan (F) wrote:
This is a limitation in tools/lib/bpf/libbpf.h, which has a #include
<linux/err.h>
in its header.
libbpf.h requires this include because its API uses ERR_PTR() to encode
error code.
For example, when calling bpf_object__open(), caller should use IS_ERR() to
check its
return value instead of compare with NULL, and use PTR_ERR() to retrive
error number.
However, linux/err.h is not a part of uapi. To make libbpf work, one has to
create its
own err.h.
What about moving them into include/uapi/linux/filter.h ? Thenwe don't want to add these macros to uapi.
normal user programs like those in samples/bpf can access
them easier.
Why not to add it to
tools/include/linux/filter.h
instead?
What I want to do in this patchset is not only removing original libbpf.c
and bpf_load.c. In fact I want libbpf in tools/lib/bpf becomes a public
available library for other userspace tools (tc for example). Switching
samples/bpf into libbpf is the first step of this goal. From doing this
I found and fixed some limitation, like those missed BPF map operations.
Making libbpf.h and bpf.h available for normal userspace programs is also
important.
Having the above goal, I think you can understand why improving tools/include
is not a good idea. You don't want to force a normal userspace program setup
a similar header environment for using libbpf. It is relatively a small
library. So it would be good if bpf.h and libbpf.h only depend on what can
be found in uapi.