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

Add --filter-trace-only-bpf #469

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/pwru/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type Flags struct {
FilterTrackSkbByStackid bool
FilterTraceTc bool
FilterTraceXdp bool
FilterTraceOnlyBpf bool
FilterTrackBpfHelpers bool
FilterIfname string
FilterPcap string
Expand Down Expand Up @@ -72,6 +73,7 @@ func (f *Flags) SetFlags() {
flag.BoolVar(&f.FilterTrackSkbByStackid, "filter-track-skb-by-stackid", false, "trace a packet even after it is kfreed (e.g., traffic going through bridge)")
flag.BoolVar(&f.FilterTraceTc, "filter-trace-tc", false, "trace TC bpf progs")
flag.BoolVar(&f.FilterTraceXdp, "filter-trace-xdp", false, "trace XDP bpf progs")
flag.BoolVar(&f.FilterTraceOnlyBpf, "filter-trace-only-bpf", false, "trace only TC and XDP bpf progs")
flag.BoolVar(&f.FilterTrackBpfHelpers, "filter-track-bpf-helpers", false, "trace BPF helper functions")
flag.StringVar(&f.FilterIfname, "filter-ifname", "", "filter skb ifname in --filter-netns (if not specified, use current netns)")
flag.UintVar(&f.FilterKprobeBatch, "filter-kprobe-batch", 10, "batch size for kprobe attaching/detaching")
Expand Down
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ func main() {
useKprobeMulti = true
}

// If --filter-trace-only-bpf is set, then trace only TC and XDP
if flags.FilterTraceOnlyBpf {
flags.FilterTraceTc = true
flags.FilterTraceXdp = true
}
funcs, err := pwru.GetFuncs(flags.FilterFunc, btfSpec, flags.KMods, useKprobeMulti)
if err != nil {
log.Fatalf("Failed to get skb-accepting functions: %s", err)
Expand Down