-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
IPv6 support for tcp* tools #582
Conversation
@@ -44,6 +42,7 @@ | |||
bpf_text = """ | |||
#include <uapi/linux/ptrace.h> | |||
#include <net/sock.h> | |||
#include <net/tcp_states.h> |
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.
Without this tcpconnlat
wouldn't work on our pre-4.6 kernels. I double-checked it still worked under 4.6 with this.
Yes, why not just use socket... From memory, I'd searched for inet_ntoa() etc, found them in a python library, but then found that was not installed on our systems, so wrote our own implementations. But I just checked socket, and that seems to be everywhere. So I don't know what it was I'd found earlier! Yes, I'd run into alignment issues earlier too. Thanks for the other fixes. The use of __int128 is much better . LGTM! |
u64 ts_us; | ||
u64 pid; | ||
unsigned __int128 saddr; |
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.
nice. surprised this actually works. I assume the align of the whole struct is still 8. We probably need to add llvm test to make sure it doesn't regress.
* tcpretrans: support full IPv6 addresses, fix --lossprobe * tcpaccept: support full IPv6 addresses, fix timestamps * tcpconnect: support full IPv6 addresses, fix timestamps * tcpconnlat: support full IPv6 addresses, fix timestamps
Currently these tools just grab the last 2 or 4 bytes of IPv6 addresses. This diff changes them to grab the whole address, as well as fixing a few other things here and there (timestamps were off by 10 and not floats, --lossprobe wasn't used).
I had to move things about in the v6 struct to make
bpf_probe_read(&data.6.daddr, sizeof(data6.daddr), &sk->...)
work correctly. Without this many of the fields were garbage so I assume this is an alignment issue (@4ast can this be caught?)@brendangregg, in #503 you mentioned moving
inet_ntoa()
into the library. Was that because you couldn't get the versions insocket
working, or was it so we could reuse the same code outside of Python? Thesocket
versions here seem to work so shout out if I missed something.Lastly, the output with IPv6 addresses is kinda grim as they overflow the v4 columns (e.g. see tools/tcpconnlat_example.txt). I'm not sure what to do about this. Making all the columns wide enough for the widest possible v6 addresses is going to make the output much wider than 80 chars. I considered changing the format based on whether the host even had a v6 address but that's quite a lot more complexity and IPv6 is rapidly becoming the norm.