From 326d9b4f201826071598f241480ee426cbabc4d1 Mon Sep 17 00:00:00 2001 From: jan Date: Wed, 3 Feb 2021 13:40:06 +0000 Subject: [PATCH] Turns off the direct ACK on every other segment The kernel uses a huge amount of processing time for sending ACKs to the sender on the receiving interface. After receiving a data segment, we send out two ACKs. The first one in tcp_input() direct after receiving. The second ACK is send out, after the userland or the sosplice task read some data out of the socket buffer. Thus, we save some processing time and improve network performance. Longer tested by sthen@ OK claudio@ --- sys/netinet/tcp_input.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 1d8fae4c560..d0a02807520 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.365 2020/06/19 22:47:22 procter Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.366 2021/02/03 13:40:06 jan 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 unless - * we have already delayed an ACK (must send an ACK every two segments). + * Macro to compute ACK transmission behavior. Delay the ACK until + * a read from the socket buffer or the delayed ACK timer causes one. * 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,8 +176,7 @@ do { \ struct ifnet *ifp = NULL; \ if (m && (m->m_flags & M_PKTHDR)) \ ifp = if_get(m->m_pkthdr.ph_ifidx); \ - if (TCP_TIMER_ISARMED(tp, TCPT_DELACK) || \ - (tcp_ack_on_push && (tiflags) & TH_PUSH) || \ + if ((tcp_ack_on_push && (tiflags) & TH_PUSH) || \ (ifp && (ifp->if_flags & IFF_LOOPBACK))) \ tp->t_flags |= TF_ACKNOW; \ else \ -- 2.20.1