From nobody Mon Mar 18 20:57:10 2024 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 4Tz6c63kmXz5F0Kj; Mon, 18 Mar 2024 20:57:10 +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 4Tz6c638WYz4NXZ; Mon, 18 Mar 2024 20:57:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710795430; 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=PFw1BDx8JtwOtNHmV08jYEHyNd9SixxZhs9gIz2n/+Q=; b=sV1IEePgTz7sMYtZe0fDZPH4dUO5lZyIMI1O9kSAmMv1X5nR1pbtbd2BCk/MT2JyhYq3a1 4KsCdGKrhvLDQ2EBvqrX0sN8gULnoVVXsDepRqalyCxwrkoopSaB+dfRDrLbgMJifOdO+D NZ0J2LtgQGqBAo7TNJMyZ8xva67yDBGWCZ01mVNPikpsRQhElQtwVmdSEO2pm7Xx+O6d7b WTV3SWEXnTIHeClJ3srtPxr12tNnzMLopZ2pNS+eFzeG6yOxWX8hVK5To6m9ueo5VvBnjt XsqxbbYiw9FF0gmw06uVpqpZ3LH3Dh1NM0FuOtkklXxwGNyYqk7EwwEMq1D/eA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710795430; a=rsa-sha256; cv=none; b=Ueyn3VHca90Qbq7AKW+k0Qkq9eCNSjvrGH7Jh1JRPe48B+z8oj5TQ2C8c0S5bzgId9rxBR zmGDdKPTQMFR803r3RUCPyprFDDKu1KHN70PXikx29bCaWjeO5fT++uVkHxJKBKQohSFOT cnnxoupzZNEY23mdd6seQ1YF8gsZaAl7vsf5JqM1GS/U5BkAraiAkbBmRFr6a+amhaqTVr QSPt8IPlOS/wb++k63AGmU+nrVvCz/xHZXBbMqXJ0xskjL+sMn4OEa0mW00djLjd61doXo KpTL+Eh5C92a1IC7WDJO3lELKFU04WBlpKg2hE206FxFHefUwPaPrcKSznvbLQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710795430; 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=PFw1BDx8JtwOtNHmV08jYEHyNd9SixxZhs9gIz2n/+Q=; b=faaTRW8w7CkEhuQdarByrIAOYHcuQ39J/jLvfSppqY15vw/5iWJVe6XAkoNJb3/OlrSVDf P9RBmgZXMef168BOEuQanWxeiJVkuNh/51NJFvVigcCuFs1hN6xGMNJAoZPqkL6MNy2slX Spwip94yjDLIxnCJeldW+n0TAcweC8jqevnJwTGdnZIQrdMLNKR32hT8HZerU+vaLLXscw b2Obi8rLwitJsGoBKctENr0iWK3r5URqHFP3i32d0c55oW+WrrfVuua/je0bx+HGnxHIVs cBgUJn35Byskne8zzpIk7N1TZrRPmKTinw4K1KZqYTaSoIcDwKNX3gMQN8nYJQ== 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 4Tz6c62m5Rzf9R; Mon, 18 Mar 2024 20:57:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 42IKvAiB009679; Mon, 18 Mar 2024 20:57:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42IKvAad009676; Mon, 18 Mar 2024 20:57:10 GMT (envelope-from git) Date: Mon, 18 Mar 2024 20:57:10 GMT Message-Id: <202403182057.42IKvAad009676@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: e34ea0196f44 - main - tcp: clear all TCP timers in tcp_timer_stop() when in callout 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: e34ea0196f4497d3f3939025aff3a89ee77b652e Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=e34ea0196f4497d3f3939025aff3a89ee77b652e commit e34ea0196f4497d3f3939025aff3a89ee77b652e Author: Gleb Smirnoff AuthorDate: 2024-03-18 20:57:00 +0000 Commit: Gleb Smirnoff CommitDate: 2024-03-18 20:57:00 +0000 tcp: clear all TCP timers in tcp_timer_stop() when in callout When a TCP callout decides to disable self, e.g. tcp_timer_2msl() calling tcp_close(), we must also clear all other possible timers. Otherwise, upon return, the callout would be scheduled again in tcp_timer_enter(). Revert 57e27ff07aff, which was a temporary partial revert of otherwise correct 62d47d73b7eb, that exposed the problem being fixed now. Add an extra assertion in tcp_timer_enter() to check we aren't arming callout for a closed connection. Reviewed by: rscheff --- sys/netinet/tcp_subr.c | 3 +-- sys/netinet/tcp_timer.c | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index f618bc1ba04b..a6f84c297688 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -2395,10 +2395,9 @@ tcp_discardcb(struct tcpcb *tp) #endif INP_WLOCK_ASSERT(inp); + MPASS(!callout_active(&tp->t_callout)); MPASS(TAILQ_EMPTY(&tp->snd_holes)); - tcp_timer_stop(tp); - /* free the reassembly queue, if any */ tcp_reass_flush(tp); diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index ed50659abf8e..785f68be5621 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -881,6 +881,7 @@ tcp_timer_enter(void *xtp) if (tp_valid) { tcp_bblog_timer(tp, which, TT_PROCESSED, 0); if ((which = tcp_timer_next(tp, &precision)) != TT_N) { + MPASS(tp->t_state > TCPS_CLOSED); callout_reset_sbt_on(&tp->t_callout, tp->t_timers[which], precision, tcp_timer_enter, tp, inp_to_cpuid(inp), C_ABSOLUTE); @@ -939,8 +940,7 @@ tcp_timer_active(struct tcpcb *tp, tt_which which) /* * Stop all timers associated with tcpcb. * - * Called only on tcpcb destruction. The tcpcb shall already be dropped from - * the pcb lookup database and socket is not losing the last reference. + * Called when tcpcb moves to TCPS_CLOSED. * * XXXGL: unfortunately our callout(9) is not able to fully stop a locked * callout even when only two threads are involved: the callout itself and the @@ -963,6 +963,8 @@ tcp_timer_stop(struct tcpcb *tp) stopped = callout_stop(&tp->t_callout); MPASS(stopped == 0); + for (tt_which i = 0; i < TT_N; i++) + tp->t_timers[i] = SBT_MAX; } else while(__predict_false(callout_stop(&tp->t_callout) == 0)) { INP_WUNLOCK(inp); kern_yield(PRI_UNCHANGED);