Cleanup display logic and add receive space values.
(Logical change 1.12)
This commit is contained in:
parent
efc6c8e9a2
commit
05e18118ec
58
misc/ss.c
58
misc/ss.c
|
|
@ -294,7 +294,7 @@ struct slabstat
|
||||||
|
|
||||||
struct slabstat slabstat;
|
struct slabstat slabstat;
|
||||||
|
|
||||||
const char *slabstat_ids[] =
|
static const char *slabstat_ids[] =
|
||||||
{
|
{
|
||||||
"sock",
|
"sock",
|
||||||
"tcp_bind_bucket",
|
"tcp_bind_bucket",
|
||||||
|
|
@ -392,7 +392,7 @@ static const char *tmr_name[] = {
|
||||||
"unknown"
|
"unknown"
|
||||||
};
|
};
|
||||||
|
|
||||||
char *print_ms_timer(int timeout)
|
const char *print_ms_timer(int timeout)
|
||||||
{
|
{
|
||||||
static char buf[64];
|
static char buf[64];
|
||||||
int secs, msecs, minutes;
|
int secs, msecs, minutes;
|
||||||
|
|
@ -419,7 +419,7 @@ char *print_ms_timer(int timeout)
|
||||||
return buf;
|
return buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
char *print_hz_timer(int timeout)
|
const char *print_hz_timer(int timeout)
|
||||||
{
|
{
|
||||||
int hz = get_hz();
|
int hz = get_hz();
|
||||||
return print_ms_timer(((timeout*1000) + hz-1)/hz);
|
return print_ms_timer(((timeout*1000) + hz-1)/hz);
|
||||||
|
|
@ -1270,22 +1270,14 @@ outerr:
|
||||||
void tcp_show_info(struct nlmsghdr *nlh, struct tcpdiagmsg *r)
|
void tcp_show_info(struct nlmsghdr *nlh, struct tcpdiagmsg *r)
|
||||||
{
|
{
|
||||||
struct rtattr * tb[TCPDIAG_MAX+1];
|
struct rtattr * tb[TCPDIAG_MAX+1];
|
||||||
const struct tcpdiag_meminfo *minfo = NULL;
|
|
||||||
const struct tcp_info *info = NULL;
|
|
||||||
const struct tcpvegas_info *vinfo = NULL;
|
|
||||||
|
|
||||||
memset(tb, 0, sizeof(tb));
|
memset(tb, 0, sizeof(tb));
|
||||||
parse_rtattr(tb, TCPDIAG_MAX, (struct rtattr*)(r+1),
|
parse_rtattr(tb, TCPDIAG_MAX, (struct rtattr*)(r+1),
|
||||||
nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
|
nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
|
||||||
|
|
||||||
if (tb[TCPDIAG_MEMINFO])
|
if (tb[TCPDIAG_MEMINFO]) {
|
||||||
minfo = RTA_DATA(tb[TCPDIAG_MEMINFO]);
|
const struct tcpdiag_meminfo *minfo
|
||||||
if (tb[TCPDIAG_INFO])
|
= RTA_DATA(tb[TCPDIAG_MEMINFO]);
|
||||||
info = RTA_DATA(tb[TCPDIAG_INFO]);
|
|
||||||
if (tb[TCPDIAG_VEGASINFO])
|
|
||||||
vinfo = RTA_DATA(tb[TCPDIAG_VEGASINFO]);
|
|
||||||
|
|
||||||
if (minfo) {
|
|
||||||
printf(" mem:(r%u,w%u,f%u,t%u)",
|
printf(" mem:(r%u,w%u,f%u,t%u)",
|
||||||
minfo->tcpdiag_rmem,
|
minfo->tcpdiag_rmem,
|
||||||
minfo->tcpdiag_wmem,
|
minfo->tcpdiag_wmem,
|
||||||
|
|
@ -1293,8 +1285,27 @@ void tcp_show_info(struct nlmsghdr *nlh, struct tcpdiagmsg *r)
|
||||||
minfo->tcpdiag_tmem);
|
minfo->tcpdiag_tmem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info) {
|
if (tb[TCPDIAG_INFO]) {
|
||||||
#ifdef TCP_INFO
|
struct tcp_info *info;
|
||||||
|
int len = RTA_PAYLOAD(tb[TCPDIAG_INFO]);
|
||||||
|
|
||||||
|
/* workaround for older kernels with less fields */
|
||||||
|
if (len < sizeof(*info)) {
|
||||||
|
info = alloca(sizeof(*info));
|
||||||
|
memset(info, 0, sizeof(*info));
|
||||||
|
memcpy(info, RTA_DATA(tb[TCPDIAG_INFO]), len);
|
||||||
|
} else
|
||||||
|
info = RTA_DATA(tb[TCPDIAG_INFO]);
|
||||||
|
|
||||||
|
if (info->tcpi_options & TCPI_OPT_TIMESTAMPS)
|
||||||
|
printf(" ts");
|
||||||
|
if (info->tcpi_options & TCPI_OPT_SACK)
|
||||||
|
printf(" sack");
|
||||||
|
if (info->tcpi_options & TCPI_OPT_WSCALE)
|
||||||
|
printf(" wscale:%d,%d", info->tcpi_snd_wscale,
|
||||||
|
info->tcpi_rcv_wscale);
|
||||||
|
if (info->tcpi_options & TCPI_OPT_ECN)
|
||||||
|
printf(" ecn");
|
||||||
if (info->tcpi_rto && info->tcpi_rto != 3000000)
|
if (info->tcpi_rto && info->tcpi_rto != 3000000)
|
||||||
printf(" rto:%g", (double)info->tcpi_rto/1000);
|
printf(" rto:%g", (double)info->tcpi_rto/1000);
|
||||||
if (info->tcpi_rtt)
|
if (info->tcpi_rtt)
|
||||||
|
|
@ -1307,9 +1318,18 @@ void tcp_show_info(struct nlmsghdr *nlh, struct tcpdiagmsg *r)
|
||||||
if (info->tcpi_snd_ssthresh < 0xFFFF)
|
if (info->tcpi_snd_ssthresh < 0xFFFF)
|
||||||
printf(" ssthresh:%d", info->tcpi_snd_ssthresh);
|
printf(" ssthresh:%d", info->tcpi_snd_ssthresh);
|
||||||
|
|
||||||
if (vinfo) {
|
if (info->tcpi_rcv_rtt)
|
||||||
|
printf(" rcv_rtt:%g", (double) info->tcpi_rcv_rtt/1000);
|
||||||
|
if (info->tcpi_rcv_space)
|
||||||
|
printf(" rcv_space:%d", info->tcpi_rcv_space);
|
||||||
|
|
||||||
|
if (tb[TCPDIAG_VEGASINFO]) {
|
||||||
|
const struct tcpvegas_info *vinfo
|
||||||
|
= RTA_DATA(tb[TCPDIAG_VEGASINFO]);
|
||||||
|
|
||||||
if (vinfo->tcpv_enabled)
|
if (vinfo->tcpv_enabled)
|
||||||
printf(" vegas");
|
printf(" vegas");
|
||||||
|
|
||||||
if (vinfo->tcpv_rtt &&
|
if (vinfo->tcpv_rtt &&
|
||||||
vinfo->tcpv_rtt != 0x7fffffff &&
|
vinfo->tcpv_rtt != 0x7fffffff &&
|
||||||
info->tcpi_snd_mss &&
|
info->tcpi_snd_mss &&
|
||||||
|
|
@ -1321,10 +1341,6 @@ void tcp_show_info(struct nlmsghdr *nlh, struct tcpdiagmsg *r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#warning No TCP_INFO. Please, do not repeat this experiment, use right kernel.
|
|
||||||
printf(" MORE_INFO_PROVIDED_YOU_COMPILED_SS_RIGHT");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int tcp_show_sock(struct nlmsghdr *nlh, struct filter *f)
|
int tcp_show_sock(struct nlmsghdr *nlh, struct filter *f)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue