From nobody Wed Apr 12 16:07:25 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 4PxSK94QQ5z451Q3; Wed, 12 Apr 2023 16:07:25 +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 4PxSK940xYz3J0d; Wed, 12 Apr 2023 16:07:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681315645; 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=lxC6GtDNbtxswqoGpDJn/Wo6G/0Dx2sSrOoaVwNmATo=; b=HrYKp4h3ZKYqdejGIrWA3DgBjZv5Bx22SXNXQJ8HyrL4UZNHzNyubEVP+MRUxug9iHFCHp bRLZl1fvZ14GKNYuvptVRskUPBGCSkUy5pXZt6tkBj+Y/wkOBcJv6dfvATEbc8PF+JV5xw l2U5Iqe+hdeEO4dG6GfmyeWjN9zTh+baA3C4xAJCWHZQ8pseV9daXyOQcA3udSvicE8YVE Wu6Ke3vTWgEcPGZ3P8nQx5fVHJ4llUKGdAAYxZ1fRQ/Hbqhp6KsZHXRheg/y0mk5dwM42k uzPKERacUJ9PSQa5o5eRFw8Oeakq/I5KYpBrWzi7f6bgClFgwnRZezRXz6t8NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681315645; 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=lxC6GtDNbtxswqoGpDJn/Wo6G/0Dx2sSrOoaVwNmATo=; b=xskNvYDEMRYCLaGX8Tz/A1Z5QMqkS7zW4gTfBlsz6BIqL+MrB3FvYAfxpgjzDaOLBatyZH N9C0oI5jONL3Hm/6lhJyb4XY0FQZn9WkT6VpcxwePNm6dJeybWDAxzx8HXsTkvnSj6CXJf ah3GeD/PpSEotFVIEXSaXisfDp0//0fc/g5Ac1mEA2VWw9l39ndnMMQ394yxPqBuqpVmiI GZg8wSoMsQRy4pmxHOPp5S1U4O4uOugrPhno/Qpop3p6m1rHBeGADFtToCrL6FBH3//c/G cp1v7yt0Mtf8Hczh9nlvkCX637zyRZEBJLr+BwlqfpUZhKmYg41BJNE25/yF7w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681315645; a=rsa-sha256; cv=none; b=QtxP945+N4XnOMYBXcpYu0z/PY70NFugbRJH1NernI7tTbmcgt6zAhSgIWTR4VLYrdHHpa uB7WiowKBsuCiwUlSNtPocAXhv8b5Yxkmt18dPmzk0hs62tDrUoYh8z+F1yvOeu3BQwD2O c0w8bft0HCn58KxgQiX11K4B5kpL/inBO0UQN40CKd8P2m0JZTNh4yV1o15nvAMnSkERC0 GHl7+x0icw2w9pll63VjKouplAU4iERQMiedJCYm6NMB1P7M7rCtZ4cwro4TJY2t29xUF7 xuor2eJ6u83KOcANE4sHp6JS6YuTBTpvzhx5uRrLxYOzYXM4yYe4dLXzOFKYLw== 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 4PxSK936dlz15ld; Wed, 12 Apr 2023 16:07:25 +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 33CG7Pn6051334; Wed, 12 Apr 2023 16:07:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33CG7PwK051333; Wed, 12 Apr 2023 16:07:25 GMT (envelope-from git) Date: Wed, 12 Apr 2023 16:07:25 GMT Message-Id: <202304121607.33CG7PwK051333@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: c687f21add77 - main - tcp: make net.inet.tcp.functions_default vnet specific Reviewed by: cc, rrs MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D39516 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: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c687f21add77f48cca6a961670ee6ef6697aea47 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=c687f21add77f48cca6a961670ee6ef6697aea47 commit c687f21add77f48cca6a961670ee6ef6697aea47 Author: Michael Tuexen AuthorDate: 2023-04-12 16:04:27 +0000 Commit: Michael Tuexen CommitDate: 2023-04-12 16:04:27 +0000 tcp: make net.inet.tcp.functions_default vnet specific Reviewed by: cc, rrs MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D39516 --- sys/netinet/tcp_subr.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index be78396260c7..6cf1f69cee69 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -393,7 +393,8 @@ static struct tcp_function_block tcp_def_funcblk = { static int tcp_fb_cnt = 0; struct tcp_funchead t_functions; -static struct tcp_function_block *tcp_func_set_ptr = &tcp_def_funcblk; +VNET_DEFINE_STATIC(struct tcp_function_block *, tcp_func_set_ptr) = &tcp_def_funcblk; +#define V_tcp_func_set_ptr VNET(tcp_func_set_ptr) void tcp_record_dsack(struct tcpcb *tp, tcp_seq start, tcp_seq end, int tlp) @@ -515,7 +516,7 @@ find_and_ref_tcp_default_fb(void) struct tcp_function_block *rblk; rw_rlock(&tcp_function_lock); - rblk = tcp_func_set_ptr; + rblk = V_tcp_func_set_ptr; refcount_acquire(&rblk->tfb_refcnt); rw_runlock(&tcp_function_lock); return (rblk); @@ -682,7 +683,7 @@ sysctl_net_inet_default_tcp_functions(SYSCTL_HANDLER_ARGS) memset(&fs, 0, sizeof(fs)); rw_rlock(&tcp_function_lock); - blk = find_tcp_fb_locked(tcp_func_set_ptr, NULL); + blk = find_tcp_fb_locked(V_tcp_func_set_ptr, NULL); if (blk) { /* Found him */ strcpy(fs.function_set_name, blk->tfb_tcp_block_name); @@ -703,14 +704,14 @@ sysctl_net_inet_default_tcp_functions(SYSCTL_HANDLER_ARGS) error = ENOENT; goto done; } - tcp_func_set_ptr = blk; + V_tcp_func_set_ptr = blk; done: rw_wunlock(&tcp_function_lock); return (error); } SYSCTL_PROC(_net_inet_tcp, OID_AUTO, functions_default, - CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, + CTLFLAG_VNET | CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_NEEDGIANT, NULL, 0, sysctl_net_inet_default_tcp_functions, "A", "Set/get the default TCP functions"); @@ -747,7 +748,7 @@ sysctl_net_inet_list_available(SYSCTL_HANDLER_ARGS) alias = (f->tf_name != f->tf_fb->tfb_tcp_block_name); linesz = snprintf(cp, bufsz, "%-32s%c %-32s %u\n", f->tf_fb->tfb_tcp_block_name, - (f->tf_fb == tcp_func_set_ptr) ? '*' : ' ', + (f->tf_fb == V_tcp_func_set_ptr) ? '*' : ' ', alias ? f->tf_name : "-", f->tf_fb->tfb_refcnt); if (linesz >= bufsz) { @@ -766,7 +767,7 @@ sysctl_net_inet_list_available(SYSCTL_HANDLER_ARGS) } SYSCTL_PROC(_net_inet_tcp, OID_AUTO, functions_available, - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, + CTLFLAG_VNET | CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, NULL, 0, sysctl_net_inet_list_available, "A", "list available TCP Function sets"); @@ -1337,17 +1338,26 @@ deregister_tcp_functions(struct tcp_function_block *blk, bool quiesce, bool force) { struct tcp_function *f; + VNET_ITERATOR_DECL(vnet_iter); if (blk == &tcp_def_funcblk) { /* You can't un-register the default */ return (EPERM); } rw_wlock(&tcp_function_lock); - if (blk == tcp_func_set_ptr) { - /* You can't free the current default */ - rw_wunlock(&tcp_function_lock); - return (EBUSY); + VNET_LIST_RLOCK_NOSLEEP(); + VNET_FOREACH(vnet_iter) { + CURVNET_SET(vnet_iter); + if (blk == V_tcp_func_set_ptr) { + /* You can't free the current default in some vnet. */ + CURVNET_RESTORE(); + VNET_LIST_RUNLOCK_NOSLEEP(); + rw_wunlock(&tcp_function_lock); + return (EBUSY); + } + CURVNET_RESTORE(); } + VNET_LIST_RUNLOCK_NOSLEEP(); /* Mark the block so no more stacks can use it. */ blk->tfb_flags |= TCP_FUNC_BEING_REMOVED; /* @@ -2206,7 +2216,7 @@ tcp_newtcpcb(struct inpcb *inp) tp->t_ccv.type = IPPROTO_TCP; tp->t_ccv.ccvc.tcp = tp; rw_rlock(&tcp_function_lock); - tp->t_fb = tcp_func_set_ptr; + tp->t_fb = V_tcp_func_set_ptr; refcount_acquire(&tp->t_fb->tfb_refcnt); rw_runlock(&tcp_function_lock); /*