ss: add option --tos for requesting ipv4 tos and ipv6 tclass

Also show socket class_id/priority used by classful qdisc.
Kernel report this together with tclass since commit
("inet_diag: fix reporting cgroup classid and fallback to priority")

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
Konstantin Khlebnikov 2019-02-13 15:39:01 +03:00 committed by Stephen Hemminger
parent bb5ae621d0
commit 0f3f0ca3a2
2 changed files with 44 additions and 0 deletions

View File

@ -244,6 +244,23 @@ the pacing rate and max pacing rate
a helper variable for TCP internal auto tuning socket receive buffer a helper variable for TCP internal auto tuning socket receive buffer
.RE .RE
.TP .TP
.B \-\-tos
Show ToS and priority information. Below fields may appear:
.RS
.P
.TP
.B tos
IPv4 Type-of-Service byte
.P
.TP
.B tclass
IPv6 Traffic Class byte
.P
.TP
.B class_id
Class id set by net_cls cgroup. If class is zero this shows priority set by SO_PRIORITY.
.RE
.TP
.B \-K, \-\-kill .B \-K, \-\-kill
Attempts to forcibly close sockets. This option displays sockets that are Attempts to forcibly close sockets. This option displays sockets that are
successfully closed and silently skips sockets that the kernel does not support successfully closed and silently skips sockets that the kernel does not support

View File

@ -110,6 +110,7 @@ static int show_header = 1;
static int follow_events; static int follow_events;
static int sctp_ino; static int sctp_ino;
static int show_tipcinfo; static int show_tipcinfo;
static int show_tos;
enum col_id { enum col_id {
COL_NETID, COL_NETID,
@ -3008,6 +3009,15 @@ static int inet_show_sock(struct nlmsghdr *nlh,
} }
} }
if (show_tos) {
if (tb[INET_DIAG_TOS])
out(" tos:%#x", rta_getattr_u8(tb[INET_DIAG_TOS]));
if (tb[INET_DIAG_TCLASS])
out(" tclass:%#x", rta_getattr_u8(tb[INET_DIAG_TCLASS]));
if (tb[INET_DIAG_CLASS_ID])
out(" class_id:%#x", rta_getattr_u32(tb[INET_DIAG_CLASS_ID]));
}
if (show_mem || (show_tcpinfo && s->type != IPPROTO_UDP)) { if (show_mem || (show_tcpinfo && s->type != IPPROTO_UDP)) {
out("\n\t"); out("\n\t");
if (s->type == IPPROTO_SCTP) if (s->type == IPPROTO_SCTP)
@ -3058,6 +3068,11 @@ static int tcpdiag_send(int fd, int protocol, struct filter *f)
req.r.idiag_ext |= (1<<(INET_DIAG_CONG-1)); req.r.idiag_ext |= (1<<(INET_DIAG_CONG-1));
} }
if (show_tos) {
req.r.idiag_ext |= (1<<(INET_DIAG_TOS-1));
req.r.idiag_ext |= (1<<(INET_DIAG_TCLASS-1));
}
iov[0] = (struct iovec){ iov[0] = (struct iovec){
.iov_base = &req, .iov_base = &req,
.iov_len = sizeof(req) .iov_len = sizeof(req)
@ -3118,6 +3133,11 @@ static int sockdiag_send(int family, int fd, int protocol, struct filter *f)
req.r.idiag_ext |= (1<<(INET_DIAG_CONG-1)); req.r.idiag_ext |= (1<<(INET_DIAG_CONG-1));
} }
if (show_tos) {
req.r.idiag_ext |= (1<<(INET_DIAG_TOS-1));
req.r.idiag_ext |= (1<<(INET_DIAG_TCLASS-1));
}
iov[0] = (struct iovec){ iov[0] = (struct iovec){
.iov_base = &req, .iov_base = &req,
.iov_len = sizeof(req) .iov_len = sizeof(req)
@ -4661,6 +4681,7 @@ static void _usage(FILE *dest)
" -i, --info show internal TCP information\n" " -i, --info show internal TCP information\n"
" --tipcinfo show internal tipc socket information\n" " --tipcinfo show internal tipc socket information\n"
" -s, --summary show socket usage summary\n" " -s, --summary show socket usage summary\n"
" --tos show tos and priority information\n"
" -b, --bpf show bpf filter socket information\n" " -b, --bpf show bpf filter socket information\n"
" -E, --events continually display sockets as they are destroyed\n" " -E, --events continually display sockets as they are destroyed\n"
" -Z, --context display process SELinux security contexts\n" " -Z, --context display process SELinux security contexts\n"
@ -4765,6 +4786,8 @@ static int scan_state(const char *state)
#define OPT_TIPCSOCK 257 #define OPT_TIPCSOCK 257
#define OPT_TIPCINFO 258 #define OPT_TIPCINFO 258
#define OPT_TOS 259
static const struct option long_opts[] = { static const struct option long_opts[] = {
{ "numeric", 0, 0, 'n' }, { "numeric", 0, 0, 'n' },
{ "resolve", 0, 0, 'r' }, { "resolve", 0, 0, 'r' },
@ -4800,6 +4823,7 @@ static const struct option long_opts[] = {
{ "contexts", 0, 0, 'z' }, { "contexts", 0, 0, 'z' },
{ "net", 1, 0, 'N' }, { "net", 1, 0, 'N' },
{ "tipcinfo", 0, 0, OPT_TIPCINFO}, { "tipcinfo", 0, 0, OPT_TIPCINFO},
{ "tos", 0, 0, OPT_TOS },
{ "kill", 0, 0, 'K' }, { "kill", 0, 0, 'K' },
{ "no-header", 0, 0, 'H' }, { "no-header", 0, 0, 'H' },
{ 0 } { 0 }
@ -4977,6 +5001,9 @@ int main(int argc, char *argv[])
case OPT_TIPCINFO: case OPT_TIPCINFO:
show_tipcinfo = 1; show_tipcinfo = 1;
break; break;
case OPT_TOS:
show_tos = 1;
break;
case 'K': case 'K':
current_filter.kill = 1; current_filter.kill = 1;
break; break;