Skip to content

Commit df81d04

Browse files
committed
Add --output-skb-cb
To be able to print skb->cb w/o requiring --filter-trace-tc. Signed-off-by: Martynas Pumputis <[email protected]>
1 parent f9bd25f commit df81d04

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

internal/pwru/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func GetConfig(flags *Flags) (cfg FilterCfg, err error) {
7070
if flags.OutputCaller {
7171
cfg.OutputFlags |= OutputCallerMask
7272
}
73-
if flags.FilterTraceTc {
73+
if flags.FilterTraceTc || flags.OutputSkbCB {
7474
cfg.OutputFlags |= OutputCbMask
7575
}
7676
if flags.FilterTrackSkb {

internal/pwru/output.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func (o *output) PrintHeader() {
142142
}
143143
if o.flags.OutputMeta {
144144
fmt.Fprintf(o.writer, " %-10s %-8s %16s %-6s %-5s %-5s", "NETNS", "MARK/x", centerAlignString("IFACE", 16), "PROTO", "MTU", "LEN")
145-
if o.flags.FilterTraceTc {
145+
if o.flags.FilterTraceTc || o.flags.OutputSkbCB {
146146
fmt.Fprintf(o.writer, " %-56s", "__sk_buff->cb[]")
147147
}
148148
}
@@ -191,7 +191,7 @@ func (o *output) PrintJson(event *Event) {
191191
d.Proto = byteorder.NetworkToHost16(event.Meta.Proto)
192192
d.Mtu = event.Meta.MTU
193193
d.Len = event.Meta.Len
194-
if o.flags.FilterTraceTc {
194+
if o.flags.FilterTraceTc || o.flags.OutputSkbCB {
195195
d.Cb = event.Meta.Cb
196196
}
197197
}
@@ -425,7 +425,7 @@ func (o *output) Print(event *Event) {
425425

426426
if o.flags.OutputMeta {
427427
fmt.Fprintf(o.writer, " %s", getMetaData(event, o))
428-
if o.flags.FilterTraceTc {
428+
if o.flags.FilterTraceTc || o.flags.OutputSkbCB {
429429
fmt.Fprintf(o.writer, " %s", getCb(event))
430430
}
431431
}

internal/pwru/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type Flags struct {
4646
OutputStack bool
4747
OutputCaller bool
4848
OutputLimitLines uint64
49+
OutputSkbCB bool
4950
OutputFile string
5051
OutputJson bool
5152

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

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

0 commit comments

Comments
 (0)