From nobody Wed Feb 23 00:12:09 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id ACF5519D3042; Wed, 23 Feb 2022 00:12:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K3GgY4SKVz4WtZ; Wed, 23 Feb 2022 00:12:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645575129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RZJAL8e8E+pmpBDNONHjVAgOJ6D7Qd3wWL3HEOWtChI=; b=Wo11VH+9ZRBiLw+/ReaOgkgQ4nRGdl6upgUpNYsD7hye+S0aa1Wbpk2h/bpyJJwQrQVzXi WInvutmBd0z4xypU8+RV7rth6jcZF37ea5jOpQoeW84xGshN5BVtySGvVc4MBkyvQ0oZzf L+IT1GLYfmQVdfH6WF9nuzdwD7lLYSOCn9sjmVK38mHtydO38xUKUMZEOV6jiJpue4iVn3 EE1tMvDTZ2n5Nl0XiwaZGKnDqrsqyVV/h91ANgAsLSZoJLfR/d6yKqfe+ZHyfcI6vnz6Es B5csnoDXhqkMNeKpkkkr5bmKrgfXzpaYtOCa4bfvybOjc3rApKB0Ku+qYagddw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 790616392; Wed, 23 Feb 2022 00:12:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21N0C9tf077924; Wed, 23 Feb 2022 00:12:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21N0C9OI077923; Wed, 23 Feb 2022 00:12:09 GMT (envelope-from git) Date: Wed, 23 Feb 2022 00:12:09 GMT Message-Id: <202202230012.21N0C9OI077923@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: dee236b2c32b - stable/13 - sockstat: add -i to display inp_gencnt List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: dee236b2c32b43a736d7e146a770777e63b527ee Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645575129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RZJAL8e8E+pmpBDNONHjVAgOJ6D7Qd3wWL3HEOWtChI=; b=WEGQv/ul5KFStitdYWGmLtygihN7m21sTDPPBTh7d8HU903iyTBGBVlM3LuOaSSS0hG+qc 5tvQjmqZT2m8/oWtyEOStJIEdeGLBpfM+YpLAV5rA/irUf36DYIpg6xAtyI6vBT0sP0mD0 nh6oMvFB5sJ+Xg/whbNhJhZjJFYmxgvw0EfuFITKUtkMb0SxcA8gkCPFdMDGYhPZ+G22nb QFMTdr0sWeEidKUQ95Ws0sTYxRyD5Ezp20KgAPqD3H6BUe/1Be/VLsQM9HX3HByI41Jmgl q8r1r42OHNwASD75+5K/gNjGMXyJTAAMIgcCDejanZfCm0QcBf5ULQO3b0Yqeg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645575129; a=rsa-sha256; cv=none; b=xboboNamA2NvnvzLPyeeSiQVQ1juBqKrdlLFayx1TDrysJTkV0HkbZVuuy+mmGRkD1hBAM Emai3Cmsxa+s95+efeO83HC2tXua5xBFgx4rmLk+b5EDh7CF5vmP0XHyBp9mS4iNKebg9f n0Yzqn9ccm9x23M50gqfaMTKwYVhOdY61Omc18lPAjiAja4gf2SYjd5hq6ND55dkgkGsbo IAB9/iYJGzW03ZGUfI9N5Z/+28xra8TR2X0URbGYAh2aKxJbdZAaTl3WE6GmZmUGnSzh/F n8gWjXXsqmlxXVrb79m1MzSn2GqYdiWr63q2ukCixEUjGx2gYZTMZOKdIQu1Gg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=dee236b2c32b43a736d7e146a770777e63b527ee commit dee236b2c32b43a736d7e146a770777e63b527ee Author: Michael Tuexen AuthorDate: 2022-02-01 14:37:03 +0000 Commit: Michael Tuexen CommitDate: 2022-02-23 00:10:32 +0000 sockstat: add -i to display inp_gencnt The inp_gencnt will be used to identify a TCP endpoint by an upcoming command line tool to set TCP socket options. Reviewed by: rscheff Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D34137 (cherry picked from commit 5f64777a4fe38acb412762fa92da583a1018e609) --- usr.bin/sockstat/sockstat.1 | 11 +++++++++-- usr.bin/sockstat/sockstat.c | 22 ++++++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/usr.bin/sockstat/sockstat.1 b/usr.bin/sockstat/sockstat.1 index bf04028ce9d4..bc8fa628f725 100644 --- a/usr.bin/sockstat/sockstat.1 +++ b/usr.bin/sockstat/sockstat.1 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 11, 2021 +.Dd February 2, 2022 .Dt SOCKSTAT 1 .Os .Sh NAME @@ -35,7 +35,7 @@ .Nd list open sockets .Sh SYNOPSIS .Nm -.Op Fl 46CcLlnqSsUuvw +.Op Fl 46CciLlnqSsUuvw .Op Fl j Ar jail .Op Fl p Ar ports .Op Fl P Ar protocols @@ -61,6 +61,9 @@ Display the congestion control module, if applicable. This is currently only implemented for TCP. .It Fl c Show connected sockets. +.It Fl i +Display the +.Dv inp_gencnt . .It Fl j Ar jail Show only sockets belonging to the specified jail ID or name. .It Fl L @@ -160,6 +163,10 @@ if the endpoint could not be determined. (Internet sockets only) The address the foreign end of the socket is bound to (see .Xr getpeername 2 ) . +.It Li ID +The inp_gencnt if +.Fl i +is specified (only for TCP or UDP). .It Li ENCAPS The remote UDP encapsulation port number if .Fl U diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c index 6edb589b5209..0a09318bd7fe 100644 --- a/usr.bin/sockstat/sockstat.c +++ b/usr.bin/sockstat/sockstat.c @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -76,6 +77,7 @@ static int opt_4; /* Show IPv4 sockets */ static int opt_6; /* Show IPv6 sockets */ static int opt_C; /* Show congestion control */ static int opt_c; /* Show connected sockets */ +static int opt_i; /* Show inp_gencnt */ static int opt_j; /* Show specified jail */ static int opt_L; /* Don't show IPv4 or IPv6 loopback sockets */ static int opt_l; /* Show listening sockets */ @@ -113,6 +115,7 @@ struct addr { struct sock { kvaddr_t socket; kvaddr_t pcb; + uint64_t inp_gencnt; int shown; int vflag; int family; @@ -697,6 +700,7 @@ gather_inet(int proto) err(1, "malloc()"); sock->socket = so->xso_so; sock->proto = proto; + sock->inp_gencnt = xip->inp_gencnt; if (xip->inp_vflag & INP_IPV4) { sock->family = AF_INET; sockaddr(&laddr->address, sock->family, @@ -1087,6 +1091,15 @@ displaysock(struct sock *s, int pos) default: abort(); } + if (opt_i) { + if (s->proto == IPPROTO_TCP || + s->proto == IPPROTO_UDP) { + while (pos < offset) + pos += xprintf(" "); + pos += xprintf("%" PRIu64, s->inp_gencnt); + } + offset += 9; + } if (opt_U) { if (faddr != NULL && ((s->proto == IPPROTO_SCTP && @@ -1184,6 +1197,8 @@ display(void) "USER", "COMMAND", "PID", "FD", "PROTO", opt_w ? 45 : 21, "LOCAL ADDRESS", opt_w ? 45 : 21, "FOREIGN ADDRESS"); + if (opt_i) + printf(" %-8s", "ID"); if (opt_U) printf(" %-6s", "ENCAPS"); if (opt_s) { @@ -1299,7 +1314,7 @@ static void usage(void) { fprintf(stderr, - "usage: sockstat [-46cLlSsUuvw] [-j jid] [-p ports] [-P protocols]\n"); + "usage: sockstat [-46ciLlSsUuvw] [-j jid] [-p ports] [-P protocols]\n"); exit(1); } @@ -1310,7 +1325,7 @@ main(int argc, char *argv[]) int o, i; opt_j = -1; - while ((o = getopt(argc, argv, "46Ccj:Llnp:P:qSsUuvw")) != -1) + while ((o = getopt(argc, argv, "46Ccij:Llnp:P:qSsUuvw")) != -1) switch (o) { case '4': opt_4 = 1; @@ -1324,6 +1339,9 @@ main(int argc, char *argv[]) case 'c': opt_c = 1; break; + case 'i': + opt_i = 1; + break; case 'j': opt_j = jail_getid(optarg); if (opt_j < 0)