git: 04682968c3f7 - main - tcp: expose AccECN mode and TCP FastOpen (TFO) in TCPI

From: Richard Scheffenegger <rscheff_at_FreeBSD.org>
Date: Tue, 20 Jun 2023 21:54:04 UTC
The branch main has been updated by rscheff:

URL: https://cgit.FreeBSD.org/src/commit/?id=04682968c3f7993cf9c07d091c9411d38fb5540b

commit 04682968c3f7993cf9c07d091c9411d38fb5540b
Author:     Richard Scheffenegger <rscheff@FreeBSD.org>
AuthorDate: 2023-06-20 21:27:11 +0000
Commit:     Richard Scheffenegger <rscheff@FreeBSD.org>
CommitDate: 2023-06-20 21:48:56 +0000

    tcp: expose AccECN mode and TCP FastOpen (TFO) in TCPI
    
    Reviewed By:            tuexen, #transport
    Sponsored by:           NetApp, Inc.
    Differential Revision:  https://reviews.freebsd.org/D40621
---
 sys/netinet/tcp.h        |  1 +
 sys/netinet/tcp_usrreq.c | 16 ++++++++++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/sys/netinet/tcp.h b/sys/netinet/tcp.h
index 3c3086eabaf4..dbafc96927b2 100644
--- a/sys/netinet/tcp.h
+++ b/sys/netinet/tcp.h
@@ -336,6 +336,7 @@ struct tcphdr {
 #define	TCPI_OPT_ECN		0x08
 #define	TCPI_OPT_TOE		0x10
 #define	TCPI_OPT_TFO		0x20
+#define	TCPI_OPT_ACE		0x40
 
 /* Maximum length of log ID. */
 #define TCP_LOG_ID_LEN	64
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index a9aee98f1332..629b47f04142 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1556,8 +1556,20 @@ tcp_fill_info(struct tcpcb *tp, struct tcp_info *ti)
 		ti->tcpi_snd_wscale = tp->snd_scale;
 		ti->tcpi_rcv_wscale = tp->rcv_scale;
 	}
-	if (tp->t_flags2 & (TF2_ECN_PERMIT | TF2_ACE_PERMIT))
-		ti->tcpi_options |= TCPI_OPT_ECN;
+	switch (tp->t_flags2 & (TF2_ECN_PERMIT | TF2_ACE_PERMIT)) {
+		case TF2_ECN_PERMIT:
+			ti->tcpi_options |= TCPI_OPT_ECN;
+			break;
+		case TF2_ACE_PERMIT:
+			/* FALLTHROUGH */
+		case TF2_ECN_PERMIT | TF2_ACE_PERMIT:
+			ti->tcpi_options |= TCPI_OPT_ACE;
+			break;
+		default:
+			break;
+	}
+	if (IS_FASTOPEN(tp->t_flags))
+		ti->tcpi_options |= TCPI_OPT_TFO;
 
 	ti->tcpi_rto = tp->t_rxtcur * tick;
 	ti->tcpi_last_data_recv = ((uint32_t)ticks - tp->t_rcvtime) * tick;