From nobody Tue Feb 08 22:21:16 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 21D0419A2168; Tue, 8 Feb 2022 22:21:17 +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 4Jtct50TfNz4sRh; Tue, 8 Feb 2022 22:21:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644358877; 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=9UHEh59c1FdSFY8YYyQgM7mYmc1c/t5MOpH+cQrJh+M=; b=U7gl1as6Py5tdCjP93DYknuyIuFCYCC/S9vLk2exCEhHOJL7qm//ArutDCVkDl/V/0EH6F 0pKMIWu498+l6f1uvgeCapiRNWRMFLRsyM0XNrT1oyNuq1LNFEfWTJgFppq4LbxQ7Y52Ns 1r5lQkcGtwVbfifU/ynKY5rpxL3R7YCSd0/l6DmuFm6m/ATtYIWcM+9NHdMtkvMZlCawn6 tZAuCciL5DYVAaTW/XuDBQ8QZWYcfO6HmZJQbEPb74een3hszVquEPr8aEo9AcdoyPoZp/ shJQaiaDNAfoOVSI30KlvEMnZw3P8oOVfOe8wfHrrS1YdwtatvfQmWkEX54HQA== 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 E4E64216CC; Tue, 8 Feb 2022 22:21:16 +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 218MLG4L095703; Tue, 8 Feb 2022 22:21:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 218MLGkV095702; Tue, 8 Feb 2022 22:21:16 GMT (envelope-from git) Date: Tue, 8 Feb 2022 22:21:16 GMT Message-Id: <202202082221.218MLGkV095702@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: fd7daa727126 - main - tcp: make tcp_ctloutput_set() non-static 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: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fd7daa727126b4b8da9e38ca35ea237ef1190a00 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644358877; 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=9UHEh59c1FdSFY8YYyQgM7mYmc1c/t5MOpH+cQrJh+M=; b=L867umekLfVfctcgYdhVVKZHcahl9YhwAdhVOQzg7WOMmkAMZUkYe+ulD0h4BpqQUXqTfi hyAykD8mGvpyib1Zzky9KN7hEGDiE684kLydmnuJ1LQIBhJdozhVpOd1j+CINIH5IJATza GS89R/rb9JsKsrtAdBAjkK4jy7kxUzA4Mj0HH2G2+T5wox4dU3wNK47RmeA7ebWPnKSFXv 8Sp7ONEgtzvFdgx5WZ6HEK3wn5EFaMpw6I9bpv71zb4PKebvbjeEGThIZrHuetswx4P7SY 3Ngay66Q5oCVf3mllYLLsWlZQDD3Rw26o2vlX86AnWFtZVSfK3QZPDfQcpAYzQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644358877; a=rsa-sha256; cv=none; b=J+C0l6ITE888aJOtpGRu390qudpIRlKfcd/E75XfyVraY44kdOVYC0K6oxq4EnATIAxs5R BEvlGqdb7U/rFDbTY9jitZiLR6GKINZIqBcF4Qat1Q48MXvNtwFgDxMHSuKntZwgIZU3Ga llTMM7zD0LKjsJq3tpGUhhsLTXy+NNCTGoQRnoK6Us193eclmaCoO0M8cNdWmI2MWUv04Z en3glTmtojAzOd2tJjKMs8lBncim1CWFAarhJ7rkWDgDxNmXBbCnu4ZTJTD4aJbheEbBdv MN82TO30Y2uEMTOa1eqz9R/pUejvA0iyKtDLyTvGzymuY7Bmrbe0uQxuk8TDMw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=fd7daa727126b4b8da9e38ca35ea237ef1190a00 commit fd7daa727126b4b8da9e38ca35ea237ef1190a00 Author: Michael Tuexen AuthorDate: 2022-02-08 17:49:44 +0000 Commit: Michael Tuexen CommitDate: 2022-02-08 17:49:44 +0000 tcp: make tcp_ctloutput_set() non-static tcp_ctloutput_set() will be used via the sysctl interface in a upcoming command line tool tcpsso. Reviewed by: glebius, rscheff Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D34164 --- sys/netinet/tcp_usrreq.c | 48 ++++++++++++++++++++++++++++-------------------- sys/netinet/tcp_var.h | 1 + 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 13e48eef459b..564225f39c88 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1713,26 +1713,30 @@ tcp_fill_info(struct tcpcb *tp, struct tcp_info *ti) } while(0) #define INP_WLOCK_RECHECK(inp) INP_WLOCK_RECHECK_CLEANUP((inp), /* noop */) -static int +int tcp_ctloutput_set(struct inpcb *inp, struct sockopt *sopt) { - struct tcpcb *tp = intotcpcb(inp); + struct socket *so = inp->inp_socket; + struct tcpcb *tp = intotcpcb(inp); int error = 0; MPASS(sopt->sopt_dir == SOPT_SET); INP_WLOCK_ASSERT(inp); + KASSERT((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) == 0, + ("inp_flags == %x", inp->inp_flags)); + KASSERT(so != NULL, ("inp_socket == NULL")); if (sopt->sopt_level != IPPROTO_TCP) { INP_WUNLOCK(inp); #ifdef INET6 if (inp->inp_vflag & INP_IPV6PROTO) - error = ip6_ctloutput(inp->inp_socket, sopt); + error = ip6_ctloutput(so, sopt); #endif #if defined(INET6) && defined(INET) else #endif #ifdef INET - error = ip_ctloutput(inp->inp_socket, sopt); + error = ip_ctloutput(so, sopt); #endif /* * When an IP-level socket option affects TCP, pass control @@ -1862,8 +1866,8 @@ tcp_ctloutput_set(struct inpcb *inp, struct sockopt *sopt) if((*tp->t_fb->tfb_tcp_fb_init)(tp) != 0) { /* Fall back failed, drop the connection */ INP_WUNLOCK(inp); - soabort(inp->inp_socket); - return(error); + soabort(so); + return (error); } } goto err_out; @@ -1882,8 +1886,6 @@ err_out: return (error); } - tp = intotcpcb(inp); - /* Pass in the INP locked, callee must unlock it. */ return (tp->t_fb->tfb_tcp_ctloutput(inp, sopt)); } @@ -1891,27 +1893,30 @@ err_out: static int tcp_ctloutput_get(struct inpcb *inp, struct sockopt *sopt) { - int error = 0; - struct tcpcb *tp; + struct socket *so = inp->inp_socket; + struct tcpcb *tp = intotcpcb(inp); + int error = 0; MPASS(sopt->sopt_dir == SOPT_GET); INP_WLOCK_ASSERT(inp); + KASSERT((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) == 0, + ("inp_flags == %x", inp->inp_flags)); + KASSERT(so != NULL, ("inp_socket == NULL")); if (sopt->sopt_level != IPPROTO_TCP) { INP_WUNLOCK(inp); #ifdef INET6 if (inp->inp_vflag & INP_IPV6PROTO) - error = ip6_ctloutput(inp->inp_socket, sopt); + error = ip6_ctloutput(so, sopt); #endif /* INET6 */ #if defined(INET6) && defined(INET) else #endif #ifdef INET - error = ip_ctloutput(inp->inp_socket, sopt); + error = ip_ctloutput(so, sopt); #endif return (error); } - tp = intotcpcb(inp); if (((sopt->sopt_name == TCP_FUNCTION_BLK) || (sopt->sopt_name == TCP_FUNCTION_ALIAS))) { struct tcp_function_set fsn; @@ -2114,7 +2119,8 @@ no_mem_needed: int tcp_default_ctloutput(struct inpcb *inp, struct sockopt *sopt) { - struct tcpcb *tp; + struct socket *so = inp->inp_socket; + struct tcpcb *tp = intotcpcb(inp); int error, opt, optval; u_int ui; struct tcp_info ti; @@ -2128,8 +2134,10 @@ tcp_default_ctloutput(struct inpcb *inp, struct sockopt *sopt) size_t len; INP_WLOCK_ASSERT(inp); + KASSERT((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) == 0, + ("inp_flags == %x", inp->inp_flags)); + KASSERT(so != NULL, ("inp_socket == NULL")); - tp = intotcpcb(inp); switch (sopt->sopt_level) { #ifdef INET6 case IPPROTO_IPV6: @@ -2347,7 +2355,7 @@ unlock_and_done: error = copyin_tls_enable(sopt, &tls); if (error) break; - error = ktls_enable_tx(inp->inp_socket, &tls); + error = ktls_enable_tx(so, &tls); break; case TCP_TXTLS_MODE: INP_WUNLOCK(inp); @@ -2356,7 +2364,7 @@ unlock_and_done: return (error); INP_WLOCK_RECHECK(inp); - error = ktls_set_tx_mode(inp->inp_socket, ui); + error = ktls_set_tx_mode(so, ui); INP_WUNLOCK(inp); break; case TCP_RXTLS_ENABLE: @@ -2365,7 +2373,7 @@ unlock_and_done: sizeof(tls)); if (error) break; - error = ktls_enable_rx(inp->inp_socket, &tls); + error = ktls_enable_rx(so, &tls); break; #endif @@ -2710,14 +2718,14 @@ unhold: #endif #ifdef KERN_TLS case TCP_TXTLS_MODE: - error = ktls_get_tx_mode(inp->inp_socket, &optval); + error = ktls_get_tx_mode(so, &optval); INP_WUNLOCK(inp); if (error == 0) error = sooptcopyout(sopt, &optval, sizeof(optval)); break; case TCP_RXTLS_MODE: - error = ktls_get_rx_mode(inp->inp_socket, &optval); + error = ktls_get_rx_mode(so, &optval); INP_WUNLOCK(inp); if (error == 0) error = sooptcopyout(sopt, &optval, diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 4f2db050799e..7fff6984f672 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1128,6 +1128,7 @@ void tcp_switch_back_to_default(struct tcpcb *tp); struct tcp_function_block * find_and_ref_tcp_fb(struct tcp_function_block *fs); int tcp_default_ctloutput(struct inpcb *inp, struct sockopt *sopt); +int tcp_ctloutput_set(struct inpcb *inp, struct sockopt *sopt); extern counter_u64_t tcp_inp_lro_direct_queue; extern counter_u64_t tcp_inp_lro_wokeup_queue;