From e28bdeb5d46650a16d66193e73fb1c7fd92420e3 Mon Sep 17 00:00:00 2001 From: bluhm Date: Fri, 16 Apr 2021 12:08:25 +0000 Subject: [PATCH] Turn on the direct ACK on every other segment. This is a backout of rev 1.366 which turned this feature off. Although sending less ACKs makes TCP faster if the CPU is busy with processing packets, there are corner cases where TCP gets slower. Especially OpenBSD 6.8 and older has a maxbust limitiation that scales badly if the other side sends too few ACKs. Also regress test relayd run-args-http-slow-consumer.pl uses strange socket buffer sizes that triggers slow performance with the new algorithm. For OpenBSD 6.9 release switch back to 6.8 delayed ACK behavior. discussed with deraadt@ benno@ claudio@ jan@ --- sys/netinet/tcp_input.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 58064906d08..cd0c12dcd3b 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.367 2021/03/10 10:21:49 jsg Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.368 2021/04/16 12:08:25 bluhm Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -165,8 +165,8 @@ do { \ #endif /* - * Macro to compute ACK transmission behavior. Delay the ACK until - * a read from the socket buffer or the delayed ACK timer causes one. + * Macro to compute ACK transmission behavior. Delay the ACK unless + * we have already delayed an ACK (must send an ACK every two segments). * We also ACK immediately if we received a PUSH and the ACK-on-PUSH * option is enabled or when the packet is coming from a loopback * interface. @@ -176,7 +176,8 @@ do { \ struct ifnet *ifp = NULL; \ if (m && (m->m_flags & M_PKTHDR)) \ ifp = if_get(m->m_pkthdr.ph_ifidx); \ - if ((tcp_ack_on_push && (tiflags) & TH_PUSH) || \ + if (TCP_TIMER_ISARMED(tp, TCPT_DELACK) || \ + (tcp_ack_on_push && (tiflags) & TH_PUSH) || \ (ifp && (ifp->if_flags & IFF_LOOPBACK))) \ tp->t_flags |= TF_ACKNOW; \ else \ -- 2.20.1