This group is locked. No changes can be made to the group while it is locked.
Date
1 - 11 of 11
Facing an error while compiling for bpf using clang
Prashanth Fernando
Hi,
I'm new to XDP, I am trying to compile a simple code to start with.
When I compile with clang, I face an error. Can someone please help me out in resolving this issue.
I'm new to XDP, I am trying to compile a simple code to start with.
When I compile with clang, I face an error. Can someone please help me out in resolving this issue.
# clang -target bpf -c drop.c -o drop.o
error: unknown target triple 'bpf', please use -triple or -arch
OS: CentOS 7
Updated Kernel:
Built the kernel with the following flags on:
OS: CentOS 7
Updated Kernel:
# uname -msr
Linux 5.1.3 x86_64
Built the kernel with the following flags on:
CONFIG_CGROUP_BPF=y
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
CONFIG_BPF_JIT_ALWAYS_ON=y
CONFIG_NETFILTER_XT_MATCH_BPF=m
CONFIG_BPFILTER=y
CONFIG_BPFILTER_UMH=m
CONFIG_NET_CLS_BPF=m
CONFIG_NET_ACT_BPF=m
CONFIG_BPF_JIT=y
CONFIG_BPF_STREAM_PARSER=y
CONFIG_LWTUNNEL_BPF=y
CONFIG_HAVE_EBPF_JIT=y
CONFIG_BPF_EVENTS=y
CONFIG_BPF_KPROBE_OVERRIDE=y
CONFIG_TEST_BPF=m
I am not sure what I am missing still.
Tom Stellard
On 05/21/2019 08:42 PM, Prashanth Fernando wrote:
target.
-Tom
Hi,Which version of clang are you using? It looks like it is missing the bpf
I'm new to XDP, I am trying to compile a simple code to start with.
When I compile with clang, I face an error. Can someone please help me out in resolving this issue.
# clang -target bpf -c drop.c -o drop.o
error: unknown target triple 'bpf', please use -triple or -arch
target.
-Tom
OS: CentOS 7
Updated Kernel:
# uname -msr
Linux 5.1.3 x86_64
Built the kernel with the following flags on:
CONFIG_CGROUP_BPF=y
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
CONFIG_BPF_JIT_ALWAYS_ON=y
CONFIG_NETFILTER_XT_MATCH_BPF=m
CONFIG_BPFILTER=y
CONFIG_BPFILTER_UMH=m
CONFIG_NET_CLS_BPF=m
CONFIG_NET_ACT_BPF=m
CONFIG_BPF_JIT=y
CONFIG_BPF_STREAM_PARSER=y
CONFIG_LWTUNNEL_BPF=y
CONFIG_HAVE_EBPF_JIT=y
CONFIG_BPF_EVENTS=y
CONFIG_BPF_KPROBE_OVERRIDE=y
CONFIG_TEST_BPF=m
I am not sure what I am missing still.
Prashanth Fernando
Hi,
The clang version I am using is 3.4.2
The clang version I am using is 3.4.2
clang --version
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-redhat-linux-gnu
Thread model: posix
Tks,
PRashanth
Tks,
PRashanth
Yonghong Song
bpf needs 3.7.1 and higher version. Later clang (>= 3.7.1) has more features.
On Tue, May 21, 2019 at 11:13 PM Prashanth Fernando
<prashanth.fernando@...> wrote:
On Tue, May 21, 2019 at 11:13 PM Prashanth Fernando
<prashanth.fernando@...> wrote:
Hi,
The clang version I am using is 3.4.2
clang --version
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-redhat-linux-gnu
Thread model: posix
Tks,
PRashanth
Prashanth Fernando
Thank You, I updated clang and now I am able to compile the code in CentOS-7.
I am facing another issue while loading the ebpf code in tc. I am able to run this in Ubuntu-18.04, but the usecase is to run it in CentOS. Can someone please help me out in resolving it.
replicator.o is my objext file and classifier/action are the classifier/action code.
Tks,
PRashanth
I am facing another issue while loading the ebpf code in tc. I am able to run this in Ubuntu-18.04, but the usecase is to run it in CentOS. Can someone please help me out in resolving it.
replicator.o is my objext file and classifier/action are the classifier/action code.
# sudo tc filter add dev enp0s8 parent ffff: bpf obj replicator.o sec classifier flowid ffff:1 \
action bpf obj replicator.o sec action ok
What is "obj"?
Usage: ... bpf ...
[inline]: run bytecode BPF_BYTECODE
[from file]: run bytecode-file FILE
[ police POLICE_SPEC ] [ action ACTION_SPEC ]
[ classid CLASSID ]
Where BPF_BYTECODE := 's,c t f k,c t f k,c t f k,...'
c,t,f,k and s are decimals; s denotes number of 4-tuples
Where FILE points to a file containing the BPF_BYTECODE string
Tks,
PRashanth
On Tue, 21 May 2019 23:17:28 -0700
"Yonghong Song" <ys114321@...> wrote:
https://github.com/torvalds/linux/blob/master/samples/bpf/README.rst
But the kernel says:
clang >= version 3.4.0 + llvm >= version 3.7.1
What is your 'llc' version?
(run command: llc --version )
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
"Yonghong Song" <ys114321@...> wrote:
bpf needs 3.7.1 and higher version. Later clang (>= 3.7.1) has more features.In the kernel tree it is documented here:
https://github.com/torvalds/linux/blob/master/samples/bpf/README.rst
But the kernel says:
clang >= version 3.4.0 + llvm >= version 3.7.1
What is your 'llc' version?
(run command: llc --version )
On Tue, May 21, 2019 at 11:13 PM Prashanth Fernando--
<prashanth.fernando@...> wrote:
Hi,
The clang version I am using is 3.4.2
clang --version
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-redhat-linux-gnu
Thread model: posix
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
On Wed, 22 May 2019 00:26:54 -0700
"Prashanth Fernando" <prashanth.fernando@...> wrote:
kernel version on CentOS-7.
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
https://linuxhint.com/centos8-release-date-and-features/
"Prashanth Fernando" <prashanth.fernando@...> wrote:
Thank You, I updated clang and now I am able to compile the code inYou have to use CentOS-8 for TC (and XDP) support, or install a newer
CentOS-7.
I am facing another issue while loading the ebpf code in tc. I am
able to run this in Ubuntu-18.04, but the usecase is to run it in
CentOS. Can someone please help me out in resolving it.
kernel version on CentOS-7.
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
https://linuxhint.com/centos8-release-date-and-features/
Prashanth Fernando
Hi,
Thanks for your response. I had a doubt that the kernel has to be upgraded.
So I upgraded the kernel to 5.1.3, still I face the issue.
I compiled the kernel with these options, have I missed out some option ?
Thanks for your response. I had a doubt that the kernel has to be upgraded.
So I upgraded the kernel to 5.1.3, still I face the issue.
I compiled the kernel with these options, have I missed out some option ?
CONFIG_CGROUP_BPF=y
CONFIG_BPF=y
CONFIG_BPF_SYSCALL=y
CONFIG_BPF_JIT_ALWAYS_ON=y
CONFIG_NETFILTER_XT_MATCH_BPF=m
CONFIG_BPFILTER=y
CONFIG_BPFILTER_UMH=m
CONFIG_NET_CLS_BPF=m
CONFIG_NET_ACT_BPF=m
CONFIG_BPF_JIT=y
CONFIG_BPF_STREAM_PARSER=y
CONFIG_LWTUNNEL_BPF=y
CONFIG_HAVE_EBPF_JIT=y
CONFIG_BPF_EVENTS=y
CONFIG_BPF_KPROBE_OVERRIDE=y
CONFIG_TEST_BPF=m
[root@localhost linux-5.1.3]# uname -msr
Linux 5.1.3 x86_64
Toke Høiland-Jørgensen
Prashanth Fernando <prashanth.fernando@...> writes:
'ip' utilities come from).
-Toke
Hi,You also need to compile a new version of iproute2 (where the 'tc' and
Thanks for your response. I had a doubt that the kernel has to be upgraded.
So I upgraded the kernel to 5.1.3, still I face the issue.
'ip' utilities come from).
-Toke
Daniel Borkmann
On 05/22/2019 09:26 AM, Prashanth Fernando wrote:
version in CentOS-7 is simply too old aka lacking eBPF support.
Try compiling one from recent Git [0] or some more recent tarball, then it
should work provided you have a proper kernel with it.
Perhaps also [1] might help you getting started, e.g. you can use cls_bpf in
direct action mode which is much more efficient than going through ac_bpf,
see the guide for more info.
[0] https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/
[1] https://cilium.readthedocs.io/en/latest/bpf/#iproute2
Thank You, I updated clang and now I am able to compile the code in CentOS-7.Judging from above error and that it works on Ubuntu 18.04, then your iproute2
I am facing another issue while loading the ebpf code in tc. I am able to run this in Ubuntu-18.04, but the usecase is to run it in CentOS. Can someone please help me out in resolving it.
replicator.o is my objext file and classifier/action are the classifier/action code.
# sudo tc filter add dev enp0s8 parent ffff: bpf obj replicator.o sec classifier flowid ffff:1 \
action bpf obj replicator.o sec action ok
What is "obj"?
Usage: ... bpf ...
version in CentOS-7 is simply too old aka lacking eBPF support.
Try compiling one from recent Git [0] or some more recent tarball, then it
should work provided you have a proper kernel with it.
Perhaps also [1] might help you getting started, e.g. you can use cls_bpf in
direct action mode which is much more efficient than going through ac_bpf,
see the guide for more info.
[0] https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/
[1] https://cilium.readthedocs.io/en/latest/bpf/#iproute2
[inline]: run bytecode BPF_BYTECODE
[from file]: run bytecode-file FILE
[ police POLICE_SPEC ] [ action ACTION_SPEC ]
[ classid CLASSID ]
Where BPF_BYTECODE := 's,c t f k,c t f k,c t f k,...'
c,t,f,k and s are decimals; s denotes number of 4-tuples
Where FILE points to a file containing the BPF_BYTECODE string
Tks,
PRashanth