Commit 10e1b14d authored by Brendan Gregg's avatar Brendan Gregg

filter to match TCP only

parent 000a4e65
......@@ -10,8 +10,6 @@ troubleshooting to see what new connections the local server is accepting.
This uses dynamic tracing of the kernel inet_csk_accept() socket function (from
tcp_prot.accept), and will need to be modified to match kernel changes.
This also traces DCCP traffic; check for future versions where this should
be filtered.
This tool only traces successful TCP accept()s. Connection attempts to closed
ports will not be shown (those can be traced via other functions).
......
......@@ -7,8 +7,6 @@
#
# This uses dynamic tracing of the kernel inet_csk_accept() socket function
# (from tcp_prot.accept), and will need to be modified to match kernel changes.
# This also traces DCCP traffic; check for future versions where this should
# be filtered (should be done via "sk_protocol != IPPROTO_TCP").
#
# IPv4 addresses are printed as dotted quads. For IPv6 addresses, the last four
# bytes are printed after "..."; check for future versions with better IPv6
......@@ -54,6 +52,13 @@ int kretprobe__inet_csk_accept(struct pt_regs *ctx)
if (newsk == NULL)
return 0;
// check this is TCP
u8 protocol = 0;
// workaround for reading the sk_protocol bitfield:
bpf_probe_read(&protocol, 1, (void *)((long)&newsk->sk_wmem_queued) - 3);
if (protocol != IPPROTO_TCP)
return 0;
// pull in details
u16 family = 0, lport = 0;
u32 saddr = 0, daddr = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment