-
Notifications
You must be signed in to change notification settings - Fork 3.4k
cmd: add output options for cilium monitor #1112
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
Conversation
By default, when `cilium monitor` is ran, a one-line summary will be output, only for drop and capture messages. A new flag, -v for verbose, is added which will output more detailed information about each packet for debug, drop, and capture messages, which was before the default behavior for `cilium monitor`. Signed-off by: Ian Vernon <ian@covalent.io>
Signed-off-by: Thomas Graf <thomas@cilium.io>
TCP forwarding: <- endpoint 64189, identity 258: 10.15.220.6:51198 -> 10.15.242.54:80 tcp SYN -> ifindex 586: 10.15.220.6:51198 -> 10.15.242.54:80 tcp SYN <- endpoint 33115, identity 257: 10.15.242.54:80 -> 10.15.220.6:51198 tcp ACK, RST -> endpoint 64189, identity 258: 10.15.242.54:80 -> 10.15.220.6:51198 tcp ACK, RST ARP: <- endpoint 33115, identity 257: ea:e1:ad:23:9e:ac -> 1e:19:55:1b:27:a0 ARP -> endpoint 33115, identity 257: 1e:19:55:1b:27:a0 -> ea:e1:ad:23:9e:ac ARP <- endpoint 64189, identity 258: 62:28:3d:b9:16:71 -> ba:15:0d:5c:cb:90 ARP -> endpoint 64189, identity 258: ba:15:0d:5c:cb:90 -> 62:28:3d:b9:16:71 ARP ICMP forwarding: <- endpoint 50098: 10.15.189.46 -> 10.15.222.137 EchoReply -> endpoint 42392: 10.15.189.46 -> 10.15.222.137 EchoReply <- endpoint 42392: 10.15.222.137 -> 10.15.189.46 EchoRequest -> endpoint 50098: 10.15.222.137 -> 10.15.189.46 EchoRequest <- endpoint 50098: 10.15.189.46 -> 10.15.222.137 EchoReply -> endpoint 42392: 10.15.189.46 -> 10.15.222.137 EchoReply Drops: <- endpoint 64189, identity 257: 10.15.220.6 -> 10.15.247.232 EchoRequest xx drop (Policy denied) to endpoint 29898, identity 257->256: 10.15.220.6 -> 10.15.247.232 EchoRequest <- endpoint 64189, identity 257: 10.15.220.6 -> 10.15.247.232 EchoRequest xx drop (Policy denied) to endpoint 29898, identity 257->256: 10.15.220.6 -> 10.15.247.232 EchoRequest Signed-off-by: Thomas Graf <thomas@cilium.io>
Require user to provide --hex flag to disabled decoding and printing in hexadecimal format. Signed-off-by: Thomas Graf <thomas@cilium.io>
Signed-off-by: Thomas Graf <thomas@cilium.io>
Allow to disable basic tracing with --disable-trace agent flag Signed-off-by: Thomas Graf <thomas@cilium.io>
Add --trace-payloadlen option to set length of captured payload Signed-off-by: Thomas Graf <thomas@cilium.io>
pkg/bpfdebug/drop.go
Outdated
@@ -81,8 +81,12 @@ func dropReason(reason uint8) string { | |||
return fmt.Sprintf("%d", reason) | |||
} | |||
|
|||
func (n *DropNotify) DumpInfo(data []byte) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported method DropNotify.DumpInfo should have comment or be unexported
pkg/bpfdebug/debug.go
Outdated
@@ -268,8 +278,33 @@ type DebugCapture struct { | |||
// data | |||
} | |||
|
|||
func (n *DebugCapture) DumpInfo(data []byte) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported method DebugCapture.DumpInfo should have comment or be unexported
pkg/bpfdebug/debug.go
Outdated
type Verbosity uint8 | ||
|
||
const ( | ||
INFO Verbosity = iota + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported const INFO should have comment (or a comment on this block) or be unexported
9cc1a81
to
715f502
Compare
Yes! This is exactly on the right track. I think we can find a better wording. |
@tgraf how about "SENDING" or "FORWARDING"? |
We have 4 main actions:
Maybe something like this?
|
OK, I went through the DebugMessage types and pulled out the ones I thought were relevant to what you mentioned above, and reformatted the others accordingly. Currently not all of what you want above is achievable as part of this first pass at this issue (i.e., getting the IPs from the various message types) - it will be once I add more rich metadata as we discussed by querying the API. Let's discuss further on Slack if this isn't what you are looking for so I can nail down the requirements. This is what the monitor looks like when ran against the
|
pkg/bpfdebug/debug.go
Outdated
@@ -158,6 +158,20 @@ type DebugMsg struct { | |||
Arg3 uint32 | |||
} | |||
|
|||
|
|||
func (n *DebugMsg) DumpInfo(data []byte) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported method DebugMsg.DumpInfo should have comment or be unexported
pkg/bpfdebug/dissect.go
Outdated
addTcpFlag := func(flag, new string) string { | ||
if flag != "" { | ||
return flag + ", " + new | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if block ends with a return statement, so drop this else and outdent its block
pkg/bpfdebug/dissect.go
Outdated
@@ -38,6 +39,94 @@ var ( | |||
lock sync.Mutex | |||
) | |||
|
|||
func getTCPInfo() string { | |||
info := "" | |||
addTcpFlag := func(flag, new string) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var addTcpFlag should be addTCPFlag
Looks good but will need a rebase. It will conflict due to my BPF changes so |
7911cfa
to
f797571
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this is an improvement but looking at the output this seems rushed IMO. For example the filter output now looks weird (sudo ./cilium/cilium monitor --type debug -v
).
// DumpInfo https://techcrunch.com/2017/07/12/soundshroud/ | ||
func (n *DropNotify) DumpInfo(data []byte) { | ||
fmt.Printf("xx drop (%s) to endpoint %d, identity %d->%d: %s\n", | ||
dropReason(n.SubType), n.DstID, n.SrcLabel, n.DstLabel, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this prefixed xx
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It indicates a dropped packet
This is to make sure that we can dynamically replace the value of pod namespace label (e.g. io.kubernetes.pod.namespace) to the value passed in CLI flag (e.g. --test-namespace). Related: cilium#1112 Signed-off-by: Tam Mach <tam.mach@cilium.io>
By default, when
cilium monitor
is ran, a one-line summary will be output, only for drop and capture messages.A new flag, -v for verbose, is added which will output more detailed information about each packet for debug, drop, and capture messages, which was before the default behavior for
cilium monitor
.Signed-off by: Ian Vernon ian@covalent.io