From nobody Fri Oct 07 02:46:56 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 4MkCQ03jv3z4f6KV; Fri, 7 Oct 2022 02:47:04 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (glebi.us [162.251.186.162]) (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 (2048 bits) client-digest SHA256) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MkCPz2ZFvz4HXl; Fri, 7 Oct 2022 02:47:03 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.16.1/8.16.1) with ESMTPS id 2972ku97041894 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 6 Oct 2022 19:46:56 -0700 (PDT) (envelope-from glebius@freebsd.org) Received: (from glebius@localhost) by cell.glebi.us (8.16.1/8.16.1/Submit) id 2972kumt041893; Thu, 6 Oct 2022 19:46:56 -0700 (PDT) (envelope-from glebius@freebsd.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@freebsd.org using -f Date: Thu, 6 Oct 2022 19:46:56 -0700 From: Gleb Smirnoff To: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 0d7445193abc - main - tcp: remove tcptw, the compressed timewait state structure Message-ID: References: <202210070235.2972Zc5S090599@gitrepo.freebsd.org> 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=us-ascii Content-Disposition: inline In-Reply-To: <202210070235.2972Zc5S090599@gitrepo.freebsd.org> X-Rspamd-Queue-Id: 4MkCPz2ZFvz4HXl X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=softfail (mx1.freebsd.org: 162.251.186.162 is neither permitted nor denied by domain of glebius@freebsd.org) smtp.mailfrom=glebius@freebsd.org X-Spamd-Result: default: False [-3.09 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.99)[-0.989]; MIME_GOOD(-0.10)[text/plain]; MLMMJ_DEST(0.00)[dev-commits-src-all@freebsd.org,dev-commits-src-main@freebsd.org]; ARC_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; ASN(0.00)[asn:27348, ipnet:162.251.186.0/24, country:US]; MIME_TRACE(0.00)[0:+]; DMARC_NA(0.00)[freebsd.org]; R_SPF_SOFTFAIL(0.00)[~all]; TO_DN_NONE(0.00)[]; FROM_HAS_DN(0.00)[]; FREEFALL_USER(0.00)[glebius]; RCVD_TLS_LAST(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; HAS_XAW(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-ThisMailContainsUnwantedMimeParts: N Hi On Fri, Oct 07, 2022 at 02:35:38AM +0000, Gleb Smirnoff wrote: T> The memory savings the tcptw brought back in 2003 (see 340c35de6a2) no T> longer justify the complexity required to maintain it. For longer T> explanation please check out the email [1]. T> T> Surpisingly through almost 20 years the TCP stack functionality of T> handling the TIME_WAIT state with a normal tcpcb did not bitrot. The T> existing tcp_input() properly handles a tcpcb in TCPS_TIME_WAIT state, T> which is confirmed by the packetdrill tcp-testsuite [2]. T> T> This change just removes tcptw and leaves INP_TIMEWAIT. The flag will T> be removed in a separate commit. This makes it easier to review and T> possibly debug the changes. T> T> [1] https://lists.freebsd.org/archives/freebsd-net/2022-January/001206.html T> [2] https://github.com/freebsd-net/tcp-testsuite T> T> Differential revision: https://reviews.freebsd.org/D36398 The memory savings cut here are more than just sizeof(struct tcpcb) - sizeof(struct tcptw). We also keep the socket around for duration of TIME_WAIT. And the stuff that may hang off the socket, e.g. kTLS context. I prepared a changeset that would free the socket when transitioning to TIME_WAIT: https://reviews.freebsd.org/D36887 However, the patch adds back some complexity that we just removed. It also introduces a problem with two recent features of pluggable TCP stacks and massive setsockopt: we got sysctl_setsockopt() that would run setsockopt on a pcb matching certain criteria. One of most common applications of this tool is to switch from one TCP stack to the other. To execute sosetopt() the sysctl_setsockopt() needs socket. With the compressed timewait structure, we didn't have it. Now we don't, too. However, the compressed timewaits were short-circuited to the default TCP stack and didn't depend on the pluggable ones. With a regular tcpcb we still reference the stack. That makes it impossible to switch off ALL existing connections from some stack with sysctl_setsockopt(). After todays discussion with mtuexen@, rscheff@ and peterlei@ we decided not to rush with checking in D36887 and have more discussion whether the memory savings worth the comlexity or not. But keep the revision around. -- Gleb Smirnoff