From 772b5f4ea9b13fcd16352ad47f487d043a588518 Mon Sep 17 00:00:00 2001 From: bluhm Date: Wed, 7 Feb 2018 00:31:10 +0000 Subject: [PATCH] Historically TCP timeouts were implemented with pr_slowtimo and pr_fasttimo. That is the reason why we have two timeout mechanisms with complicated ticks calculation. Move the delay ACK timeout to milliseconds and remove some ticks and hz mess from the others. This makes it easier to see the actual values. OK florian@ dhill@ dlg@ --- sys/netinet/tcp_timer.c | 8 ++++---- sys/netinet/tcp_timer.h | 7 ++++--- sys/netinet/tcp_var.h | 5 ++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index 5c16bd04ab7..b8ac1ac8087 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_timer.c,v 1.63 2018/02/06 15:13:08 bluhm Exp $ */ +/* $OpenBSD: tcp_timer.c,v 1.64 2018/02/07 00:31:10 bluhm Exp $ */ /* $NetBSD: tcp_timer.c,v 1.14 1996/02/13 23:44:09 christos Exp $ */ /* @@ -64,7 +64,7 @@ int tcp_maxidle; * Time to delay the ACK. This is initialized in tcp_init(), unless * its patched. */ -int tcp_delack_ticks; +int tcp_delack_msecs; void tcp_timer_rexmt(void *); void tcp_timer_persist(void *); @@ -96,8 +96,8 @@ tcp_timer_init(void) if (tcp_maxpersistidle == 0) tcp_maxpersistidle = TCPTV_KEEP_IDLE; - if (tcp_delack_ticks == 0) - tcp_delack_ticks = TCP_DELACK_TICKS; + if (tcp_delack_msecs == 0) + tcp_delack_msecs = TCP_DELACK_MSECS; } /* diff --git a/sys/netinet/tcp_timer.h b/sys/netinet/tcp_timer.h index 966b533e7e3..6d685649647 100644 --- a/sys/netinet/tcp_timer.h +++ b/sys/netinet/tcp_timer.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_timer.h,v 1.16 2018/02/06 15:13:08 bluhm Exp $ */ +/* $OpenBSD: tcp_timer.h,v 1.17 2018/02/07 00:31:10 bluhm Exp $ */ /* $NetBSD: tcp_timer.h,v 1.6 1995/03/26 20:32:37 jtc Exp $ */ /* @@ -106,7 +106,7 @@ #define TCP_MAXRXTSHIFT 12 /* maximum retransmits */ -#define TCP_DELACK_TICKS (hz / PR_FASTHZ) /* time to delay ACK */ +#define TCP_DELACK_MSECS 200 /* time to delay ACK */ #ifdef TCPTIMERS const char *tcptimers[TCPT_NTIMERS] = @@ -122,7 +122,7 @@ const char *tcptimers[TCPT_NTIMERS] = #define TCP_TIMER_ARM(tp, timer, nticks) \ do { \ SET((tp)->t_flags, TF_TIMER << (timer)); \ - timeout_add(&(tp)->t_timer[(timer)], (nticks) * (hz / PR_SLOWHZ)); \ + timeout_add_msec(&(tp)->t_timer[(timer)], (nticks) * 500); \ } while (0) #define TCP_TIMER_DISARM(tp, timer) \ @@ -151,6 +151,7 @@ typedef void (*tcp_timer_func_t)(void *); extern const tcp_timer_func_t tcp_timer_funcs[TCPT_NTIMERS]; +extern int tcp_delack_msecs; /* delayed ACK timeout in millisecs */ extern int tcptv_keep_init; extern int tcp_always_keepalive; /* assume SO_KEEPALIVE is always set */ extern int tcp_keepidle; /* time before keepalive probes begin */ diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index eb6d3ac2a7b..0ad9b2444f4 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_var.h,v 1.130 2018/02/06 15:13:08 bluhm Exp $ */ +/* $OpenBSD: tcp_var.h,v 1.131 2018/02/07 00:31:10 bluhm Exp $ */ /* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */ /* @@ -205,14 +205,13 @@ struct tcpcb { #define sototcpcb(so) (intotcpcb(sotoinpcb(so))) #ifdef _KERNEL -extern int tcp_delack_ticks; void tcp_delack(void *); #define TCP_INIT_DELACK(tp) \ timeout_set_proc(&(tp)->t_delack_to, tcp_delack, tp) #define TCP_RESTART_DELACK(tp) \ - timeout_add(&(tp)->t_delack_to, tcp_delack_ticks) + timeout_add_msec(&(tp)->t_delack_to, tcp_delack_msecs) #define TCP_SET_DELACK(tp) \ do { \ -- 2.20.1