git: 0924ae8f47ae - main - tcp: allow window scale and timestamps to be toggled individually

From: Richard Scheffenegger <rscheff_at_FreeBSD.org>
Date: Mon, 03 Oct 2022 17:25:37 UTC
The branch main has been updated by rscheff:

URL: https://cgit.FreeBSD.org/src/commit/?id=0924ae8f47ae7095a048843e588a81a12787a819

commit 0924ae8f47ae7095a048843e588a81a12787a819
Author:     Richard Scheffenegger <rscheff@FreeBSD.org>
AuthorDate: 2022-10-03 17:18:58 +0000
Commit:     Richard Scheffenegger <rscheff@FreeBSD.org>
CommitDate: 2022-10-03 17:21:46 +0000

    tcp: allow window scale and timestamps to be toggled individually
    
    Simple change to allow for the individual toggling of
    RFC7323 window scaling and timestamp option.
    
    Reviewed By:            rrs, tuexen, glebius, guest-ccui, #transport
    Sponsored by:           NetApp, Inc.
    Differential Revision:  https://reviews.freebsd.org/D36863
---
 share/man/man4/tcp.4   | 13 ++++++++++++-
 sys/netinet/tcp_subr.c | 16 ++++++++++++++--
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/share/man/man4/tcp.4 b/share/man/man4/tcp.4
index 0b38fd63e165..e6f4ced0c1cf 100644
--- a/share/man/man4/tcp.4
+++ b/share/man/man4/tcp.4
@@ -892,7 +892,18 @@ minimum, which gives us an effective minimum of 200ms (similar to
 The initial value is used before an RTT measurement has been performed.
 .It Va rfc1323
 Implement the window scaling and timestamp options of RFC 1323/RFC 7323
-(default is true).
+(default is 1).
+Settings:
+.Bl -tag -compact
+.It 0
+Disable window scaling and timestamp option.
+.It 1
+Enable window scaling and timestamp option.
+.It 2
+Enable only window scaling.
+.It 3
+Enable only timestamp option.
+.El
 .It Va rfc3042
 Enable the Limited Transmit algorithm as described in RFC 3042.
 It helps avoid timeouts on lossy links and also when the congestion window
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index f9dc57e1df66..9b3525815f73 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -2280,8 +2280,20 @@ tcp_newtcpcb(struct inpcb *inp)
 	callout_init(&tp->t_timers->tt_2msl, 1);
 	callout_init(&tp->t_timers->tt_delack, 1);
 
-	if (V_tcp_do_rfc1323)
-		tp->t_flags = (TF_REQ_SCALE|TF_REQ_TSTMP);
+	switch (V_tcp_do_rfc1323) {
+		case 0:
+			break;
+		default:
+		case 1:
+			tp->t_flags = (TF_REQ_SCALE|TF_REQ_TSTMP);
+			break;
+		case 2:
+			tp->t_flags = TF_REQ_SCALE;
+			break;
+		case 3:
+			tp->t_flags = TF_REQ_TSTMP;
+			break;
+	}
 	if (V_tcp_do_sack)
 		tp->t_flags |= TF_SACK_PERMIT;
 	TAILQ_INIT(&tp->snd_holes);