ugwis / ebpf-http-parser

Parse HTTP(S) requests by eBPF hooks without APM
Apache License 2.0
3 stars 0 forks source link

about the header file error #2

Open qwe75983 opened 2 years ago

qwe75983 commented 2 years ago

When I finished configuring the environment I found some errors as follows

root@zy-virtual-machine:~/桌面/ebpf-http-parser-master# make
go generate
/root/桌面/ebpf-http-parser-master/kprobe.c:3:10: fatal error: 'bpf_tracing.h' file not found
#include <bpf_tracing.h>
         ^~~~~~~~~~~~~~~
1 error generated.
Error: clang-9: exit status 1
exit status 1
main.go:30: running "go": exit status 1
make: *** [Makefile:8:main] 错误 1

So I tried to find the header file, and I put the header file of the bpftool folder in it, and then I found that something else was missing

root@zy-virtual-machine:~/桌面/ebpf-http-parser-master# find / -name bpf_tracing.h
/var/lib/docker/overlay2/b8fc50d0d4e7f9f6d337b245c7a0d6819441c6ec04b8987707bf94cf5b356ba0/diff/usr/include/bpf/bpf_tracing.h
/root/桌面/bcc/src/cc/libbpf/src/bpf_tracing.h
/root/桌面/bcc/libbpf-tools/bpftool/libbpf/src/bpf_tracing.h
/root/桌面/bpftool/libbpf/src/bpf_tracing.h
root@zy-virtual-machine:~/桌面/ebpf-http-parser-master# make
go generate
/root/桌面/ebpf-http-parser-master/kprobe.c:4:10: fatal error: 'common.h' file not found
#include "common.h"
         ^~~~~~~~~~
1 error generated.
Error: clang-9: exit status 1
exit status 1
main.go:30: running "go": exit status 1
make: *** [Makefile:8:main] 错误 1

I put /usr/src/linux-hwe-5.13-headers-5.13.0-52/arch/x86/include/asm/trace/common.h and found other unsolvable problems

root@zy-virtual-machine:~/桌面/ebpf-http-parser-master# find / -name common.h
/usr/src/linux-hwe-5.13-headers-5.13.0-52/arch/mips/include/asm/netlogic/common.h
/usr/src/linux-hwe-5.13-headers-5.13.0-52/arch/x86/include/asm/trace/common.h
/usr/src/linux-hwe-5.13-headers-5.13.0-52/arch/arm/plat-orion/include/plat/common.h
/usr/src/linux-hwe-5.13-headers-5.13.0-52/arch/arm/mach-davinci/include/mach/common.h
/usr/src/linux-hwe-5.13-headers-5.13.0-52/include/dt-bindings/leds/common.h
/usr/src/linux-hwe-5.13-headers-5.13.0-52/include/soc/tegra/common.h
/usr/src/linux-hwe-5.15-headers-5.15.0-43/arch/mips/include/asm/netlogic/common.h
/usr/src/linux-hwe-5.15-headers-5.15.0-43/arch/x86/include/asm/trace/common.h
/usr/src/linux-hwe-5.15-headers-5.15.0-43/arch/arm/plat-orion/include/plat/common.h
/usr/src/linux-hwe-5.15-headers-5.15.0-43/arch/arm/mach-davinci/include/mach/common.h
/usr/src/linux-hwe-5.15-headers-5.15.0-43/include/dt-bindings/leds/common.h
/usr/src/linux-hwe-5.15-headers-5.15.0-43/include/soc/tegra/common.h
root@zy-virtual-machine:~/桌面/ebpf-http-parser-master# make
go generate
In file included from /root/桌面/ebpf-http-parser-master/kprobe.c:4:
/root/桌面/ebpf-http-parser-master/common.h:9:15: error: unknown type name 'bool'
static inline bool trace_pagefault_enabled(void) { return false; }
              ^
/root/桌面/ebpf-http-parser-master/common.h:9:59: error: use of undeclared identifier 'false'; did you mean 'else'?
static inline bool trace_pagefault_enabled(void) { return false; }
                                                          ^~~~~
                                                          else
/root/桌面/ebpf-http-parser-master/common.h:9:59: error: expected expression
/root/桌面/ebpf-http-parser-master/kprobe.c:14:17: error: expected ';' after top level declarator
char __license[] SEC("license") = "Dual MIT/GPL";
                ^
                ;
/root/桌面/ebpf-http-parser-master/kprobe.c:21:24: error: expected parameter declarator
struct bpf_map_def SEC("maps/connectlist") connectlist = {
                       ^
/root/桌面/ebpf-http-parser-master/kprobe.c:21:24: error: expected ')'
/root/桌面/ebpf-http-parser-master/kprobe.c:21:23: note: to match this '('
struct bpf_map_def SEC("maps/connectlist") connectlist = {
                      ^
/root/桌面/ebpf-http-parser-master/kprobe.c:21:44: error: expected function body after function declarator
struct bpf_map_def SEC("maps/connectlist") connectlist = {
                                           ^
/root/桌面/ebpf-http-parser-master/kprobe.c:32:24: error: expected parameter declarator
struct bpf_map_def SEC("maps/probe_cache") probe_cache = {
                       ^
/root/桌面/ebpf-http-parser-master/kprobe.c:32:24: error: expected ')'
/root/桌面/ebpf-http-parser-master/kprobe.c:32:23: note: to match this '('
struct bpf_map_def SEC("maps/probe_cache") probe_cache = {
                      ^
/root/桌面/ebpf-http-parser-master/kprobe.c:32:44: error: expected function body after function declarator
struct bpf_map_def SEC("maps/probe_cache") probe_cache = {
                                           ^
/root/桌面/ebpf-http-parser-master/kprobe.c:39:24: error: expected parameter declarator
struct bpf_map_def SEC("maps/dataevent") dataevent = {
                       ^
/root/桌面/ebpf-http-parser-master/kprobe.c:39:24: error: expected ')'
/root/桌面/ebpf-http-parser-master/kprobe.c:39:23: note: to match this '('
struct bpf_map_def SEC("maps/dataevent") dataevent = {
                      ^
/root/桌面/ebpf-http-parser-master/kprobe.c:39:42: error: expected function body after function declarator
struct bpf_map_def SEC("maps/dataevent") dataevent = {
                                         ^
/root/桌面/ebpf-http-parser-master/kprobe.c:46:2: error: unknown type name 'u8'
        u8   type;
        ^
/root/桌面/ebpf-http-parser-master/kprobe.c:47:2: error: unknown type name 'u32'
        u32  sock_fd;
        ^
/root/桌面/ebpf-http-parser-master/kprobe.c:48:2: error: unknown type name 'u8'
        u8   buf[1024];
        ^
/root/桌面/ebpf-http-parser-master/kprobe.c:51:24: error: expected parameter declarator
struct bpf_map_def SEC("maps/messagelist") messagelist = {
                       ^
/root/桌面/ebpf-http-parser-master/kprobe.c:51:24: error: expected ')'
/root/桌面/ebpf-http-parser-master/kprobe.c:51:23: note: to match this '('
struct bpf_map_def SEC("maps/messagelist") messagelist = {
                      ^
/root/桌面/ebpf-http-parser-master/kprobe.c:51:44: error: expected function body after function declarator
struct bpf_map_def SEC("maps/messagelist") messagelist = {
                                           ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
Error: clang-9: exit status 1
exit status 1
main.go:30: running "go": exit status 1
make: *** [Makefile:8:main] 错误 1
root@zy-virtual-machine:~/桌面/ebpf-http-parser-master# 

Now I don't know what to do please help me

ugwis commented 2 years ago

Hi. I guess that you cloned this repository without --recursive.

ebpf-http-parser uses github.com/cilium/ebpf/examples/headers and linked at here, so you should clone git submodule. Try it.

git submodule update --init --recursive

Thanks.