Skip to content

Commit

Permalink
Add --output-skb-cb
Browse files Browse the repository at this point in the history
To be able to print skb->cb w/o requiring --filter-trace-tc.

Signed-off-by: Martynas Pumputis <[email protected]>
  • Loading branch information
brb committed Dec 6, 2024
1 parent f9bd25f commit 2a8f800
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/pwru/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func GetConfig(flags *Flags) (cfg FilterCfg, err error) {
if flags.OutputCaller {
cfg.OutputFlags |= OutputCallerMask
}
if flags.FilterTraceTc {
if flags.FilterTraceTc || flags.OutputSkbCB {
cfg.OutputFlags |= OutputCbMask
}
if flags.FilterTrackSkb {
Expand Down
6 changes: 3 additions & 3 deletions internal/pwru/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (o *output) PrintHeader() {
}
if o.flags.OutputMeta {
fmt.Fprintf(o.writer, " %-10s %-8s %16s %-6s %-5s %-5s", "NETNS", "MARK/x", centerAlignString("IFACE", 16), "PROTO", "MTU", "LEN")
if o.flags.FilterTraceTc {
if o.flags.FilterTraceTc || o.flags.OutputSkbCB {
fmt.Fprintf(o.writer, " %-56s", "__sk_buff->cb[]")
}
}
Expand Down Expand Up @@ -191,7 +191,7 @@ func (o *output) PrintJson(event *Event) {
d.Proto = byteorder.NetworkToHost16(event.Meta.Proto)
d.Mtu = event.Meta.MTU
d.Len = event.Meta.Len
if o.flags.FilterTraceTc {
if o.flags.FilterTraceTc || o.flags.OutputSkbCB {
d.Cb = event.Meta.Cb
}
}
Expand Down Expand Up @@ -425,7 +425,7 @@ func (o *output) Print(event *Event) {

if o.flags.OutputMeta {
fmt.Fprintf(o.writer, " %s", getMetaData(event, o))
if o.flags.FilterTraceTc {
if o.flags.FilterTraceTc || o.flags.OutputSkbCB {
fmt.Fprintf(o.writer, " %s", getCb(event))
}
}
Expand Down
2 changes: 2 additions & 0 deletions internal/pwru/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Flags struct {
OutputStack bool
OutputCaller bool
OutputLimitLines uint64
OutputSkbCB bool
OutputFile string
OutputJson bool

Expand Down Expand Up @@ -82,6 +83,7 @@ func (f *Flags) SetFlags() {
flag.BoolVar(&f.OutputStack, "output-stack", false, "print stack")
flag.BoolVar(&f.OutputCaller, "output-caller", false, "print caller function name")
flag.Uint64Var(&f.OutputLimitLines, "output-limit-lines", 0, "exit the program after the number of events has been received/printed")
flag.BoolVar(&f.OutputSkbCB, "output-skb-cb", false, "print skb->cb")

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

Expand Down

0 comments on commit 2a8f800

Please sign in to comment.