diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index a3bdb08817a4..aa2b86dcdf1c 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -1781,10 +1781,13 @@ tcp_twstart(struct tcpcb *tp) * Set t_recent if timestamps are used on the connection. */ if ((tp->t_flags & (TF_REQ_TSTMP|TF_RCVD_TSTMP|TF_NOOPT)) == - (TF_REQ_TSTMP|TF_RCVD_TSTMP)) + (TF_REQ_TSTMP|TF_RCVD_TSTMP)) { tw->t_recent = tp->ts_recent; - else + tw->ts_offset = tp->ts_offset; + } else { tw->t_recent = 0; + tw->ts_offset = 0; + } tw->snd_nxt = tp->snd_nxt; tw->rcv_nxt = tp->rcv_nxt; @@ -1986,7 +1989,7 @@ tcp_twrespond(struct tcptw *tw, int flags) */ if (tw->t_recent && flags == TH_ACK) { to.to_flags |= TOF_TS; - to.to_tsval = ticks; + to.to_tsval = ticks + tw->ts_offset; to.to_tsecr = tw->t_recent; } optlen = tcp_addoptions(&to, (u_char *)(th + 1)); diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index a3bdb08817a4..aa2b86dcdf1c 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -1781,10 +1781,13 @@ tcp_twstart(struct tcpcb *tp) * Set t_recent if timestamps are used on the connection. */ if ((tp->t_flags & (TF_REQ_TSTMP|TF_RCVD_TSTMP|TF_NOOPT)) == - (TF_REQ_TSTMP|TF_RCVD_TSTMP)) + (TF_REQ_TSTMP|TF_RCVD_TSTMP)) { tw->t_recent = tp->ts_recent; - else + tw->ts_offset = tp->ts_offset; + } else { tw->t_recent = 0; + tw->ts_offset = 0; + } tw->snd_nxt = tp->snd_nxt; tw->rcv_nxt = tp->rcv_nxt; @@ -1986,7 +1989,7 @@ tcp_twrespond(struct tcptw *tw, int flags) */ if (tw->t_recent && flags == TH_ACK) { to.to_flags |= TOF_TS; - to.to_tsval = ticks; + to.to_tsval = ticks + tw->ts_offset; to.to_tsecr = tw->t_recent; } optlen = tcp_addoptions(&to, (u_char *)(th + 1)); diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 9a1a40095fce..bb1c18d1db4d 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -271,6 +271,7 @@ struct tcptw { u_short tw_so_options; /* copy of so_options */ struct ucred *tw_cred; /* user credentials */ u_long t_recent; + u_int32_t ts_offset; /* our timestamp offset */ u_long t_starttime; int tw_time; TAILQ_ENTRY(tcptw) tw_2msl;