Skip to content

add prerequisite libbpf in README#49

Open
apowerfulmei wants to merge 2 commits into
trusslab:devfrom
apowerfulmei:dev
Open

add prerequisite libbpf in README#49
apowerfulmei wants to merge 2 commits into
trusslab:devfrom
apowerfulmei:dev

Conversation

@apowerfulmei

Copy link
Copy Markdown

When I was building a BRF environment from scratch on Docker, I realized that because of the lack of libbpf, it would cause some errors when I try to make the BRF source code. So I think it would be really helpful to add a description of libbpf in the README file.

@apowerfulmei

apowerfulmei commented Apr 15, 2025

Copy link
Copy Markdown
Author

Detailed error message is as blow:

In file included from executor/common_linux.h:5691,
                 from executor/common.h:505,
                 from executor/executor.cc:196:
executor/common_brf_linux.h: In function ‘bool check_attach_res(bpf_program*, int*)’:
executor/common_brf_linux.h:96:21: error: ‘bpf_map_create_opts’ was not declared in this scope; did you mean ‘bpf_link_create_opts’?
   96 |         LIBBPF_OPTS(bpf_map_create_opts, opts);
      |                     ^~~~~~~~~~~~~~~~~~~
      |                     bpf_link_create_opts
executor/common_brf_linux.h:96:42: error: ‘opts’ was not declared in this scope
   96 |         LIBBPF_OPTS(bpf_map_create_opts, opts);
      |                                          ^~~~
executor/common_brf_linux.h:96:9: error: ‘LIBBPF_OPTS’ was not declared in this scope; did you mean ‘LIBBPF_API’?
   96 |         LIBBPF_OPTS(bpf_map_create_opts, opts);
      |         ^~~~~~~~~~~
      |         LIBBPF_API
executor/common_brf_linux.h:108:17: error: ‘bpf_program__type’ was not declared in this scope; did you mean ‘bpf_program__title’?
  108 |         switch (bpf_program__type(prog)) {
      |                 ^~~~~~~~~~~~~~~~~
      |                 bpf_program__title
executor/common_brf_linux.h:130:24: error: ‘bpf_map_create’ was not declared in this scope; did you mean ‘bpf_map_freeze’?
  130 |                 *res = bpf_map_create(BPF_MAP_TYPE_SOCKMAP, "brf",
      |                        ^~~~~~~~~~~~~~
      |                        bpf_map_freeze
executor/common_brf_linux.h: In function ‘int bpf_program_attach(bpf_program*, int, bpf_link**)’:
executor/common_brf_linux.h:153:29: error: aggregate ‘bpf_program_attach(bpf_program*, int, bpf_link**)::bpf_tcx_opts tcx_opts’ has incomplete type and cannot be defined
  153 |         struct bpf_tcx_opts tcx_opts;
      |                             ^~~~~~~~
executor/common_brf_linux.h:154:35: error: aggregate ‘bpf_program_attach(bpf_program*, int, bpf_link**)::bpf_netfilter_opts nf_opts’ has incomplete type and cannot be defined
  154 |         struct bpf_netfilter_opts nf_opts;
      |                                   ^~~~~~~
executor/common_brf_linux.h:160:48: error: ‘bpf_program__type’ was not declared in this scope; did you mean ‘bpf_program__title’?
  160 |                       libbpf_bpf_prog_type_str(bpf_program__type(prog)));
      |                                                ^~~~~~~~~~~~~~~~~
      |                                                bpf_program__title
executor/common_brf_linux.h:160:23: error: ‘libbpf_bpf_prog_type_str’ was not declared in this scope
  160 |                       libbpf_bpf_prog_type_str(bpf_program__type(prog)));
      |                       ^~~~~~~~~~~~~~~~~~~~~~~~
executor/common_brf_linux.h:166:17: error: ‘bpf_program__type’ was not declared in this scope; did you mean ‘bpf_program__title’?
  166 |         switch (bpf_program__type(prog)) {
      |                 ^~~~~~~~~~~~~~~~~
      |                 bpf_program__title
executor/common_brf_linux.h:178:25: error: ‘bpf_program__attach_tcx’ was not declared in this scope; did you mean ‘bpf_program__attach_xdp’?
  178 |                 *link = bpf_program__attach_tcx(prog, res, &tcx_opts);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~
      |                         bpf_program__attach_xdp
executor/common_brf_linux.h:224:14: error: ‘BPF_PROG_TYPE_NETFILTER’ was not declared in this scope; did you mean ‘BPF_PROG_TYPE_SOCKET_FILTER’?
  224 |         case BPF_PROG_TYPE_NETFILTER:
      |              ^~~~~~~~~~~~~~~~~~~~~~~
      |              BPF_PROG_TYPE_SOCKET_FILTER
executor/common_brf_linux.h:225:25: error: ‘bpf_program__attach_netfilter’ was not declared in this scope; did you mean ‘bpf_program__attach_iter’?
  225 |                 *link = bpf_program__attach_netfilter(prog, &nf_opts);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                         bpf_program__attach_iter
At global scope:
cc1plus: note: unrecognized command-line option ‘-Wno-unused-command-line-argument’ may have been intended to silence earlier diagnostics
make: *** [Makefile:143:executor]

#46 encountered the same issue, I guess it solved this issue by changing the library search path to where the libbpf is installed in Makefile

	$(CC) -o ./bin/$(TARGETOS)_$(TARGETARCH)/syz-executor$(EXE) executor/executor.cc \
		$(ADDCFLAGS) $(CFLAGS) -L/usr/local/lib64 -lbpf -lelf -lz -DGOOS_$(TARGETOS)=1 -DGOARCH_$(TARGETARCH)=1 \
		-DHOSTGOOS_$(HOSTOS)=1 -DGIT_REVISION=\"$(REV)\"

change -L/usr/local/lib64 to -L/usr/lib64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant