bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/6] libbpf: Fix pinning and error message bugs and add new getters
@ 2019-11-07 16:52 Toke Høiland-Jørgensen
  2019-11-07 16:52 ` [PATCH bpf-next 1/6] libbpf: Unpin auto-pinned maps if loading fails Toke Høiland-Jørgensen
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Toke Høiland-Jørgensen @ 2019-11-07 16:52 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: Alexei Starovoitov, Martin KaFai Lau, Song Liu, Yonghong Song,
	Jesper Dangaard Brouer, Andrii Nakryiko, David Miller, netdev,
	bpf

This series fixes a few bugs in libbpf that I discovered while playing around
with the new auto-pinning code, and writing the first utility in xdp-tools[0]:

- If object loading fails, libbpf does not clean up the pinnings created by the
  auto-pinning mechanism.
- EPERM is not propagated to the caller on program load
- Netlink functions write error messages directly to stderr

In addition, libbpf currently only has a somewhat limited getter function for
XDP link info, which makes it impossible to discover whether an attached program
is in SKB mode or not. So the last patch in the series adds a new getter for XDP
link info which returns all the information returned via netlink (and which can
be extended later).

Finally, add a getter for BPF program size, which can be used by the caller to
estimate the amount of locked memory needed to load a program.

A selftest is added for the pinning change, while the other features were tested
in the xdp-filter tool from the xdp-tools repo. The 'new-libbpf-features' branch
contains the commits that make use of the new XDP getter and the corrected EPERM
error code.

[0] https://github.com/xdp-project/xdp-tools

---

Toke Høiland-Jørgensen (6):
      libbpf: Unpin auto-pinned maps if loading fails
      selftests/bpf: Add tests for automatic map unpinning on load failure
      libbpf: Propagate EPERM to caller on program load
      libbpf: Use pr_warn() when printing netlink errors
      libbpf: Add bpf_get_link_xdp_info() function to get more XDP information
      libbpf: Add getter for program size


 tools/lib/bpf/libbpf.c                           |   25 +++++--
 tools/lib/bpf/libbpf.h                           |   11 +++
 tools/lib/bpf/libbpf.map                         |    2 +
 tools/lib/bpf/netlink.c                          |   81 ++++++++++++++--------
 tools/lib/bpf/nlattr.c                           |   10 +--
 tools/testing/selftests/bpf/prog_tests/pinning.c |   20 +++++
 tools/testing/selftests/bpf/progs/test_pinning.c |    2 -
 7 files changed, 109 insertions(+), 42 deletions(-)


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-11-08 20:04 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-07 16:52 [PATCH bpf-next 0/6] libbpf: Fix pinning and error message bugs and add new getters Toke Høiland-Jørgensen
2019-11-07 16:52 ` [PATCH bpf-next 1/6] libbpf: Unpin auto-pinned maps if loading fails Toke Høiland-Jørgensen
2019-11-08 19:27   ` Song Liu
2019-11-07 16:52 ` [PATCH bpf-next 2/6] selftests/bpf: Add tests for automatic map unpinning on load failure Toke Høiland-Jørgensen
2019-11-08 19:33   ` Song Liu
2019-11-08 20:00     ` Toke Høiland-Jørgensen
2019-11-07 16:52 ` [PATCH bpf-next 3/6] libbpf: Propagate EPERM to caller on program load Toke Høiland-Jørgensen
2019-11-08 19:36   ` Song Liu
2019-11-07 16:52 ` [PATCH bpf-next 4/6] libbpf: Use pr_warn() when printing netlink errors Toke Høiland-Jørgensen
2019-11-08 19:37   ` Song Liu
2019-11-07 16:52 ` [PATCH bpf-next 5/6] libbpf: Add bpf_get_link_xdp_info() function to get more XDP information Toke Høiland-Jørgensen
2019-11-08 19:52   ` Song Liu
2019-11-08 20:04     ` Toke Høiland-Jørgensen
2019-11-07 16:52 ` [PATCH bpf-next 6/6] libbpf: Add getter for program size Toke Høiland-Jørgensen
2019-11-08 19:55   ` Song Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).