From nobody Mon Jun 5 21:01:20 2023 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 4QZmHN4Zy6z4ZQ6c; Mon, 5 Jun 2023 21:01:20 +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 4QZmHN48vxz45gx; Mon, 5 Jun 2023 21:01:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685998880; 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=gnX3aZYr4ZZTMZhBOm2Hyu0AK8FpgXu80cT7bs6PqEg=; b=dbodMmF0fQID7n/J6E57rPVpMA5i66Fb1fDQgH8kGq1C2PJMkhVRPLb2GRlK0Oy6G+q8hH wWdXjfuc+Ya2yTguiUdae/a8iAWNQmKCZojNCwYytUC7wyzsCEH/HMyfd/XurFwQz5jGPi CDSbgLBlvSxXoO9s3PVpYv9y7KSjogmwfZ6hdjAOkfiiitaQJJzrHbgKLSiwjpcS3SZ1hG ergTx5SCh2fDZz9+l157mUpfHLbMH95hrZqM8MMUrrB3xoFRiY16d8HH+923lxfs0KAQx5 UoM9LMWDnC2saaQPzjU4X9Ga9PLTlvGePRWci43l3hWw3wG5vpWPVPNOqrPvjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685998880; 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=gnX3aZYr4ZZTMZhBOm2Hyu0AK8FpgXu80cT7bs6PqEg=; b=DCTgE0xM7ks1BUqHK9KBUbmHCabgOeM2Fo7CcVjrem0xUvC4YnUoOMgE9PU/QJOy7O9SAx Cw2MueAIyjMqbh9OlksX/VGd49paYg1QoZGU0XX+/XDvUVU1tED4rTOqXPhss2gbDI80s4 hobA7aNOXBdvTibrBa98l7Ovx4yt+yKFDhdAmt59sAE3a/rMxXLeH9VG53x1wsR5HYs8xK rxwhifJOtxRlz3typsvwKnGE0kdkUyZTxSXoO53wPyQs3KvT+hvrklMxtJEUhmBRj1NGNT o14lQH8FiN5HlA6k+JQYa0lKghz4KE+RAGLFEltwkSbm6qvC9p4CekGfKLYdUQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685998880; a=rsa-sha256; cv=none; b=NVAa41u/5Nmx3xmWPtkKVl/LscL85W6Fe3JVi/RIOXvJRQX+L+SoB7WQlglNafSry3Tg2U FrLNKsCXT7OmGF23al03wIXinTlsA+XYvm1VRM7LRMGvVdBXFqJi1IhcFCBnR2iVR3eRG4 kPNDnxed6Qh9/IvBItHKKZ/U/BSBRtKI8L0laovaMTOOjec0inOksosJN+xElzOA+b1vtJ q3A/E6HZZ6rb3AUFIrBVqfjoSYIyfh2EAc0/FOTz7MRXLPjScb8waI0OzNnByq+SfHqCWo VAoasfWV15dbQZ+Pm52EtJg+amWH9lOmU1hv5Ybf5WKjaeqnkbnL/ChxV4yKzQ== 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 4QZmHN3DVsz12nt; Mon, 5 Jun 2023 21:01:20 +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 355L1Kx2078549; Mon, 5 Jun 2023 21:01:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 355L1K9c078548; Mon, 5 Jun 2023 21:01:20 GMT (envelope-from git) Date: Mon, 5 Jun 2023 21:01:20 GMT Message-Id: <202306052101.355L1K9c078548@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: d66540e829ec - main - tcp: improve sending of TTL/hoplimit and DSCP 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: d66540e829ec22b9654cf4b9119bed9326f89fad Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=d66540e829ec22b9654cf4b9119bed9326f89fad commit d66540e829ec22b9654cf4b9119bed9326f89fad Author: Michael Tuexen AuthorDate: 2023-06-05 16:43:06 +0000 Commit: Michael Tuexen CommitDate: 2023-06-05 16:43:06 +0000 tcp: improve sending of TTL/hoplimit and DSCP Ensure that a user specified value of TTL/hoplimit and DSCP is used when sending packets. Reviewed by: cc, rscheff MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D40423 --- sys/netinet/tcp_stacks/rack.c | 27 ++------------------------- sys/netinet/tcp_subr.c | 13 ++++++++++--- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index affd135bb453..c9b5b937cc46 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -18826,7 +18826,7 @@ rack_fast_rsm_output(struct tcpcb *tp, struct tcp_rack *rack, struct rack_sendma } #ifdef INET6 if (rack->r_is_v6) { - error = ip6_output(m, NULL, + error = ip6_output(m, inp->in6p_outputopts, &inp->inp_route6, ip_sendflag, NULL, NULL, inp); } @@ -19338,7 +19338,7 @@ again: lgb = NULL; #ifdef INET6 if (rack->r_is_v6) { - error = ip6_output(m, NULL, + error = ip6_output(m, inp->in6p_outputopts, &inp->inp_route6, 0, NULL, NULL, inp); } @@ -21792,11 +21792,7 @@ send: TCP_PROBE5(send, NULL, tp, ip6, tp, th); /* TODO: IPv6 IP6TOS_ECT bit on */ error = ip6_output(m, -#if defined(IPSEC) || defined(IPSEC_SUPPORT) inp->in6p_outputopts, -#else - NULL, -#endif &inp->inp_route6, ((rsm || sack_rxmit) ? IP_NO_SND_TAG_RL : 0), NULL, NULL, inp); @@ -23448,10 +23444,6 @@ static int rack_set_sockopt(struct tcpcb *tp, struct sockopt *sopt) { struct inpcb *inp = tptoinpcb(tp); -#ifdef INET6 - struct ip6_hdr *ip6; - int32_t mask, tclass; -#endif #ifdef INET struct ip *ip; #endif @@ -23465,9 +23457,6 @@ rack_set_sockopt(struct tcpcb *tp, struct sockopt *sopt) INP_WUNLOCK(inp); return (EINVAL); } -#ifdef INET6 - ip6 = (struct ip6_hdr *)rack->r_ctl.fsb.tcp_ip_hdr; -#endif #ifdef INET ip = (struct ip *)rack->r_ctl.fsb.tcp_ip_hdr; #endif @@ -23480,18 +23469,6 @@ rack_set_sockopt(struct tcpcb *tp, struct sockopt *sopt) case IPV6_USE_MIN_MTU: tcp6_use_min_mtu(tp); break; - case IPV6_TCLASS: - /* - * The DSCP codepoint has changed, update the fsb - * by overwriting any previous traffic class. - */ - if (inp->in6p_outputopts) { - mask = 0xfc; - tclass = inp->in6p_outputopts->ip6po_tclass; - ip6->ip6_flow &= htonl((~mask) << 20); - ip6->ip6_flow |= htonl((tclass & mask) << 20); - } - break; } INP_WUNLOCK(inp); return (0); diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index fe065fd08737..47eb2d80efd6 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -2049,9 +2049,15 @@ tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m, ulen = tlen - sizeof(struct ip); uh->uh_ulen = htons(ulen); } - ip->ip_tos = ect; ip->ip_len = htons(tlen); - ip->ip_ttl = V_ip_defttl; + if (inp != NULL) { + ip->ip_tos = inp->inp_ip_tos & ~IPTOS_ECN_MASK; + ip->ip_ttl = inp->inp_ip_ttl; + } else { + ip->ip_tos = 0; + ip->ip_ttl = V_ip_defttl; + } + ip->ip_tos |= ect; if (port) { ip->ip_p = IPPROTO_UDP; } else { @@ -2195,7 +2201,8 @@ tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m, #ifdef INET6 if (isipv6) { TCP_PROBE5(send, NULL, tp, ip6, tp, nth); - output_ret = ip6_output(m, NULL, NULL, 0, NULL, NULL, inp); + output_ret = ip6_output(m, inp ? inp->in6p_outputopts : NULL, + NULL, 0, NULL, NULL, inp); } #endif /* INET6 */ #if defined(INET) && defined(INET6)