From nobody Tue Oct 04 05:22:56 2022 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 4MhR1F0Kg2z4dvcD; Tue, 4 Oct 2022 05:22:57 +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 4MhR1D6ZTgz40dj; Tue, 4 Oct 2022 05:22:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664860976; 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=5jG12W0b7hGpwMjEUkFyStdFPFXyBKFas146HZ3uJuw=; b=gbkjQ2Tc65CqXWQUaUEIAhPWtIjJpdPTxIATkZ7a7ZHHQMyj3vUkucsXoPZ/k7psMXvnfy 7wKI2GpVnp+C7yND5lZ8K8R7Sz4FeJUvNk51layEIZTiSaExCOkrajd3Pihu60gEyHfYiw pbN/ylNWCs8JPZnD0C3U8d43ZXJPSDrWHPvczc4lz0q4OjZaqM4GiZIuG8T2qZCClnQp7o uTQ+ce1TKj9LHmyznM+Zu/ChicN1zbbQ3zvWoymU2eqzt2P2SH7P+e0VDIEoiu1kZE4bph z1+8wgoAIRp8is0cin8zFk+nbiPXUgzdx60XsOWoThzBtXNur+m7jes6Rd/bmA== 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 4MhR1D5SgQzS7F; Tue, 4 Oct 2022 05:22:56 +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 2945Mugx027302; Tue, 4 Oct 2022 05:22:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2945MuBK027301; Tue, 4 Oct 2022 05:22:56 GMT (envelope-from git) Date: Tue, 4 Oct 2022 05:22:56 GMT Message-Id: <202210040522.2945MuBK027301@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: 77198a945ae5 - main - tcp_timers: provide tcp_timer_drop() and tcp_timer_close() 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: 77198a945ae5dc04ac46f379cb624208a1453c65 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664860976; 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=5jG12W0b7hGpwMjEUkFyStdFPFXyBKFas146HZ3uJuw=; b=aYCS25tskWSrW0l1CcGUm2dfKzq6frQS513u5GAgdZyUc156OUpNGuOIEF0smEcHqWFTJe vn5D0Q1lkzrBdX0z2tq+wtA6WwlruXa4PUa7Gc+64A7KL2ItjbZszP2TduvXw5P7e26dFu m4+pEfIkwrZP+fIfeUtPfzMHwmvvCweEwZaMFPpaW3HK7FWoUZHqkX24mZR4KtLSjd9paG /MqUGeVHP9Ew0ADrUk2HhdXkZVK0R9tAFQf1ER5+PgO6a9VzNVmx261LGr55QfDqJShLTN d8LOvT0P+Pja8zy3Z45aVj1B1XwqmNUQ+1Cq758YjAhZ08u5529YAUAba7USuw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664860976; a=rsa-sha256; cv=none; b=VIKT7we6u8je8CpwKZ6bCC+1s8QYNQNqLbIhjpxeKmpvAhjykQckk6isd7ZarBYobbMacI h8tSSAvzs7pijtjLZC5UzQ8VgH/wWiYKAbQsbIIqXhlCq3ZQTWF1rQX7MV54plssB87GtU LLKjdA9Jr0EpQ2Gn9CYFMRgGoaq1soUfxwFVm88YTqS13fxgalsurU1djKE8pR4mmXDebk HWU/stS+Hw0txJYEcF70ThDSND0Mx1UXuoMfyfsuMkxpaWxwyesYPjaWMWsB0kTwnhzA0F qJ7IvfbEgYRmxkp8JvLqLXUM7bDLoFX2JQcvp4E7fBcU66neoiqzkvH/Inz7pA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=77198a945ae5dc04ac46f379cb624208a1453c65 commit 77198a945ae5dc04ac46f379cb624208a1453c65 Author: Gleb Smirnoff AuthorDate: 2022-10-04 05:21:55 +0000 Commit: Gleb Smirnoff CommitDate: 2022-10-04 05:21:55 +0000 tcp_timers: provide tcp_timer_drop() and tcp_timer_close() Two functions to call tcp_drop() and tcp_close() from a callout context. Garbage collect tcp_inpinfo_lock_del(), it has a single use now. Differential revision: https://reviews.freebsd.org/D36397 --- sys/netinet/tcp_timer.c | 87 +++++++++++++++++++++++++++++-------------------- sys/netinet/tcp_timer.h | 2 -- 2 files changed, 51 insertions(+), 38 deletions(-) diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index 11b64ac726a1..a3837a7db90c 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -311,10 +311,39 @@ tcp_timer_delack(void *xtp) CURVNET_RESTORE(); } -void -tcp_inpinfo_lock_del(struct inpcb *inp, struct tcpcb *tp) +/* + * Call tcp_close() from a callout context. + */ +static void +tcp_timer_close(struct tcpcb *tp) { - if (inp && tp != NULL) + struct epoch_tracker et; + struct inpcb *inp = tp->t_inpcb; + + INP_WLOCK_ASSERT(inp); + + NET_EPOCH_ENTER(et); + tp = tcp_close(tp); + NET_EPOCH_EXIT(et); + if (tp != NULL) + INP_WUNLOCK(inp); +} + +/* + * Call tcp_drop() from a callout context. + */ +static void +tcp_timer_drop(struct tcpcb *tp) +{ + struct epoch_tracker et; + struct inpcb *inp = tp->t_inpcb; + + INP_WLOCK_ASSERT(inp); + + NET_EPOCH_ENTER(et); + tp = tcp_drop(tp, ETIMEDOUT); + NET_EPOCH_EXIT(et); + if (tp != NULL) INP_WUNLOCK(inp); } @@ -323,7 +352,6 @@ tcp_timer_2msl(void *xtp) { struct tcpcb *tp = xtp; struct inpcb *inp; - struct epoch_tracker et; CURVNET_SET(tp->t_vnet); #ifdef TCPDEBUG int ostate; @@ -363,34 +391,28 @@ tcp_timer_2msl(void *xtp) tp->t_inpcb && tp->t_inpcb->inp_socket && (tp->t_inpcb->inp_socket->so_rcv.sb_state & SBS_CANTRCVMORE)) { TCPSTAT_INC(tcps_finwait2_drops); - NET_EPOCH_ENTER(et); - tp = tcp_close(tp); - NET_EPOCH_EXIT(et); - tcp_inpinfo_lock_del(inp, tp); - goto out; + tcp_timer_close(tp); + CURVNET_RESTORE(); + return; } else { if (ticks - tp->t_rcvtime <= TP_MAXIDLE(tp)) { callout_reset(&tp->t_timers->tt_2msl, TP_KEEPINTVL(tp), tcp_timer_2msl, tp); } else { - NET_EPOCH_ENTER(et); - tp = tcp_close(tp); - NET_EPOCH_EXIT(et); - tcp_inpinfo_lock_del(inp, tp); - goto out; + tcp_timer_close(tp); + CURVNET_RESTORE(); + return; } } #ifdef TCPDEBUG - if (tp != NULL && (tp->t_inpcb->inp_socket->so_options & SO_DEBUG)) + if (tp->t_inpcb->inp_socket->so_options & SO_DEBUG) tcp_trace(TA_USER, ostate, tp, (void *)0, (struct tcphdr *)0, PRU_SLOWTIMO); #endif TCP_PROBE2(debug__user, tp, PRU_SLOWTIMO); - if (tp != NULL) - INP_WUNLOCK(inp); -out: + INP_WUNLOCK(inp); CURVNET_RESTORE(); } @@ -507,7 +529,8 @@ dropit: #endif TCP_PROBE2(debug__user, tp, PRU_SLOWTIMO); NET_EPOCH_EXIT(et); - tcp_inpinfo_lock_del(inp, tp); + if (tp != NULL) + INP_WUNLOCK(inp); CURVNET_RESTORE(); } @@ -587,12 +610,10 @@ tcp_timer_persist(void *xtp) ticks - tp->t_rcvtime >= TCP_REXMTVAL(tp) * tcp_totbackoff))) { if (!progdrop) TCPSTAT_INC(tcps_persistdrop); - NET_EPOCH_ENTER(et); tcp_log_end_status(tp, TCP_EI_STATUS_PERSIST_MAX); - tp = tcp_drop(tp, ETIMEDOUT); - NET_EPOCH_EXIT(et); - tcp_inpinfo_lock_del(inp, tp); - goto out; + tcp_timer_drop(tp); + CURVNET_RESTORE(); + return; } /* * If the user has closed the socket then drop a persisting @@ -601,12 +622,10 @@ tcp_timer_persist(void *xtp) if (tp->t_state > TCPS_CLOSE_WAIT && (ticks - tp->t_rcvtime) >= TCPTV_PERSMAX) { TCPSTAT_INC(tcps_persistdrop); - NET_EPOCH_ENTER(et); tcp_log_end_status(tp, TCP_EI_STATUS_PERSIST_MAX); - tp = tcp_drop(tp, ETIMEDOUT); - NET_EPOCH_EXIT(et); - tcp_inpinfo_lock_del(inp, tp); - goto out; + tcp_timer_drop(tp); + CURVNET_RESTORE(); + return; } tcp_setpersist(tp); tp->t_flags |= TF_FORCEDATA; @@ -621,7 +640,6 @@ tcp_timer_persist(void *xtp) TCP_PROBE2(debug__user, tp, PRU_SLOWTIMO); (void) tcp_unlock_or_drop(tp, outrv); NET_EPOCH_EXIT(et); -out: CURVNET_RESTORE(); } @@ -675,12 +693,10 @@ tcp_timer_rexmt(void * xtp) if (tp->t_rxtshift > TCP_MAXRXTSHIFT) TCPSTAT_INC(tcps_timeoutdrop); tp->t_rxtshift = TCP_MAXRXTSHIFT; - NET_EPOCH_ENTER(et); tcp_log_end_status(tp, TCP_EI_STATUS_RETRAN); - tp = tcp_drop(tp, ETIMEDOUT); - NET_EPOCH_EXIT(et); - tcp_inpinfo_lock_del(inp, tp); - goto out; + tcp_timer_drop(tp); + CURVNET_RESTORE(); + return; } if (tp->t_state == TCPS_SYN_SENT) { /* @@ -906,7 +922,6 @@ tcp_timer_rexmt(void * xtp) TCP_PROBE2(debug__user, tp, PRU_SLOWTIMO); (void) tcp_unlock_or_drop(tp, outrv); NET_EPOCH_EXIT(et); -out: CURVNET_RESTORE(); } diff --git a/sys/netinet/tcp_timer.h b/sys/netinet/tcp_timer.h index 71b37e46f23b..bb47ab72a63d 100644 --- a/sys/netinet/tcp_timer.h +++ b/sys/netinet/tcp_timer.h @@ -227,8 +227,6 @@ VNET_DECLARE(int, tcp_v6pmtud_blackhole_mss); VNET_DECLARE(int, tcp_msl); #define V_tcp_msl VNET(tcp_msl) -void tcp_inpinfo_lock_del(struct inpcb *inp, struct tcpcb *tp); - void tcp_timer_init(void); void tcp_timer_2msl(void *xtp); struct tcptw *