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

v0.13.0 tools/tcptracer ipv6 support is broken #2781

Closed
Safari77 opened this issue Mar 1, 2020 · 2 comments · Fixed by #3114
Closed

v0.13.0 tools/tcptracer ipv6 support is broken #2781

Safari77 opened this issue Mar 1, 2020 · 2 comments · Fixed by #3114

Comments

@Safari77
Copy link

Safari77 commented Mar 1, 2020

v0.13.0 shows ports as 0 and addresses are also wrong.
In the output source IP 2003:df:5f14:d9aa:1:2:3:4 is shown as [::2003:df:5f14:d9aa], and destination IP 2a03:b0c0:3:d0:5:6:7:8 is shown as [1:2:3:4:2a03:b0c0:3:d0].

Running Fedora 30 x86_64 on Linux 4.19.106.

@yonghong-song
Copy link
Collaborator

Does this fixed the issue?

diff --git a/tools/tcptracer.py b/tools/tcptracer.py
index 8e6e1ec2..63a4e626 100755
--- a/tools/tcptracer.py
+++ b/tools/tcptracer.py
@@ -70,12 +70,12 @@ struct tcp_ipv6_event_t {
     u32 type;
     u32 pid;
     char comm[TASK_COMM_LEN];
-    u8 ip;
     unsigned __int128 saddr;
     unsigned __int128 daddr;
     u16 sport;
     u16 dport;
     u32 netns;
+    u8 ip;
 };
 BPF_PERF_OUTPUT(tcp_ipv6_event);

Probably some recent change to convert C structures to python structures which does not support __int128 type had some regressions.

@jeromemarchand
Copy link
Contributor

Does this fixed the issue?

I've seen the same problem on v0.15.0 and this fixed it.

diff --git a/tools/tcptracer.py b/tools/tcptracer.py
index 8e6e1ec2..63a4e626 100755
--- a/tools/tcptracer.py
+++ b/tools/tcptracer.py
@@ -70,12 +70,12 @@ struct tcp_ipv6_event_t {
     u32 type;
     u32 pid;
     char comm[TASK_COMM_LEN];
-    u8 ip;
     unsigned __int128 saddr;
     unsigned __int128 daddr;
     u16 sport;
     u16 dport;
     u32 netns;
+    u8 ip;
 };
 BPF_PERF_OUTPUT(tcp_ipv6_event);

Probably some recent change to convert C structures to python structures which does not support __int128 type had some regressions.

Yes it must be some alignment wrt __int128 type. There is no problem with the ipv4 structure which also have the u8 field in the same place, but no __int128 ones.

jeromemarchand added a commit to jeromemarchand/bcc that referenced this issue Sep 17, 2020
On IPv6, tcptracer ports always appears as zeros:

Tracing TCP established connections. Ctrl-C to end.
T  PID    COMM             IP SADDR            DADDR            SPORT  DPORT
X  7055   nc               4  127.0.0.1        127.0.0.1        49476  9999
C  7074   nc               4  127.0.0.1        127.0.0.1        49478  9999
X  7074   nc               4  127.0.0.1        127.0.0.1        49478  9999
C  7085   nc               6  [::]             [0:0:0:1::]      0      0
X  7085   nc               6  [::]             [0:0:0:1::]      0      0
C  7086   nc               6  [::]             [0:0:0:1::]      0      0

This seems related to alignment issue wrt to the __int128 type in
tcp_ipv6_event_t structure. Moving the u8 field ip to the end of the
structure fixes the issue.

Fixes iovisor#2781
jeromemarchand added a commit to jeromemarchand/bcc that referenced this issue Sep 30, 2020
On IPv6, tcptracer ports always appears as zeros:

Tracing TCP established connections. Ctrl-C to end.
T  PID    COMM             IP SADDR            DADDR            SPORT  DPORT
X  7055   nc               4  127.0.0.1        127.0.0.1        49476  9999
C  7074   nc               4  127.0.0.1        127.0.0.1        49478  9999
X  7074   nc               4  127.0.0.1        127.0.0.1        49478  9999
C  7085   nc               6  [::]             [0:0:0:1::]      0      0
X  7085   nc               6  [::]             [0:0:0:1::]      0      0
C  7086   nc               6  [::]             [0:0:0:1::]      0      0

This seems related to alignment issue wrt to the __int128 type in
tcp_ipv6_event_t structure. Moving the u8 field ip to the end of the
structure fixes the issue.

Fixes iovisor#2781
yonghong-song pushed a commit that referenced this issue Oct 1, 2020
On IPv6, tcptracer ports always appears as zeros:

Tracing TCP established connections. Ctrl-C to end.
T  PID    COMM             IP SADDR            DADDR            SPORT  DPORT
X  7055   nc               4  127.0.0.1        127.0.0.1        49476  9999
C  7074   nc               4  127.0.0.1        127.0.0.1        49478  9999
X  7074   nc               4  127.0.0.1        127.0.0.1        49478  9999
C  7085   nc               6  [::]             [0:0:0:1::]      0      0
X  7085   nc               6  [::]             [0:0:0:1::]      0      0
C  7086   nc               6  [::]             [0:0:0:1::]      0      0

This seems related to alignment issue wrt to the __int128 type in
tcp_ipv6_event_t structure. Moving the u8 field ip to the end of the
structure fixes the issue.

Fixes #2781
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 a pull request may close this issue.

3 participants