summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/tcp_input.c24
-rw-r--r--sys/netinet/tcp_timer.c16
-rw-r--r--sys/netinet/tcp_timer.h16
-rw-r--r--sys/netinet/tcp_usrreq.c39
-rw-r--r--sys/netinet/tcp_var.h5
5 files changed, 62 insertions, 38 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index e59647715ee..1077746e8dc 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_input.c,v 1.386 2023/01/22 12:05:44 mvs Exp $ */
+/* $OpenBSD: tcp_input.c,v 1.387 2023/03/14 00:24:05 yasuoka Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/*
@@ -867,7 +867,7 @@ findpcb:
*/
tp->t_rcvtime = now;
if (TCPS_HAVEESTABLISHED(tp->t_state))
- TCP_TIMER_ARM(tp, TCPT_KEEP, TCP_TIME(tcp_keepidle));
+ TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepidle);
if (tp->sack_enable)
tcp_del_sackholes(tp, th); /* Delete stale SACK holes */
@@ -1177,7 +1177,7 @@ findpcb:
soisconnected(so);
tp->t_flags &= ~TF_BLOCKOUTPUT;
tp->t_state = TCPS_ESTABLISHED;
- TCP_TIMER_ARM(tp, TCPT_KEEP, TCP_TIME(tcp_keepidle));
+ TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepidle);
/* Do window scaling on this connection? */
if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
(TF_RCVD_SCALE|TF_REQ_SCALE)) {
@@ -1463,7 +1463,7 @@ trimthenstep6:
soisconnected(so);
tp->t_flags &= ~TF_BLOCKOUTPUT;
tp->t_state = TCPS_ESTABLISHED;
- TCP_TIMER_ARM(tp, TCPT_KEEP, TCP_TIME(tcp_keepidle));
+ TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepidle);
/* Do window scaling? */
if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
(TF_RCVD_SCALE|TF_REQ_SCALE)) {
@@ -1798,8 +1798,7 @@ trimthenstep6:
tp->t_flags |= TF_BLOCKOUTPUT;
soisdisconnected(so);
tp->t_flags &= ~TF_BLOCKOUTPUT;
- TCP_TIMER_ARM(tp, TCPT_2MSL,
- TCP_TIME(tcp_maxidle));
+ TCP_TIMER_ARM(tp, TCPT_2MSL, tcp_maxidle);
}
tp->t_state = TCPS_FIN_WAIT_2;
}
@@ -1815,8 +1814,7 @@ trimthenstep6:
if (ourfinisacked) {
tp->t_state = TCPS_TIME_WAIT;
tcp_canceltimers(tp);
- TCP_TIMER_ARM(tp, TCPT_2MSL,
- TCP_TIME(2 * TCPTV_MSL));
+ TCP_TIMER_ARM(tp, TCPT_2MSL, 2 * TCPTV_MSL);
tp->t_flags |= TF_BLOCKOUTPUT;
soisdisconnected(so);
tp->t_flags &= ~TF_BLOCKOUTPUT;
@@ -1842,7 +1840,7 @@ trimthenstep6:
* it and restart the finack timer.
*/
case TCPS_TIME_WAIT:
- TCP_TIMER_ARM(tp, TCPT_2MSL, TCP_TIME(2 * TCPTV_MSL));
+ TCP_TIMER_ARM(tp, TCPT_2MSL, 2 * TCPTV_MSL);
goto dropafterack;
}
}
@@ -2018,7 +2016,7 @@ dodata: /* XXX */
case TCPS_FIN_WAIT_2:
tp->t_state = TCPS_TIME_WAIT;
tcp_canceltimers(tp);
- TCP_TIMER_ARM(tp, TCPT_2MSL, TCP_TIME(2 * TCPTV_MSL));
+ TCP_TIMER_ARM(tp, TCPT_2MSL, 2 * TCPTV_MSL);
tp->t_flags |= TF_BLOCKOUTPUT;
soisdisconnected(so);
tp->t_flags &= ~TF_BLOCKOUTPUT;
@@ -2028,7 +2026,7 @@ dodata: /* XXX */
* In TIME_WAIT state restart the 2 MSL time_wait timer.
*/
case TCPS_TIME_WAIT:
- TCP_TIMER_ARM(tp, TCPT_2MSL, TCP_TIME(2 * TCPTV_MSL));
+ TCP_TIMER_ARM(tp, TCPT_2MSL, 2 * TCPTV_MSL);
break;
}
}
@@ -3356,7 +3354,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 >= TCP_TIME(tcptv_keep_init))
+ if (sc->sc_rxttot >= tcptv_keep_init)
goto dropit;
tcpstat_inc(tcps_sc_retransmitted);
@@ -3631,7 +3629,7 @@ syn_cache_get(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th,
tp->t_sndtime = now;
tp->t_rcvacktime = now;
tp->t_sndacktime = now;
- TCP_TIMER_ARM(tp, TCPT_KEEP, TCP_TIME(tcptv_keep_init));
+ TCP_TIMER_ARM(tp, TCPT_KEEP, tcptv_keep_init);
tcpstat_inc(tcps_accepts);
tcp_mss(tp, sc->sc_peermaxseg); /* sets t_maxseg */
diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c
index 73f553963bd..d1dbc8fa3f2 100644
--- a/sys/netinet/tcp_timer.c
+++ b/sys/netinet/tcp_timer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_timer.c,v 1.71 2022/11/07 11:22:55 yasuoka Exp $ */
+/* $OpenBSD: tcp_timer.c,v 1.72 2023/03/14 00:24:05 yasuoka Exp $ */
/* $NetBSD: tcp_timer.c,v 1.14 1996/02/13 23:44:09 christos Exp $ */
/*
@@ -423,7 +423,7 @@ tcp_timer_persist(void *arg)
rto = tp->t_rttmin;
now = tcp_now();
if (tp->t_rxtshift == TCP_MAXRXTSHIFT &&
- ((now - tp->t_rcvtime) >= TCP_TIME(tcp_maxpersistidle) ||
+ ((now - tp->t_rcvtime) >= tcp_maxpersistidle ||
(now - tp->t_rcvtime) >= rto * tcp_totbackoff)) {
tcpstat_inc(tcps_persistdrop);
tp = tcp_drop(tp, ETIMEDOUT);
@@ -467,8 +467,8 @@ tcp_timer_keep(void *arg)
maxidle = READ_ONCE(tcp_maxidle);
now = tcp_now();
- if ((maxidle > 0) && ((now - tp->t_rcvtime) >=
- TCP_TIME(tcp_keepidle + maxidle)))
+ if ((maxidle > 0) &&
+ ((now - tp->t_rcvtime) >= tcp_keepidle + maxidle))
goto dropit;
/*
* Send a packet designed to force a response
@@ -485,9 +485,9 @@ tcp_timer_keep(void *arg)
tcpstat_inc(tcps_keepprobe);
tcp_respond(tp, mtod(tp->t_template, caddr_t),
NULL, tp->rcv_nxt, tp->snd_una - 1, 0, 0, now);
- TCP_TIMER_ARM(tp, TCPT_KEEP, TCP_TIME(tcp_keepintvl));
+ TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepintvl);
} else
- TCP_TIMER_ARM(tp, TCPT_KEEP, TCP_TIME(tcp_keepidle));
+ TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepidle);
if (otp)
tcp_trace(TA_TIMER, ostate, tp, otp, NULL, TCPT_KEEP, 0);
out:
@@ -524,8 +524,8 @@ tcp_timer_2msl(void *arg)
maxidle = READ_ONCE(tcp_maxidle);
now = tcp_now();
if (tp->t_state != TCPS_TIME_WAIT &&
- ((maxidle == 0) || ((now - tp->t_rcvtime) <= TCP_TIME(maxidle))))
- TCP_TIMER_ARM(tp, TCPT_2MSL, TCP_TIME(tcp_keepintvl));
+ ((maxidle == 0) || ((now - tp->t_rcvtime) <= maxidle)))
+ TCP_TIMER_ARM(tp, TCPT_2MSL, tcp_keepintvl);
else
tp = tcp_close(tp);
if (otp)
diff --git a/sys/netinet/tcp_timer.h b/sys/netinet/tcp_timer.h
index c0f417f55dc..53027af4f3a 100644
--- a/sys/netinet/tcp_timer.h
+++ b/sys/netinet/tcp_timer.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_timer.h,v 1.19 2022/11/07 11:22:55 yasuoka Exp $ */
+/* $OpenBSD: tcp_timer.h,v 1.20 2023/03/14 00:24:05 yasuoka Exp $ */
/* $NetBSD: tcp_timer.h,v 1.6 1995/03/26 20:32:37 jtc Exp $ */
/*
@@ -86,17 +86,17 @@
/*
* Time constants.
*/
-#define TCPTV_MSL 30 /* max seg lifetime (hah!) */
+#define TCPTV_MSL TCP_TIME(30) /* max seg lifetime (hah!) */
#define TCPTV_SRTTBASE 0 /* base roundtrip time;
if 0, no idea yet */
-#define TCPTV_SRTTDFLT TCP_TIME_MSEC(1500) /* assumed RTT if no info */
+#define TCPTV_SRTTDFLT TCP_TIME(3) /* assumed RTT if no info */
-#define TCPTV_PERSMIN 5 /* retransmit persistence */
-#define TCPTV_PERSMAX 60 /* maximum persist interval */
+#define TCPTV_PERSMIN TCP_TIME(5) /* retransmit persistence */
+#define TCPTV_PERSMAX TCP_TIME(60) /* maximum persist interval */
-#define TCPTV_KEEP_INIT 75 /* initial connect keep alive */
-#define TCPTV_KEEP_IDLE 120*60 /* dflt time before probing */
-#define TCPTV_KEEPINTVL 75 /* default probe interval */
+#define TCPTV_KEEP_INIT TCP_TIME(75) /* initial connect keep alive */
+#define TCPTV_KEEP_IDLE TCP_TIME(120*60) /* dflt time before probing */
+#define TCPTV_KEEPINTVL TCP_TIME(75) /* default probe interval */
#define TCPTV_KEEPCNT 8 /* max probes before drop */
#define TCPTV_MIN TCP_TIME(1) /* minimum allowable value */
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 3297953a8d9..c676a5782b2 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_usrreq.c,v 1.216 2023/01/22 12:05:44 mvs Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.217 2023/03/14 00:24:05 yasuoka Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
@@ -155,9 +155,6 @@ const struct pr_usrreqs tcp6_usrreqs = {
const struct sysctl_bounded_args tcpctl_vars[] = {
{ TCPCTL_RFC1323, &tcp_do_rfc1323, 0, 1 },
- { TCPCTL_KEEPINITTIME, &tcptv_keep_init, 1, 3 * TCPTV_KEEP_INIT },
- { TCPCTL_KEEPIDLE, &tcp_keepidle, 1, 5 * TCPTV_KEEP_IDLE },
- { TCPCTL_KEEPINTVL, &tcp_keepintvl, 1, 3 * TCPTV_KEEPINTVL },
{ TCPCTL_SACK, &tcp_do_sack, 0, 1 },
{ TCPCTL_MSSDFLT, &tcp_mssdflt, TCP_MSS, 65535 },
{ TCPCTL_RSTPPSLIMIT, &tcp_rst_ppslim, 1, 1000 * 1000 },
@@ -672,7 +669,7 @@ tcp_connect(struct socket *so, struct mbuf *nam)
soisconnecting(so);
tcpstat_inc(tcps_connattempt);
tp->t_state = TCPS_SYN_SENT;
- TCP_TIMER_ARM(tp, TCPT_KEEP, TCP_TIME(tcptv_keep_init));
+ TCP_TIMER_ARM(tp, TCPT_KEEP, tcptv_keep_init);
tcp_set_iss_tsm(tp);
tcp_sendseqinit(tp);
tp->snd_last = tp->snd_una;
@@ -1110,7 +1107,7 @@ tcp_usrclosed(struct tcpcb *tp)
* not left in FIN_WAIT_2 forever.
*/
if (tp->t_state == TCPS_FIN_WAIT_2)
- TCP_TIMER_ARM(tp, TCPT_2MSL, TCP_TIME(tcp_maxidle));
+ TCP_TIMER_ARM(tp, TCPT_2MSL, tcp_maxidle);
}
return (tp);
}
@@ -1373,6 +1370,36 @@ tcp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
return (ENOTDIR);
switch (name[0]) {
+ case TCPCTL_KEEPINITTIME:
+ NET_LOCK();
+ nval = tcptv_keep_init / TCP_TIME(1);
+ error = sysctl_int_bounded(oldp, oldlenp, newp, newlen, &nval,
+ 1, 3 * (TCPTV_KEEP_INIT / TCP_TIME(1)));
+ if (!error)
+ tcptv_keep_init = TCP_TIME(nval);
+ NET_UNLOCK();
+ return (error);
+
+ case TCPCTL_KEEPIDLE:
+ NET_LOCK();
+ nval = tcp_keepidle / TCP_TIME(1);
+ error = sysctl_int_bounded(oldp, oldlenp, newp, newlen, &nval,
+ 1, 5 * (TCPTV_KEEP_IDLE / TCP_TIME(1)));
+ if (!error)
+ tcp_keepidle = TCP_TIME(nval);
+ NET_UNLOCK();
+ return (error);
+
+ case TCPCTL_KEEPINTVL:
+ NET_LOCK();
+ nval = tcp_keepintvl / TCP_TIME(1);
+ error = sysctl_int_bounded(oldp, oldlenp, newp, newlen, &nval,
+ 1, 3 * (TCPTV_KEEPINTVL / TCP_TIME(1)));
+ if (!error)
+ tcp_keepintvl = TCP_TIME(nval);
+ NET_UNLOCK();
+ return (error);
+
case TCPCTL_BADDYNAMIC:
NET_LOCK();
error = sysctl_struct(oldp, oldlenp, newp, newlen,
diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
index e4931ab441d..72424e0eff0 100644
--- a/sys/netinet/tcp_var.h
+++ b/sys/netinet/tcp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_var.h,v 1.162 2022/12/13 18:10:55 claudio Exp $ */
+/* $OpenBSD: tcp_var.h,v 1.163 2023/03/14 00:24:05 yasuoka Exp $ */
/* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
/*
@@ -644,8 +644,7 @@ tcp_now(void)
return (getnsecruntime() / 1000000);
}
-#define TCP_TIME_MSEC(_ms) (_ms) /* tcp_now() is in milliseconds */
-#define TCP_TIME(_sec) ((_sec) * 1000)
+#define TCP_TIME(_sec) ((_sec) * 1000) /* tcp_now() is in milliseconds */
extern struct mutex tcp_timer_mtx;
extern const struct pr_usrreqs tcp_usrreqs;