From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCA73C282C2 for ; Wed, 13 Feb 2019 12:39:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB5E9222B5 for ; Wed, 13 Feb 2019 12:39:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=yandex-team.ru header.i=@yandex-team.ru header.b="kk9wHdha" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730456AbfBMMjG (ORCPT ); Wed, 13 Feb 2019 07:39:06 -0500 Received: from forwardcorp1o.cmail.yandex.net ([37.9.109.47]:60920 "EHLO forwardcorp1o.cmail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726418AbfBMMjG (ORCPT ); Wed, 13 Feb 2019 07:39:06 -0500 Received: from mxbackcorp2j.mail.yandex.net (mxbackcorp2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::119]) by forwardcorp1o.cmail.yandex.net (Yandex) with ESMTP id 5920920F73; Wed, 13 Feb 2019 15:39:02 +0300 (MSK) Received: from smtpcorp1j.mail.yandex.net (smtpcorp1j.mail.yandex.net [2a02:6b8:0:1619::137]) by mxbackcorp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id X8hZJa4Q5y-d2WikUwN; Wed, 13 Feb 2019 15:39:02 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1550061542; bh=pWvXDFK2A8QOi6uPMMzxbN31PnEuMxeo2B+YvCjPSEY=; h=Subject:From:To:Cc:Date:Message-ID; b=kk9wHdhaWmgOowku4DhmDSgYM4LvUv6FWCukV0tNqvpOJ8n6gUC/qHg8B7+VrWw+c SbefDhB3legP4DsG8K9HjSxwEY50GveYg9mPxr26UiVveVp2cEtxXXvUGBU7OwNPUU lkRcdK1h5apZ/o+2u9ok60Wepnw//BLVBestHKTY= Authentication-Results: mxbackcorp2j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:ccb1:d36:e945:f357]) by smtpcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ZpQKxG8zA6-d24OVjoB; Wed, 13 Feb 2019 15:39:02 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) Subject: [PATCH iproute2] ss: add option --tos for requesting ipv4 tos and ipv6 tclass From: Konstantin Khlebnikov To: Stephen Hemminger , netdev@vger.kernel.org Cc: Eric Dumazet Date: Wed, 13 Feb 2019 15:39:01 +0300 Message-ID: <155006154185.449020.2783123004054072980.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- man/man8/ss.8 | 17 +++++++++++++++++ misc/ss.c | 27 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/man/man8/ss.8 b/man/man8/ss.8 index 553a6cf46f0e..9f21202de424 100644 --- a/man/man8/ss.8 +++ b/man/man8/ss.8 @@ -244,6 +244,23 @@ the pacing rate and max pacing rate a helper variable for TCP internal auto tuning socket receive buffer .RE .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 Attempts to forcibly close sockets. This option displays sockets that are successfully closed and silently skips sockets that the kernel does not support diff --git a/misc/ss.c b/misc/ss.c index 3589ebedc5a0..9e821faf0d31 100644 --- a/misc/ss.c +++ b/misc/ss.c @@ -110,6 +110,7 @@ static int show_header = 1; static int follow_events; static int sctp_ino; static int show_tipcinfo; +static int show_tos; enum col_id { 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)) { out("\n\t"); 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)); } + 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_base = &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)); } + 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_base = &req, .iov_len = sizeof(req) @@ -4661,6 +4681,7 @@ static void _usage(FILE *dest) " -i, --info show internal TCP information\n" " --tipcinfo show internal tipc socket information\n" " -s, --summary show socket usage summary\n" +" --tos show tos and priority information\n" " -b, --bpf show bpf filter socket information\n" " -E, --events continually display sockets as they are destroyed\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_TIPCINFO 258 +#define OPT_TOS 259 + static const struct option long_opts[] = { { "numeric", 0, 0, 'n' }, { "resolve", 0, 0, 'r' }, @@ -4800,6 +4823,7 @@ static const struct option long_opts[] = { { "contexts", 0, 0, 'z' }, { "net", 1, 0, 'N' }, { "tipcinfo", 0, 0, OPT_TIPCINFO}, + { "tos", 0, 0, OPT_TOS }, { "kill", 0, 0, 'K' }, { "no-header", 0, 0, 'H' }, { 0 } @@ -4977,6 +5001,9 @@ int main(int argc, char *argv[]) case OPT_TIPCINFO: show_tipcinfo = 1; break; + case OPT_TOS: + show_tos = 1; + break; case 'K': current_filter.kill = 1; break;