0

man bpf states that

Some complete working code can be found in the samples/bpf directory in the kernel source tree.

However I can't find any samples at that location:

$ uname -r
5.1.11-200.fc29.x86_64
$ ls /usr/src/kernels/5.1.11-200.fc29.x86_64/samples/bpf
Makefile

sudo make appears to error due to another cause, however it looks like the Makefile there expects the existence of samples in samples/bpf (BPF_SAMPLES_PATH):

$ cd /usr/src/kernels/5.1.11-200.fc29.x86_64/
$ sudo make headers_install
$ sudo make samples/bpf/
  HOSTCC  scripts/selinux/genheaders/genheaders
scripts/selinux/genheaders/genheaders.c:18:10: fatal error: classmap.h: No such file or directory
 #include "classmap.h"
          ^~~~~~~~~~~~
compilation terminated.
make[3]: *** [scripts/Makefile.host:92: scripts/selinux/genheaders/genheaders] Error 1
make[2]: *** [scripts/Makefile.build:486: scripts/selinux/genheaders] Error 2
make[1]: *** [scripts/Makefile.build:486: scripts/selinux] Error 2
make: *** [Makefile:1069: scripts] Error 2

Also, the remote linux kernel repo includes a README with examples.

Are there BPF samples in the Fedora linux kernel directory? If so, where are they located?

category
  • 103
  • 4

1 Answers1

0

You need the installed LLVM packet to compile the sample programs to the byte-code, that will be executed by in-kernel virtual machine.

Also the kernel headers should be installed.

Anton Danilov
  • 5,082
  • 2
  • 13
  • 23
  • I've installed `clang` and `llvm`, and still get the `classmap.h` error (will update question) - however my question is aimed at the lack of sample programs in `samples/bpf`. – category Jul 17 '19 at 16:19
  • I've also run `make headers_install` from the base kernel directory (will update question) however the above still applies - .the `classmap.h` error still exists, however my question is aimed at the lack of sample programs in `samples/bpf`. – category Jul 17 '19 at 16:57