From nobody Thu Jan 13 21:20:58 2022 X-Original-To: dev-commits-src-all@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 DC0F7195800C; Thu, 13 Jan 2022 21:20:58 +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 4JZcmV5p0tz3pQk; Thu, 13 Jan 2022 21:20:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642108858; 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=6T2ZYAVClh53M/3YNZ/dMzUlXPWtggZfKvq2e8yzs+w=; b=sla2bUvMQBPDOmgicr3EcbhkTQvZlx7NdhlLaYtiygFPmYAz2rqkFFkCsS6UuBmirSIc9Q L9As7I1wsKov/Mb9lgoZR0psNguybmV/UaMDN0mWAMT2H0687yn4Z6Sqiu+hQCvsPzjvp+ d55L4Zd4c+mTfx7RtXUV2ky12/WjGflb8RjZyN4rnyzzFGdf+BabSkXGXXbzbHiN+1aTHg FW7lNJPGAWMo37j7rZ4qem9iM8qm+sjgTRGkBaHLu24cPYSYLLxUNS8KFGhpfT/q/MWK/W SnXiXCbMpgig4+kL6IC6SvduTXw5hAfG3iRI63hM5tA70iaquq7ISwtVqWKcZw== 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 9F65C27A88; Thu, 13 Jan 2022 21:20:58 +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 20DLKwT0025873; Thu, 13 Jan 2022 21:20:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20DLKwE2025872; Thu, 13 Jan 2022 21:20:58 GMT (envelope-from git) Date: Thu, 13 Jan 2022 21:20:58 GMT Message-Id: <202201132120.20DLKwE2025872@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gleb Smirnoff Subject: git: 1e2a0cef6bf1 - stable/13 - tcptw: count how many times a tcptw was actually useful List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 1e2a0cef6bf10db00f230f33ee14293f5b00e894 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642108858; 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=6T2ZYAVClh53M/3YNZ/dMzUlXPWtggZfKvq2e8yzs+w=; b=FpG+uvYa6WpntJFOGxVfpu/fU/CcMNJyQYLYVz9tch7XYPToAEYsgtGPk0E6kzX9sJ9UeF VyhFKpyimC27e2BgmXmPs/ppb/tsbmdOwYiClyzd6tlq9QDLtH2ilVUtw4eYOeELCwUebZ QtvAYf0Z834QxxLLGTOK6spVKI4r8YcNM4K9FXQkY9yhBaDBBP+we1hhrmZQYdU5EIud7W IFcWxqNwBX8t/zEfr4/EuPg4qo7Dz0OhBswhgLmOGU5x6Pnn1zDavvcIBGOiFYMeQUj3CQ kb8iGfvYnCdYN0lgtmpUE1/kaiWoDHX2DqHkZMGgXBmRglvGUHXOgvcULXRVMQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642108858; a=rsa-sha256; cv=none; b=Mw/EhoXzKsYJsjvSZnvIhZOxF15aSKXWdZfYv/69vLKw1SFdIhmTmkwoBX0KcxGGm/etW4 RgPKlkF/vlaPyvdPSyoOuPipEL3r9Bg83pcW0CuXouvH0D+kXcs12vPhjrqdpDvMPS8EqZ DxfWfFJM+wTBeJMqkMM+j2Y2mBRjPZkBllhy1WXtdd7Qkl8WBPoXrBjLsp6mss3vuNpfMa R3MCDvhGdBCGWBhDtvNDhzpeeb695Ry9m0zpwJvladEphq8fc3Szqg6DadaMX8Jgn7lSO3 sp6vIEzDoYMKEB5oqn1ncemSSc6z71hl/ouI5lC9yK6XikmQhL5RltfVDEuNwQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=1e2a0cef6bf10db00f230f33ee14293f5b00e894 commit 1e2a0cef6bf10db00f230f33ee14293f5b00e894 Author: Gleb Smirnoff AuthorDate: 2022-01-13 21:19:40 +0000 Commit: Gleb Smirnoff CommitDate: 2022-01-13 21:19:40 +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. (cherry picked from commit 71d2d5adfe18e80e5f8afeb4f86ef69be1aaad81) --- sys/netinet/tcp_timewait.c | 3 +++ sys/netinet/tcp_var.h | 7 ++++++- usr.bin/netstat/inet.c | 14 ++++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index b62386ddca05..0ed3856b68a4 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -443,6 +443,7 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th, */ if ((thflags & TH_SYN) && SEQ_GT(th->th_seq, tw->rcv_nxt)) { tcp_twclose(tw, 0); + TCPSTAT_INC(tcps_tw_recycles); return (1); } @@ -462,6 +463,7 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th, th->th_seq+tlen, (tcp_seq)0, TH_RST|TH_ACK); } INP_WUNLOCK(inp); + TCPSTAT_INC(tcps_tw_resets); return (0); } @@ -498,6 +500,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 323472f96cfb..86783c0eae38 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -700,7 +700,12 @@ struct tcpstat { uint64_t tcps_tunneled_pkts; /* Packets encap's in UDP received */ uint64_t tcps_tunneled_errs; /* Packets that had errors that were UDP encaped */ - uint64_t _pad[10]; /* 6 UTO, 6 TBD */ + /* 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[7]; }; #define tcps_rcvmemdrop tcps_rcvreassfull /* compat */ diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index b46f5c92e808..ec8128e19baf 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -849,13 +849,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");