From nobody Wed Oct 27 15:22:58 2021 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 A10B11813DFD; Wed, 27 Oct 2021 15:22:59 +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 4HfXWR29sNz3F2P; Wed, 27 Oct 2021 15:22:59 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 AA9BA12B3A; Wed, 27 Oct 2021 15:22:58 +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 19RFMwYD084048; Wed, 27 Oct 2021 15:22:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19RFMwUx084047; Wed, 27 Oct 2021 15:22:58 GMT (envelope-from git) Date: Wed, 27 Oct 2021 15:22:58 GMT Message-Id: <202110271522.19RFMwUx084047@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: de156263a598 - main - Several IP level socket options may affect TCP. 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: de156263a598a0277b7bbc13ef8bdc6f4541b604 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=de156263a598a0277b7bbc13ef8bdc6f4541b604 commit de156263a598a0277b7bbc13ef8bdc6f4541b604 Author: Gleb Smirnoff AuthorDate: 2021-10-26 03:40:12 +0000 Commit: Gleb Smirnoff CommitDate: 2021-10-27 15:21:59 +0000 Several IP level socket options may affect TCP. After handling them in IP level ctloutput, pass them down to TCP ctloutput. We already have a hack to handle IPV6_USE_MIN_MTU. Leave it in place for now, but comment out how it should be handled. For IPv4 we are interested in IP_TOS and IP_TTL. Reviewed by: rrs Differential Revision: https://reviews.freebsd.org/D32655 --- sys/netinet/tcp_usrreq.c | 75 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 21 deletions(-) diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 0fca9b88e6f3..b6e345bd454c 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1739,20 +1739,44 @@ tcp_ctloutput_set(struct inpcb *inp, struct sockopt *sopt) if (sopt->sopt_level != IPPROTO_TCP) { #ifdef INET6 - if (inp->inp_vflag & INP_IPV6PROTO) { + if (inp->inp_vflag & INP_IPV6PROTO) error = ip6_ctloutput(inp->inp_socket, sopt); - /* - * In case of the IPV6_USE_MIN_MTU socket option, - * the INC_IPV6MINMTU flag to announce a corresponding - * MSS during the initial handshake. - * If the TCP connection is not in the front states, - * just reduce the MSS being used. - * This avoids the sending of TCP segments which will - * be fragmented at the IPv6 layer. - */ - if ((error == 0) && - (sopt->sopt_level == IPPROTO_IPV6) && - (sopt->sopt_name == IPV6_USE_MIN_MTU)) { +#endif +#if defined(INET6) && defined(INET) + else +#endif +#ifdef INET + error = ip_ctloutput(inp->inp_socket, sopt); +#endif + /* + * When an IP-level socket option affects TCP, pass control + * down to stack tfb_tcp_ctloutput, otherwise return what + * IP level returned. + */ + switch (sopt->sopt_level) { +#ifdef INET6 + case IPPROTO_IPV6: + if ((inp->inp_vflag & INP_IPV6PROTO) == 0) + return (error); + switch (sopt->sopt_name) { + case IPV6_TCLASS: + /* Notify tcp stacks that care (e.g. RACK). */ + break; + case IPV6_USE_MIN_MTU: + /* + * XXXGL: this handling should belong to + * stack specific tfb_tcp_ctloutput, we + * should just break here. + * + * In case of the IPV6_USE_MIN_MTU socket + * option, the INC_IPV6MINMTU flag to announce + * a corresponding MSS during the initial + * handshake. If the TCP connection is not in + * the front states, just reduce the MSS being + * used. This avoids the sending of TCP + * segments which will be fragmented at the + * IPv6 layer. + */ INP_WLOCK(inp); if ((inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED))) { @@ -1775,18 +1799,27 @@ tcp_ctloutput_set(struct inpcb *inp, struct sockopt *sopt) } } INP_WUNLOCK(inp); + /* FALLTHROUGH */ + default: + return (error); } - } -#endif /* INET6 */ -#if defined(INET6) && defined(INET) - else + break; #endif #ifdef INET - { - error = ip_ctloutput(inp->inp_socket, sopt); - } + case IPPROTO_IP: + switch (sopt->sopt_name) { + case IP_TOS: + case IP_TTL: + /* Notify tcp stacks that care (e.g. RACK). */ + break; + default: + return (error); + } + break; #endif - return (error); + default: + return (error); + } } else if (sopt->sopt_name == TCP_FUNCTION_BLK) { /* * Protect the TCP option TCP_FUNCTION_BLK so