Re: Facing an error while compiling for bpf using clang

Daniel Borkmann

On 05/22/2019 09:26 AM, Prashanth Fernando wrote:
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.

# 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 ...
Judging from above error and that it works on Ubuntu 18.04, then your iproute2
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.


[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


Join to automatically receive all group messages.