From nobody Sun Jul 21 23:57:32 2024 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 4WS0hY1kB3z5QqF1; Sun, 21 Jul 2024 23:57:33 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WS0hY173tz4bjT; Sun, 21 Jul 2024 23:57:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721606253; 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=Nv0nqlTcdQSlQAhp/yrcpVZgK6DLawzGCx4wSciAI9U=; b=S5oC9n1Rr2NlFmhpnvPa2qPRGUsIUNP1yunWq+oJtpUNAhY8iiPdp/+2LQOHGoN6Rb0i0o x2zg3gaLQhkcBWNzx7cpek0leRC0/x3asKJxgV+UsRxztOYuvvUmPfGfDNsFuBlfV3KXMc X8FeDIhezkk7CkYu1esDAlS2kR+otspiP1hFdwRGyW1bl0jWv0Oq4e8iMkClhJzUnQkUu8 b/9AfFOpNHKssdi6b/S3P1R4nVfDJpDjQ6SqVaFf5yKE+v40J/J251P2/nO5eQdJf0beUd shXJXpDiJSyTVC6U3gKj2qNPLWVENf6gMZ0mDtl3+cYDQB5Ni7htDuAcxr24lg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721606253; a=rsa-sha256; cv=none; b=YCSpQuCsVT+Na+jmV+C0Hhyi2RH3KyH+rJJ307fRJwI4yJF+ybPKSqPXB5sI9lT52dMeMD 7UR35PTl6CfDNoGrOdJjXtHSWBuJRehZrPl+ENg5NzI3wazXaMPogvQaMWy5HASaxAzKHV 4dRL4rg2cTi/QT/W6raig+5RM0UPQQx5IxfBTRdSWQR+q8NwwQyTyaGdRaQA4wxAqCqqKK eoQDNa6y2NlPXcg6VsOuKa62yYiC7/Usj3gj5G2UJde2lNfAN0pgtoSKfyQQFivjxCpbkg 4U9cKAZayKx8q5rQxU3kcC+ntkgwdu99aIOIl9hopzp/TswzsKhPr59M/hROow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721606253; 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=Nv0nqlTcdQSlQAhp/yrcpVZgK6DLawzGCx4wSciAI9U=; b=M72cwtHUIc1CVfOYrootKlgRDCHFMf855xUR+3vVdgMizj2A6CKgFX8KXqprXFFbuudh8e xaakXNcTi+NTjkUoyWFYPXzjujCbu5FVXYuoN909IBQ61Fkmv/YYk/8Jm64gD573Luwb+0 ciayCWsY4kySdIIHW7HazMaZTZjqrcQ7403GGu3/vTe3s/Iahna0ISqdOeizMBUmxxe1Cn brvaqbMxt7gIJ7ZuSYcv9Gz9wILrY/HbOsImliMWoBzqwl2xdWnbQMh6ROMjIYafi3ipzx GfkTIctdhqofr+HHAk/gFTIHv9gUB+aFV7zYq4UclY/CogLN73BZogVdRmVEcg== 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 4WS0hY0dNTzLvm; Sun, 21 Jul 2024 23:57:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46LNvWql006299; Sun, 21 Jul 2024 23:57:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46LNvWw4006296; Sun, 21 Jul 2024 23:57:32 GMT (envelope-from git) Date: Sun, 21 Jul 2024 23:57:32 GMT Message-Id: <202407212357.46LNvWw4006296@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: e0b080f850cc - main - tcp: mark TCP stacks which can serve as a default stack 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-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: e0b080f850cc0418353cc196cbfe81075cf76661 Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=e0b080f850cc0418353cc196cbfe81075cf76661 commit e0b080f850cc0418353cc196cbfe81075cf76661 Author: Michael Tuexen AuthorDate: 2024-07-21 13:06:10 +0000 Commit: Michael Tuexen CommitDate: 2024-07-21 13:06:10 +0000 tcp: mark TCP stacks which can serve as a default stack Allow a TCP function block (tfb) to become the default stack only if tfb->tfb_flags has the TCP_FUNC_DEFAULT_OK flags set. This allows a TCP function block, that is not suitable as a default function block to ensure that it is not set as the default via sysctl. In this case sysctl would return EINVAL. Reviewed by: gallatin, Peter Lei Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D45419 --- sys/netinet/tcp_stacks/bbr.c | 2 +- sys/netinet/tcp_stacks/rack.c | 2 +- sys/netinet/tcp_subr.c | 5 +++++ sys/netinet/tcp_var.h | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/netinet/tcp_stacks/bbr.c b/sys/netinet/tcp_stacks/bbr.c index 445ba064b316..cf64451f0c87 100644 --- a/sys/netinet/tcp_stacks/bbr.c +++ b/sys/netinet/tcp_stacks/bbr.c @@ -14181,7 +14181,7 @@ struct tcp_function_block __tcp_bbr = { .tfb_tcp_mtu_chg = bbr_mtu_chg, .tfb_pru_options = bbr_pru_options, .tfb_switch_failed = bbr_switch_failed, - .tfb_flags = TCP_FUNC_OUTPUT_CANDROP, + .tfb_flags = TCP_FUNC_OUTPUT_CANDROP | TCP_FUNC_DEFAULT_OK, }; /* diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index bd7583d3843a..44ddfac2a6ca 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -25289,7 +25289,7 @@ static struct tcp_function_block __tcp_rack = { .tfb_compute_pipe = rack_compute_pipe, .tfb_stack_info = rack_stack_information, .tfb_inherit = rack_inherit, - .tfb_flags = TCP_FUNC_OUTPUT_CANDROP, + .tfb_flags = TCP_FUNC_OUTPUT_CANDROP | TCP_FUNC_DEFAULT_OK, }; diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 6dc8e0c1c46e..42d29d64e09f 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -359,6 +359,7 @@ static struct tcp_function_block tcp_def_funcblk = { .tfb_tcp_fb_init = tcp_default_fb_init, .tfb_tcp_fb_fini = tcp_default_fb_fini, .tfb_switch_failed = tcp_default_switch_failed, + .tfb_flags = TCP_FUNC_DEFAULT_OK, }; static int tcp_fb_cnt = 0; @@ -676,6 +677,10 @@ sysctl_net_inet_default_tcp_functions(SYSCTL_HANDLER_ARGS) error = ENOENT; goto done; } + if ((blk->tfb_flags & TCP_FUNC_DEFAULT_OK) == 0) { + error = EINVAL; + goto done; + } V_tcp_func_set_ptr = blk; done: rw_wunlock(&tcp_function_lock); diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 099fb32ee613..52fd0f181e01 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -540,6 +540,7 @@ typedef enum { /* Flags for tcp functions */ #define TCP_FUNC_BEING_REMOVED 0x01 /* Can no longer be referenced */ #define TCP_FUNC_OUTPUT_CANDROP 0x02 /* tfb_tcp_output may ask tcp_drop */ +#define TCP_FUNC_DEFAULT_OK 0x04 /* Can be used as default */ /** * tfb_tcp_handoff_ok is a mandatory function allowing