diff options
| author | thorpej <thorpej@NetBSD.org> | 2008-04-08 01:03:58 +0000 |
|---|---|---|
| committer | thorpej <thorpej@NetBSD.org> | 2008-04-08 01:03:58 +0000 |
| commit | f5c68c0b9fc4ff7e896f0f6d757995c19351d8a7 (patch) | |
| tree | b2d38957962ebc8a6d489268c1105d29a7ebcbc7 | |
| parent | 27b03461ec930d8ba4c9885fa97fb79a0fa310fd (diff) | |
Change TCP stats from a structure to an array of uint64_t's.
Note: This is ABI-compatible with the old tcpstat structure; old netstat
binaries will continue to work properly.
| -rw-r--r-- | sys/dist/pf/net/pf.c | 6 | ||||
| -rw-r--r-- | sys/netinet/tcp_input.c | 156 | ||||
| -rw-r--r-- | sys/netinet/tcp_output.c | 32 | ||||
| -rw-r--r-- | sys/netinet/tcp_subr.c | 16 | ||||
| -rw-r--r-- | sys/netinet/tcp_timer.c | 20 | ||||
| -rw-r--r-- | sys/netinet/tcp_usrreq.c | 8 | ||||
| -rw-r--r-- | sys/netinet/tcp_var.h | 173 | ||||
| -rw-r--r-- | usr.bin/netstat/inet.c | 170 | ||||
| -rw-r--r-- | usr.bin/systat/tcp.c | 159 |
9 files changed, 352 insertions, 388 deletions
diff --git a/sys/dist/pf/net/pf.c b/sys/dist/pf/net/pf.c index 1da6880a2ec..dfd02ff06c9 100644 --- a/sys/dist/pf/net/pf.c +++ b/sys/dist/pf/net/pf.c @@ -1,4 +1,4 @@ -/* $NetBSD: pf.c,v 1.47 2008/04/07 06:31:27 thorpej Exp $ */ +/* $NetBSD: pf.c,v 1.48 2008/04/08 01:03:58 thorpej Exp $ */ /* $OpenBSD: pf.c,v 1.487 2005/04/22 09:53:18 dhartmei Exp $ */ /* @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pf.c,v 1.47 2008/04/07 06:31:27 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pf.c,v 1.48 2008/04/08 01:03:58 thorpej Exp $"); #include "bpfilter.h" #include "pflog.h" @@ -5829,7 +5829,7 @@ pf_check_proto_cksum(struct mbuf *m, int off, int len, u_int8_t p, #endif switch (p) { case IPPROTO_TCP: - tcpstat.tcps_rcvbadsum++; + tcpstat[TCP_STAT_RCVBADSUM]++; break; case IPPROTO_UDP: udpstat[UDP_STAT_BADSUM]++; diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 60d18bf3cb6..fe0c82f6d8f 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_input.c,v 1.282 2008/03/01 14:16:52 rmind Exp $ */ +/* $NetBSD: tcp_input.c,v 1.283 2008/04/08 01:03:58 thorpej Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -152,7 +152,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.282 2008/03/01 14:16:52 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.283 2008/04/08 01:03:58 thorpej Exp $"); #include "opt_inet.h" #include "opt_ipsec.h" @@ -579,8 +579,8 @@ tcp_reass(struct tcpcb *tp, const struct tcphdr *th, struct mbuf *m, int *tlen) */ if (SEQ_LEQ(q->ipqe_seq, pkt_seq) && SEQ_GEQ(q->ipqe_seq + q->ipqe_len, pkt_seq + pkt_len)) { - tcpstat.tcps_rcvduppack++; - tcpstat.tcps_rcvdupbyte += pkt_len; + tcpstat[TCP_STAT_RCVDUPPACK]++; + tcpstat[TCP_STAT_RCVDUPBYTE] += pkt_len; tcp_new_dsack(tp, pkt_seq, pkt_len); m_freem(m); if (tiqe != NULL) { @@ -723,7 +723,7 @@ tcp_reass(struct tcpcb *tp, const struct tcphdr *th, struct mbuf *m, int *tlen) if (tiqe == NULL) { tiqe = tcpipqent_alloc(); if (tiqe == NULL) { - tcpstat.tcps_rcvmemdrop++; + tcpstat[TCP_STAT_RCVMEMDROP]++; m_freem(m); return (0); } @@ -732,11 +732,11 @@ tcp_reass(struct tcpcb *tp, const struct tcphdr *th, struct mbuf *m, int *tlen) /* * Update the counters. */ - tcpstat.tcps_rcvoopack++; - tcpstat.tcps_rcvoobyte += rcvoobyte; + tcpstat[TCP_STAT_RCVOOPACK]++; + tcpstat[TCP_STAT_RCVOOBYTE] += rcvoobyte; if (rcvpartdupbyte) { - tcpstat.tcps_rcvpartduppack++; - tcpstat.tcps_rcvpartdupbyte += rcvpartdupbyte; + tcpstat[TCP_STAT_RCVPARTDUPPACK]++; + tcpstat[TCP_STAT_RCVPARTDUPBYTE] += rcvpartdupbyte; } /* @@ -814,7 +814,7 @@ tcp6_input(struct mbuf **mp, int *offp, int proto) struct ip6_hdr *ip6; if (m->m_len < sizeof(struct ip6_hdr)) { if ((m = m_pullup(m, sizeof(struct ip6_hdr))) == NULL) { - tcpstat.tcps_rcvshort++; + tcpstat[TCP_STAT_RCVSHORT]++; return IPPROTO_DONE; } } @@ -974,7 +974,7 @@ tcp_input_checksum(int af, struct mbuf *m, const struct tcphdr *th, return 0; badcsum: - tcpstat.tcps_rcvbadsum++; + tcpstat[TCP_STAT_RCVBADSUM]++; return -1; } @@ -1016,7 +1016,7 @@ tcp_input(struct mbuf *m, ...) (void)va_arg(ap, int); /* ignore value, advance ap */ va_end(ap); - tcpstat.tcps_rcvtotal++; + tcpstat[TCP_STAT_RCVTOTAL]++; bzero(&opti, sizeof(opti)); opti.ts_present = 0; @@ -1059,7 +1059,7 @@ tcp_input(struct mbuf *m, ...) IP6_EXTHDR_GET(th, struct tcphdr *, m, toff, sizeof(struct tcphdr)); if (th == NULL) { - tcpstat.tcps_rcvshort++; + tcpstat[TCP_STAT_RCVSHORT]++; return; } /* We do the checksum after PCB lookup... */ @@ -1077,7 +1077,7 @@ tcp_input(struct mbuf *m, ...) IP6_EXTHDR_GET(th, struct tcphdr *, m, toff, sizeof(struct tcphdr)); if (th == NULL) { - tcpstat.tcps_rcvshort++; + tcpstat[TCP_STAT_RCVSHORT]++; return; } @@ -1129,7 +1129,7 @@ tcp_input(struct mbuf *m, ...) */ off = th->th_off << 2; if (off < sizeof (struct tcphdr) || off > tlen) { - tcpstat.tcps_rcvbadoff++; + tcpstat[TCP_STAT_RCVBADOFF]++; goto drop; } tlen -= off; @@ -1144,7 +1144,7 @@ tcp_input(struct mbuf *m, ...) if (off > sizeof (struct tcphdr)) { IP6_EXTHDR_GET(th, struct tcphdr *, m, toff, off); if (th == NULL) { - tcpstat.tcps_rcvshort++; + tcpstat[TCP_STAT_RCVSHORT]++; return; } /* @@ -1188,7 +1188,7 @@ findpcb: inp = in_pcblookup_connect(&tcbtable, ip->ip_src, th->th_sport, ip->ip_dst, th->th_dport); if (inp == 0) { - ++tcpstat.tcps_pcbhashmiss; + tcpstat[TCP_STAT_PCBHASHMISS]++; inp = in_pcblookup_bind(&tcbtable, ip->ip_dst, th->th_dport); } #ifdef INET6 @@ -1205,7 +1205,7 @@ findpcb: in6p = in6_pcblookup_connect(&tcbtable, &s, th->th_sport, &d, th->th_dport, 0); if (in6p == 0) { - ++tcpstat.tcps_pcbhashmiss; + tcpstat[TCP_STAT_PCBHASHMISS]++; in6p = in6_pcblookup_bind(&tcbtable, &d, th->th_dport, 0); } @@ -1217,7 +1217,7 @@ findpcb: if (inp == 0 && in6p == 0) #endif { - ++tcpstat.tcps_noport; + tcpstat[TCP_STAT_NOPORT]++; if (tcp_log_refused && (tiflags & (TH_RST|TH_ACK|TH_SYN)) == TH_SYN) { tcp4_log_refused(ip, th); @@ -1255,12 +1255,12 @@ findpcb: in6p = in6_pcblookup_connect(&tcbtable, &ip6->ip6_src, th->th_sport, &ip6->ip6_dst, th->th_dport, faith); if (in6p == NULL) { - ++tcpstat.tcps_pcbhashmiss; + tcpstat[TCP_STAT_PCBHASHMISS]++; in6p = in6_pcblookup_bind(&tcbtable, &ip6->ip6_dst, th->th_dport, faith); } if (in6p == NULL) { - ++tcpstat.tcps_noport; + tcpstat[TCP_STAT_NOPORT]++; if (tcp_log_refused && (tiflags & (TH_RST|TH_ACK|TH_SYN)) == TH_SYN) { tcp6_log_refused(ip6, th); @@ -1588,7 +1588,7 @@ findpcb: i = 1; } if (i) { - tcpstat.tcps_badsyn++; + tcpstat[TCP_STAT_BADSYN]++; goto drop; } } @@ -1643,10 +1643,10 @@ after_listen: switch (iptos & IPTOS_ECN_MASK) { case IPTOS_ECN_CE: tp->t_flags |= TF_ECN_SND_ECE; - tcpstat.tcps_ecn_ce++; + tcpstat[TCP_STAT_ECN_CE]++; break; case IPTOS_ECN_ECT0: - tcpstat.tcps_ecn_ect++; + tcpstat[TCP_STAT_ECN_ECT]++; break; case IPTOS_ECN_ECT1: /* XXX: ignore for now -- rpaulo */ @@ -1725,7 +1725,7 @@ after_listen: /* * this is a pure ack for outstanding data. */ - ++tcpstat.tcps_predack; + tcpstat[TCP_STAT_PREDACK]++; if (ts_rtt) tcp_xmit_timer(tp, ts_rtt); else if (tp->t_rtttime && @@ -1733,8 +1733,8 @@ after_listen: tcp_xmit_timer(tp, tcp_now - tp->t_rtttime); acked = th->th_ack - tp->snd_una; - tcpstat.tcps_rcvackpack++; - tcpstat.tcps_rcvackbyte += acked; + tcpstat[TCP_STAT_RCVACKPACK]++; + tcpstat[TCP_STAT_RCVACKBYTE] += acked; nd6_hint(tp); if (acked > (tp->t_lastoff - tp->t_inoff)) @@ -1783,10 +1783,10 @@ after_listen: * with nothing on the reassembly queue and * we have enough buffer space to take it. */ - ++tcpstat.tcps_preddat; + tcpstat[TCP_STAT_PREDDAT]++; tp->rcv_nxt += tlen; - tcpstat.tcps_rcvpack++; - tcpstat.tcps_rcvbyte += tlen; + tcpstat[TCP_STAT_RCVPACK]++; + tcpstat[TCP_STAT_RCVBYTE] += tlen; nd6_hint(tp); /* @@ -1929,7 +1929,7 @@ after_listen: if ((tiflags & TH_ECE) && tcp_do_ecn) { tp->t_flags |= TF_ECN_PERMIT; - tcpstat.tcps_ecn_shs++; + tcpstat[TCP_STAT_ECN_SHS]++; } } @@ -1960,7 +1960,7 @@ after_listen: tcp_rmx_rtt(tp); if (tiflags & TH_ACK) { - tcpstat.tcps_connects++; + tcpstat[TCP_STAT_CONNECTS]++; soisconnected(so); tcp_established(tp); /* Do window scaling on this connection? */ @@ -1992,8 +1992,8 @@ after_listen: m_adj(m, -todrop); tlen = tp->rcv_wnd; tiflags &= ~TH_FIN; - tcpstat.tcps_rcvpackafterwin++; - tcpstat.tcps_rcvbyteafterwin += todrop; + tcpstat[TCP_STAT_RCVPACKAFTERWIN]++; + tcpstat[TCP_STAT_RCVBYTEAFTERWIN] += todrop; } tp->snd_wl1 = th->th_seq - 1; tp->rcv_up = th->th_seq; @@ -2040,9 +2040,9 @@ after_listen: */ tp->ts_recent = 0; } else { - tcpstat.tcps_rcvduppack++; - tcpstat.tcps_rcvdupbyte += tlen; - tcpstat.tcps_pawsdrop++; + tcpstat[TCP_STAT_RCVDUPPACK]++; + tcpstat[TCP_STAT_RCVDUPBYTE] += tlen; + tcpstat[TCP_STAT_PAWSDROP]++; tcp_new_dsack(tp, th->th_seq, tlen); goto dropafterack; } @@ -2079,8 +2079,8 @@ after_listen: tp->t_flags |= TF_ACKNOW; todrop = tlen; dupseg = true; - tcpstat.tcps_rcvdupbyte += todrop; - tcpstat.tcps_rcvduppack++; + tcpstat[TCP_STAT_RCVDUPPACK]++; + tcpstat[TCP_STAT_RCVDUPBYTE] += todrop; } else if ((tiflags & TH_RST) && th->th_seq != tp->last_ack_sent) { /* @@ -2089,8 +2089,8 @@ after_listen: */ goto dropafterack_ratelim; } else { - tcpstat.tcps_rcvpartduppack++; - tcpstat.tcps_rcvpartdupbyte += todrop; + tcpstat[TCP_STAT_RCVPARTDUPPACK]++; + tcpstat[TCP_STAT_RCVPARTDUPBYTE] += todrop; } tcp_new_dsack(tp, th->th_seq, todrop); hdroptlen += todrop; /*drop from head afterwards*/ @@ -2111,7 +2111,7 @@ after_listen: if ((so->so_state & SS_NOFDREF) && tp->t_state > TCPS_CLOSE_WAIT && tlen) { tp = tcp_close(tp); - tcpstat.tcps_rcvafterclose++; + tcpstat[TCP_STAT_RCVAFTERCLOSE]++; goto dropwithreset; } @@ -2121,7 +2121,7 @@ after_listen: */ todrop = (th->th_seq + tlen) - (tp->rcv_nxt+tp->rcv_wnd); if (todrop > 0) { - tcpstat.tcps_rcvpackafterwin++; + tcpstat[TCP_STAT_RCVPACKAFTERWIN]++; if (todrop >= tlen) { /* * The segment actually starts after the window. @@ -2129,7 +2129,7 @@ after_listen: * th->th_seq - tp->rcv_nxt - tp->rcv_wnd >= 0 * th->th_seq >= tp->rcv_nxt + tp->rcv_wnd */ - tcpstat.tcps_rcvbyteafterwin += tlen; + tcpstat[TCP_STAT_RCVBYTEAFTERWIN] += tlen; /* * If a new connection request is received * while in TIME_WAIT, drop the old connection @@ -2159,11 +2159,11 @@ after_listen: */ if (tp->rcv_wnd == 0 && th->th_seq == tp->rcv_nxt) { tp->t_flags |= TF_ACKNOW; - tcpstat.tcps_rcvwinprobe++; + tcpstat[TCP_STAT_RCVWINPROBE]++; } else goto dropafterack; } else - tcpstat.tcps_rcvbyteafterwin += todrop; + tcpstat[TCP_STAT_RCVBYTEAFTERWIN] += todrop; m_adj(m, -todrop); tlen -= todrop; tiflags &= ~(TH_PUSH|TH_FIN); @@ -2221,7 +2221,7 @@ after_listen: so->so_error = ECONNRESET; close: tp->t_state = TCPS_CLOSED; - tcpstat.tcps_drops++; + tcpstat[TCP_STAT_DROPS]++; tp = tcp_close(tp); goto drop; @@ -2277,7 +2277,7 @@ after_listen: if (SEQ_GT(tp->snd_una, th->th_ack) || SEQ_GT(th->th_ack, tp->snd_max)) goto dropwithreset; - tcpstat.tcps_connects++; + tcpstat[TCP_STAT_CONNECTS]++; soisconnected(so); tcp_established(tp); /* Do window scaling? */ @@ -2310,7 +2310,7 @@ after_listen: if (SEQ_LEQ(th->th_ack, tp->snd_una)) { if (tlen == 0 && !dupseg && tiwin == tp->snd_wnd) { - tcpstat.tcps_rcvdupack++; + tcpstat[TCP_STAT_RCVDUPPACK]++; /* * If we have outstanding data (other than * a window probe), this is a completely @@ -2370,12 +2370,12 @@ after_listen: else tp->t_congctl->fast_retransmit_newack(tp, th); if (SEQ_GT(th->th_ack, tp->snd_max)) { - tcpstat.tcps_rcvacktoomuch++; + tcpstat[TCP_STAT_RCVACKTOOMUCH]++; goto dropafterack; } acked = th->th_ack - tp->snd_una; - tcpstat.tcps_rcvackpack++; - tcpstat.tcps_rcvackbyte += acked; + tcpstat[TCP_STAT_RCVACKPACK]++; + tcpstat[TCP_STAT_RCVACKBYTE] += acked; /* * If we have a timestamp reply, update smoothed @@ -2509,7 +2509,7 @@ step6: /* keep track of pure window updates */ if (tlen == 0 && tp->snd_wl2 == th->th_ack && tiwin > tp->snd_wnd) - tcpstat.tcps_rcvwinupd++; + tcpstat[TCP_STAT_RCVWINUPD]++; tp->snd_wnd = tiwin; tp->snd_wl1 = th->th_seq; tp->snd_wl2 = th->th_ack; @@ -2609,8 +2609,8 @@ dodata: /* XXX */ tcp_setup_ack(tp, th); tp->rcv_nxt += tlen; tiflags = th->th_flags & TH_FIN; - tcpstat.tcps_rcvpack++; - tcpstat.tcps_rcvbyte += tlen; + tcpstat[TCP_STAT_RCVPACK]++; + tcpstat[TCP_STAT_RCVBYTE] += tlen; nd6_hint(tp); if (so->so_state & SS_CANTRCVMORE) m_freem(m); @@ -2705,7 +2705,7 @@ badsyn: /* * Received a bad SYN. Increment counters and dropwithreset. */ - tcpstat.tcps_badsyn++; + tcpstat[TCP_STAT_BADSYN]++; tp = NULL; goto dropwithreset; @@ -3112,7 +3112,7 @@ tcp_dooptions(struct tcpcb *tp, const u_char *cp, int cnt, tcp_fields_to_host(th); if (bcmp(sig, sigp, TCP_SIGLEN)) { - tcpstat.tcps_badsig++; + tcpstat[TCP_STAT_BADSIG]++; if (sav == NULL) return (-1); #ifdef FAST_IPSEC @@ -3122,7 +3122,7 @@ tcp_dooptions(struct tcpcb *tp, const u_char *cp, int cnt, #endif return (-1); } else - tcpstat.tcps_goodsig++; + tcpstat[TCP_STAT_GOODSIG]++; key_sa_recordxfer(sav, m); #ifdef FAST_IPSEC @@ -3176,7 +3176,7 @@ tcp_xmit_timer(struct tcpcb *tp, uint32_t rtt) { int32_t delta; - tcpstat.tcps_rttupdated++; + tcpstat[TCP_STAT_RTTUPDATED]++; if (tp->t_srtt != 0) { /* * srtt is stored as fixed point with 3 bits after the @@ -3363,7 +3363,7 @@ syn_cache_insert(struct syn_cache *sc, struct tcpcb *tp) */ s = splsoftnet(); if (scp->sch_length >= tcp_syn_bucket_limit) { - tcpstat.tcps_sc_bucketoverflow++; + tcpstat[TCP_STAT_SC_BUCKETOVERFLOW]++; /* * The bucket is full. Toss the oldest element in the * bucket. This will be the first entry in the bucket. @@ -3382,7 +3382,7 @@ syn_cache_insert(struct syn_cache *sc, struct tcpcb *tp) } else if (syn_cache_count >= tcp_syn_cache_limit) { struct syn_cache_head *scp2, *sce; - tcpstat.tcps_sc_overflowed++; + tcpstat[TCP_STAT_SC_OVERFLOWED]++; /* * The cache is full. Toss the oldest entry in the * first non-empty bucket we can find. @@ -3430,7 +3430,7 @@ syn_cache_insert(struct syn_cache *sc, struct tcpcb *tp) scp->sch_length++; syn_cache_count++; - tcpstat.tcps_sc_added++; + tcpstat[TCP_STAT_SC_ADDED]++; splx(s); } @@ -3449,7 +3449,7 @@ syn_cache_timer(void *arg) callout_ack(&sc->sc_timer); if (__predict_false(sc->sc_flags & SCF_DEAD)) { - tcpstat.tcps_sc_delayed_free++; + tcpstat[TCP_STAT_SC_DELAYED_FREE]++; callout_destroy(&sc->sc_timer); pool_put(&syn_cache_pool, sc); splx(s); @@ -3470,7 +3470,7 @@ syn_cache_timer(void *arg) if (sc->sc_rxttot >= tcp_keepinit) goto dropit; - tcpstat.tcps_sc_retransmitted++; + tcpstat[TCP_STAT_SC_RETRANSMITTED]++; (void) syn_cache_respond(sc, NULL); /* Advance the timer back-off. */ @@ -3481,7 +3481,7 @@ syn_cache_timer(void *arg) return; dropit: - tcpstat.tcps_sc_timed_out++; + tcpstat[TCP_STAT_SC_TIMED_OUT]++; syn_cache_rm(sc); syn_cache_put(sc); /* calls pool_put but see spl above */ splx(s); @@ -3804,7 +3804,7 @@ syn_cache_get(struct sockaddr *src, struct sockaddr *dst, tcp_rcvseqinit(tp); tp->t_state = TCPS_SYN_RECEIVED; TCP_TIMER_ARM(tp, TCPT_KEEP, tp->t_keepinit); - tcpstat.tcps_accepts++; + tcpstat[TCP_STAT_ACCEPTS]++; if ((sc->sc_flags & SCF_SACK_PERMIT) && tcp_do_sack) tp->t_flags |= TF_WILL_SACK; @@ -3858,7 +3858,7 @@ syn_cache_get(struct sockaddr *src, struct sockaddr *dst, tp->t_partialacks = -1; tp->t_dupacks = 0; - tcpstat.tcps_sc_completed++; + tcpstat[TCP_STAT_SC_COMPLETED]++; s = splsoftnet(); syn_cache_put(sc); splx(s); @@ -3872,7 +3872,7 @@ abort: s = splsoftnet(); syn_cache_put(sc); splx(s); - tcpstat.tcps_sc_aborted++; + tcpstat[TCP_STAT_SC_ABORTED]++; return ((struct socket *)(-1)); } @@ -3899,7 +3899,7 @@ syn_cache_reset(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th) return; } syn_cache_rm(sc); - tcpstat.tcps_sc_reset++; + tcpstat[TCP_STAT_SC_RESET]++; syn_cache_put(sc); /* calls pool_put but see spl above */ splx(s); } @@ -3938,7 +3938,7 @@ syn_cache_unreach(const struct sockaddr *src, const struct sockaddr *dst, } syn_cache_rm(sc); - tcpstat.tcps_sc_unreach++; + tcpstat[TCP_STAT_SC_UNREACH]++; syn_cache_put(sc); /* calls pool_put but see spl above */ splx(s); } @@ -4023,7 +4023,7 @@ syn_cache_add(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th, * as a retransmission (XXX though maybe we should). */ if ((sc = syn_cache_lookup(src, dst, &scp)) != NULL) { - tcpstat.tcps_sc_dupesyn++; + tcpstat[TCP_STAT_SC_DUPESYN]++; if (ipopts) { /* * If we were remembering a previous source route, @@ -4035,8 +4035,8 @@ syn_cache_add(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th, } sc->sc_timestamp = tb.ts_recent; if (syn_cache_respond(sc, m) == 0) { - tcpstat.tcps_sndacks++; - tcpstat.tcps_sndtotal++; + tcpstat[TCP_STAT_SNDACKS]++; + tcpstat[TCP_STAT_SNDTOTAL]++; } return (1); } @@ -4144,13 +4144,13 @@ syn_cache_add(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th, sc->sc_tp = tp; if (syn_cache_respond(sc, m) == 0) { syn_cache_insert(sc, tp); - tcpstat.tcps_sndacks++; - tcpstat.tcps_sndtotal++; + tcpstat[TCP_STAT_SNDACKS]++; + tcpstat[TCP_STAT_SNDTOTAL]++; } else { s = splsoftnet(); syn_cache_put(sc); splx(s); - tcpstat.tcps_sc_dropped++; + tcpstat[TCP_STAT_SC_DROPPED]++; } return (1); } @@ -4318,7 +4318,7 @@ syn_cache_respond(struct syn_cache *sc, struct mbuf *m) if ((sc->sc_flags & SCF_ECN_PERMIT) && tp && SEQ_GEQ(tp->snd_nxt, tp->snd_max)) { th->th_flags |= TH_ECE; - tcpstat.tcps_ecn_shs++; + tcpstat[TCP_STAT_ECN_SHS]++; /* * draft-ietf-tcpm-ecnsyn-00.txt @@ -4355,7 +4355,7 @@ syn_cache_respond(struct syn_cache *sc, struct mbuf *m) break; #endif } - tcpstat.tcps_ecn_ect++; + tcpstat[TCP_STAT_ECN_ECT]++; } #ifdef TCP_SIGNATURE diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 477d377813e..e809704c51f 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_output.c,v 1.164 2008/01/14 04:19:10 dyoung Exp $ */ +/* $NetBSD: tcp_output.c,v 1.165 2008/04/08 01:03:58 thorpej Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -142,7 +142,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.164 2008/01/14 04:19:10 dyoung Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_output.c,v 1.165 2008/04/08 01:03:58 thorpej Exp $"); #include "opt_inet.h" #include "opt_ipsec.h" @@ -446,13 +446,13 @@ tcp_build_datapkt(struct tcpcb *tp, struct socket *so, int off, struct mbuf *m, *m0; if (tp->t_force && len == 1) - tcpstat.tcps_sndprobe++; + tcpstat[TCP_STAT_SNDPROBE]++; else if (SEQ_LT(tp->snd_nxt, tp->snd_max)) { - tcpstat.tcps_sndrexmitpack++; - tcpstat.tcps_sndrexmitbyte += len; + tcpstat[TCP_STAT_SNDREXMITPACK]++; + tcpstat[TCP_STAT_SNDREXMITBYTE] += len; } else { - tcpstat.tcps_sndpack++; - tcpstat.tcps_sndbyte += len; + tcpstat[TCP_STAT_SNDPACK]++; + tcpstat[TCP_STAT_SNDBYTE] += len; } #ifdef notyet if ((m = m_copypack(so->so_snd.sb_mb, off, @@ -1264,13 +1264,13 @@ send: flags |= TH_PUSH; } else { if (tp->t_flags & TF_ACKNOW) - tcpstat.tcps_sndacks++; + tcpstat[TCP_STAT_SNDACKS]++; else if (flags & (TH_SYN|TH_FIN|TH_RST)) - tcpstat.tcps_sndctrl++; + tcpstat[TCP_STAT_SNDCTRL]++; else if (SEQ_GT(tp->snd_up, tp->snd_una)) - tcpstat.tcps_sndurg++; + tcpstat[TCP_STAT_SNDURG]++; else - tcpstat.tcps_sndwinup++; + tcpstat[TCP_STAT_SNDWINUP]++; MGETHDR(m, M_DONTWAIT, MT_HEADER); if (m != NULL && max_linkhdr + hdrlen > MHLEN) { @@ -1356,7 +1356,7 @@ send: break; #endif } - tcpstat.tcps_ecn_ect++; + tcpstat[TCP_STAT_ECN_ECT]++; } /* @@ -1520,7 +1520,7 @@ send: if (tp->t_rtttime == 0) { tp->t_rtttime = tcp_now; tp->t_rtseq = startseq; - tcpstat.tcps_segstimed++; + tcpstat[TCP_STAT_SEGSTIMED]++; } } @@ -1641,7 +1641,7 @@ timer: if (error) { out: if (error == ENOBUFS) { - tcpstat.tcps_selfquench++; + tcpstat[TCP_STAT_SELFQUENCH]++; #ifdef INET if (tp->t_inpcb) tcp_quench(tp->t_inpcb, 0); @@ -1671,9 +1671,9 @@ out: if (packetlen > tp->t_pmtud_mtu_sent) tp->t_pmtud_mtu_sent = packetlen; - tcpstat.tcps_sndtotal++; + tcpstat[TCP_STAT_SNDTOTAL]++; if (tp->t_flags & TF_DELACK) - tcpstat.tcps_delack++; + tcpstat[TCP_STAT_DELACK]++; /* * Data sent (as far as we can tell). diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index c07c83b5a1b..594c99d724b 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_subr.c,v 1.225 2008/03/27 00:18:56 cube Exp $ */ +/* $NetBSD: tcp_subr.c,v 1.226 2008/04/08 01:03:58 thorpej Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -98,7 +98,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.225 2008/03/27 00:18:56 cube Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.226 2008/04/08 01:03:58 thorpej Exp $"); #include "opt_inet.h" #include "opt_ipsec.h" @@ -170,7 +170,7 @@ __KERNEL_RCSID(0, "$NetBSD: tcp_subr.c,v 1.225 2008/03/27 00:18:56 cube Exp $"); struct inpcbtable tcbtable; /* head of queue of active tcpcb's */ -struct tcpstat tcpstat; /* tcp statistics */ +uint64_t tcpstat[TCP_NSTATS]; /* tcp statistics */ u_int32_t tcp_now; /* for RFC 1323 timestamps */ /* patchable/settable parameters for tcp */ @@ -1094,9 +1094,9 @@ tcp_drop(struct tcpcb *tp, int errno) if (TCPS_HAVERCVDSYN(tp->t_state)) { tp->t_state = TCPS_CLOSED; (void) tcp_output(tp); - tcpstat.tcps_drops++; + tcpstat[TCP_STAT_DROPS]++; } else - tcpstat.tcps_conndrops++; + tcpstat[TCP_STAT_CONNDROPS]++; if (errno == ETIMEDOUT && tp->t_softerror) errno = tp->t_softerror; so->so_error = errno; @@ -1122,7 +1122,7 @@ tcp_isdead(struct tcpcb *tp) if (tcp_timers_invoking(tp) > 0) /* not quite there yet -- count separately? */ return dead; - tcpstat.tcps_delayed_free++; + tcpstat[TCP_STAT_DELAYED_FREE]++; for (i = 0; i < TCPT_NTIMERS; i++) callout_destroy(&tp->t_timer[i]); callout_destroy(&tp->t_delack_ch); @@ -1275,7 +1275,7 @@ tcp_close(struct tcpcb *tp) in6_pcbdetach(in6p); } #endif - tcpstat.tcps_closed++; + tcpstat[TCP_STAT_CLOSED]++; return ((struct tcpcb *)0); } @@ -1342,7 +1342,7 @@ tcp_drain(void) if (tcp_reass_lock_try(tp) == 0) continue; if (tcp_freeq(tp)) - tcpstat.tcps_connsdrained++; + tcpstat[TCP_STAT_CONNSDRAINED]++; TCP_REASS_UNLOCK(tp); } } diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index 5ab8eb641a8..fa20d0eb1d8 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_timer.c,v 1.77 2007/06/20 15:29:18 christos Exp $ */ +/* $NetBSD: tcp_timer.c,v 1.78 2008/04/08 01:03:58 thorpej Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -100,7 +100,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.77 2007/06/20 15:29:18 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_timer.c,v 1.78 2008/04/08 01:03:58 thorpej Exp $"); #include "opt_inet.h" #include "opt_tcp_debug.h" @@ -349,12 +349,12 @@ tcp_timer_rexmt(void *arg) if (++tp->t_rxtshift > TCP_MAXRXTSHIFT) { tp->t_rxtshift = TCP_MAXRXTSHIFT; - tcpstat.tcps_timeoutdrop++; + tcpstat[TCP_STAT_TIMEOUTDROP]++; tp = tcp_drop(tp, tp->t_softerror ? tp->t_softerror : ETIMEDOUT); goto out; } - tcpstat.tcps_rexmttimeo++; + tcpstat[TCP_STAT_REXMTTIMEO]++; rto = TCP_REXMTVAL(tp); if (rto < tp->t_rttmin) rto = tp->t_rttmin; @@ -371,7 +371,7 @@ tcp_timer_rexmt(void *arg) * value here... */ if (tp->t_mtudisc && tp->t_rxtshift > TCP_MAXRXTSHIFT / 6) { - tcpstat.tcps_pmtublackhole++; + tcpstat[TCP_STAT_PMTUBLACKHOLE]++; #ifdef INET /* try turning PMTUD off */ @@ -486,11 +486,11 @@ tcp_timer_persist(void *arg) if (tp->t_rxtshift == TCP_MAXRXTSHIFT && ((tcp_now - tp->t_rcvtime) >= tcp_maxpersistidle || (tcp_now - tp->t_rcvtime) >= rto * tcp_totbackoff)) { - tcpstat.tcps_persistdrops++; + tcpstat[TCP_STAT_PERSISTDROPS]++; tp = tcp_drop(tp, ETIMEDOUT); goto out; } - tcpstat.tcps_persisttimeo++; + tcpstat[TCP_STAT_PERSISTTIMEO]++; tcp_setpersist(tp); tp->t_force = 1; (void) tcp_output(tp); @@ -531,7 +531,7 @@ tcp_timer_keep(void *arg) * or drop connection if idle for too long. */ - tcpstat.tcps_keeptimeo++; + tcpstat[TCP_STAT_KEEPTIMEO]++; if (TCPS_HAVEESTABLISHED(tp->t_state) == 0) goto dropit; #ifdef INET @@ -561,7 +561,7 @@ tcp_timer_keep(void *arg) * by the protocol spec, this requires the * correspondent TCP to respond. */ - tcpstat.tcps_keepprobe++; + tcpstat[TCP_STAT_KEEPPROBE]++; if (tcp_compat_42) { /* * The keepalive packet must have nonzero @@ -588,7 +588,7 @@ tcp_timer_keep(void *arg) return; dropit: - tcpstat.tcps_keepdrops++; + tcpstat[TCP_STAT_KEEPDROPS]++; (void) tcp_drop(tp, ETIMEDOUT); splx(s); } diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 34eb9491b24..b9990c3a6b8 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_usrreq.c,v 1.140 2007/12/16 14:12:35 elad Exp $ */ +/* $NetBSD: tcp_usrreq.c,v 1.141 2008/04/08 01:03:58 thorpej Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -102,7 +102,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.140 2007/12/16 14:12:35 elad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.141 2008/04/08 01:03:58 thorpej Exp $"); #include "opt_inet.h" #include "opt_ipsec.h" @@ -436,7 +436,7 @@ tcp_usrreq(struct socket *so, int req, (TCP_MAXWIN << tp->request_r_scale) < sb_max) tp->request_r_scale++; soisconnecting(so); - tcpstat.tcps_connattempt++; + tcpstat[TCP_STAT_CONNATTEMPT]++; tp->t_state = TCPS_SYN_SENT; TCP_TIMER_ARM(tp, TCPT_KEEP, tp->t_keepinit); tp->iss = tcp_new_iss(tp, 0); @@ -1959,7 +1959,7 @@ sysctl_net_inet_tcp_setup2(struct sysctllog **clog, int pf, const char *pfname, CTLFLAG_PERMANENT, CTLTYPE_STRUCT, "stats", SYSCTL_DESCR("TCP statistics"), - NULL, 0, &tcpstat, sizeof(tcpstat), + NULL, 0, tcpstat, sizeof(tcpstat), CTL_NET, pf, IPPROTO_TCP, TCPCTL_STATS, CTL_EOL); #ifdef TCP_DEBUG diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index b0119be3401..1411900c6f0 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1,4 +1,4 @@ -/* $NetBSD: tcp_var.h,v 1.153 2008/02/29 07:39:17 matt Exp $ */ +/* $NetBSD: tcp_var.h,v 1.154 2008/04/08 01:03:58 thorpej Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -567,96 +567,91 @@ struct syn_cache_head { /* * TCP statistics. - * Many of these should be kept per connection, - * but that's inconvenient at the moment. + * Each counter is an unsigned 64-bit value. + * + * Many of these should be kept per connection, but that's inconvenient + * at the moment. */ -struct tcpstat { - u_quad_t tcps_connattempt; /* connections initiated */ - u_quad_t tcps_accepts; /* connections accepted */ - u_quad_t tcps_connects; /* connections established */ - u_quad_t tcps_drops; /* connections dropped */ - u_quad_t tcps_conndrops; /* embryonic connections dropped */ - u_quad_t tcps_closed; /* conn. closed (includes drops) */ - u_quad_t tcps_segstimed; /* segs where we tried to get rtt */ - u_quad_t tcps_rttupdated; /* times we succeeded */ - u_quad_t tcps_delack; /* delayed acks sent */ - u_quad_t tcps_timeoutdrop; /* conn. dropped in rxmt timeout */ - u_quad_t tcps_rexmttimeo; /* retransmit timeouts */ - u_quad_t tcps_persisttimeo; /* persist timeouts */ - u_quad_t tcps_keeptimeo; /* keepalive timeouts */ - u_quad_t tcps_keepprobe; /* keepalive probes sent */ - u_quad_t tcps_keepdrops; /* connections dropped in keepalive */ - u_quad_t tcps_persistdrops; /* connections dropped in persist */ - u_quad_t tcps_connsdrained; /* connections drained due to memory +#define TCP_STAT_CONNATTEMPT 0 /* connections initiated */ +#define TCP_STAT_ACCEPTS 1 /* connections accepted */ +#define TCP_STAT_CONNECTS 2 /* connections established */ +#define TCP_STAT_DROPS 3 /* connections dropped */ +#define TCP_STAT_CONNDROPS 4 /* embryonic connections dropped */ +#define TCP_STAT_CLOSED 5 /* conn. closed (includes drops) */ +#define TCP_STAT_SEGSTIMED 6 /* segs where we tried to get rtt */ +#define TCP_STAT_RTTUPDATED 7 /* times we succeeded */ +#define TCP_STAT_DELACK 8 /* delayed ACKs sent */ +#define TCP_STAT_TIMEOUTDROP 9 /* conn. dropped in rxmt timeout */ +#define TCP_STAT_REXMTTIMEO 10 /* retransmit timeouts */ +#define TCP_STAT_PERSISTTIMEO 11 /* persist timeouts */ +#define TCP_STAT_KEEPTIMEO 12 /* keepalive timeouts */ +#define TCP_STAT_KEEPPROBE 13 /* keepalive probes sent */ +#define TCP_STAT_KEEPDROPS 14 /* connections dropped in keepalive */ +#define TCP_STAT_PERSISTDROPS 15 /* connections dropped in persist */ +#define TCP_STAT_CONNSDRAINED 16 /* connections drained due to memory shortage */ - u_quad_t tcps_pmtublackhole; /* PMTUD blackhole detected */ - - u_quad_t tcps_sndtotal; /* total packets sent */ - u_quad_t tcps_sndpack; /* data packets sent */ - u_quad_t tcps_sndbyte; /* data bytes sent */ - u_quad_t tcps_sndrexmitpack; /* data packets retransmitted */ - u_quad_t tcps_sndrexmitbyte; /* data bytes retransmitted */ - u_quad_t tcps_sndacks; /* ack-only packets sent */ - u_quad_t tcps_sndprobe; /* window probes sent */ - u_quad_t tcps_sndurg; /* packets sent with URG only */ - u_quad_t tcps_sndwinup; /* window update-only packets sent */ - u_quad_t tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */ - - u_quad_t tcps_rcvtotal; /* total packets received */ - u_quad_t tcps_rcvpack; /* packets received in sequence */ - u_quad_t tcps_rcvbyte; /* bytes received in sequence */ - u_quad_t tcps_rcvbadsum; /* packets received with ccksum errs */ - u_quad_t tcps_rcvbadoff; /* packets received with bad offset */ - u_quad_t tcps_rcvmemdrop; /* packets dropped for lack of memory */ - u_quad_t tcps_rcvshort; /* packets received too short */ - u_quad_t tcps_rcvduppack; /* duplicate-only packets received */ - u_quad_t tcps_rcvdupbyte; /* duplicate-only bytes received */ - u_quad_t tcps_rcvpartduppack; /* packets with some duplicate data */ - u_quad_t tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */ - u_quad_t tcps_rcvoopack; /* out-of-order packets received */ - u_quad_t tcps_rcvoobyte; /* out-of-order bytes received */ - u_quad_t tcps_rcvpackafterwin; /* packets with data after window */ - u_quad_t tcps_rcvbyteafterwin; /* bytes rcvd after window */ - u_quad_t tcps_rcvafterclose; /* packets rcvd after "close" */ - u_quad_t tcps_rcvwinprobe; /* rcvd window probe packets */ - u_quad_t tcps_rcvdupack; /* rcvd duplicate acks */ - u_quad_t tcps_rcvacktoomuch; /* rcvd acks for unsent data */ - u_quad_t tcps_rcvackpack; /* rcvd ack packets */ - u_quad_t tcps_rcvackbyte; /* bytes acked by rcvd acks */ - u_quad_t tcps_rcvwinupd; /* rcvd window update packets */ - u_quad_t tcps_pawsdrop; /* segments dropped due to PAWS */ - u_quad_t tcps_predack; /* times hdr predict ok for acks */ - u_quad_t tcps_preddat; /* times hdr predict ok for data pkts */ - - u_quad_t tcps_pcbhashmiss; /* input packets missing pcb hash */ - u_quad_t tcps_noport; /* no socket on port */ - u_quad_t tcps_badsyn; /* received ack for which we have +#define TCP_STAT_PMTUBLACKHOLE 17 /* PMTUD blackhole detected */ +#define TCP_STAT_SNDTOTAL 18 /* total packets sent */ +#define TCP_STAT_SNDPACK 19 /* data packlets sent */ +#define TCP_STAT_SNDBYTE 20 /* data bytes sent */ +#define TCP_STAT_SNDREXMITPACK 21 /* data packets retransmitted */ +#define TCP_STAT_SNDREXMITBYTE 22 /* data bytes retransmitted */ +#define TCP_STAT_SNDACKS 23 /* ACK-only packets sent */ +#define TCP_STAT_SNDPROBE 24 /* window probes sent */ +#define TCP_STAT_SNDURG 25 /* packets sent with URG only */ +#define TCP_STAT_SNDWINUP 26 /* window update-only packets sent */ +#define TCP_STAT_SNDCTRL 27 /* control (SYN|FIN|RST) packets sent */ +#define TCP_STAT_RCVTOTAL 28 /* total packets received */ +#define TCP_STAT_RCVPACK 29 /* packets received in sequence */ +#define TCP_STAT_RCVBYTE 30 /* bytes received in sequence */ +#define TCP_STAT_RCVBADSUM 31 /* packets received with cksum errs */ +#define TCP_STAT_RCVBADOFF 32 /* packets received with bad offset */ +#define TCP_STAT_RCVMEMDROP 33 /* packets dropped for lack of memory */ +#define TCP_STAT_RCVSHORT 34 /* packets received too short */ +#define TCP_STAT_RCVDUPPACK 35 /* duplicate-only packets received */ +#define TCP_STAT_RCVDUPBYTE 36 /* duplicate-only bytes received */ +#define TCP_STAT_RCVPARTDUPPACK 37 /* packets with some duplicate data */ +#define TCP_STAT_RCVPARTDUPBYTE 38 /* dup. bytes in part-dup. packets */ +#define TCP_STAT_RCVOOPACK 39 /* out-of-order packets received */ +#define TCP_STAT_RCVOOBYTE 40 /* out-of-order bytes received */ +#define TCP_STAT_RCVPACKAFTERWIN 41 /* packets with data after window */ +#define TCP_STAT_RCVBYTEAFTERWIN 42 /* bytes received after window */ +#define TCP_STAT_RCVAFTERCLOSE 43 /* packets received after "close" */ +#define TCP_STAT_RCVWINPROBE 44 /* rcvd window probe packets */ +#define TCP_STAT_RCVDUPACK 45 /* rcvd duplicate ACKs */ +#define TCP_STAT_RCVACKTOOMUCH 46 /* rcvd ACKs for unsent data */ +#define TCP_STAT_RCVACKPACK 47 /* rcvd ACK packets */ +#define TCP_STAT_RCVACKBYTE 48 /* bytes ACKed by rcvd ACKs */ +#define TCP_STAT_RCVWINUPD 49 /* rcvd window update packets */ +#define TCP_STAT_PAWSDROP 50 /* segments dropped due to PAWS */ +#define TCP_STAT_PREDACK 51 /* times hdr predict OK for ACKs */ +#define TCP_STAT_PREDDAT 52 /* times hdr predict OK for data pkts */ +#define TCP_STAT_PCBHASHMISS 53 /* input packets missing PCB hash */ +#define TCP_STAT_NOPORT 54 /* no socket on port */ +#define TCP_STAT_BADSYN 55 /* received ACK for which we have no SYN in compressed state */ - u_quad_t tcps_delayed_free; /* delayed pool_put() of tcpcb */ - - /* These statistics deal with the SYN cache. */ - u_quad_t tcps_sc_added; /* # of entries added */ - u_quad_t tcps_sc_completed; /* # of connections completed */ - u_quad_t tcps_sc_timed_out; /* # of entries timed out */ - u_quad_t tcps_sc_overflowed; /* # dropped due to overflow */ - u_quad_t tcps_sc_reset; /* # dropped due to RST */ - u_quad_t tcps_sc_unreach; /* # dropped due to ICMP unreach */ - u_quad_t tcps_sc_bucketoverflow;/* # dropped due to bucket overflow */ - u_quad_t tcps_sc_aborted; /* # of entries aborted (no mem) */ - u_quad_t tcps_sc_dupesyn; /* # of duplicate SYNs received */ - u_quad_t tcps_sc_dropped; /* # of SYNs dropped (no route/mem) */ - u_quad_t tcps_sc_collisions; /* # of hash collisions */ - u_quad_t tcps_sc_retransmitted; /* # of retransmissions */ - u_quad_t tcps_sc_delayed_free; /* # of delayed pool_put()s */ - - u_quad_t tcps_selfquench; /* # of ENOBUFS we get on output */ - u_quad_t tcps_badsig; /* # of drops due to bad signature */ - u_quad_t tcps_goodsig; /* # of packets with good signature */ - - u_quad_t tcps_ecn_shs; /* # of sucessful ECN handshakes */ - u_quad_t tcps_ecn_ce; /* # of packets with CE bit */ - u_quad_t tcps_ecn_ect; /* # of packets with ECT(0) bit */ -}; +#define TCP_STAT_DELAYED_FREE 56 /* delayed pool_put() of tcpcb */ +#define TCP_STAT_SC_ADDED 57 /* # of sc entries added */ +#define TCP_STAT_SC_COMPLETED 58 /* # of sc connections completed */ +#define TCP_STAT_SC_TIMED_OUT 59 /* # of sc entries timed out */ +#define TCP_STAT_SC_OVERFLOWED 60 /* # of sc drops due to overflow */ +#define TCP_STAT_SC_RESET 61 /* # of sc drops due to RST */ +#define TCP_STAT_SC_UNREACH 62 /* # of sc drops due to ICMP unreach */ +#define TCP_STAT_SC_BUCKETOVERFLOW 63 /* # of sc drops due to bucket ovflow */ +#define TCP_STAT_SC_ABORTED 64 /* # of sc entries aborted (no mem) */ +#define TCP_STAT_SC_DUPESYN 65 /* # of duplicate SYNs received */ +#define TCP_STAT_SC_DROPPED 66 /* # of SYNs dropped (no route/mem) */ +#define TCP_STAT_SC_COLLISIONS 67 /* # of sc hash collisions */ +#define TCP_STAT_SC_RETRANSMITTED 68 /* # of sc retransmissions */ +#define TCP_STAT_SC_DELAYED_FREE 69 /* # of delayed pool_put()s */ +#define TCP_STAT_SELFQUENCH 70 /* # of ENOBUFS we get on output */ +#define TCP_STAT_BADSIG 71 /* # of drops due to bad signature */ +#define TCP_STAT_GOODSIG 72 /* # of packets with good signature */ +#define TCP_STAT_ECN_SHS 73 /* # of successful ECN handshakes */ +#define TCP_STAT_ECN_CE 74 /* # of packets with CE bit */ +#define TCP_STAT_ECN_ECT 75 /* # of packets with ECT(0) bit */ + +#define TCP_NSTATS 76 /* * Names for TCP sysctl objects. @@ -739,7 +734,7 @@ struct tcpstat { #ifdef _KERNEL extern struct inpcbtable tcbtable; /* head of queue of active tcpcb's */ -extern struct tcpstat tcpstat; /* tcp statistics */ +extern uint64_t tcpstat[TCP_NSTATS]; /* tcp statistics */ extern u_int32_t tcp_now; /* for RFC 1323 timestamps */ extern int tcp_do_rfc1323; /* enabled/disabled? */ extern int tcp_do_sack; /* SACK enabled/disabled? */ diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index 6bfe91dfc82..e10fd31e7c3 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -1,4 +1,4 @@ -/* $NetBSD: inet.c,v 1.82 2008/04/07 06:31:28 thorpej Exp $ */ +/* $NetBSD: inet.c,v 1.83 2008/04/08 01:03:58 thorpej Exp $ */ /* * Copyright (c) 1983, 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94"; #else -__RCSID("$NetBSD: inet.c,v 1.82 2008/04/07 06:31:28 thorpej Exp $"); +__RCSID("$NetBSD: inet.c,v 1.83 2008/04/08 01:03:58 thorpej Exp $"); #endif #endif /* not lint */ @@ -125,7 +125,7 @@ protopr0(intptr_t ppcb, u_long rcv_sb_cc, u_long snd_sb_cc, struct in_addr *faddr, u_int16_t fport, short t_state, char *name) { - static char *shorttcpstates[] = { + static const char *shorttcpstates[] = { "CLOSED", "LISTEN", "SYNSEN", "SYSRCV", "ESTABL", "CLWAIT", "FWAIT1", "CLOSNG", "LASTAK", "FWAIT2", "TMWAIT", @@ -279,123 +279,121 @@ protopr(off, name) * Dump TCP statistics structure. */ void -tcp_stats(off, name) - u_long off; - char *name; +tcp_stats(u_long off, char *name) { - struct tcpstat tcpstat; + uint64_t tcpstat[TCP_NSTATS]; if (use_sysctl) { size_t size = sizeof(tcpstat); - if (sysctlbyname("net.inet.tcp.stats", &tcpstat, &size, + if (sysctlbyname("net.inet.tcp.stats", tcpstat, &size, NULL, 0) == -1) err(1, "net.inet.tcp.stats"); } else { if (off == 0) return; - kread(off, (char *)&tcpstat, sizeof (tcpstat)); + kread(off, (char *)tcpstat, sizeof (tcpstat)); } printf ("%s:\n", name); -#define ps(f, m) if (tcpstat.f || sflag <= 1) \ - printf(m, (unsigned long long)tcpstat.f) -#define p(f, m) if (tcpstat.f || sflag <= 1) \ - printf(m, (unsigned long long)tcpstat.f, plural(tcpstat.f)) -#define p2(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \ - printf(m, (unsigned long long)tcpstat.f1, plural(tcpstat.f1), \ - (unsigned long long)tcpstat.f2, plural(tcpstat.f2)) -#define p2s(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \ - printf(m, (unsigned long long)tcpstat.f1, plural(tcpstat.f1), \ - (unsigned long long)tcpstat.f2) -#define p3(f, m) if (tcpstat.f || sflag <= 1) \ - printf(m, (unsigned long long)tcpstat.f, plurales(tcpstat.f)) - - p(tcps_sndtotal, "\t%llu packet%s sent\n"); - p2(tcps_sndpack,tcps_sndbyte, +#define ps(f, m) if (tcpstat[f] || sflag <= 1) \ + printf(m, (unsigned long long)tcpstat[f]) +#define p(f, m) if (tcpstat[f] || sflag <= 1) \ + printf(m, (unsigned long long)tcpstat[f], plural(tcpstat[f])) +#define p2(f1, f2, m) if (tcpstat[f1] || tcpstat[f2] || sflag <= 1) \ + printf(m, (unsigned long long)tcpstat[f1], plural(tcpstat[f1]), \ + (unsigned long long)tcpstat[f2], plural(tcpstat[f2])) +#define p2s(f1, f2, m) if (tcpstat[f1] || tcpstat[f2] || sflag <= 1) \ + printf(m, (unsigned long long)tcpstat[f1], plural(tcpstat[f1]), \ + (unsigned long long)tcpstat[f2]) +#define p3(f, m) if (tcpstat[f] || sflag <= 1) \ + printf(m, (unsigned long long)tcpstat[f], plurales(tcpstat[f])) + + p(TCP_STAT_SNDTOTAL, "\t%llu packet%s sent\n"); + p2(TCP_STAT_SNDPACK,TCP_STAT_SNDBYTE, "\t\t%llu data packet%s (%llu byte%s)\n"); - p2(tcps_sndrexmitpack, tcps_sndrexmitbyte, + p2(TCP_STAT_SNDREXMITPACK, TCP_STAT_SNDREXMITBYTE, "\t\t%llu data packet%s (%llu byte%s) retransmitted\n"); - p2s(tcps_sndacks, tcps_delack, + p2s(TCP_STAT_SNDACKS, TCP_STAT_DELACK, "\t\t%llu ack-only packet%s (%llu delayed)\n"); - p(tcps_sndurg, "\t\t%llu URG only packet%s\n"); - p(tcps_sndprobe, "\t\t%llu window probe packet%s\n"); - p(tcps_sndwinup, "\t\t%llu window update packet%s\n"); - p(tcps_sndctrl, "\t\t%llu control packet%s\n"); - p(tcps_selfquench, + p(TCP_STAT_SNDURG, "\t\t%llu URG only packet%s\n"); + p(TCP_STAT_SNDPROBE, "\t\t%llu window probe packet%s\n"); + p(TCP_STAT_SNDWINUP, "\t\t%llu window update packet%s\n"); + p(TCP_STAT_SNDCTRL, "\t\t%llu control packet%s\n"); + p(TCP_STAT_SELFQUENCH, "\t\t%llu send attempt%s resulted in self-quench\n"); - p(tcps_rcvtotal, "\t%llu packet%s received\n"); - p2(tcps_rcvackpack, tcps_rcvackbyte, + p(TCP_STAT_RCVTOTAL, "\t%llu packet%s received\n"); + p2(TCP_STAT_RCVACKPACK, TCP_STAT_RCVACKBYTE, "\t\t%llu ack%s (for %llu byte%s)\n"); - p(tcps_rcvdupack, "\t\t%llu duplicate ack%s\n"); - p(tcps_rcvacktoomuch, "\t\t%llu ack%s for unsent data\n"); - p2(tcps_rcvpack, tcps_rcvbyte, + p(TCP_STAT_RCVDUPACK, "\t\t%llu duplicate ack%s\n"); + p(TCP_STAT_RCVACKTOOMUCH, "\t\t%llu ack%s for unsent data\n"); + p2(TCP_STAT_RCVPACK, TCP_STAT_RCVBYTE, "\t\t%llu packet%s (%llu byte%s) received in-sequence\n"); - p2(tcps_rcvduppack, tcps_rcvdupbyte, + p2(TCP_STAT_RCVDUPPACK, TCP_STAT_RCVDUPBYTE, "\t\t%llu completely duplicate packet%s (%llu byte%s)\n"); - p(tcps_pawsdrop, "\t\t%llu old duplicate packet%s\n"); - p2(tcps_rcvpartduppack, tcps_rcvpartdupbyte, + p(TCP_STAT_PAWSDROP, "\t\t%llu old duplicate packet%s\n"); + p2(TCP_STAT_RCVPARTDUPPACK, TCP_STAT_RCVPARTDUPBYTE, "\t\t%llu packet%s with some dup. data (%llu byte%s duped)\n"); - p2(tcps_rcvoopack, tcps_rcvoobyte, + p2(TCP_STAT_RCVOOPACK, TCP_STAT_RCVOOBYTE, "\t\t%llu out-of-order packet%s (%llu byte%s)\n"); - p2(tcps_rcvpackafterwin, tcps_rcvbyteafterwin, + p2(TCP_STAT_RCVPACKAFTERWIN, TCP_STAT_RCVBYTEAFTERWIN, "\t\t%llu packet%s (%llu byte%s) of data after window\n"); - p(tcps_rcvwinprobe, "\t\t%llu window probe%s\n"); - p(tcps_rcvwinupd, "\t\t%llu window update packet%s\n"); - p(tcps_rcvafterclose, "\t\t%llu packet%s received after close\n"); - p(tcps_rcvbadsum, "\t\t%llu discarded for bad checksum%s\n"); - p(tcps_rcvbadoff, "\t\t%llu discarded for bad header offset field%s\n"); - ps(tcps_rcvshort, "\t\t%llu discarded because packet too short\n"); - p(tcps_connattempt, "\t%llu connection request%s\n"); - p(tcps_accepts, "\t%llu connection accept%s\n"); - p(tcps_connects, + p(TCP_STAT_RCVWINPROBE, "\t\t%llu window probe%s\n"); + p(TCP_STAT_RCVWINUPD, "\t\t%llu window update packet%s\n"); + p(TCP_STAT_RCVAFTERCLOSE, "\t\t%llu packet%s received after close\n"); + p(TCP_STAT_RCVBADSUM, "\t\t%llu discarded for bad checksum%s\n"); + p(TCP_STAT_RCVBADOFF, "\t\t%llu discarded for bad header offset field%s\n"); + ps(TCP_STAT_RCVSHORT, "\t\t%llu discarded because packet too short\n"); + p(TCP_STAT_CONNATTEMPT, "\t%llu connection request%s\n"); + p(TCP_STAT_ACCEPTS, "\t%llu connection accept%s\n"); + p(TCP_STAT_CONNECTS, "\t%llu connection%s established (including accepts)\n"); - p2(tcps_closed, tcps_drops, + p2(TCP_STAT_CLOSED, TCP_STAT_DROPS, "\t%llu connection%s closed (including %llu drop%s)\n"); - p(tcps_conndrops, "\t%llu embryonic connection%s dropped\n"); - p(tcps_delayed_free, "\t%llu delayed free%s of tcpcb\n"); - p2(tcps_rttupdated, tcps_segstimed, + p(TCP_STAT_CONNDROPS, "\t%llu embryonic connection%s dropped\n"); + p(TCP_STAT_DELAYED_FREE, "\t%llu delayed free%s of tcpcb\n"); + p2(TCP_STAT_RTTUPDATED, TCP_STAT_SEGSTIMED, "\t%llu segment%s updated rtt (of %llu attempt%s)\n"); - p(tcps_rexmttimeo, "\t%llu retransmit timeout%s\n"); - p(tcps_timeoutdrop, + p(TCP_STAT_REXMTTIMEO, "\t%llu retransmit timeout%s\n"); + p(TCP_STAT_TIMEOUTDROP, "\t\t%llu connection%s dropped by rexmit timeout\n"); - p2(tcps_persisttimeo, tcps_persistdrops, + p2(TCP_STAT_PERSISTTIMEO, TCP_STAT_PERSISTDROPS, "\t%llu persist timeout%s (resulting in %llu dropped " "connection%s)\n"); - p(tcps_keeptimeo, "\t%llu keepalive timeout%s\n"); - p(tcps_keepprobe, "\t\t%llu keepalive probe%s sent\n"); - p(tcps_keepdrops, "\t\t%llu connection%s dropped by keepalive\n"); - p(tcps_predack, "\t%llu correct ACK header prediction%s\n"); - p(tcps_preddat, "\t%llu correct data packet header prediction%s\n"); - p3(tcps_pcbhashmiss, "\t%llu PCB hash miss%s\n"); - ps(tcps_noport, "\t%llu dropped due to no socket\n"); - p(tcps_connsdrained, "\t%llu connection%s drained due to memory " + p(TCP_STAT_KEEPTIMEO, "\t%llu keepalive timeout%s\n"); + p(TCP_STAT_KEEPPROBE, "\t\t%llu keepalive probe%s sent\n"); + p(TCP_STAT_KEEPDROPS, "\t\t%llu connection%s dropped by keepalive\n"); + p(TCP_STAT_PREDACK, "\t%llu correct ACK header prediction%s\n"); + p(TCP_STAT_PREDDAT, "\t%llu correct data packet header prediction%s\n"); + p3(TCP_STAT_PCBHASHMISS, "\t%llu PCB hash miss%s\n"); + ps(TCP_STAT_NOPORT, "\t%llu dropped due to no socket\n"); + p(TCP_STAT_CONNSDRAINED, "\t%llu connection%s drained due to memory " "shortage\n"); - p(tcps_pmtublackhole, "\t%llu PMTUD blackhole%s detected\n"); - - p(tcps_badsyn, "\t%llu bad connection attempt%s\n"); - ps(tcps_sc_added, "\t%llu SYN cache entries added\n"); - p(tcps_sc_collisions, "\t\t%llu hash collision%s\n"); - ps(tcps_sc_completed, "\t\t%llu completed\n"); - ps(tcps_sc_aborted, "\t\t%llu aborted (no space to build PCB)\n"); - ps(tcps_sc_timed_out, "\t\t%llu timed out\n"); - ps(tcps_sc_overflowed, "\t\t%llu dropped due to overflow\n"); - ps(tcps_sc_bucketoverflow, "\t\t%llu dropped due to bucket overflow\n"); - ps(tcps_sc_reset, "\t\t%llu dropped due to RST\n"); - ps(tcps_sc_unreach, "\t\t%llu dropped due to ICMP unreachable\n"); - ps(tcps_sc_delayed_free, "\t\t%llu delayed free of SYN cache " + p(TCP_STAT_PMTUBLACKHOLE, "\t%llu PMTUD blackhole%s detected\n"); + + p(TCP_STAT_BADSYN, "\t%llu bad connection attempt%s\n"); + ps(TCP_STAT_SC_ADDED, "\t%llu SYN cache entries added\n"); + p(TCP_STAT_SC_COLLISIONS, "\t\t%llu hash collision%s\n"); + ps(TCP_STAT_SC_COMPLETED, "\t\t%llu completed\n"); + ps(TCP_STAT_SC_ABORTED, "\t\t%llu aborted (no space to build PCB)\n"); + ps(TCP_STAT_SC_TIMED_OUT, "\t\t%llu timed out\n"); + ps(TCP_STAT_SC_OVERFLOWED, "\t\t%llu dropped due to overflow\n"); + ps(TCP_STAT_SC_BUCKETOVERFLOW, "\t\t%llu dropped due to bucket overflow\n"); + ps(TCP_STAT_SC_RESET, "\t\t%llu dropped due to RST\n"); + ps(TCP_STAT_SC_UNREACH, "\t\t%llu dropped due to ICMP unreachable\n"); + ps(TCP_STAT_SC_DELAYED_FREE, "\t\t%llu delayed free of SYN cache " "entries\n"); - p(tcps_sc_retransmitted, "\t%llu SYN,ACK%s retransmitted\n"); - p(tcps_sc_dupesyn, "\t%llu duplicate SYN%s received for entries " + p(TCP_STAT_SC_RETRANSMITTED, "\t%llu SYN,ACK%s retransmitted\n"); + p(TCP_STAT_SC_DUPESYN, "\t%llu duplicate SYN%s received for entries " "already in the cache\n"); - p(tcps_sc_dropped, "\t%llu SYN%s dropped (no route or no space)\n"); - p(tcps_badsig, "\t%llu packet%s with bad signature\n"); - p(tcps_goodsig, "\t%llu packet%s with good signature\n"); + p(TCP_STAT_SC_DROPPED, "\t%llu SYN%s dropped (no route or no space)\n"); + p(TCP_STAT_BADSIG, "\t%llu packet%s with bad signature\n"); + p(TCP_STAT_GOODSIG, "\t%llu packet%s with good signature\n"); - p(tcps_ecn_shs, "\t%llu sucessful ECN handshake%s\n"); - p(tcps_ecn_ce, "\t%llu packet%s with ECN CE bit\n"); - p(tcps_ecn_ect, "\t%llu packet%s ECN ECT(0) bit\n"); + p(TCP_STAT_ECN_SHS, "\t%llu sucessful ECN handshake%s\n"); + p(TCP_STAT_ECN_CE, "\t%llu packet%s with ECN CE bit\n"); + p(TCP_STAT_ECN_ECT, "\t%llu packet%s ECN ECT(0) bit\n"); #undef p #undef ps #undef p2 diff --git a/usr.bin/systat/tcp.c b/usr.bin/systat/tcp.c index ea2ce682683..c1cb9c247e7 100644 --- a/usr.bin/systat/tcp.c +++ b/usr.bin/systat/tcp.c @@ -1,4 +1,4 @@ -/* $NetBSD: tcp.c,v 1.12 2006/10/22 16:43:24 christos Exp $ */ +/* $NetBSD: tcp.c,v 1.13 2008/04/08 01:03:58 thorpej Exp $ */ /* * Copyright (c) 1999, 2000 Andrew Doran <ad@NetBSD.org> @@ -29,7 +29,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: tcp.c,v 1.12 2006/10/22 16:43:24 christos Exp $"); +__RCSID("$NetBSD: tcp.c,v 1.13 2008/04/08 01:03:58 thorpej Exp $"); #endif /* not lint */ #include <sys/param.h> @@ -51,7 +51,7 @@ __RCSID("$NetBSD: tcp.c,v 1.12 2006/10/22 16:43:24 christos Exp $"); #define LHD(row, str) mvwprintw(wnd, row, 10, str) #define RHD(row, str) mvwprintw(wnd, row, 45, str) #define SHOW(row, col, stat) \ - mvwprintw(wnd, row, col, "%9llu", (unsigned long long)curstat.stat) + mvwprintw(wnd, row, col, "%9llu", (unsigned long long)curstat[stat]) enum update { UPDATE_TIME, @@ -60,9 +60,9 @@ enum update { }; static enum update update = UPDATE_TIME; -static struct tcpstat curstat; -static struct tcpstat newstat; -static struct tcpstat oldstat; +static uint64_t curstat[TCP_NSTATS]; +static uint64_t newstat[TCP_NSTATS]; +static uint64_t oldstat[TCP_NSTATS]; static struct nlist namelist[] = { { .n_name = "_tcpstat" }, @@ -135,18 +135,18 @@ void showtcpsyn(void) { - SHOW(0, 0, tcps_sc_added); - SHOW(1, 0, tcps_sc_completed); - SHOW(2, 0, tcps_sc_timed_out); - SHOW(3, 0, tcps_sc_dupesyn); - SHOW(4, 0, tcps_sc_collisions); - SHOW(5, 0, tcps_sc_retransmitted); - SHOW(6, 0, tcps_sc_aborted); - SHOW(7, 0, tcps_sc_overflowed); - SHOW(8, 0, tcps_sc_reset); - SHOW(9, 0, tcps_sc_unreach); - SHOW(10, 0, tcps_sc_bucketoverflow); - SHOW(11, 0, tcps_sc_dropped); + SHOW(0, 0, TCP_STAT_SC_ADDED); + SHOW(1, 0, TCP_STAT_SC_COMPLETED); + SHOW(2, 0, TCP_STAT_SC_TIMED_OUT); + SHOW(3, 0, TCP_STAT_SC_DUPESYN); + SHOW(4, 0, TCP_STAT_SC_COLLISIONS); + SHOW(5, 0, TCP_STAT_SC_RETRANSMITTED); + SHOW(6, 0, TCP_STAT_SC_ABORTED); + SHOW(7, 0, TCP_STAT_SC_OVERFLOWED); + SHOW(8, 0, TCP_STAT_SC_RESET); + SHOW(9, 0, TCP_STAT_SC_UNREACH); + SHOW(10, 0, TCP_STAT_SC_BUCKETOVERFLOW); + SHOW(11, 0, TCP_STAT_SC_DROPPED); } void @@ -172,43 +172,43 @@ void showtcp(void) { - SHOW(0, 0, tcps_connattempt); - SHOW(1, 0, tcps_accepts); - SHOW(2, 0, tcps_connects); - - SHOW(4, 0, tcps_drops); - SHOW(5, 0, tcps_conndrops); - SHOW(6, 0, tcps_timeoutdrop); - SHOW(7, 0, tcps_keepdrops); - SHOW(8, 0, tcps_persistdrops); - - SHOW(10, 0, tcps_segstimed); - SHOW(11, 0, tcps_rttupdated); - SHOW(12, 0, tcps_delack); - SHOW(13, 0, tcps_rexmttimeo); - SHOW(14, 0, tcps_persisttimeo); - SHOW(15, 0, tcps_keepprobe); - SHOW(16, 0, tcps_keeptimeo); - - SHOW(0, 35, tcps_sndtotal); - SHOW(1, 35, tcps_sndpack); - SHOW(2, 35, tcps_sndrexmitpack); - - SHOW(3, 35, tcps_sndacks); - SHOW(4, 35, tcps_sndprobe); - SHOW(5, 35, tcps_sndwinup); - SHOW(6, 35, tcps_sndurg); - SHOW(7, 35, tcps_sndctrl); - - SHOW(9, 35, tcps_rcvtotal); - SHOW(10, 35, tcps_rcvpack); - SHOW(11, 35, tcps_rcvduppack); - SHOW(12, 35, tcps_rcvpartduppack); - SHOW(13, 35, tcps_rcvoopack); - SHOW(14, 35, tcps_rcvdupack); - SHOW(15, 35, tcps_rcvackpack); - SHOW(16, 35, tcps_rcvwinprobe); - SHOW(17, 35, tcps_rcvwinupd); + SHOW(0, 0, TCP_STAT_CONNATTEMPT); + SHOW(1, 0, TCP_STAT_ACCEPTS); + SHOW(2, 0, TCP_STAT_CONNECTS); + + SHOW(4, 0, TCP_STAT_DROPS); + SHOW(5, 0, TCP_STAT_CONNDROPS); + SHOW(6, 0, TCP_STAT_TIMEOUTDROP); + SHOW(7, 0, TCP_STAT_KEEPDROPS); + SHOW(8, 0, TCP_STAT_PERSISTDROPS); + + SHOW(10, 0, TCP_STAT_SEGSTIMED); + SHOW(11, 0, TCP_STAT_RTTUPDATED); + SHOW(12, 0, TCP_STAT_DELACK); + SHOW(13, 0, TCP_STAT_REXMTTIMEO); + SHOW(14, 0, TCP_STAT_PERSISTTIMEO); + SHOW(15, 0, TCP_STAT_KEEPPROBE); + SHOW(16, 0, TCP_STAT_KEEPTIMEO); + + SHOW(0, 35, TCP_STAT_SNDTOTAL); + SHOW(1, 35, TCP_STAT_SNDPACK); + SHOW(2, 35, TCP_STAT_SNDREXMITPACK); + + SHOW(3, 35, TCP_STAT_SNDACKS); + SHOW(4, 35, TCP_STAT_SNDPROBE); + SHOW(5, 35, TCP_STAT_SNDWINUP); + SHOW(6, 35, TCP_STAT_SNDURG); + SHOW(7, 35, TCP_STAT_SNDCTRL); + + SHOW(9, 35, TCP_STAT_RCVTOTAL); + SHOW(10, 35, TCP_STAT_RCVPACK); + SHOW(11, 35, TCP_STAT_RCVDUPPACK); + SHOW(12, 35, TCP_STAT_RCVPARTDUPPACK); + SHOW(13, 35, TCP_STAT_RCVOOPACK); + SHOW(14, 35, TCP_STAT_RCVDUPACK); + SHOW(15, 35, TCP_STAT_RCVACKPACK); + SHOW(16, 35, TCP_STAT_RCVWINPROBE); + SHOW(17, 35, TCP_STAT_RCVWINUPD); } int @@ -231,51 +231,22 @@ inittcp(void) void fetchtcp(void) { + int i; - KREAD((void *)namelist[0].n_value, &newstat, sizeof(newstat)); - - ADJINETCTR(curstat, oldstat, newstat, tcps_connattempt); - ADJINETCTR(curstat, oldstat, newstat, tcps_accepts); - ADJINETCTR(curstat, oldstat, newstat, tcps_connects); - ADJINETCTR(curstat, oldstat, newstat, tcps_drops); - ADJINETCTR(curstat, oldstat, newstat, tcps_conndrops); - ADJINETCTR(curstat, oldstat, newstat, tcps_timeoutdrop); - ADJINETCTR(curstat, oldstat, newstat, tcps_keepdrops); - ADJINETCTR(curstat, oldstat, newstat, tcps_persistdrops); - ADJINETCTR(curstat, oldstat, newstat, tcps_segstimed); - ADJINETCTR(curstat, oldstat, newstat, tcps_rttupdated); - ADJINETCTR(curstat, oldstat, newstat, tcps_delack); - ADJINETCTR(curstat, oldstat, newstat, tcps_rexmttimeo); - ADJINETCTR(curstat, oldstat, newstat, tcps_persisttimeo); - ADJINETCTR(curstat, oldstat, newstat, tcps_keepprobe); - ADJINETCTR(curstat, oldstat, newstat, tcps_keeptimeo); - ADJINETCTR(curstat, oldstat, newstat, tcps_sndtotal); - ADJINETCTR(curstat, oldstat, newstat, tcps_sndpack); - ADJINETCTR(curstat, oldstat, newstat, tcps_sndrexmitpack); - ADJINETCTR(curstat, oldstat, newstat, tcps_sndacks); - ADJINETCTR(curstat, oldstat, newstat, tcps_sndprobe); - ADJINETCTR(curstat, oldstat, newstat, tcps_sndwinup); - ADJINETCTR(curstat, oldstat, newstat, tcps_sndurg); - ADJINETCTR(curstat, oldstat, newstat, tcps_sndctrl); - ADJINETCTR(curstat, oldstat, newstat, tcps_rcvtotal); - ADJINETCTR(curstat, oldstat, newstat, tcps_rcvpack); - ADJINETCTR(curstat, oldstat, newstat, tcps_rcvduppack); - ADJINETCTR(curstat, oldstat, newstat, tcps_rcvpartduppack); - ADJINETCTR(curstat, oldstat, newstat, tcps_rcvoopack); - ADJINETCTR(curstat, oldstat, newstat, tcps_rcvdupack); - ADJINETCTR(curstat, oldstat, newstat, tcps_rcvackpack); - ADJINETCTR(curstat, oldstat, newstat, tcps_rcvwinprobe); - ADJINETCTR(curstat, oldstat, newstat, tcps_rcvwinupd); + KREAD((void *)namelist[0].n_value, newstat, sizeof(newstat)); + + for (i = 0; i < TCP_NSTATS; i++) + xADJINETCTR(curstat, oldstat, newstat, i); if (update == UPDATE_TIME) - memcpy(&oldstat, &newstat, sizeof(oldstat)); + memcpy(oldstat, newstat, sizeof(oldstat)); } void tcp_boot(char *args) { - memset(&oldstat, 0, sizeof(oldstat)); + memset(oldstat, 0, sizeof(oldstat)); update = UPDATE_BOOT; } @@ -284,7 +255,7 @@ tcp_run(char *args) { if (update != UPDATE_RUN) { - memcpy(&oldstat, &newstat, sizeof(oldstat)); + memcpy(oldstat, newstat, sizeof(oldstat)); update = UPDATE_RUN; } } @@ -294,7 +265,7 @@ tcp_time(char *args) { if (update != UPDATE_TIME) { - memcpy(&oldstat, &newstat, sizeof(oldstat)); + memcpy(oldstat, newstat, sizeof(oldstat)); update = UPDATE_TIME; } } @@ -304,5 +275,5 @@ tcp_zero(char *args) { if (update == UPDATE_RUN) - memcpy(&oldstat, &newstat, sizeof(oldstat)); + memcpy(oldstat, newstat, sizeof(oldstat)); } |
