-/* $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 $ */
/*
*/
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 */
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)) {
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)) {
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;
}
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;
* 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;
}
}
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;
* 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;
}
}
* 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);
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 */
-/* $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 $ */
/*
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);
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
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:
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)
-/* $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 $ */
/*
/*
* 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 */
-/* $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 $ */
/*
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 },
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;
* 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);
}
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,
-/* $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 $ */
/*
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;