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

bpf: Remove OUTPUT_SKB&HAS_KPROBE_MULTI macros #455

Merged
merged 4 commits into from
Nov 19, 2024

Commits on Nov 13, 2024

  1. Move btf id from bpf to Go

    It's to avoid the following issue for next commit, especially on Ubuntu
    20.04:
    
     ; instruction poisoned by CO-RE
     938: (85) call unknown#195896080
     invalid func unknown#195896080
     processed 519 insns (limit 1000000) max_states_per_insn 0 total_states 29 peak_states 29 mark_read 27
    
    Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
    Asphaltt committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    9a34456 View commit details
    Browse the repository at this point in the history
  2. bpf: Remove unnecessary OUTPUT_SKB macro

    When call set_skb_btf() or set_shinfo_btf(), these functions are
    protected by constant CFG.
    
    Then, while loading kprobe_pwru into kernel, if no
    --output-skb/--output-skb-shared-info, set_skb_btf()/set_shinfo_btf()
    won't be verified. Next, these unreachable code will be eliminated by
    verifier.
    
    Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
    Asphaltt committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    9d3fc67 View commit details
    Browse the repository at this point in the history
  3. bpf: Remove HAS_KPROBE_MULTI macro

    Simplify bpf code.
    
    And use Go to determine loading kprobe or kprobe.multi bpf prog.
    
    Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
    Asphaltt committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    43e98ac View commit details
    Browse the repository at this point in the history
  4. Fix a panic when stop pwru early

    Fix this panic:
    
    $ sudo ./pwru --output-tuple 'dst host 1.0.0.1 and port 8080'
    2024/11/12 13:58:41 Attaching kprobes (via kprobe)...
    102 / 1255 [---------->_________________________________________________________________________________________________________________________] 8.13% 96 p/s
    231 / 1255 [----------------------->__________________________________________________________________________________________________________] 18.41% 120 p/s
    2024/11/12 13:58:43 Listening for events..
    SKB                CPU PROCESS          NETNS      MARK/x        IFACE       PROTO  MTU   LEN   TUPLE FUNC
    2024/11/12 13:58:43 Received signal, exiting program..
    2024/11/12 13:58:43 Detaching kprobes...
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x6675d8]
    
    goroutine 1 [running]:
    github.com/cilium/pwru/internal/pwru.(*kprober).DetachKprobes(0x0)
    	/root/Projects/leonhwang/pwru/internal/pwru/kprobe.go:130 +0xb8
    main.main()
    	/root/Projects/leonhwang/pwru/main.go:322 +0x2013
    
    Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
    Asphaltt committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    34fcd87 View commit details
    Browse the repository at this point in the history