From nobody Tue Apr 25 19:21:51 2023 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 4Q5X1X1nGTz46c3D; Tue, 25 Apr 2023 19:21:52 +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 4Q5X1X1HKZz4LxD; Tue, 25 Apr 2023 19:21:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682450512; 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=0wfjHBNrVXrnJCDx94P7aFn7EEua8X2btyUOq2aFvZU=; b=HPpYHg9GK2dhSHU6PQOSX179JCigIMQ+Un75Q82hL9eyVMeX8Ny36HPSxcjeAvUqTdVATa tZx4dWDOJTMxFa448lezFveZcArw29SDK+DVtYEVNICnKJtaTOc6VLUFJv85jz30BMIIdZ xoNWFGi1S8wQwiPRflqIZcIiwShoLL/OY+W6ZSbw0OqaWcR4rtIxN2ZFtdRcOqP7hOFmaq cPQG9NwxoLMFgV0MSMSnpT+c5dZn+GZ9s+4WAm8cOllovU9y2gEZGa4qpeuG1Ws0lIfzqj LqmW8fskaioYBcJhiKxb+jC1bj3xms3sfKYeU8S8G54CMiMeh+k73UAr5vb0Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682450512; 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=0wfjHBNrVXrnJCDx94P7aFn7EEua8X2btyUOq2aFvZU=; b=MIuvdFUfnqr+oQlQqelS7yEB/fe3GAdb6tSs7E+kQfGpkegrmTalKjEq8wfRFS3OUI0mF2 6XfkM0BKsamR2iwVjgYUKuHuNd9lkDCVG2vyvU1GoK/g4DdPpVvl2RGSAz2K8VnPa8X0hF XxJZsCbEFEEkRF2HJ47Ki/foHr6PhXsPJjK257QTj4kn/mGpekBX2NQFPMYXeMG6tifOpT BgahFwMroDlBpwSFEm6tXFLBBuiJ4LTLl2Y45AumaMrIs6dCXGJKf80meWKiRyhYyWSgdR jzo3zS5C8vwDhLHSPWPYOJdaFzf/2UohRDJgKzXGrcGr1hvciT5GvU7en5jEEA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682450512; a=rsa-sha256; cv=none; b=ESjRBhJfMWKoTLTJy+GH56NrPFv6aITDQCcqvi7DghmzWHJ8JUTQuWcYspST3EYZvyv2m7 c1Ee60ooibBEkKEKCEklxPbfPQ6ckAV2NCTWMb9okTQWs6FMCysbraF0NHhl/+W5/5QDt5 WiaF3UARGoaENz43ZwCRjAOpfmeAQzytb9BawpTZ9MK9ECxgHgkEq5hfKolf9w7clth2yu UnIp6u4BSB3HbiQHlgu4xGtDJes9NAqFMOif+1MLDagSA83gDKw4whhAYLRuFfyZbxtDXS ydwR4suq3yb7ScvOFABoFEi/r65E/KnEnT8GScUdO2QuT6FJpye+jIWNVc3K1A== 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 4Q5X1X0LYHz1KHk; Tue, 25 Apr 2023 19:21:52 +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 33PJLpe1022972; Tue, 25 Apr 2023 19:21:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33PJLpvp022971; Tue, 25 Apr 2023 19:21:51 GMT (envelope-from git) Date: Tue, 25 Apr 2023 19:21:51 GMT Message-Id: <202304251921.33PJLpvp022971@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: 144259f67303 - main - tcp: purge the input queue from tcp_discardcb() 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: 144259f673038635709022506d3adc819da137b6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=144259f673038635709022506d3adc819da137b6 commit 144259f673038635709022506d3adc819da137b6 Author: Gleb Smirnoff AuthorDate: 2023-04-25 19:18:19 +0000 Commit: Gleb Smirnoff CommitDate: 2023-04-25 19:18:19 +0000 tcp: purge the input queue from tcp_discardcb() The purge was intentionally removed in a540cdca3183. My assumption was that the stacks that use the input queue always call the tcp_handle_orphaned_packets() in their tfb_tcp_fb_fini method. However, rack will skip doing that if t_fb_ptr is NULL and there are scenarios when it is NULL, e.g. close(2) on a socket (but some special close(2)). Instead of working out all possible scenarios let's put this safebelt back. Reviewed by: rrs Differential Revision: https://reviews.freebsd.org/D39696 --- sys/netinet/tcp_subr.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index d7ca44e8a581..c57eedef151f 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -2379,6 +2379,7 @@ tcp_discardcb(struct tcpcb *tp) { struct inpcb *inp = tptoinpcb(tp); struct socket *so = tptosocket(tp); + struct mbuf *m; #ifdef INET6 bool isipv6 = (inp->inp_vflag & INP_IPV6) != 0; #endif @@ -2422,7 +2423,13 @@ tcp_discardcb(struct tcpcb *tp) #endif CC_ALGO(tp) = NULL; + if ((m = STAILQ_FIRST(&tp->t_inqueue)) != NULL) { + struct mbuf *prev; + STAILQ_INIT(&tp->t_inqueue); + STAILQ_FOREACH_FROM_SAFE(m, &tp->t_inqueue, m_stailqpkt, prev) + m_freem(m); + } TCPSTATES_DEC(tp->t_state); if (tp->t_fb->tfb_tcp_fb_fini) @@ -2430,7 +2437,6 @@ tcp_discardcb(struct tcpcb *tp) #ifdef TCP_BLACKBOX tcp_log_tcpcbfini(tp); #endif - MPASS(STAILQ_EMPTY(&tp->t_inqueue)); /* * If we got enough samples through the srtt filter,