From nobody Sun Dec 19 16:23:07 2021 X-Original-To: dev-commits-src-main@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 705601908CC2; Sun, 19 Dec 2021 16:23:08 +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 4JH7LM7374z3Pk8; Sun, 19 Dec 2021 16:23:07 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 D399E25ED8; Sun, 19 Dec 2021 16:23:07 +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 1BJGN788006791; Sun, 19 Dec 2021 16:23:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BJGN7qV006790; Sun, 19 Dec 2021 16:23:07 GMT (envelope-from git) Date: Sun, 19 Dec 2021 16:23:07 GMT Message-Id: <202112191623.1BJGN7qV006790@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 71d2d5adfe18 - main - tcptw: count how many times a tcptw was actually useful List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 71d2d5adfe18e80e5f8afeb4f86ef69be1aaad81 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639930988; 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=M7YiNShdrwz0d6Hnc5Zvilbnu1X3hBwwJzn2QaInNFE=; b=Z/7yoh553zm2abKmlp+23XedPKOGODDu3eyOJoJFVz9XzDnbytYAPIUImfGjlARB97OHWY GWcrdv7/uAi7L3uC2Oc+BgujhNTF3TuDls7DHhMwqgCn/GlVyE3vzLfGodvpeyClOVMqYe 4veJzvLXKeQWrwG9uZcZau2TByRpU4FXMqqm45TWJmSdUKzvdsinCRazY5b4rPdjd0tAbl SK5NOAbUOrO1d3Q6A6KVlnBnBhUPA/Vhfma9fA489LSkRsUzot/owjD/AbTXM2SdILfTI1 FrDzcDMjhW6exgJybyoKvg2N01pd7BFTNxqRwgZWaMovTygkSgolHiYnUQuo8w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639930988; a=rsa-sha256; cv=none; b=UfhadG2Hfo80wv7w13Ywec9sTcej2qSILDCbSEgVb7CqKLN1vtk/AVfTQXw/QiXYL0P4t+ 1RgWLi1l2RPQLupT2XjcekJjwHL9u+UhuD2JajT9wIwqTR+XYaLHHFFAxlgUwgPXqwGm5d ujPP7RtykLWMYz2IWQ1gRj22RWURT6xYqrfubXGk1cJfIPs1RNSX9crjNpNdgPVuXHK1YK V5OfH+KYnjHBVpMqlac64QjyfFT0zV9Gpw8izbmuAm3tutneEIWrWg7WgvX9/KyK+Lg5y7 al4FztBEbQuJ+KLhjuY2Kcr+ZE988bTooNoUgG/gm7Lb/nPwRN1DlzZBZm1oGg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=71d2d5adfe18e80e5f8afeb4f86ef69be1aaad81 commit 71d2d5adfe18e80e5f8afeb4f86ef69be1aaad81 Author: Gleb Smirnoff AuthorDate: 2021-12-19 16:22:12 +0000 Commit: Gleb Smirnoff CommitDate: 2021-12-19 16:22:12 +0000 tcptw: count how many times a tcptw was actually useful This will allow a sysadmin to lower net.inet.tcp.msl and see how long tcptw are actually useful. --- sys/netinet/tcp_timewait.c | 3 +++ sys/netinet/tcp_var.h | 5 +++++ usr.bin/netstat/inet.c | 14 ++++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index f0ab77100336..999328df8392 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -462,6 +462,7 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th, INP_TRY_UPGRADE(inp) == 0) goto drop; tcp_twclose(tw, 0); + TCPSTAT_INC(tcps_tw_recycles); return (1); } @@ -481,6 +482,7 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th, th->th_seq+tlen, (tcp_seq)0, TH_RST|TH_ACK); } INP_UNLOCK(inp); + TCPSTAT_INC(tcps_tw_resets); return (0); } @@ -519,6 +521,7 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th, th->th_seq != tw->rcv_nxt || th->th_ack != tw->snd_nxt) { TCP_PROBE5(receive, NULL, NULL, m, NULL, th); tcp_twrespond(tw, TH_ACK); + TCPSTAT_INC(tcps_tw_responds); goto dropnoprobe; } drop: diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 6b121a7fd311..c8e262ddf357 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -706,6 +706,11 @@ struct tcpstat { uint64_t tcps_dsack_bytes; /* Number of bytes DSACK'ed no TLP */ uint64_t tcps_dsack_tlp_bytes; /* Number of bytes DSACK'ed due to TLPs */ + /* TCPS_TIME_WAIT usage stats */ + uint64_t tcps_tw_recycles; /* Times time-wait was recycled. */ + uint64_t tcps_tw_resets; /* Times time-wait sent a reset. */ + uint64_t tcps_tw_responds; /* Times time-wait sent a valid ack. */ + uint64_t _pad[6]; /* 3 UTO, 3 TBD */ }; diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index dc777b0be990..b77447575911 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -857,13 +857,23 @@ tcp_stats(u_long off, const char *name, int af1 __unused, int proto __unused) "{N:/Path MTU discovery black hole detection min MSS activation%s}\n"); p(tcps_pmtud_blackhole_failed, "\t{:pmtud-failed/%ju} " "{N:/Path MTU discovery black hole detection failure%s}\n"); + + xo_close_container("pmtud"); + xo_open_container("tw"); + + p(tcps_tw_responds, "\t{:tw_responds/%ju} " + "{N:/time%s connection in TIME-WAIT responded with ACK}\n"); + p(tcps_tw_recycles, "\t{:tw_recycles/%ju} " + "{N:/time%s connection in TIME-WAIT was actively recycled}\n"); + p(tcps_tw_resets, "\t{:tw_resets/%ju} " + "{N:/time%s connection in TIME-WAIT responded with RST}\n"); + + xo_close_container("tw"); #undef p #undef p1a #undef p2 #undef p2a #undef p3 - xo_close_container("pmtud"); - xo_open_container("TCP connection count by state"); xo_emit("{T:/TCP connection count by state}:\n");