git: 6bf91573c153 - main - tcp: update repeat <SYN,ACK> with latest IP ECN info

From: Richard Scheffenegger <rscheff_at_FreeBSD.org>
Date: Fri, 07 Oct 2022 14:56:25 UTC
The branch main has been updated by rscheff:

URL: https://cgit.FreeBSD.org/src/commit/?id=6bf91573c153d48344d9eb66dd654e44ab2a1002

commit 6bf91573c153d48344d9eb66dd654e44ab2a1002
Author:     Richard Scheffenegger <rscheff@FreeBSD.org>
AuthorDate: 2022-10-06 23:50:02 +0000
Commit:     Richard Scheffenegger <rscheff@FreeBSD.org>
CommitDate: 2022-10-06 23:51:19 +0000

    tcp: update repeat <SYN,ACK> with latest IP ECN info
    
    When multiple <SYN> segments are received, update the <SYN,ACK>
    sent in response to the latest IP ECN and TCP ECN information.
    
    On retransmitting the <SYN,ACK>, once ECN maxtries are done, not
    only disable RFC3168 ECN, but AccECN also.
    
    Reviewed By:            tuexen, #transport
    Sponsored by:           NetApp, Inc.
    Differential Revision:  https://reviews.freebsd.org/D36875
---
 sys/netinet/tcp_syncache.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c
index 2f0e6236f612..ad1811fc68cd 100644
--- a/sys/netinet/tcp_syncache.c
+++ b/sys/netinet/tcp_syncache.c
@@ -514,7 +514,7 @@ syncache_timer(void *xsch)
 			continue;
 		}
 		if (sc->sc_rxmits > V_tcp_ecn_maxretries) {
-			sc->sc_flags &= ~SCF_ECN;
+			sc->sc_flags &= ~SCF_ECN_MASK;
 		}
 		if (sc->sc_rxmits > V_tcp_syncache.rexmt_limit) {
 			if ((s = tcp_log_addrs(&sc->sc_inc, NULL, NULL, NULL))) {
@@ -1564,11 +1564,12 @@ syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th,
 		else
 			sc->sc_flags &= ~SCF_TIMESTAMP;
 		/*
-		 * Disable ECN if needed.
+		 * Adjust ECN response if needed, e.g. different
+		 * IP ECN field, or a fallback by the remote host.
 		 */
-		if ((sc->sc_flags & SCF_ECN) &&
-		    ((tcp_get_flags(th) & (TH_ECE|TH_CWR)) != (TH_ECE|TH_CWR))) {
-			sc->sc_flags &= ~SCF_ECN;
+		if (sc->sc_flags & SCF_ECN_MASK) {
+			sc->sc_flags &= ~SCF_ECN_MASK;
+			sc->sc_flags = tcp_ecn_syncache_add(tcp_get_flags(th), iptos);
 		}
 #ifdef MAC
 		/*