From nobody Mon Oct 31 15:58:00 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 4N1HqY2HkVz4gYDW; Mon, 31 Oct 2022 15:58:01 +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 4N1HqY1GDxz3XMj; Mon, 31 Oct 2022 15:58:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667231881; 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=4PXBfwBzGUihnpz/0nLUgkvzS6u9tfMluNrJ8/7PwD8=; b=dsTKFyAXrrjm0qhmSDILy7JV65BuDmjnmyu+CjZ0zYOzeYpQ4vl4XdAUFPLvg9eaQCbdT2 ctHTS0CqZe/lqCvpTVl/2STIGbBcGea3sBLEdWLdQD/uJpJLVJsUPBm8xQBV25N0+nRkPG +qY54mv7twXfC9SGVuaIExBw3RfjvYJJqPmvWtYN1UcSMrY3fcJ6XDCYllVf/oY+qPoPsS TKw9bd+ooR4+wWLIqLx7gM2a3y/f8rBwd3kE9EGcZiRgafQZMVbDcvvShWvngZmnNp3nmA MQOHnbjbalhW3YjTd5rrnGuspNVW0tNTK9evqc7dMmecuIVHwOhjdw/hxk7Axw== 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 4N1HqX6zk3zj4s; Mon, 31 Oct 2022 15:58:00 +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 29VFw0SG089978; Mon, 31 Oct 2022 15:58:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29VFw0Bk089977; Mon, 31 Oct 2022 15:58:00 GMT (envelope-from git) Date: Mon, 31 Oct 2022 15:58:00 GMT Message-Id: <202210311558.29VFw0Bk089977@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: c348e8805365 - main - tcp: make tcp_handle_wakeup() static and robust 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: c348e8805365dab2a042ab951045b879a290602b Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667231881; 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=4PXBfwBzGUihnpz/0nLUgkvzS6u9tfMluNrJ8/7PwD8=; b=xI7ok2jip31/SdfO2eLvkA8KxBT1rCdrFTIW+Rlqkr93NZmmJASO72xJIugVnI/Hrbhk/K lcJBB/yxMtpXFofqawBjIB22EmrMJ7GFKaZ018I75/9IamHjR26PoWQpmrW34L0zsJ5VFc FdCFzsuHP5Obs1t9ttuFKRlbXbBEtEiJAMpg6Xr08pEI4dUwf35aZFcvKhtSSqurj4JhLo fCiMAAI8OiAmrIRKFuHZkxsJjorx/pbAkeImFN+JxG3OXPJd03WalLyBpzGXXRzswA4mwD pYEbnVi/qx/BbiD37LGzNotJjU+Tw2hQ/N5e6jxAGG/V4+qC3MeTYiOHnGJD7g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667231881; a=rsa-sha256; cv=none; b=saIjgtgz52HlKDzyjE1XC9lm3xP0ejcb7ahUk2p7bYUGN4hS1C8nayfoHoiRpsXTEXFl79 V5yJeb71ydVVS+CHgThbdxh2GgC+gPRg7/Eb++6jH972WAFHZvXSL4fTSAUnNoJ+XDiJqJ o+tIztfWsmUDCzepRrJ5yQIowgIOzj6Y0CXNKVRkDs36VHl1BPuQ9qCx2q6cjfdc0u2B1w jri62QegcQ2Znn8d8qjGEq8DenAAqQIyVpUUAbLLeuWPNH5ToK9LC1boIqngK83QIjr+fJ 9iPqVjk6Q9KP6pJZZzQPXbX98km+IC0DvHZE3EXE1Fi5AcN9BruJTLQT8Y/DSg== 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=c348e8805365dab2a042ab951045b879a290602b commit c348e8805365dab2a042ab951045b879a290602b Author: Gleb Smirnoff AuthorDate: 2022-10-31 15:57:15 +0000 Commit: Gleb Smirnoff CommitDate: 2022-10-31 15:57:15 +0000 tcp: make tcp_handle_wakeup() static and robust It is called only from tcp_input() and always has valid parameter. Reviewed by: rscheff, tuexen Differential revision: https://reviews.freebsd.org/D37115 --- sys/netinet/tcp_input.c | 25 +++++++++---------------- sys/netinet/tcp_var.h | 1 - 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 1ea3d72d9a9d..84574aaa00ae 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1520,22 +1520,15 @@ tcp_input(struct mbuf **mp, int *offp, int proto) return(tcp_input_with_port(mp, offp, proto, 0)); } -void -tcp_handle_wakeup(struct tcpcb *tp, struct socket *so) +static void +tcp_handle_wakeup(struct tcpcb *tp) { - /* - * Since tp might be gone if the session entered - * the TIME_WAIT state before coming here, we need - * to check if the socket is still connected. - */ - if (tp == NULL) { - return; - } - if (so == NULL) { - return; - } - INP_LOCK_ASSERT(tp->t_inpcb); + + INP_WLOCK_ASSERT(tp->t_inpcb); + if (tp->t_flags & TF_WAKESOR) { + struct socket *so = tp->t_inpcb->inp_socket; + tp->t_flags &= ~TF_WAKESOR; SOCKBUF_LOCK_ASSERT(&so->so_rcv); sorwakeup_locked(so); @@ -2521,7 +2514,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so, if (tlen == 0 && (thflags & TH_FIN) == 0) { (void) tcp_reass(tp, (struct tcphdr *)0, NULL, 0, (struct mbuf *)0); - tcp_handle_wakeup(tp, so); + tcp_handle_wakeup(tp); } tp->snd_wl1 = th->th_seq - 1; /* FALLTHROUGH */ @@ -3258,7 +3251,7 @@ dodata: /* XXX */ save_start + tlen); } } - tcp_handle_wakeup(tp, so); + tcp_handle_wakeup(tp); #if 0 /* * Note the amount of data that peer has sent into diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 1514e016ee13..d115a18d66d5 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1099,7 +1099,6 @@ int tcp_input(struct mbuf **, int *, int); int tcp_autorcvbuf(struct mbuf *, struct tcphdr *, struct socket *, struct tcpcb *, int); int tcp_input_with_port(struct mbuf **, int *, int, uint16_t); -void tcp_handle_wakeup(struct tcpcb *, struct socket *); void tcp_do_segment(struct mbuf *, struct tcphdr *, struct socket *, struct tcpcb *, int, int, uint8_t);