From 35f3fc10867da8cc427b46fa54de6595eea77e32 Mon Sep 17 00:00:00 2001 From: Mike Karels Date: Fri, 20 Feb 1987 00:54:32 -0800 Subject: [PATCH] new stats; change keepalives to use rcv_nxt instead of rcv_nxt-1 with no data (so we won't ignore the resets) SCCS-vsn: sys/netinet/tcp_subr.c 7.3 SCCS-vsn: sys/netinet/tcp_timer.c 7.2 --- usr/src/sys/netinet/tcp_subr.c | 10 ++++++---- usr/src/sys/netinet/tcp_timer.c | 29 +++++++++++++++++++---------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/usr/src/sys/netinet/tcp_subr.c b/usr/src/sys/netinet/tcp_subr.c index 5b46127c4c..c76dc07960 100644 --- a/usr/src/sys/netinet/tcp_subr.c +++ b/usr/src/sys/netinet/tcp_subr.c @@ -3,7 +3,7 @@ * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * - * @(#)tcp_subr.c 7.2 (Berkeley) %G% + * @(#)tcp_subr.c 7.3 (Berkeley) %G% */ #include "param.h" @@ -118,7 +118,6 @@ tcp_respond(tp, ti, ack, seq, flags) *mtod(m, struct tcpiphdr *) = *ti; ti = mtod(m, struct tcpiphdr *); flags = TH_ACK; - tlen = 1; } else { m = dtom(ti); m_freem(m->m_next); @@ -129,8 +128,8 @@ tcp_respond(tp, ti, ack, seq, flags) xchg(ti->ti_dst.s_addr, ti->ti_src.s_addr, u_long); xchg(ti->ti_dport, ti->ti_sport, u_short); #undef xchg - tlen = 0; } + tlen = 0; ti->ti_next = ti->ti_prev = 0; ti->ti_x1 = 0; ti->ti_len = htons((u_short)(sizeof (struct tcphdr) + tlen)); @@ -187,7 +186,9 @@ tcp_drop(tp, errno) if (TCPS_HAVERCVDSYN(tp->t_state)) { tp->t_state = TCPS_CLOSED; (void) tcp_output(tp); - } + tcpstat.tcps_drops++; + } else + tcpstat.tcps_conndrops++; so->so_error = errno; return (tcp_close(tp)); } @@ -222,6 +223,7 @@ tcp_close(tp) inp->inp_ppcb = 0; soisdisconnected(so); in_pcbdetach(inp); + tcpstat.tcps_closed++; return ((struct tcpcb *)0); } diff --git a/usr/src/sys/netinet/tcp_timer.c b/usr/src/sys/netinet/tcp_timer.c index 0b0324a6b0..529a52a902 100644 --- a/usr/src/sys/netinet/tcp_timer.c +++ b/usr/src/sys/netinet/tcp_timer.c @@ -3,7 +3,7 @@ * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * - * @(#)tcp_timer.c 7.1 (Berkeley) %G% + * @(#)tcp_timer.c 7.2 (Berkeley) %G% */ #include "param.h" @@ -46,6 +46,7 @@ tcp_fasttimo() (tp->t_flags & TF_DELACK)) { tp->t_flags &= ~TF_DELACK; tp->t_flags |= TF_ACKNOW; + tcpstat.tcps_delack++; (void) tcp_output(tp); } splx(s); @@ -147,9 +148,11 @@ tcp_timers(tp, timer) case TCPT_REXMT: tp->t_rxtshift++; if (tp->t_rxtshift > TCP_MAXRXTSHIFT) { + tcpstat.tcps_timeoutdrop++; tp = tcp_drop(tp, ETIMEDOUT); break; } + tcpstat.tcps_rexmttimeo++; if (tp->t_srtt == 0) rexmt = tcp_beta * TCPTV_SRTTDFLT; else @@ -180,6 +183,7 @@ tcp_timers(tp, timer) * Force a byte to be output, if possible. */ case TCPT_PERSIST: + tcpstat.tcps_persisttimeo++; tcp_setpersist(tp); tp->t_force = 1; (void) tcp_output(tp); @@ -191,6 +195,7 @@ tcp_timers(tp, timer) * or drop connection if idle for too long. */ case TCPT_KEEP: + tcpstat.tcps_keeptimeo++; if (tp->t_state < TCPS_ESTABLISHED) goto dropit; if (tp->t_inpcb->inp_socket->so_options & SO_KEEPALIVE && @@ -198,21 +203,25 @@ tcp_timers(tp, timer) if (tp->t_idle >= TCPTV_MAXIDLE) goto dropit; /* - * Saying tp->rcv_nxt-1 lies about what - * we have received, and by the protocol spec - * requires the correspondent TCP to respond. - * Saying tp->snd_una-1 causes the transmitted - * byte to lie outside the receive window; this - * is important because we don't necessarily - * have a byte in the window to send (consider - * a one-way stream!) + * Send a packet designed to force a response + * if the peer is up and reachable: + * either an ACK if the connection is still alive, + * or an RST if the peer has closed the connection + * due to timeout or reboot. + * Using sequence number tp->snd_una-1 + * causes the transmitted zero-length segment + * to lie outside the receive window; + * by the protocol spec, this requires the + * correspondent TCP to respond. */ + tcpstat.tcps_keepprobe++; tcp_respond(tp, - tp->t_template, tp->rcv_nxt-1, tp->snd_una-1, 0); + tp->t_template, tp->rcv_nxt, tp->snd_una-1, 0); } tp->t_timer[TCPT_KEEP] = TCPTV_KEEP; break; dropit: + tcpstat.tcps_keepdrops++; tp = tcp_drop(tp, ETIMEDOUT); break; } -- 2.20.1