From b72e56e7586787d3147eda9881bc4da3c5dbe9bf Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Sun, 1 Dec 2019 20:35:41 +0000 Subject: [PATCH] This is an initial step in implementing the new congestion window validation as specified in RFC 7661. Submitted by: Richard Scheffenegger Reviewed by: rrs@, tuexen@ Differential Revision: https://reviews.freebsd.org/D21798 --- share/man/man4/tcp.4 | 6 ++++++ sys/netinet/tcp_input.c | 9 ++++++++- sys/netinet/tcp_stacks/rack.c | 4 +++- sys/netinet/tcp_var.h | 2 ++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/share/man/man4/tcp.4 b/share/man/man4/tcp.4 index b4aa22169824..f6f0c59b96d8 100644 --- a/share/man/man4/tcp.4 +++ b/share/man/man4/tcp.4 @@ -538,6 +538,12 @@ The value should be relative to the link capacity. Start with small values for lower-capacity links. Large bursts can cause buffer overruns and packet drops if routers have small buffers or the link is experiencing congestion. +.It Va newcwd +Enable the New Congestion Window Validation mechanism as described in RFC 7661. +This gently reduces the congestion window during periods, where TCP is +application limited and the network bandwidth is not utilized completely. +That prevents self-inflicted packet losses once the application starts to +transmit data at a higher speed. .It Va rfc6675_pipe Calculate the bytes in flight using the algorithm described in RFC 6675, and is also a prerequisite to enable Proportional Rate Reduction. diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 6a542d0205c3..9c2afbf17e7c 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -150,6 +150,11 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, drop_synfin, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(drop_synfin), 0, "Drop TCP packets with SYN+FIN set"); +VNET_DEFINE(int, tcp_do_newcwv) = 0; +SYSCTL_INT(_net_inet_tcp, OID_AUTO, newcwv, CTLFLAG_VNET | CTLFLAG_RW, + &VNET_NAME(tcp_do_newcwv), 0, + "Enable New Congestion Window Validation per RFC7661"); + VNET_DEFINE(int, tcp_do_rfc6675_pipe) = 0; SYSCTL_INT(_net_inet_tcp, OID_AUTO, rfc6675_pipe, CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_do_rfc6675_pipe), 0, @@ -297,7 +302,9 @@ cc_ack_received(struct tcpcb *tp, struct tcphdr *th, uint16_t nsegs, tp->ccv->nsegs = nsegs; tp->ccv->bytes_this_ack = BYTES_THIS_ACK(tp, th); - if (tp->snd_cwnd <= tp->snd_wnd) + if ((!V_tcp_do_newcwv && (tp->snd_cwnd <= tp->snd_wnd)) || + (V_tcp_do_newcwv && (tp->snd_cwnd <= tp->snd_wnd) && + (tp->snd_cwnd < (tcp_compute_pipe(tp) * 2)))) tp->ccv->flags |= CCF_CWND_LIMITED; else tp->ccv->flags &= ~CCF_CWND_LIMITED; diff --git a/sys/netinet/tcp_stacks/rack.c b/sys/netinet/tcp_stacks/rack.c index a820e09b1446..07813b5ede7c 100644 --- a/sys/netinet/tcp_stacks/rack.c +++ b/sys/netinet/tcp_stacks/rack.c @@ -1663,7 +1663,9 @@ rack_ack_received(struct tcpcb *tp, struct tcp_rack *rack, struct tcphdr *th, ui tp->ccv->bytes_this_ack = max; } } - if (tp->snd_cwnd <= tp->snd_wnd) + if ((!V_tcp_do_newcwv && (tp->snd_cwnd <= tp->snd_wnd)) || + (V_tcp_do_newcwv && (tp->snd_cwnd <= tp->snd_wnd) && + (tp->snd_cwnd < (ctf_flight_size(tp, rack->r_ctl.rc_sacked) * 2)))) tp->ccv->flags |= CCF_CWND_LIMITED; else tp->ccv->flags &= ~CCF_CWND_LIMITED; diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 48136abed775..bae84ea4a9bc 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -767,6 +767,7 @@ VNET_DECLARE(int, tcp_delack_enabled); VNET_DECLARE(int, tcp_do_autorcvbuf); VNET_DECLARE(int, tcp_do_autosndbuf); VNET_DECLARE(int, tcp_do_ecn); +VNET_DECLARE(int, tcp_do_newcwv); VNET_DECLARE(int, tcp_do_rfc1323); VNET_DECLARE(int, tcp_do_rfc3042); VNET_DECLARE(int, tcp_do_rfc3390); @@ -789,6 +790,7 @@ VNET_DECLARE(int, tcp_sendspace); VNET_DECLARE(struct inpcbhead, tcb); VNET_DECLARE(struct inpcbinfo, tcbinfo); +#define V_tcp_do_newcwv VNET(tcp_do_newcwv) #define V_drop_synfin VNET(drop_synfin) #define V_path_mtu_discovery VNET(path_mtu_discovery) #define V_tcb VNET(tcb)