From nobody Tue Feb 07 17:22:42 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 4PB91Z45Sfz3nT3x; Tue, 7 Feb 2023 17:22:42 +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 4PB91Z3XHtz4C8v; Tue, 7 Feb 2023 17:22:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675790562; 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=tdkk3TE/LVzPMr4Lw/pWiGFqMRWf4pHEcW6E5urzOLI=; b=GizeRXq2r7g6yxLZpKxlsya4ysqzhPaP30g9m6fWkgLUzg00IuIeCJvcNV7vNcp0W7sfzS yy4W9G8bLqTMSwr/VtxzIlZg9O0Pni3imiJs2PRAGcw+JJDeUMfXZ40pC3InVIIbKbA6tB wjxebk0Aq3otKalg6+pYLwGaMa2G2fT3sal5uFm9E8Ht/rX937UqlzIyYy2uNPPGY+tnjl hUYo4ABl2EGAM2ZOQp46EoFzHMagDgD8+QS+0EnycoDlleDAix0AjqfmCudgD9CACERT5k gQXNJzfe8KV9hOiFuMpVQyKYEnkaOM7zyT04w5ycKOfbsH0JNMCCms7O+0ZejQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675790562; 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=tdkk3TE/LVzPMr4Lw/pWiGFqMRWf4pHEcW6E5urzOLI=; b=NQ5AlOluhe3IA0+1eKmJLbdYvRCgndcDLYfPR8tmnxr3wXuAWRP/aqB+OJIz8XRqWFLSjS GM4WH51Ir0hG4R/iU57nipZEP96a4V1tTPN9TTTEYdQFl3jAqsqTEusF3N7ZXUxdatmqdm 85lHxKC/UeD47A5Fj32BrITRvXzj4RzekJ1ilzyQzYya+ssS9XC8GNYzf06hb4Z5CtFTJ5 IfMUzQuG/BNB3Cs6+0+AG5FxlN5ikKjINocVjykww10oc7OBGwvV5vpqW0MCiPkhS0OxSq Ca/uw4376wp77PbPYJ0IGvSzxA8iybztODSRtNApazpsbAJjEsrKwCBz8jppFQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675790562; a=rsa-sha256; cv=none; b=V1csUcpQ/Sy7uiRSHyz5pgp2W10WtviQEOkmBJWe0cG5xnaaIV45cdBzmfWq2DPcO9hxTw itr0tkuB4jzq8mcKMjA3o+eXF65AvZXlX4vQNAd+cOjE3qhG69jnUzS23WUO9mWv3e4P6N S0HbKDkgdr6WdpGXYsKC21IFwthcqoPYjH1MvIshgf8NSbPN26a8iokG2ZWjRjkzjj1WU5 zHnm590DwlM6cLv+Zm1u99zmE1M1keIA8SfX8NS2XNkozHK3mkXNrMaZrps+P5dYfetuoE FiJZWjyTbTuRtWah/S71qslEdDKGeybtrKGXAh/FKVkZjOoyI9EtHFRyNV2UrA== 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 4PB91Z2YnzzQ55; Tue, 7 Feb 2023 17:22:42 +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 317HMgQJ089883; Tue, 7 Feb 2023 17:22:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 317HMgI2089882; Tue, 7 Feb 2023 17:22:42 GMT (envelope-from git) Date: Tue, 7 Feb 2023 17:22:42 GMT Message-Id: <202302071722.317HMgI2089882@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: dfc4d218ce5d - main - tcp: use straight in_pcbconnect() in tcp_connect() 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: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dfc4d218ce5d9e1d1d2be09c6cfc3d1c89ad27ff Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=dfc4d218ce5d9e1d1d2be09c6cfc3d1c89ad27ff commit dfc4d218ce5d9e1d1d2be09c6cfc3d1c89ad27ff Author: Gleb Smirnoff AuthorDate: 2023-02-07 17:21:52 +0000 Commit: Gleb Smirnoff CommitDate: 2023-02-07 17:21:52 +0000 tcp: use straight in_pcbconnect() in tcp_connect() This brings tcp_connect() par with tcp6_connect(). The code removed now is a remnant of "truncating old TIME-WAIT" removed back in 2004 in c94c54e4df9a. Reviewed by: markj, tuexen Differential Revision: https://reviews.freebsd.org/D38405 --- sys/netinet/tcp_usrreq.c | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 2ae1c4b89c8e..c204fc356ed7 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1387,48 +1387,25 @@ struct protosw tcp6_protosw = { #ifdef INET /* * Common subroutine to open a TCP connection to remote host specified - * by struct sockaddr_in. Call in_pcbconnect_setup() to choose local - * host address and assign a local port number if needed. Initialize - * connection parameters and enter SYN-SENT state. + * by struct sockaddr_in. Call in_pcbconnect() to choose local host address + * and assign a local port number and install the inpcb into the hash. + * Initialize connection parameters and enter SYN-SENT state. */ static int tcp_connect(struct tcpcb *tp, struct sockaddr_in *sin, struct thread *td) { struct inpcb *inp = tptoinpcb(tp); struct socket *so = tptosocket(tp); - struct in_addr laddr; - u_short lport; int error; NET_EPOCH_ASSERT(); INP_WLOCK_ASSERT(inp); INP_HASH_WLOCK(&V_tcbinfo); - /* - * Cannot simply call in_pcbconnect, because there might be an - * earlier incarnation of this same connection still in - * TIME_WAIT state, creating an ADDRINUSE error. - */ - laddr = inp->inp_laddr; - lport = inp->inp_lport; - error = in_pcbconnect_setup(inp, sin, &laddr.s_addr, &lport, - &inp->inp_faddr.s_addr, &inp->inp_fport, td->td_ucred); - if (error) { - INP_HASH_WUNLOCK(&V_tcbinfo); - return (error); - } - /* Handle initial bind if it hadn't been done in advance. */ - if (inp->inp_lport == 0) { - inp->inp_lport = lport; - if (in_pcbinshash(inp) != 0) { - inp->inp_lport = 0; - INP_HASH_WUNLOCK(&V_tcbinfo); - return (EAGAIN); - } - } - inp->inp_laddr = laddr; - in_pcbrehash(inp); + error = in_pcbconnect(inp, sin, td->td_ucred, true); INP_HASH_WUNLOCK(&V_tcbinfo); + if (error != 0) + return (error); /* * Compute window scaling to request: