mbox series

[bpf-next,V3,0/5] tools/libbpf improvements and selftests

Message ID 151809046123.4625.11746882480100311060.stgit@firesoul
Headers show
Series tools/libbpf improvements and selftests | expand

Message

Jesper Dangaard Brouer Feb. 8, 2018, 11:48 a.m. UTC
While playing with using libbpf for the Suricata project, we had
issues LLVM >= 4.0.1 generating ELF files that could not be loaded
with libbpf (tools/lib/bpf/).

During the troubleshooting phase, I wrote a test program and improved
the debugging output in libbpf.  I turned this into a selftests
program, and it also serves as a code example for libbpf in itself.

I discovered that there are at least three ELF load issues with
libbpf.  I left them as TODO comments in (tools/testing/selftests/bpf)
test_libbpf.sh. I've only fixed the load issue with eh_frames, and
other types of relo-section that does not have exec flags.  We can
work on the other issues later.

---

Jesper Dangaard Brouer (5):
      bpf: Sync kernel ABI header with tooling header for bpf_common.h
      tools/libbpf: improve the pr_debug statements to contain section numbers
      selftests/bpf: add test program for loading BPF ELF files
      selftests/bpf: add selftest that use test_libbpf_open
      tools/libbpf: handle issues with bpf ELF objects containing .eh_frames


 tools/include/uapi/linux/bpf_common.h          |    7 +
 tools/lib/bpf/libbpf.c                         |   51 ++++++--
 tools/testing/selftests/bpf/Makefile           |   12 ++
 tools/testing/selftests/bpf/test_libbpf.sh     |   49 ++++++++
 tools/testing/selftests/bpf/test_libbpf_open.c |  150 ++++++++++++++++++++++++
 5 files changed, 253 insertions(+), 16 deletions(-)
 create mode 100755 tools/testing/selftests/bpf/test_libbpf.sh
 create mode 100644 tools/testing/selftests/bpf/test_libbpf_open.c

--

Comments

Daniel Borkmann Feb. 9, 2018, 1:32 a.m. UTC | #1
On 02/08/2018 12:48 PM, Jesper Dangaard Brouer wrote:
> While playing with using libbpf for the Suricata project, we had
> issues LLVM >= 4.0.1 generating ELF files that could not be loaded
> with libbpf (tools/lib/bpf/).
> 
> During the troubleshooting phase, I wrote a test program and improved
> the debugging output in libbpf.  I turned this into a selftests
> program, and it also serves as a code example for libbpf in itself.
> 
> I discovered that there are at least three ELF load issues with
> libbpf.  I left them as TODO comments in (tools/testing/selftests/bpf)
> test_libbpf.sh. I've only fixed the load issue with eh_frames, and
> other types of relo-section that does not have exec flags.  We can
> work on the other issues later.

Applied it to bpf tree, thanks Jesper!
Jesper Dangaard Brouer Feb. 9, 2018, 8:18 a.m. UTC | #2
On Fri, 9 Feb 2018 02:32:27 +0100
Daniel Borkmann <daniel@iogearbox.net> wrote:

> On 02/08/2018 12:48 PM, Jesper Dangaard Brouer wrote:
> > While playing with using libbpf for the Suricata project, we had
> > issues LLVM >= 4.0.1 generating ELF files that could not be loaded
> > with libbpf (tools/lib/bpf/).
> > 
> > During the troubleshooting phase, I wrote a test program and improved
> > the debugging output in libbpf.  I turned this into a selftests
> > program, and it also serves as a code example for libbpf in itself.
> > 
> > I discovered that there are at least three ELF load issues with
> > libbpf.  I left them as TODO comments in (tools/testing/selftests/bpf)
> > test_libbpf.sh. I've only fixed the load issue with eh_frames, and
> > other types of relo-section that does not have exec flags.  We can
> > work on the other issues later.  
> 
> Applied it to bpf tree, thanks Jesper!

Thank you for applying this the 'bpf' tree! -- appreciate it!
Daniel Borkmann Feb. 9, 2018, 11:50 a.m. UTC | #3
On 02/09/2018 09:18 AM, Jesper Dangaard Brouer wrote:
> On Fri, 9 Feb 2018 02:32:27 +0100
> Daniel Borkmann <daniel@iogearbox.net> wrote:
> 
>> On 02/08/2018 12:48 PM, Jesper Dangaard Brouer wrote:
>>> While playing with using libbpf for the Suricata project, we had
>>> issues LLVM >= 4.0.1 generating ELF files that could not be loaded
>>> with libbpf (tools/lib/bpf/).
>>>
>>> During the troubleshooting phase, I wrote a test program and improved
>>> the debugging output in libbpf.  I turned this into a selftests
>>> program, and it also serves as a code example for libbpf in itself.
>>>
>>> I discovered that there are at least three ELF load issues with
>>> libbpf.  I left them as TODO comments in (tools/testing/selftests/bpf)
>>> test_libbpf.sh. I've only fixed the load issue with eh_frames, and
>>> other types of relo-section that does not have exec flags.  We can
>>> work on the other issues later.  
>>
>> Applied it to bpf tree, thanks Jesper!
> 
> Thank you for applying this the 'bpf' tree! -- appreciate it!

Btw, if you have a chance to send a small doc update for the
Documentation/bpf/bpf_devel_QA.txt and describe somewhere in
the LLVM section of the doc the discussed issue around
gnu/stubs-32.h with possible workarounds, that would be great.

Thanks,
Daniel