$ cd bpf-test $ make ... LLVM ERROR: 'helper_test_init' label emitted multiple times to assembly file Makefile:69: recipe for target 'test_bpf_helper_init_kern.o' failed ...
root@ubuntu:~/bpftest/linux-blog-sample-code/bpf-test# make test make -C bpf test make[1]: Entering directory '/root/bpftest/linux-blog-sample-code/bpf-test/bpf' make[1]: 'test' is up to date. make[1]: Leaving directory '/root/bpftest/linux-blog-sample-code/bpf-test/bpf' make -C user test make[1]: Entering directory '/root/bpftest/linux-blog-sample-code/bpf-test/user' bash test_bpf_helper_run.sh before setup 0 maps not supported in current map section! Error fixing up map structure, incompatible struct bpf_elf_map used? Error fetching ELF ancillary data! Unable to load program setup ok could not find map bpf_helper_test_map: No such file or directory Makefile:63: recipe for target 'test' failed make[1]: *** [test] Error 1 make[1]: Leaving directory '/root/bpftest/linux-blog-sample-code/bpf-test/user' Makefile:69: recipe for target 'test-user' failed make: *** [test-user] Error 2
大致是说在bpf程序中找不到map。
测试命令执行的是以下命令
1 2 3
tc filter add dev veth1 ingress bpf da \ obj ../bpf/test_bpf_helper_init_kern.o \ sec helper_test_init
static int bpf_fetch_maps_end(struct bpf_elf_ctx *ctx) { struct bpf_elf_map fixup[ARRAY_SIZE(ctx->maps)] = {}; int i, sym_num = bpf_map_num_sym(ctx); __u8 *buff;
if (sym_num == 0 || sym_num > ARRAY_SIZE(ctx->maps)) { fprintf(stderr, "%u maps not supported in current map section!\n", sym_num); ... static int bpf_map_num_sym(struct bpf_elf_ctx *ctx) { int i, num = 0; GElf_Sym sym;
for (i = 0; i < ctx->sym_num; i++) { int type;
if (gelf_getsym(ctx->sym_tab, i, &sym) != &sym) continue;
type = GELF_ST_TYPE(sym.st_info); if (GELF_ST_BIND(sym.st_info) != STB_GLOBAL || (type != STT_NOTYPE && type != STT_OBJECT) || sym.st_shndx != ctx->sec_maps) continue; num++; }