Skip to content

Commit

Permalink
libbpf-tools: fix tcppktlat show wrong ports
Browse files Browse the repository at this point in the history
Signed-off-by: Wenbo Zhang <[email protected]>
  • Loading branch information
Wenbo Zhang authored and chenhengqi committed Jul 25, 2023
1 parent 18b00a9 commit 7ce3d7d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libbpf-tools/tcppktlat.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state)
fprintf(stderr, "invalid lport: %s\n", arg);
argp_usage(state);
}
env.lport = htons(env.lport);
break;
case 'r':
errno = 0;
Expand All @@ -108,6 +109,7 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state)
fprintf(stderr, "invalid rport: %s\n", arg);
argp_usage(state);
}
env.rport = htons(env.rport);
break;
case 'w':
column_width = 26;
Expand Down Expand Up @@ -162,8 +164,8 @@ static int handle_event(void *ctx, void *data, size_t data_sz)
inet_ntop(e->family, &e->daddr, daddr, sizeof(daddr));

printf("%-7d %-7d %-16s %-*s %-5d %-*s %-5d %-.2f\n",
e->pid, e->tid, e->comm, column_width, saddr, e->sport, column_width, daddr,
e->dport, e->delta_us / 1000.0);
e->pid, e->tid, e->comm, column_width, saddr, ntohs(e->sport), column_width, daddr,
ntohs(e->dport), e->delta_us / 1000.0);

return 0;
}
Expand Down

0 comments on commit 7ce3d7d

Please sign in to comment.