Skip to content
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

Merged
merged 4 commits into from
Jun 26, 2016
Merged

IPv6 support for tcp* tools #582

merged 4 commits into from
Jun 26, 2016

Conversation

markdrayton
Copy link
Contributor

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 in socket working, or was it so we could reuse the same code outside of Python? The socket 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.

@@ -44,6 +42,7 @@
bpf_text = """
#include <uapi/linux/ptrace.h>
#include <net/sock.h>
#include <net/tcp_states.h>
Copy link
Contributor Author

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.

@brendangregg
Copy link
Member

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;
Copy link
Member

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.

@4ast 4ast merged commit 11de298 into iovisor:master Jun 26, 2016
@markdrayton markdrayton deleted the tcp-tools-ipv6 branch June 26, 2016 23:05
abirchall pushed a commit to abirchall/bcc that referenced this pull request Jul 11, 2016
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants