Skip to content

Commit

Permalink
Add --filter-track-skb-across-namespaces
Browse files Browse the repository at this point in the history
Signed-off-by: Zhichuan Liang <gray.liang@isovalent.com>
  • Loading branch information
jschwinger233 committed Aug 28, 2023
1 parent 968af5f commit aab3737
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
3 changes: 1 addition & 2 deletions internal/libpcap/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (
)

/*
#cgo CFLAGS: -I${SRCDIR}/../../libpcap
#cgo LDFLAGS: -L${SRCDIR}/../../libpcap -lpcap -static
#cgo LDFLAGS: -L/usr/local/lib -lpcap -static
#include <stdlib.h>
#include <pcap.h>

Check failure on line 15 in internal/libpcap/compile.go

View workflow job for this annotation

GitHub Actions / build

fatal error: pcap.h: No such file or directory
*/
Expand Down
12 changes: 7 additions & 5 deletions internal/pwru/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ type Flags struct {

KernelBTF string

FilterNetns uint32
FilterMark uint32
FilterFunc string
FilterTrackSkb bool
FilterPcap string
FilterNetns uint32
FilterMark uint32
FilterFunc string
FilterTrackSkb bool
FilterTrackSkbAcrossNamespaces bool
FilterPcap string

OutputTS string
OutputMeta bool
Expand Down Expand Up @@ -62,6 +63,7 @@ func (f *Flags) SetFlags() {
flag.BoolVar(&f.OutputStack, "output-stack", false, "print stack")
flag.Uint64Var(&f.OutputLimitLines, "output-limit-lines", 0, "exit the program after the number of events has been received/printed")
flag.BoolVar(&f.FilterTrackSkb, "filter-track-skb", false, "trace a packet even if it does not match given filters (e.g., after NAT or tunnel decapsulation)")
flag.BoolVar(&f.FilterTrackSkbAcrossNamespaces, "filter-track-skb-across-namespaces", false, "...")

flag.StringVar(&f.OutputFile, "output-file", "", "write traces to file")

Expand Down
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,12 @@ func main() {
ignored := 0
bar := pb.StartNew(len(funcs))

// Must attach this first @gray
if flags.FilterTrackSkb {
// eth_type_trans?
for _, name := range []string{"kfree_skbmem"} {
skbLifetimeEndAt := []string{"kfree_skbmem"}
if !flags.FilterTrackSkbAcrossNamespaces {
skbLifetimeEndAt = append(skbLifetimeEndAt, "eth_type_trans")
}
for _, name := range skbLifetimeEndAt {
kp, err := link.Kprobe(name, kprobeLifetimeEnd, nil)
bar.Increment()
if err != nil {
Expand Down

0 comments on commit aab3737

Please sign in to comment.