Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/kprobe for http1 #8

Conversation

yxshen20
Copy link

@yxshen20 yxshen20 commented Apr 6, 2024

This commit includes the implementation of kprobes for HTTP/1.x observability

@datawine
Copy link
Collaborator

datawine commented Apr 7, 2024

This PR needs to be resubmitted to address issues with commit formatting, licensing, file directory structure, and the README, among other aspects.

@thu-gyt
Copy link
Collaborator

thu-gyt commented Apr 21, 2024

Dependency error, I did not see any installation instructions related to dependencies.

sudo go run ./sniffer/main.go ./sniffer/kprobe_http1_src.c
# github.com/iovisor/gobpf/bcc
/root/go/pkg/mod/github.com/iovisor/gobpf@v0.2.0/bcc/module.go:32:10: fatal error: bcc/bcc_common.h: No such file or directory
   32 | #include <bcc/bcc_common.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.

Please supplement the dependencies used and the installation process.

@yxshen20
Copy link
Author

Addressed the following issues:

  1. Added LICENSE and comments to the source files, adhering to the policies of Apache 2.0
  2. Added scripts for installing depencencies
  3. Updated to a more detailed README file

@thu-gyt
Copy link
Collaborator

thu-gyt commented Apr 22, 2024

I installed the dependencies according to the installation script, but there seems to be an error in the environment of bcc.

sudo go run ./sniffer/main.go ./sniffer/kprobe_http1_src.c
In file included from <built-in>:2:
In file included from /virtual/include/bcc/bpf.h:12:
In file included from include/linux/types.h:6:
In file included from include/uapi/linux/types.h:14:
In file included from include/uapi/linux/posix_types.h:5:
In file included from include/linux/stddef.h:5:
In file included from include/uapi/linux/stddef.h:5:
In file included from include/linux/compiler_types.h:80:
include/linux/compiler-clang.h:41:9: warning: '__HAVE_BUILTIN_BSWAP32__' macro redefined [-Wmacro-redefined]
#define __HAVE_BUILTIN_BSWAP32__
        ^
<command line>:4:9: note: previous definition is here
#define __HAVE_BUILTIN_BSWAP32__ 1
        ^
In file included from <built-in>:2:
In file included from /virtual/include/bcc/bpf.h:12:
In file included from include/linux/types.h:6:
In file included from include/uapi/linux/types.h:14:
In file included from include/uapi/linux/posix_types.h:5:
In file included from include/linux/stddef.h:5:
In file included from include/uapi/linux/stddef.h:5:
In file included from include/linux/compiler_types.h:80:
include/linux/compiler-clang.h:42:9: warning: '__HAVE_BUILTIN_BSWAP64__' macro redefined [-Wmacro-redefined]
#define __HAVE_BUILTIN_BSWAP64__
        ^
<command line>:5:9: note: previous definition is here
#define __HAVE_BUILTIN_BSWAP64__ 1
        ^
In file included from <built-in>:2:
In file included from /virtual/include/bcc/bpf.h:12:
In file included from include/linux/types.h:6:
In file included from include/uapi/linux/types.h:14:
In file included from include/uapi/linux/posix_types.h:5:
In file included from include/linux/stddef.h:5:
In file included from include/uapi/linux/stddef.h:5:
In file included from include/linux/compiler_types.h:80:
include/linux/compiler-clang.h:43:9: warning: '__HAVE_BUILTIN_BSWAP16__' macro redefined [-Wmacro-redefined]
#define __HAVE_BUILTIN_BSWAP16__
        ^
<command line>:3:9: note: previous definition is here
#define __HAVE_BUILTIN_BSWAP16__ 1
        ^
In file included from /virtual/main.c:24:
In file included from include/net/inet_sock.h:19:
In file included from include/linux/netdevice.h:41:
In file included from include/net/netprio_cgroup.h:11:
In file included from include/linux/cgroup.h:28:
In file included from include/linux/cgroup-defs.h:22:
In file included from include/linux/bpf-cgroup.h:5:
include/linux/bpf.h:211:35: error: invalid application of 'sizeof' to an incomplete type 'struct bpf_timer'
                memset(dst + map->timer_off, 0, sizeof(struct bpf_timer));
                                                ^     ~~~~~~~~~~~~~~~~~~
include/linux/bpf.h:211:49: note: forward declaration of 'struct bpf_timer'
                memset(dst + map->timer_off, 0, sizeof(struct bpf_timer));
                                                              ^
include/linux/bpf.h:225:10: error: invalid application of 'sizeof' to an incomplete type 'struct bpf_timer'
                t_sz = sizeof(struct bpf_timer);
                       ^     ~~~~~~~~~~~~~~~~~~
include/linux/bpf.h:225:24: note: forward declaration of 'struct bpf_timer'
                t_sz = sizeof(struct bpf_timer);
                                     ^
include/linux/bpf.h:539:26: error: use of undeclared identifier 'BPF_PSEUDO_FUNC'
               insn->src_reg == BPF_PSEUDO_FUNC;
                                ^
In file included from /virtual/main.c:24:
In file included from include/net/inet_sock.h:22:
In file included from include/net/sock.h:59:
include/linux/filter.h:1518:44: error: use of undeclared identifier 'BPF_F_BROADCAST'; did you mean 'IFF_BROADCAST'?
        if (unlikely(!ri->tgt_value) && !(flags & BPF_F_BROADCAST)) {
                                                  ^~~~~~~~~~~~~~~
                                                  IFF_BROADCAST
include/uapi/linux/if.h:86:2: note: 'IFF_BROADCAST' declared here
        IFF_BROADCAST                   = 1<<1,  /* volatile */
        ^
In file included from /virtual/main.c:24:
In file included from include/net/inet_sock.h:22:
In file included from include/net/sock.h:59:
include/linux/filter.h:1533:14: error: use of undeclared identifier 'BPF_F_BROADCAST'; did you mean 'IFF_BROADCAST'?
        if (flags & BPF_F_BROADCAST) {
                    ^~~~~~~~~~~~~~~
                    IFF_BROADCAST
include/uapi/linux/if.h:86:2: note: 'IFF_BROADCAST' declared here
        IFF_BROADCAST                   = 1<<1,  /* volatile */
        ^
3 warnings and 5 errors generated.
2024/04/22 11:08:29 bpf is nil
2024/04/22 11:08:29 Application crashed: bpf is nil
stack: goroutine 1 [running]:
runtime/debug.Stack()
        /usr/lib/go-1.18/src/runtime/debug/stack.go:24 +0x65
main.recoverFromCrashes()
        /home/ubuntu/gyt-file/microservice-failure-analysis/kprobe_http1/sniffer/main.go:53 +0x39
panic({0x4d1c40, 0xc000074050})
        /usr/lib/go-1.18/src/runtime/panic.go:838 +0x207
log.Panic({0xc00006cf10?, 0x45eb?, 0x0?})
        /usr/lib/go-1.18/src/log/log.go:385 +0x65
main.main()
        /home/ubuntu/gyt-file/microservice-failure-analysis/kprobe_http1/sniffer/main.go:81 +0x277

I successfully installed using the installation script from iovisor/bcc#3993 (comment)

@yxshen20
Copy link
Author

Have you tried the following

  1. sudo apt update and sudo apt upgrade
  2. delete the original bcc folder, and run bcc_install.sh again

If it still doesn't work, then the issue may be the Ubuntu version. I'm using Ubuntu 22.04; for Ubuntu 20.04, perhaps you can change the packages installed in bcc_install.sh to

sudo apt install -y zip bison build-essential cmake flex git libedit-dev libllvm12 llvm-12-dev libclang-12-dev python zlib1g-dev libelf-dev libfl-dev python3-setuptools liblzma-dev arping iperf

@yxshen20
Copy link
Author

The installation script you linked (iovisor/bcc#3993 (comment)) uses v0.25.0 of bcc, but to run the code we need version v0.24.0. I believe that's the reason compilation failed

@thu-gyt
Copy link
Collaborator

thu-gyt commented Apr 22, 2024

I am using Ubuntu 22.04. I tried to use your installation script to install version 0.24 and 0.25, but encountered the same error for both versions. I followed the instructions in iovisor/bcc#3993 (comment) and successfully ran bcc 0.25. I'm not sure where the problem lies. Just leave a record here.

@thu-gyt
Copy link
Collaborator

thu-gyt commented Apr 22, 2024

kprobe and uprobe run successfully.

@thu-gyt
Copy link
Collaborator

thu-gyt commented Apr 22, 2024

It is recommended to describe the functionality of the program in the README, such as program output examples, observable aspects of HTTP, and so on. Because I am not sure if the running result meets expectations.

@thu-gyt thu-gyt merged commit 9ac683c into netsyscode:feature/http-observability Sep 14, 2024
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.

3 participants