From 0f086867d618d515cf1933bec70af3058575d4d3 Mon Sep 17 00:00:00 2001 From: bluhm Date: Wed, 29 Nov 2023 19:19:25 +0000 Subject: [PATCH] Run TCP syn cache timer without kernel lock. As syn_cache_timer() uses syn cache mutex and exclusive net lock, it does not need kernel lock. OK mvs@ --- sys/netinet/tcp_input.c | 7 ++++--- sys/netinet/tcp_var.h | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 2a4aec3e8d8..0354ece8be2 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.394 2023/11/27 20:37:15 bluhm Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.395 2023/11/29 19:19:25 bluhm Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -3360,7 +3360,7 @@ syn_cache_timer(void *arg) * than the keep alive timer would allow, expire it. */ sc->sc_rxttot += sc->sc_rxtcur; - if (sc->sc_rxttot >= tcptv_keep_init) + if (sc->sc_rxttot >= READ_ONCE(tcptv_keep_init)) goto dropit; /* Advance the timer back-off. */ @@ -3867,7 +3867,8 @@ syn_cache_add(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th, return (-1); } refcnt_init_trace(&sc->sc_refcnt, DT_REFCNT_IDX_SYNCACHE); - timeout_set_proc(&sc->sc_timer, syn_cache_timer, sc); + timeout_set_flags(&sc->sc_timer, syn_cache_timer, sc, + KCLOCK_NONE, TIMEOUT_PROC | TIMEOUT_MPSAFE); /* * Fill in the cache, and put the necessary IP and TCP diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index f5c88511626..b687d436dc5 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_var.h,v 1.172 2023/11/16 18:27:48 bluhm Exp $ */ +/* $OpenBSD: tcp_var.h,v 1.173 2023/11/29 19:19:25 bluhm Exp $ */ /* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */ /* @@ -686,7 +686,7 @@ extern const struct pr_usrreqs tcp6_usrreqs; extern struct pool tcpcb_pool; extern struct inpcbtable tcbtable; /* head of queue of active tcpcb's */ extern int tcp_do_rfc1323; /* enabled/disabled? */ -extern int tcptv_keep_init; /* time to keep alive the initial SYN packet */ +extern int tcptv_keep_init; /* [N] time to keep alive initial SYN packet */ extern int tcp_mssdflt; /* default maximum segment size */ extern int tcp_rst_ppslim; /* maximum outgoing RST packet per second */ extern int tcp_ack_on_push; /* ACK immediately on PUSH */ -- 2.20.1