From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
netdev@vger.kernel.org, Daniel Borkmann <borkmann@iogearbox.net>,
wangnan0@huawei.com, jakub.kicinski@netronome.com, joe@ovn.org,
acme@redhat.com, eric@regit.org, yhs@fb.com,
Victor Julien <victor@inliniac.net>,
brouer@redhat.com
Subject: Re: [bpf-next V2 PATCH 5/5] tools/libbpf: handle issues with bpf ELF objects containing .eh_frames
Date: Wed, 7 Feb 2018 15:58:11 +0100 [thread overview]
Message-ID: <20180207155811.4e0e18e3@redhat.com> (raw)
In-Reply-To: <5e9c9b1c-e3ee-a237-9536-319cf118ff09@iogearbox.net>
On Wed, 7 Feb 2018 14:19:00 +0100
Daniel Borkmann <daniel@iogearbox.net> wrote:
> On 02/07/2018 01:40 PM, Jesper Dangaard Brouer wrote:
> > On Tue, 6 Feb 2018 20:05:43 +0100 Daniel Borkmann <daniel@iogearbox.net> wrote:
> >> On 02/06/2018 06:03 PM, Jesper Dangaard Brouer wrote:
> > [...]
> >>> [...] I plan to follow up and do a more complete solution later. This
> >>> is a workaround to get the Suricata use-case working and also that
> >>> samples/bpf/ can be loaded.
> >>
> >> Aside from a needed fix in any case, is there a specifc reason why Suricata
> >> cannot rely on 'clang -target bpf'? Is it asm inline headers in your case?
> >
> > Below is the error I get when using 'clang' with '-target bpf'
> >
> > $ dirs
> > ~/git/suricata/src/ebpf
> >
> > $ clang -Wall -Iinclude -O2 -D__KERNEL__ -target bpf -emit-llvm -c xdp_filter.c -o - | llc -march=bpf -filetype=obj -o xdp_filter.bpf
> > In file included from xdp_filter.c:19:
> > In file included from /usr/bin/../lib64/clang/4.0.1/include/stdint.h:63:
> > In file included from /usr/include/stdint.h:26:
> > In file included from /usr/include/bits/libc-header-start.h:33:
> > In file included from /usr/include/features.h:434:
> > /usr/include/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-32.h' file not found
> > # include <gnu/stubs-32.h>
> > ^~~~~~~~~~~~~~~~
> >
> > I'll leave it up to Eric Leblond to figure out that he need to change
> > in the eBPF programs to make it compile with '-target bpf'. Maybe you
> > can offer him some guidance here?
> >
> > Direct link to code:
> > https://github.com/OISF/suricata/blob/master/ebpf/xdp_filter.c
>
> Sure, you just need glibc-devel.i686, see:
>
> $ clang -Wall -Iinclude -O2 -D__KERNEL__ -target bpf -emit-llvm -c xdp_filter.c -o - | llc -march=bpf -filetype=obj -o xdp_filter.bpf
> In file included from xdp_filter.c:19:
> In file included from /home/darkstar/llvm/build/lib/clang/7.0.0/include/stdint.h:63:
> In file included from /usr/include/stdint.h:25:
> In file included from /usr/include/features.h:392:
> /usr/include/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-32.h' file not found
> # include <gnu/stubs-32.h>
> ^~~~~~~~~~~~~~~~
> 1 error generated.
> # yum install glibc-devel.i686
> [...]
> $ clang -Wall -Iinclude -O2 -D__KERNEL__ -target bpf -emit-llvm -c xdp_filter.c -o - | llc -march=bpf -filetype=obj -o xdp_filter.bpf
> $
Could you please explain why if makes a difference to install glibc-devel.i686 ?
How will people compiling suricata figure out the new dependency, that
on their 64-bit (x86_64) distro's they also need to install the 32-bit
(i686) variant of glibc-devel ?
> Alternatively, you could do something like done in selftests to provide a
> dummy, see commit 1c2dd16add7e ("selftests/bpf: get rid of -D__x86_64__").
That is a funny way to workaround the problem (having an empty
<gnu/stubs.h> file in include path), but it might be a better solution
to avoid frustrations for people compiling suricata.
An alternative solution is to NOT:
#include <stdint.h>
#include <string.h>
And then change:
uint64_t -> __u64
uint32_t -> __u32
uint16_t -> __u16
uint8_t -> __u8
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2018-02-07 14:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-06 14:54 [bpf-next V2 PATCH 0/5] tools/libbpf improvements and selftests Jesper Dangaard Brouer
2018-02-06 14:54 ` [bpf-next V2 PATCH 1/5] bpf: Sync kernel ABI header with tooling header for bpf_common.h Jesper Dangaard Brouer
2018-02-06 14:54 ` [bpf-next V2 PATCH 2/5] tools/libbpf: improve the pr_debug statements to contain section numbers Jesper Dangaard Brouer
2018-02-06 14:54 ` [bpf-next V2 PATCH 3/5] selftests/bpf: add test program for loading BPF ELF files Jesper Dangaard Brouer
2018-02-06 14:54 ` [bpf-next V2 PATCH 4/5] selftests/bpf: add selftest that use test_libbpf_open Jesper Dangaard Brouer
2018-02-06 14:54 ` [bpf-next V2 PATCH 5/5] tools/libbpf: handle issues with bpf ELF objects containing .eh_frames Jesper Dangaard Brouer
2018-02-06 16:00 ` Alexei Starovoitov
2018-02-06 17:03 ` Jesper Dangaard Brouer
2018-02-06 19:05 ` Daniel Borkmann
2018-02-07 12:40 ` Jesper Dangaard Brouer
2018-02-07 13:19 ` Daniel Borkmann
2018-02-07 14:58 ` Jesper Dangaard Brouer [this message]
2018-02-07 16:18 ` Daniel Borkmann
2018-02-07 22:21 ` [suricata PATCH 0/3] Suricata cleanup makefile Jesper Dangaard Brouer
2018-02-07 22:21 ` [suricata PATCH 1/3] suricata/ebpf: take clang -target bpf include issue of stdint.h into account Jesper Dangaard Brouer
2018-02-07 23:52 ` Eric Leblond
2018-02-08 8:42 ` Jesper Dangaard Brouer
2018-02-07 22:21 ` [suricata PATCH 2/3] suricata/ebpf: compile with clang -target bpf Jesper Dangaard Brouer
2018-02-07 22:21 ` [suricata PATCH 3/3] suricata/ebpf: improving the ebpf makefile Jesper Dangaard Brouer
2018-02-07 22:38 ` [suricata PATCH 0/3] Suricata cleanup makefile Eric Leblond
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180207155811.4e0e18e3@redhat.com \
--to=brouer@redhat.com \
--cc=acme@redhat.com \
--cc=alexei.starovoitov@gmail.com \
--cc=borkmann@iogearbox.net \
--cc=daniel@iogearbox.net \
--cc=eric@regit.org \
--cc=jakub.kicinski@netronome.com \
--cc=joe@ovn.org \
--cc=netdev@vger.kernel.org \
--cc=victor@inliniac.net \
--cc=wangnan0@huawei.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.