diff options
author | Jerome Marchand <jmarchan@redhat.com> | 2023-02-21 10:53:54 +0100 |
---|---|---|
committer | yonghong-song <ys114321@gmail.com> | 2023-08-20 16:05:33 -0700 |
commit | 01673352497d3a170fcf43e35a2df992b1f4c39e (patch) | |
tree | 11a5682ad4ffe6fc7b54b94a71b7cff54116b61e | |
parent | 9d78fb4c3cae11fab2d2494b9ce474ea4452846b (diff) | |
download | bcc-01673352497d3a170fcf43e35a2df992b1f4c39e.tar.gz |
tools, libpf-tools: increase IPv6 address width to 39 characters
Several tcp tools have a --wide option to accommodate longer IPv6
address. However, they seem to assume that IPv6 addresses are at most
26 characters. I don't know where that numbers comes from, but that's
obviously not right: 8 number of 4 digits plus the colons, that would
make 39.
INET6_ADDRSTRLEN is defined as 46 (so 45 characters) probably to
accommodate for IPv6 mixed notation
(ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255).
I don't think that we have to align on 45 characters as I doubt
inet_ntop would return a mixed notation address, but 39 is a must.
Closes #4460
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
-rw-r--r-- | libbpf-tools/tcplife.c | 2 | ||||
-rw-r--r-- | libbpf-tools/tcpstates.c | 6 | ||||
-rwxr-xr-x | tools/tcplife.lua | 4 | ||||
-rwxr-xr-x | tools/tcplife.py | 4 | ||||
-rwxr-xr-x | tools/tcpstates.py | 4 |
5 files changed, 10 insertions, 10 deletions
diff --git a/libbpf-tools/tcplife.c b/libbpf-tools/tcplife.c index 07f8e969..9af3ea06 100644 --- a/libbpf-tools/tcplife.c +++ b/libbpf-tools/tcplife.c @@ -78,7 +78,7 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state) target_family = AF_INET6; break; case 'w': - column_width = 26; + column_width = 39; break; case 'L': target_sports = strdup(arg); diff --git a/libbpf-tools/tcpstates.c b/libbpf-tools/tcpstates.c index 74993dbd..6367432e 100644 --- a/libbpf-tools/tcpstates.c +++ b/libbpf-tools/tcpstates.c @@ -153,7 +153,7 @@ static void sig_int(int signo) static void handle_event(void *ctx, int cpu, void *data, __u32 data_sz) { - char ts[32], saddr[26], daddr[26]; + char ts[32], saddr[39], daddr[39]; struct event *e = data; struct tm *tm; int family; @@ -170,7 +170,7 @@ static void handle_event(void *ctx, int cpu, void *data, __u32 data_sz) inet_ntop(e->family, &e->daddr, daddr, sizeof(daddr)); if (wide_output) { family = e->family == AF_INET ? 4 : 6; - printf("%-16llx %-7d %-16s %-2d %-26s %-5d %-26s %-5d %-11s -> %-11s %.3f\n", + printf("%-16llx %-7d %-16s %-2d %-39s %-5d %-39s %-5d %-11s -> %-11s %.3f\n", e->skaddr, e->pid, e->task, family, saddr, e->sport, daddr, e->dport, tcp_states[e->oldstate], tcp_states[e->newstate], (double)e->delta_us / 1000); } else { @@ -269,7 +269,7 @@ int main(int argc, char **argv) if (emit_timestamp) printf("%-8s ", "TIME(s)"); if (wide_output) - printf("%-16s %-7s %-16s %-2s %-26s %-5s %-26s %-5s %-11s -> %-11s %s\n", + printf("%-16s %-7s %-16s %-2s %-39s %-5s %-39s %-5s %-11s -> %-11s %s\n", "SKADDR", "PID", "COMM", "IP", "LADDR", "LPORT", "RADDR", "RPORT", "OLDSTATE", "NEWSTATE", "MS"); else diff --git a/tools/tcplife.lua b/tools/tcplife.lua index f2fe9069..bfeaec2d 100755 --- a/tools/tcplife.lua +++ b/tools/tcplife.lua @@ -362,8 +362,8 @@ local function parse_arg(utils) program = program:gsub('FILTER_LPORT', '') if args.wide then - header_string = "%-5s %-16.16s %-2s %-26s %-5s %-26s %-5s %6s %6s %s" - format_string = "%-5d %-16.16s %-2s %-26s %-5s %-26s %-5d %6d %6d %.2f" + header_string = "%-5s %-16.16s %-2s %-39s %-5s %-39s %-5s %6s %6s %s" + format_string = "%-5d %-16.16s %-2s %-39s %-5s %-39s %-5d %6d %6d %.2f" ip_string = "IP" ip_version = true end diff --git a/tools/tcplife.py b/tools/tcplife.py index d5198218..125f0fea 100755 --- a/tools/tcplife.py +++ b/tools/tcplife.py @@ -419,8 +419,8 @@ if debug or args.ebpf: header_string = "%-5s %-10.10s %s%-15s %-5s %-15s %-5s %5s %5s %s" format_string = "%-5d %-10.10s %s%-15s %-5d %-15s %-5d %5d %5d %.2f" if args.wide: - header_string = "%-5s %-16.16s %-2s %-26s %-5s %-26s %-5s %6s %6s %s" - format_string = "%-5d %-16.16s %-2s %-26s %-5s %-26s %-5d %6d %6d %.2f" + header_string = "%-5s %-16.16s %-2s %-39s %-5s %-39s %-5s %6s %6s %s" + format_string = "%-5d %-16.16s %-2s %-39s %-5s %-39s %-5d %6d %6d %.2f" if args.csv: header_string = "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s" format_string = "%d,%s,%s,%s,%s,%s,%d,%d,%d,%.2f" diff --git a/tools/tcpstates.py b/tools/tcpstates.py index 6c845c9b..22894ad6 100755 --- a/tools/tcpstates.py +++ b/tools/tcpstates.py @@ -295,9 +295,9 @@ header_string = "%-16s %-5s %-10.10s %s%-15s %-5s %-15s %-5s %-11s -> %-11s %s" format_string = ("%-16x %-5d %-10.10s %s%-15s %-5d %-15s %-5d %-11s " + "-> %-11s %.3f") if args.wide: - header_string = ("%-16s %-5s %-16.16s %-2s %-26s %-5s %-26s %-5s %-11s " + + header_string = ("%-16s %-5s %-16.16s %-2s %-39s %-5s %-39s %-5s %-11s " + "-> %-11s %s") - format_string = ("%-16x %-5d %-16.16s %-2s %-26s %-5s %-26s %-5d %-11s " + + format_string = ("%-16x %-5d %-16.16s %-2s %-39s %-5s %-39s %-5d %-11s " + "-> %-11s %.3f") if args.csv: header_string = "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s" |