Skip to content

Commit

Permalink
tools: tcptracer: fix alignement in tcp_ipv6_event_t
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jeromemarchand authored and yonghong-song committed Oct 1, 2020
1 parent 7e3f0c0 commit 21b810a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/tcptracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@
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);
Expand Down

0 comments on commit 21b810a

Please sign in to comment.