From nobody Fri Feb 17 17:14:34 2023 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 4PJJMb0fNlz3rB06; Fri, 17 Feb 2023 17:14:35 +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 4PJJMb07m4z3n3D; Fri, 17 Feb 2023 17:14:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676654075; 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=S8v7hFyHvPFkSMKhKJqupJM7x2SAAc6Blk0pq/hPpGU=; b=pGb4lNjSp8JbxxTi8gnBb9Eo1FIGdms9wRpmf0XXGdTEXtd4ggrU35NnbQ5KUCZK363pGG filC9e6z6DC7ccKbyPwZ1TmEMPXNdKpLKQw1idQcRryAuvgXnhmII/jbbWxDkM1vJrAGnO ay2PrsvTYA0Daqt9DBhJ2kjV5x0ZvIE/zwH80GlZwDX6/pP6KUwZWB7UL2bmsbfT2EjeqO yw/yn8jPpWB/xxDuh6jry7flu9BdHUqroxbK7Fr47mVVkZOAFTBvShiQBhls6U3Np6zPfw +vzxHXKslAVgCLsNwjpU0k7qWzLV82QhAs9DduPzPJui1XyOIlJThlAgfrx3vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676654075; 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=S8v7hFyHvPFkSMKhKJqupJM7x2SAAc6Blk0pq/hPpGU=; b=yTlsq8WdffrKLLlRUMUxN3grm4lklUjLxPYqs+GZf+YnoAnjLUDg1sKpqJFft13J2Zf6Pl WxvY3hBLhFjo9EIfZnfSlk2zbrfIaTUBYzPnTUhUm+eZfQYjdLyl5Q81oVkXUStIZSKbye yA5smS79B8joOSZbBz1TuVoLVb/fQE+AmcK34lUlwTJrrDvIM32C85m0AEu4eD2TtWO6I4 b4WU+HACBuhriwNHR75ZYFmLf2IOpboCY5qq+zuklDd2v38OlJInZvlmfqZXCepO9TUr5P ru7BGALCR9BT/JC19UWxX9Qrrtck5olO5Mk+nVoDvBjjJFqBmrQh05/US/iSHg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676654075; a=rsa-sha256; cv=none; b=KP24Vf9l667OEt4NSGxbCu6MA8pcXMRGN4Oz+BdRqPTxXX+sLtMDh+sqClykqGkI0sQOX9 plSZyWMbZtve2FFFVsl0g9FAPC0RQqElHpA8Ia7ZEZZkpc6S4bcxh1UeRSaK/ARIx7yvTX 2W/OgqvLd+5LTIiePSQrZ9yycPMPXp/YSI86/O4AHyi3F0mm1ttdF2h/FogTFKflDF8pnc u+c4mvMpILNYnlfuxS9WcmwSdGuhI16s/tspicHpqGWAplOoJOyIIED+MmCRuaSSp95+BR ++3s+y2lIxHFbNMCVBgNuVMoNR2ZYh6AsqlSKQFvjIdoRz42Agv27O2Lrw9PGg== 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 4PJJMZ6GCXzqq2; Fri, 17 Feb 2023 17:14:34 +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 31HHEYlW068974; Fri, 17 Feb 2023 17:14:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31HHEYAT068973; Fri, 17 Feb 2023 17:14:34 GMT (envelope-from git) Date: Fri, 17 Feb 2023 17:14:34 GMT Message-Id: <202302171714.31HHEYAT068973@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: cda6bdbaa15e - main - tcp: Don't try to disconnect a socket multiple times. 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cda6bdbaa15e04857e2c0ae7ac06e9dbabac9835 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=cda6bdbaa15e04857e2c0ae7ac06e9dbabac9835 commit cda6bdbaa15e04857e2c0ae7ac06e9dbabac9835 Author: John Baldwin AuthorDate: 2023-02-17 17:13:53 +0000 Commit: John Baldwin CommitDate: 2023-02-17 17:13:53 +0000 tcp: Don't try to disconnect a socket multiple times. When the checks for INP_TIMEWAIT were removed, tcp_usr_close() and tcp_usr_disconnect() were no longer prevented from calling tcp_disconnect() on a socket that was already disconnected. This triggered a panic in cxgbe(4) for TOE where the tcp_disconnect() on an already-disconnected socket invoked tcp_output() on a socket that was already in time-wait. Reviewed by: rrs, np Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D37112 --- sys/netinet/tcp_usrreq.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 1dbf4659ad00..0c36e4281010 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -654,6 +654,8 @@ tcp_usr_disconnect(struct socket *so) goto out; } tp = intotcpcb(inp); + if (tp->t_state == TCPS_TIME_WAIT) + goto out; tcp_disconnect(tp); out: TCP_PROBE2(debug__user, tp, PRU_DISCONNECT); @@ -1248,14 +1250,16 @@ tcp_usr_close(struct socket *so) ("tcp_usr_close: inp_socket == NULL")); /* - * If we still have full TCP state, and we're not dropped, initiate + * If we are still connected and we're not dropped, initiate * a disconnect. */ if (!(inp->inp_flags & INP_DROPPED)) { tp = intotcpcb(inp); - tp->t_flags |= TF_CLOSED; - tcp_disconnect(tp); - TCP_PROBE2(debug__user, tp, PRU_CLOSE); + if (tp->t_state != TCPS_TIME_WAIT) { + tp->t_flags |= TF_CLOSED; + tcp_disconnect(tp); + TCP_PROBE2(debug__user, tp, PRU_CLOSE); + } } if (!(inp->inp_flags & INP_DROPPED)) { soref(so);