From nobody Wed Feb 23 18:25:07 2022 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 AD50519C91F4; Wed, 23 Feb 2022 18:25:07 +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 4K3kwg4TDvz3NVF; Wed, 23 Feb 2022 18:25:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645640707; 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=jOwFhVN2tlypQ6fIqoxL4pUKORrm1Bqi+UhSIbUebKw=; b=e0d3RbJvYddEG4f83zd7zHZ1fYxf9rZyht63kWok/la8KWzVHxLJCgsJ/L3G2moBajCPr3 yFFxI2jyZEOLbhMFCJgLwYDdtsiRXwi0uRNFrTkC0AnGVOVF2ZqgXdI7gWzmid2oTEjUSM wopXwxCa6hSIeU4UwBzMovvDstHICbpYCQYi04YwBdXMV9dMh6298LINqYLVvAdk9YapZb 26gAuGlWTbwJRYvAbZFT/LEKUkZUjAtjy4vU/52WDAmJyV3HJL6vTXK+T6v3/TmGE9yFQ2 1UpSBC1B3FS2bi6n5jfNZktlByilHWvcjpzaRShcaJQCytLMbNze8K5XiQjn7A== 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 6FC881CFA7; Wed, 23 Feb 2022 18:25:07 +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 21NIP7jC042616; Wed, 23 Feb 2022 18:25:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21NIP7TP042615; Wed, 23 Feb 2022 18:25:07 GMT (envelope-from git) Date: Wed, 23 Feb 2022 18:25:07 GMT Message-Id: <202202231825.21NIP7TP042615@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Robert Wing Subject: git: 95eea15111b0 - stable/13 - tcp_twrespond: send signed segment when connection is TCP-MD5 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: rew X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 95eea15111b0aca59c3fe8b0f9b33fd38df6ee9f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645640707; 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=jOwFhVN2tlypQ6fIqoxL4pUKORrm1Bqi+UhSIbUebKw=; b=VkXsen79EX7zVToGZ3evObB0F9ld50cuFsYWPM2y0o4aq1yfIt9F2JzC9AsdXmVSlGFc5q /Q1lHeesAqd3HgGxB7OUv4yegvHc5o224IdlEiokYY0EHPK3n40YBvlmDb7QT1QiOwJtLk gRfzDJE0lvjLeKsgH3/6TswQUJf5p5gs7RUD/jnmO2/mFcsMZqIeGXlqQR2KgImFEqeS9V 2ppqRVb/H2skmQEH1US25QFqh89PPzPInGN2qXoFP5xIDf2zN/73X3r+A30uI3Mm4Mgg4i 37EfjJ5tovS6m3Mkv+aFlT6wn0f65ynJ71YZv9/eyC7If42NMnfoaW2Rq9NeBw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645640707; a=rsa-sha256; cv=none; b=DMQNo2icPe/7gIFK1dWaGdQiIE3P6N7FXZYoF06+2zjAyFYoJN/eCeBhXF07d3l7TV59Jz 3b51+GWDebg47S1/d5r4Gob7lFxyV/tRIk+Bx1SmLglG6NIBhgn94Uf8kqS6Wm3s9jwEtj wzSvBwvX2UrDalcAvvcmhSxi5GtDgv1lHWIh7wqon0eSEFCf7JSx40NnC71Kr91QvsAI8K 6Xu1JwUXd17MFTGi4FqXG7s7CZNz+GrzkmsbG8at2gYfVdGyIPbiIQmSPP5iZAglZbaLK4 uZ903t56AOWha6vGIkNcpKXwr5xk6WP49UAMkPLhJNH5tB5VRDRx8CTW0meb3w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by rew: URL: https://cgit.FreeBSD.org/src/commit/?id=95eea15111b0aca59c3fe8b0f9b33fd38df6ee9f commit 95eea15111b0aca59c3fe8b0f9b33fd38df6ee9f Author: Robert Wing AuthorDate: 2021-12-20 20:30:24 +0000 Commit: Robert Wing CommitDate: 2022-02-23 18:19:59 +0000 tcp_twrespond: send signed segment when connection is TCP-MD5 When a connection is established to use TCP-MD5, tcp_twrespond() doesn't respond with a signed segment. This results in the host performing the active close to remain in a TIME_WAIT state and the other host in the LAST_ACK state. Fix this by sending a signed segment when the connection is established to use TCP-MD5. Reviewed by: glebius Differential Revision: https://reviews.freebsd.org/D33490 (cherry picked from commit 2a28b045ca7f9b24dc2a8fee2148578edfc87143) --- sys/netinet/tcp_timewait.c | 16 ++++++++++++++++ sys/netinet/tcp_var.h | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index 0ed3856b68a4..ee31c449cd1e 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include "opt_inet.h" #include "opt_inet6.h" +#include "opt_ipsec.h" #include "opt_tcpdebug.h" #include @@ -95,6 +96,9 @@ __FBSDID("$FreeBSD$"); #include #include + +#include + #include #include @@ -326,6 +330,7 @@ tcp_twstart(struct tcpcb *tp) tw->irs = tp->irs; tw->t_starttime = tp->t_starttime; tw->tw_time = 0; + tw->tw_flags = tp->t_flags; /* XXX * If this code will @@ -648,6 +653,10 @@ tcp_twrespond(struct tcptw *tw, int flags) to.to_tsval = tcp_ts_getticks() + tw->ts_offset; to.to_tsecr = tw->t_recent; } +#if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) + if (tw->tw_flags & TF_SIGNATURE) + to.to_flags |= TOF_SIGNATURE; +#endif optlen = tcp_addoptions(&to, (u_char *)(th + 1)); if (udp) { @@ -665,6 +674,13 @@ tcp_twrespond(struct tcptw *tw, int flags) th->th_flags = flags; th->th_win = htons(tw->last_win); +#if defined(IPSEC_SUPPORT) || defined(TCP_SIGNATURE) + if (tw->tw_flags & TF_SIGNATURE) { + if (!TCPMD5_ENABLED() || + TCPMD5_OUTPUT(m, th, to.to_signature) != 0) + return (-1); + } +#endif #ifdef INET6 if (isipv6) { if (tw->t_port) { diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 3dfe3cc2a035..4a05f0f5ab2e 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -538,7 +538,7 @@ struct tcptw { int tw_time; TAILQ_ENTRY(tcptw) tw_2msl; void *tw_pspare; /* TCP_SIGNATURE */ - u_int *tw_spare; /* TCP_SIGNATURE */ + u_int tw_flags; /* tcpcb t_flags */ }; #define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb)