diff options
-rw-r--r-- | debug.c | 160 | ||||
-rw-r--r-- | icmp_var.h | 18 | ||||
-rw-r--r-- | if.h | 20 | ||||
-rw-r--r-- | ip.h | 37 | ||||
-rw-r--r-- | ip_icmp.c | 14 | ||||
-rw-r--r-- | ip_input.c | 21 | ||||
-rw-r--r-- | ip_output.c | 7 | ||||
-rw-r--r-- | libslirp.h | 1 | ||||
-rw-r--r-- | mbuf.c | 5 | ||||
-rw-r--r-- | mbuf.h | 11 | ||||
-rw-r--r-- | slirp.h | 11 | ||||
-rw-r--r-- | tcp_input.c | 48 | ||||
-rw-r--r-- | tcp_output.c | 23 | ||||
-rw-r--r-- | tcp_subr.c | 7 | ||||
-rw-r--r-- | tcp_timer.c | 11 | ||||
-rw-r--r-- | tcp_var.h | 63 | ||||
-rw-r--r-- | udp.c | 11 | ||||
-rw-r--r-- | udp.h | 20 |
18 files changed, 6 insertions, 482 deletions
@@ -10,163 +10,3 @@ FILE *dfd = NULL; int slirp_debug = 0; - -#ifdef LOG_ENABLED -static void ipstats(void) -{ - lprint(" \r\n"); - - lprint("IP stats:\r\n"); - lprint(" %6d total packets received (%d were unaligned)\r\n", - ipstat.ips_total, ipstat.ips_unaligned); - lprint(" %6d with incorrect version\r\n", ipstat.ips_badvers); - lprint(" %6d with bad header checksum\r\n", ipstat.ips_badsum); - lprint(" %6d with length too short (len < sizeof(iphdr))\r\n", - ipstat.ips_tooshort); - lprint(" %6d with length too small (len < ip->len)\r\n", - ipstat.ips_toosmall); - lprint(" %6d with bad header length\r\n", ipstat.ips_badhlen); - lprint(" %6d with bad packet length\r\n", ipstat.ips_badlen); - lprint(" %6d fragments received\r\n", ipstat.ips_fragments); - lprint(" %6d fragments dropped\r\n", ipstat.ips_fragdropped); - lprint(" %6d fragments timed out\r\n", ipstat.ips_fragtimeout); - lprint(" %6d packets reassembled ok\r\n", ipstat.ips_reassembled); - lprint(" %6d outgoing packets fragmented\r\n", ipstat.ips_fragmented); - lprint(" %6d total outgoing fragments\r\n", ipstat.ips_ofragments); - lprint(" %6d with bad protocol field\r\n", ipstat.ips_noproto); - lprint(" %6d total packets delivered\r\n", ipstat.ips_delivered); -} - -static void tcpstats(void) -{ - lprint(" \r\n"); - - lprint("TCP stats:\r\n"); - - lprint(" %6d packets sent\r\n", tcpstat.tcps_sndtotal); - lprint(" %6d data packets (%d bytes)\r\n", tcpstat.tcps_sndpack, - tcpstat.tcps_sndbyte); - lprint(" %6d data packets retransmitted (%d bytes)\r\n", - tcpstat.tcps_sndrexmitpack, tcpstat.tcps_sndrexmitbyte); - lprint(" %6d ack-only packets (%d delayed)\r\n", - tcpstat.tcps_sndacks, tcpstat.tcps_delack); - lprint(" %6d URG only packets\r\n", tcpstat.tcps_sndurg); - lprint(" %6d window probe packets\r\n", tcpstat.tcps_sndprobe); - lprint(" %6d window update packets\r\n", tcpstat.tcps_sndwinup); - lprint(" %6d control (SYN/FIN/RST) packets\r\n", - tcpstat.tcps_sndctrl); - lprint(" %6d times tcp_output did nothing\r\n", - tcpstat.tcps_didnuttin); - - lprint(" %6d packets received\r\n", tcpstat.tcps_rcvtotal); - lprint(" %6d acks (for %d bytes)\r\n", tcpstat.tcps_rcvackpack, - tcpstat.tcps_rcvackbyte); - lprint(" %6d duplicate acks\r\n", tcpstat.tcps_rcvdupack); - lprint(" %6d acks for unsent data\r\n", - tcpstat.tcps_rcvacktoomuch); - lprint(" %6d packets received in sequence (%d bytes)\r\n", - tcpstat.tcps_rcvpack, tcpstat.tcps_rcvbyte); - lprint(" %6d completely duplicate packets (%d bytes)\r\n", - tcpstat.tcps_rcvduppack, tcpstat.tcps_rcvdupbyte); - - lprint( - " %6d packets with some duplicate data (%d bytes duped)\r\n", - tcpstat.tcps_rcvpartduppack, tcpstat.tcps_rcvpartdupbyte); - lprint(" %6d out-of-order packets (%d bytes)\r\n", - tcpstat.tcps_rcvoopack, tcpstat.tcps_rcvoobyte); - lprint(" %6d packets of data after window (%d bytes)\r\n", - tcpstat.tcps_rcvpackafterwin, tcpstat.tcps_rcvbyteafterwin); - lprint(" %6d window probes\r\n", tcpstat.tcps_rcvwinprobe); - lprint(" %6d window update packets\r\n", tcpstat.tcps_rcvwinupd); - lprint(" %6d packets received after close\r\n", - tcpstat.tcps_rcvafterclose); - lprint(" %6d discarded for bad checksums\r\n", - tcpstat.tcps_rcvbadsum); - lprint(" %6d discarded for bad header offset fields\r\n", - tcpstat.tcps_rcvbadoff); - - lprint(" %6d connection requests\r\n", tcpstat.tcps_connattempt); - lprint(" %6d connection accepts\r\n", tcpstat.tcps_accepts); - lprint(" %6d connections established (including accepts)\r\n", - tcpstat.tcps_connects); - lprint(" %6d connections closed (including %d drop)\r\n", - tcpstat.tcps_closed, tcpstat.tcps_drops); - lprint(" %6d embryonic connections dropped\r\n", tcpstat.tcps_conndrops); - lprint(" %6d segments we tried to get rtt (%d succeeded)\r\n", - tcpstat.tcps_segstimed, tcpstat.tcps_rttupdated); - lprint(" %6d retransmit timeouts\r\n", tcpstat.tcps_rexmttimeo); - lprint(" %6d connections dropped by rxmt timeout\r\n", - tcpstat.tcps_timeoutdrop); - lprint(" %6d persist timeouts\r\n", tcpstat.tcps_persisttimeo); - lprint(" %6d keepalive timeouts\r\n", tcpstat.tcps_keeptimeo); - lprint(" %6d keepalive probes sent\r\n", tcpstat.tcps_keepprobe); - lprint(" %6d connections dropped by keepalive\r\n", - tcpstat.tcps_keepdrops); - lprint(" %6d correct ACK header predictions\r\n", tcpstat.tcps_predack); - lprint(" %6d correct data packet header predictions\n", - tcpstat.tcps_preddat); - lprint(" %6d TCP cache misses\r\n", tcpstat.tcps_socachemiss); -} - -static void udpstats(void) -{ - lprint(" \r\n"); - - lprint("UDP stats:\r\n"); - lprint(" %6d datagrams received\r\n", udpstat.udps_ipackets); - lprint(" %6d with packets shorter than header\r\n", udpstat.udps_hdrops); - lprint(" %6d with bad checksums\r\n", udpstat.udps_badsum); - lprint(" %6d with data length larger than packet\r\n", - udpstat.udps_badlen); - lprint(" %6d UDP socket cache misses\r\n", udpstat.udpps_pcbcachemiss); - lprint(" %6d datagrams sent\r\n", udpstat.udps_opackets); -} - -static void icmpstats(void) -{ - lprint(" \r\n"); - lprint("ICMP stats:\r\n"); - lprint(" %6d ICMP packets received\r\n", icmpstat.icps_received); - lprint(" %6d were too short\r\n", icmpstat.icps_tooshort); - lprint(" %6d with bad checksums\r\n", icmpstat.icps_checksum); - lprint(" %6d with type not supported\r\n", icmpstat.icps_notsupp); - lprint(" %6d with bad type feilds\r\n", icmpstat.icps_badtype); - lprint(" %6d ICMP packets sent in reply\r\n", icmpstat.icps_reflect); -} - -static void mbufstats(void) -{ - struct mbuf *m; - int i; - - lprint(" \r\n"); - - lprint("Mbuf stats:\r\n"); - - lprint(" %6d mbufs allocated (%d max)\r\n", mbuf_alloced, mbuf_max); - - i = 0; - for (m = m_freelist.m_next; m != &m_freelist; m = m->m_next) - i++; - lprint(" %6d mbufs on free list\r\n", i); - - i = 0; - for (m = m_usedlist.m_next; m != &m_usedlist; m = m->m_next) - i++; - lprint(" %6d mbufs on used list\r\n", i); - lprint(" %6d mbufs queued as packets\r\n\r\n", if_queued); -} -#endif - -void slirp_stats(void) -{ -#ifdef LOG_ENABLED - ipstats(); - tcpstats(); - udpstats(); - icmpstats(); - mbufstats(); -#else - lprint("SLIRP statistics code not compiled.\n"); -#endif -} @@ -34,20 +34,6 @@ #define _NETINET_ICMP_VAR_H_ /* - * Variables related to this implementation - * of the internet control message protocol. - */ -struct icmpstat { - /* statistics related to input messages processed */ - u_long icps_received; /* #ICMP packets received */ - u_long icps_tooshort; /* packet < ICMP_MINLEN */ - u_long icps_checksum; /* bad checksum */ - u_long icps_notsupp; /* #ICMP packets not supported */ - u_long icps_badtype; /* #with bad type feild */ - u_long icps_reflect; /* number of responses */ -}; - -/* * Names for ICMP sysctl objects */ #define ICMPCTL_MASKREPL 1 /* allow replies to netmask requests */ @@ -59,8 +45,4 @@ struct icmpstat { { 0, 0 }, { "maskrepl", CTLTYPE_INT }, { "stats", CTLTYPE_STRUCT }, \ } -#ifdef LOG_ENABLED -extern struct icmpstat icmpstat; -#endif - #endif @@ -28,24 +28,4 @@ extern struct mbuf *next_m; #define ifs_init(ifm) ((ifm)->ifs_next = (ifm)->ifs_prev = (ifm)) -#ifdef LOG_ENABLED -/* Interface statistics */ -struct slirp_ifstats { - u_int out_pkts; /* Output packets */ - u_int out_bytes; /* Output bytes */ - u_int out_errpkts; /* Output Error Packets */ - u_int out_errbytes; /* Output Error Bytes */ - u_int in_pkts; /* Input packets */ - u_int in_bytes; /* Input bytes */ - u_int in_errpkts; /* Input Error Packets */ - u_int in_errbytes; /* Input Error Bytes */ - - u_int bytes_saved; /* Number of bytes that compression "saved" */ - /* ie: number of bytes that didn't need to be sent over the link - * because of compression */ - - u_int in_mbad; /* Bad incoming packets */ -}; -#endif - #endif @@ -250,43 +250,6 @@ struct ipoption { int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */ }; -#ifdef LOG_ENABLED -/* - * Structure attached to inpcb.ip_moptions and - * passed to ip_output when IP multicast options are in use. - */ - -struct ipstat { - u_long ips_total; /* total packets received */ - u_long ips_badsum; /* checksum bad */ - u_long ips_tooshort; /* packet too short */ - u_long ips_toosmall; /* not enough data */ - u_long ips_badhlen; /* ip header length < data size */ - u_long ips_badlen; /* ip length < ip header length */ - u_long ips_fragments; /* fragments received */ - u_long ips_fragdropped; /* frags dropped (dups, out of space) */ - u_long ips_fragtimeout; /* fragments timed out */ - u_long ips_forward; /* packets forwarded */ - u_long ips_cantforward; /* packets rcvd for unreachable dest */ - u_long ips_redirectsent; /* packets forwarded on same net */ - u_long ips_noproto; /* unknown or unsupported protocol */ - u_long ips_delivered; /* datagrams delivered to upper level*/ - u_long ips_localout; /* total ip packets generated here */ - u_long ips_odropped; /* lost packets due to nobufs, etc. */ - u_long ips_reassembled; /* total packets reassembled ok */ - u_long ips_fragmented; /* datagrams successfully fragmented */ - u_long ips_ofragments; /* output fragments created */ - u_long ips_cantfrag; /* don't fragment flag was set, etc. */ - u_long ips_badoptions; /* error in option processing */ - u_long ips_noroute; /* packets discarded due to no route */ - u_long ips_badvers; /* ip version != 4 */ - u_long ips_rawout; /* total raw ip packets generated */ - u_long ips_unaligned; /* times the ip packet was not aligned */ -}; - -extern struct ipstat ipstat; -#endif - extern struct ipq ipq; /* ip reass. queue */ extern u_int16_t ip_id; /* ip packet ctr, for ids */ @@ -33,10 +33,6 @@ #include "slirp.h" #include "ip_icmp.h" -#ifdef LOG_ENABLED -struct icmpstat icmpstat; -#endif - /* The message sent when emulating PING */ /* Be nice and tell them it's just a pseudo-ping packet */ static const char icmp_ping_msg[] = @@ -79,14 +75,11 @@ void icmp_input(struct mbuf *m, int hlen) DEBUG_ARG("m = %lx", (long)m); DEBUG_ARG("m_len = %d", m->m_len); - STAT(icmpstat.icps_received++); - /* * Locate icmp structure in mbuf, and check * that its not corrupted and of at least minimum length. */ if (icmplen < ICMP_MINLEN) { /* min 8 bytes payload */ - STAT(icmpstat.icps_tooshort++); freeit: m_freem(m); goto end_error; @@ -96,7 +89,6 @@ void icmp_input(struct mbuf *m, int hlen) m->m_data += hlen; icp = mtod(m, struct icmp *); if (cksum(m, icmplen)) { - STAT(icmpstat.icps_checksum++); goto freeit; } m->m_len += hlen; @@ -162,12 +154,10 @@ void icmp_input(struct mbuf *m, int hlen) case ICMP_TSTAMP: case ICMP_MASKREQ: case ICMP_REDIRECT: - STAT(icmpstat.icps_notsupp++); m_freem(m); break; default: - STAT(icmpstat.icps_badtype++); m_freem(m); } /* swith */ @@ -311,8 +301,6 @@ void icmp_error(struct mbuf *msrc, u_char type, u_char code, int minsize, (void)ip_output((struct socket *)NULL, m); - STAT(icmpstat.icps_reflect++); - end_error: return; } @@ -365,6 +353,4 @@ void icmp_reflect(struct mbuf *m) } (void)ip_output((struct socket *)NULL, m); - - STAT(icmpstat.icps_reflect++); } @@ -42,10 +42,6 @@ #include <osdep.h> #include "ip_icmp.h" -#ifdef LOG_ENABLED -struct ipstat ipstat; -#endif - struct ipq ipq; static struct ip *ip_reass(register struct ip *ip, register struct ipq *fp); @@ -78,24 +74,19 @@ void ip_input(struct mbuf *m) DEBUG_ARG("m = %lx", (long)m); DEBUG_ARG("m_len = %d", m->m_len); - STAT(ipstat.ips_total++); - if (m->m_len < sizeof(struct ip)) { - STAT(ipstat.ips_toosmall++); return; } ip = mtod(m, struct ip *); if (ip->ip_v != IPVERSION) { - STAT(ipstat.ips_badvers++); goto bad; } hlen = ip->ip_hl << 2; if (hlen < sizeof(struct ip) || hlen > m->m_len) { /* min header length */ - STAT(ipstat.ips_badhlen++); /* or packet too short */ - goto bad; + goto bad; /* or packet too short */ } /* keep ip header intact for ICMP reply @@ -103,7 +94,6 @@ void ip_input(struct mbuf *m) * if (ip->ip_sum) { */ if (cksum(m, hlen)) { - STAT(ipstat.ips_badsum++); goto bad; } @@ -112,7 +102,6 @@ void ip_input(struct mbuf *m) */ NTOHS(ip->ip_len); if (ip->ip_len < hlen) { - STAT(ipstat.ips_badlen++); goto bad; } NTOHS(ip->ip_id); @@ -125,7 +114,6 @@ void ip_input(struct mbuf *m) * Drop packet if shorter than we expect. */ if (m->m_len < ip->ip_len) { - STAT(ipstat.ips_tooshort++); goto bad; } @@ -206,11 +194,9 @@ void ip_input(struct mbuf *m) * attempt reassembly; if it succeeds, proceed. */ if (ip->ip_tos & 1 || ip->ip_off) { - STAT(ipstat.ips_fragments++); ip = ip_reass(ip, fp); if (ip == NULL) return; - STAT(ipstat.ips_reassembled++); m = dtom(ip); } else if (fp) ip_freef(fp); @@ -221,7 +207,6 @@ void ip_input(struct mbuf *m) /* * Switch out to protocol's input routine. */ - STAT(ipstat.ips_delivered++); switch (ip->ip_p) { case IPPROTO_TCP: tcp_input(m, hlen, (struct socket *)NULL); @@ -233,7 +218,6 @@ void ip_input(struct mbuf *m) icmp_input(m, hlen); break; default: - STAT(ipstat.ips_noproto++); m_free(m); } return; @@ -394,7 +378,6 @@ insert: return ip; dropfrag: - STAT(ipstat.ips_fragdropped++); m_freem(m); return NULL; } @@ -460,7 +443,6 @@ void ip_slowtimo(void) struct ipq *fp = container_of(l, struct ipq, ip_link); l = l->next; if (--fp->ipq_ttl == 0) { - STAT(ipstat.ips_fragtimeout++); ip_freef(fp); } } @@ -656,7 +638,6 @@ int ip_dooptions(m) struct mbuf *m; return (0); bad : icmp_error(m, type, code, 0, 0); -STAT(ipstat.ips_badoptions++); return (1); } diff --git a/ip_output.c b/ip_output.c index d0d4003..865a807 100644 --- a/ip_output.c +++ b/ip_output.c @@ -71,7 +71,6 @@ int ip_output(struct socket *so, struct mbuf *m0) ip->ip_off &= IP_DF; ip->ip_id = htons(ip_id++); ip->ip_hl = hlen >> 2; - STAT(ipstat.ips_localout++); /* * If small enough for interface, can just send directly. @@ -92,7 +91,6 @@ int ip_output(struct socket *so, struct mbuf *m0) */ if (ip->ip_off & IP_DF) { error = -1; - STAT(ipstat.ips_cantfrag++); goto bad; } @@ -117,7 +115,6 @@ int ip_output(struct socket *so, struct mbuf *m0) m = m_get(); if (m == NULL) { error = -1; - STAT(ipstat.ips_odropped++); goto sendorfree; } m->m_data += IF_MAXLINKHDR; @@ -144,7 +141,6 @@ int ip_output(struct socket *so, struct mbuf *m0) mhip->ip_sum = cksum(m, mhlen); *mnext = m; mnext = &m->m_nextpkt; - STAT(ipstat.ips_ofragments++); } /* * Update first fragment by trimming what's been copied out @@ -165,9 +161,6 @@ int ip_output(struct socket *so, struct mbuf *m0) else m_freem(m); } - - if (error == 0) - STAT(ipstat.ips_fragmented++); } done: @@ -26,7 +26,6 @@ int slirp_remove_hostfwd(int is_udp, struct in_addr host_addr, int host_port); int slirp_add_exec(int do_pty, const void *args, struct in_addr guest_addr, int guest_port); -void slirp_stats(void); void slirp_connection_info(Monitor *mon); void slirp_socket_recv(struct in_addr guest_addr, int guest_port, @@ -17,10 +17,9 @@ #include <slirp.h> -int mbuf_alloced = 0; +static int mbuf_alloced; struct mbuf m_freelist, m_usedlist; #define MBUF_THRESH 30 -int mbuf_max = 0; /* * Find a nice value for msize @@ -56,8 +55,6 @@ struct mbuf *m_get(void) mbuf_alloced++; if (mbuf_alloced > MBUF_THRESH) flags = M_DOFREE; - if (mbuf_alloced > mbuf_max) - mbuf_max = mbuf_alloced; } else { m = m_freelist.m_next; remque(m); @@ -114,18 +114,7 @@ struct mbuf { 0x08 /* when m_free is called on the mbuf, free() \ * it rather than putting it on the free list */ -/* - * Mbuf statistics. XXX - */ - -struct mbstat { - int mbs_alloced; /* Number of mbufs allocated */ -}; - -extern struct mbstat mbstat; -extern int mbuf_alloced; extern struct mbuf m_freelist, m_usedlist; -extern int mbuf_max; void m_init _P((void)); struct mbuf *m_get _P((void)); @@ -3,17 +3,6 @@ //#define DEBUG 1 -// Uncomment the following line to enable SLIRP statistics printing in Qemu -//#define LOG_ENABLED - -#ifdef LOG_ENABLED -#define STAT(expr) expr -#else -#define STAT(expr) \ - do { \ - } while (0) -#endif - #include "config-host.h" #include "slirp_config.h" diff --git a/tcp_input.c b/tcp_input.c index e51be5a..21e8b0a 100644 --- a/tcp_input.c +++ b/tcp_input.c @@ -75,8 +75,6 @@ tcp_seq tcp_iss; /* tcp initial send seq # */ tp->t_flags |= TF_DELACK; \ (tp)->rcv_nxt += (ti)->ti_len; \ flags = (ti)->ti_flags & TH_FIN; \ - STAT(tcpstat.tcps_rcvpack++); \ - STAT(tcpstat.tcps_rcvbyte += (ti)->ti_len); \ if (so->so_emu) { \ if (tcp_emu((so), (m))) \ sbappend((so), (m)); \ @@ -95,8 +93,6 @@ tcp_seq tcp_iss; /* tcp initial send seq # */ tp->t_flags |= TF_DELACK; \ (tp)->rcv_nxt += (ti)->ti_len; \ flags = (ti)->ti_flags & TH_FIN; \ - STAT(tcpstat.tcps_rcvpack++); \ - STAT(tcpstat.tcps_rcvbyte += (ti)->ti_len); \ if (so->so_emu) { \ if (tcp_emu((so), (m))) \ sbappend(so, (m)); \ @@ -146,8 +142,6 @@ static int tcp_reass(register struct tcpcb *tp, register struct tcpiphdr *ti, i = q->ti_seq + q->ti_len - ti->ti_seq; if (i > 0) { if (i >= ti->ti_len) { - STAT(tcpstat.tcps_rcvduppack++); - STAT(tcpstat.tcps_rcvdupbyte += ti->ti_len); m_freem(m); /* * Try to present any queued data @@ -163,8 +157,6 @@ static int tcp_reass(register struct tcpcb *tp, register struct tcpiphdr *ti, } q = tcpiphdr_next(q); } - STAT(tcpstat.tcps_rcvoopack++); - STAT(tcpstat.tcps_rcvoobyte += ti->ti_len); ti->ti_mbuf = m; /* @@ -264,8 +256,6 @@ void tcp_input(struct mbuf *m, int iphlen, struct socket *inso) goto cont_conn; } - - STAT(tcpstat.tcps_rcvtotal++); /* * Get IP and TCP header together in first mbuf. * Note: IP leaves IP header in first mbuf. @@ -296,7 +286,6 @@ void tcp_input(struct mbuf *m, int iphlen, struct socket *inso) ti->ti_len = htons((u_int16_t)tlen); len = sizeof(struct ip) + tlen; if (cksum(m, len)) { - STAT(tcpstat.tcps_rcvbadsum++); goto drop; } @@ -306,7 +295,6 @@ void tcp_input(struct mbuf *m, int iphlen, struct socket *inso) */ off = ti->ti_off << 2; if (off < sizeof(struct tcphdr) || off > tlen) { - STAT(tcpstat.tcps_rcvbadoff++); goto drop; } tlen -= off; @@ -352,7 +340,6 @@ findso: so = solookup(&tcb, ti->ti_src, ti->ti_sport, ti->ti_dst, ti->ti_dport); if (so) tcp_last_so = so; - STAT(tcpstat.tcps_socachemiss++); } /* @@ -458,12 +445,9 @@ findso: /* * this is a pure ack for outstanding data. */ - STAT(tcpstat.tcps_predack++); if (tp->t_rtt && SEQ_GT(ti->ti_ack, tp->t_rtseq)) tcp_xmit_timer(tp, tp->t_rtt); acked = ti->ti_ack - tp->snd_una; - STAT(tcpstat.tcps_rcvackpack++); - STAT(tcpstat.tcps_rcvackbyte += acked); sbdrop(&so->so_snd, acked); tp->snd_una = ti->ti_ack; m_freem(m); @@ -499,10 +483,7 @@ findso: * with nothing on the reassembly queue and * we have enough buffer space to take it. */ - STAT(tcpstat.tcps_preddat++); tp->rcv_nxt += ti->ti_len; - STAT(tcpstat.tcps_rcvpack++); - STAT(tcpstat.tcps_rcvbyte += ti->ti_len); /* * Add data to socket buffer. */ @@ -658,7 +639,6 @@ findso: tp->t_flags |= TF_ACKNOW; tp->t_state = TCPS_SYN_RECEIVED; tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; - STAT(tcpstat.tcps_accepts++); goto trimthenstep6; } /* case TCPS_LISTEN */ @@ -698,7 +678,6 @@ findso: tcp_rcvseqinit(tp); tp->t_flags |= TF_ACKNOW; if (tiflags & TH_ACK && SEQ_GT(tp->snd_una, tp->iss)) { - STAT(tcpstat.tcps_connects++); soisfconnected(so); tp->t_state = TCPS_ESTABLISHED; @@ -724,8 +703,6 @@ findso: m_adj(m, -todrop); ti->ti_len = tp->rcv_wnd; tiflags &= ~TH_FIN; - STAT(tcpstat.tcps_rcvpackafterwin++); - STAT(tcpstat.tcps_rcvbyteafterwin += todrop); } tp->snd_wl1 = ti->ti_seq - 1; tp->rcv_up = ti->ti_seq; @@ -766,11 +743,6 @@ findso: */ tp->t_flags |= TF_ACKNOW; todrop = ti->ti_len; - STAT(tcpstat.tcps_rcvduppack++); - STAT(tcpstat.tcps_rcvdupbyte += todrop); - } else { - STAT(tcpstat.tcps_rcvpartduppack++); - STAT(tcpstat.tcps_rcvpartdupbyte += todrop); } m_adj(m, todrop); ti->ti_seq += todrop; @@ -789,7 +761,6 @@ findso: if ((so->so_state & SS_NOFDREF) && tp->t_state > TCPS_CLOSE_WAIT && ti->ti_len) { tp = tcp_close(tp); - STAT(tcpstat.tcps_rcvafterclose++); goto dropwithreset; } @@ -799,9 +770,7 @@ findso: */ todrop = (ti->ti_seq + ti->ti_len) - (tp->rcv_nxt + tp->rcv_wnd); if (todrop > 0) { - STAT(tcpstat.tcps_rcvpackafterwin++); if (todrop >= ti->ti_len) { - STAT(tcpstat.tcps_rcvbyteafterwin += ti->ti_len); /* * If a new connection request is received * while in TIME_WAIT, drop the old connection @@ -823,11 +792,10 @@ findso: */ if (tp->rcv_wnd == 0 && ti->ti_seq == tp->rcv_nxt) { tp->t_flags |= TF_ACKNOW; - STAT(tcpstat.tcps_rcvwinprobe++); - } else + } else { goto dropafterack; - } else - STAT(tcpstat.tcps_rcvbyteafterwin += todrop); + } + } m_adj(m, -todrop); ti->ti_len -= todrop; tiflags &= ~(TH_PUSH | TH_FIN); @@ -851,7 +819,6 @@ findso: case TCPS_FIN_WAIT_2: case TCPS_CLOSE_WAIT: tp->t_state = TCPS_CLOSED; - STAT(tcpstat.tcps_drops++); tp = tcp_close(tp); goto drop; @@ -890,7 +857,6 @@ findso: if (SEQ_GT(tp->snd_una, ti->ti_ack) || SEQ_GT(ti->ti_ack, tp->snd_max)) goto dropwithreset; - STAT(tcpstat.tcps_connects++); tp->t_state = TCPS_ESTABLISHED; /* * The sent SYN is ack'ed with our sequence number +1 @@ -941,7 +907,6 @@ findso: if (SEQ_LEQ(ti->ti_ack, tp->snd_una)) { if (ti->ti_len == 0 && tiwin == tp->snd_wnd) { - STAT(tcpstat.tcps_rcvdupack++); DEBUG_MISC( (dfd, " dup ack m = %lx so = %lx \n", (long)m, (long)so)); /* @@ -1006,12 +971,9 @@ findso: tp->snd_cwnd = tp->snd_ssthresh; tp->t_dupacks = 0; if (SEQ_GT(ti->ti_ack, tp->snd_max)) { - STAT(tcpstat.tcps_rcvacktoomuch++); goto dropafterack; } acked = ti->ti_ack - tp->snd_una; - STAT(tcpstat.tcps_rcvackpack++); - STAT(tcpstat.tcps_rcvackbyte += acked); /* * If transmit timer is running and timed sequence @@ -1132,9 +1094,6 @@ step6: (tp->snd_wl1 == ti->ti_seq && (SEQ_LT(tp->snd_wl2, ti->ti_ack) || (tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd))))) { - /* keep track of pure window updates */ - if (ti->ti_len == 0 && tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd) - STAT(tcpstat.tcps_rcvwinupd++); tp->snd_wnd = tiwin; tp->snd_wl1 = ti->ti_seq; tp->snd_wl2 = ti->ti_ack; @@ -1413,7 +1372,6 @@ static void tcp_xmit_timer(register struct tcpcb *tp, int rtt) DEBUG_ARG("tp = %lx", (long)tp); DEBUG_ARG("rtt = %d", rtt); - STAT(tcpstat.tcps_rttupdated++); if (tp->t_srtt != 0) { /* * srtt is stored as fixed point with 3 bits after the diff --git a/tcp_output.c b/tcp_output.c index e91c15a..1791002 100644 --- a/tcp_output.c +++ b/tcp_output.c @@ -246,8 +246,6 @@ again: /* * No reason to send a segment, just return. */ - STAT(tcpstat.tcps_didnuttin++); - return (0); send: @@ -291,16 +289,6 @@ send: * the template for sends on this connection. */ if (len) { - if (tp->t_force && len == 1) - STAT(tcpstat.tcps_sndprobe++); - else if (SEQ_LT(tp->snd_nxt, tp->snd_max)) { - STAT(tcpstat.tcps_sndrexmitpack++); - STAT(tcpstat.tcps_sndrexmitbyte += len); - } else { - STAT(tcpstat.tcps_sndpack++); - STAT(tcpstat.tcps_sndbyte += len); - } - m = m_get(); if (m == NULL) { error = 1; @@ -321,15 +309,6 @@ send: if (off + len == so->so_snd.sb_cc) flags |= TH_PUSH; } else { - if (tp->t_flags & TF_ACKNOW) - STAT(tcpstat.tcps_sndacks++); - else if (flags & (TH_SYN | TH_FIN | TH_RST)) - STAT(tcpstat.tcps_sndctrl++); - else if (SEQ_GT(tp->snd_up, tp->snd_una)) - STAT(tcpstat.tcps_sndurg++); - else - STAT(tcpstat.tcps_sndwinup++); - m = m_get(); if (m == NULL) { error = 1; @@ -434,7 +413,6 @@ send: if (tp->t_rtt == 0) { tp->t_rtt = 1; tp->t_rtseq = startseq; - STAT(tcpstat.tcps_segstimed++); } } @@ -476,7 +454,6 @@ send: out: return (error); } - STAT(tcpstat.tcps_sndtotal++); /* * Data sent (as far as we can tell). @@ -224,9 +224,7 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err) if (TCPS_HAVERCVDSYN(tp->t_state)) { tp->t_state = TCPS_CLOSED; (void)tcp_output(tp); - STAT(tcpstat.tcps_drops++); - } else - STAT(tcpstat.tcps_conndrops++); + } return (tcp_close(tp)); } @@ -262,7 +260,6 @@ struct tcpcb *tcp_close(struct tcpcb *tp) sbfree(&so->so_rcv); sbfree(&so->so_snd); sofree(so); - STAT(tcpstat.tcps_closed++); return ((struct tcpcb *)0); } @@ -443,8 +440,6 @@ void tcp_connect(struct socket *inso) tcp_template(tp); - STAT(tcpstat.tcps_connattempt++); - tp->t_state = TCPS_SYN_SENT; tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; tp->iss = tcp_iss; diff --git a/tcp_timer.c b/tcp_timer.c index 8044172..a90f08d 100644 --- a/tcp_timer.c +++ b/tcp_timer.c @@ -32,10 +32,6 @@ #include <slirp.h> -#ifdef LOG_ENABLED -struct tcpstat tcpstat; /* tcp statistics */ -#endif - u_int32_t tcp_now; /* for RFC 1323 timestamps */ static struct tcpcb *tcp_timers(register struct tcpcb *tp, int timer); @@ -57,7 +53,6 @@ void tcp_fasttimo(void) (tp->t_flags & TF_DELACK)) { tp->t_flags &= ~TF_DELACK; tp->t_flags |= TF_ACKNOW; - STAT(tcpstat.tcps_delack++); (void)tcp_output(tp); } } @@ -173,7 +168,6 @@ static struct tcpcb *tcp_timers(register struct tcpcb *tp, int timer) * We tried our best, now the connection must die! */ tp->t_rxtshift = TCP_MAXRXTSHIFT; - STAT(tcpstat.tcps_timeoutdrop++); tp = tcp_drop(tp, tp->t_softerror); /* tp->t_softerror : ETIMEDOUT); */ /* XXX */ return (tp); /* XXX */ @@ -185,7 +179,6 @@ static struct tcpcb *tcp_timers(register struct tcpcb *tp, int timer) */ tp->t_rxtshift = 6; } - STAT(tcpstat.tcps_rexmttimeo++); rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift]; TCPT_RANGESET(tp->t_rxtcur, rexmt, (short)tp->t_rttmin, TCPTV_REXMTMAX); /* XXX */ @@ -247,7 +240,6 @@ static struct tcpcb *tcp_timers(register struct tcpcb *tp, int timer) * Force a byte to be output, if possible. */ case TCPT_PERSIST: - STAT(tcpstat.tcps_persisttimeo++); tcp_setpersist(tp); tp->t_force = 1; (void)tcp_output(tp); @@ -259,7 +251,6 @@ static struct tcpcb *tcp_timers(register struct tcpcb *tp, int timer) * or drop connection if idle for too long. */ case TCPT_KEEP: - STAT(tcpstat.tcps_keeptimeo++); if (tp->t_state < TCPS_ESTABLISHED) goto dropit; @@ -278,7 +269,6 @@ static struct tcpcb *tcp_timers(register struct tcpcb *tp, int timer) * by the protocol spec, this requires the * correspondent TCP to respond. */ - STAT(tcpstat.tcps_keepprobe++); tcp_respond(tp, &tp->t_template, (struct mbuf *)NULL, tp->rcv_nxt, tp->snd_una - 1, 0); tp->t_timer[TCPT_KEEP] = TCPTV_KEEPINTVL; @@ -287,7 +277,6 @@ static struct tcpcb *tcp_timers(register struct tcpcb *tp, int timer) break; dropit: - STAT(tcpstat.tcps_keepdrops++); tp = tcp_drop(tp, 0); break; } @@ -157,69 +157,6 @@ struct tcpcb { */ #define TCP_REXMTVAL(tp) (((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar) -#ifdef LOG_ENABLED -/* - * TCP statistics. - * Many of these should be kept per connection, - * but that's inconvenient at the moment. - */ -struct tcpstat { - u_long tcps_connattempt; /* connections initiated */ - u_long tcps_accepts; /* connections accepted */ - u_long tcps_connects; /* connections established */ - u_long tcps_drops; /* connections dropped */ - u_long tcps_conndrops; /* embryonic connections dropped */ - u_long tcps_closed; /* conn. closed (includes drops) */ - u_long tcps_segstimed; /* segs where we tried to get rtt */ - u_long tcps_rttupdated; /* times we succeeded */ - u_long tcps_delack; /* delayed acks sent */ - u_long tcps_timeoutdrop; /* conn. dropped in rxmt timeout */ - u_long tcps_rexmttimeo; /* retransmit timeouts */ - u_long tcps_persisttimeo; /* persist timeouts */ - u_long tcps_keeptimeo; /* keepalive timeouts */ - u_long tcps_keepprobe; /* keepalive probes sent */ - u_long tcps_keepdrops; /* connections dropped in keepalive */ - - u_long tcps_sndtotal; /* total packets sent */ - u_long tcps_sndpack; /* data packets sent */ - u_long tcps_sndbyte; /* data bytes sent */ - u_long tcps_sndrexmitpack; /* data packets retransmitted */ - u_long tcps_sndrexmitbyte; /* data bytes retransmitted */ - u_long tcps_sndacks; /* ack-only packets sent */ - u_long tcps_sndprobe; /* window probes sent */ - u_long tcps_sndurg; /* packets sent with URG only */ - u_long tcps_sndwinup; /* window update-only packets sent */ - u_long tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */ - - u_long tcps_rcvtotal; /* total packets received */ - u_long tcps_rcvpack; /* packets received in sequence */ - u_long tcps_rcvbyte; /* bytes received in sequence */ - u_long tcps_rcvbadsum; /* packets received with ccksum errs */ - u_long tcps_rcvbadoff; /* packets received with bad offset */ - u_long tcps_rcvduppack; /* duplicate-only packets received */ - u_long tcps_rcvdupbyte; /* duplicate-only bytes received */ - u_long tcps_rcvpartduppack; /* packets with some duplicate data */ - u_long tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */ - u_long tcps_rcvoopack; /* out-of-order packets received */ - u_long tcps_rcvoobyte; /* out-of-order bytes received */ - u_long tcps_rcvpackafterwin; /* packets with data after window */ - u_long tcps_rcvbyteafterwin; /* bytes rcvd after window */ - u_long tcps_rcvafterclose; /* packets rcvd after "close" */ - u_long tcps_rcvwinprobe; /* rcvd window probe packets */ - u_long tcps_rcvdupack; /* rcvd duplicate acks */ - u_long tcps_rcvacktoomuch; /* rcvd acks for unsent data */ - u_long tcps_rcvackpack; /* rcvd ack packets */ - u_long tcps_rcvackbyte; /* bytes acked by rcvd acks */ - u_long tcps_rcvwinupd; /* rcvd window update packets */ - u_long tcps_predack; /* times hdr predict ok for acks */ - u_long tcps_preddat; /* times hdr predict ok for data pkts */ - u_long tcps_socachemiss; /* tcp_last_so misses */ - u_long tcps_didnuttin; /* Times tcp_output didn't do anything XXX */ -}; - -extern struct tcpstat tcpstat; /* tcp statistics */ -#endif - extern u_int32_t tcp_now; /* for RFC 1323 timestamps */ #endif @@ -41,10 +41,6 @@ #include <slirp.h> #include "ip_icmp.h" -#ifdef LOG_ENABLED -struct udpstat udpstat; -#endif - struct socket udb; static u_int8_t udp_tos(struct socket *so); @@ -72,8 +68,6 @@ void udp_input(register struct mbuf *m, int iphlen) DEBUG_ARG("m = %lx", (long)m); DEBUG_ARG("iphlen = %d", iphlen); - STAT(udpstat.udps_ipackets++); - /* * Strip IP options, if any; should skip this, * make available to user, and use on returned packets, @@ -99,7 +93,6 @@ void udp_input(register struct mbuf *m, int iphlen) if (ip->ip_len != len) { if (len > ip->ip_len) { - STAT(udpstat.udps_badlen++); goto bad; } m_adj(m, len - ip->ip_len); @@ -121,7 +114,6 @@ void udp_input(register struct mbuf *m, int iphlen) ((struct ipovly *)ip)->ih_x1 = 0; ((struct ipovly *)ip)->ih_len = uh->uh_ulen; if (cksum(m, len + sizeof(struct ip))) { - STAT(udpstat.udps_badsum++); goto bad; } } @@ -163,7 +155,6 @@ void udp_input(register struct mbuf *m, int iphlen) if (tmp == &udb) { so = NULL; } else { - STAT(udpstat.udpps_pcbcachemiss++); udp_last_so = so; } } @@ -278,8 +269,6 @@ int udp_output2(struct socket *so, struct mbuf *m, struct sockaddr_in *saddr, ((struct ip *)ui)->ip_ttl = IPDEFTTL; ((struct ip *)ui)->ip_tos = iptos; - STAT(udpstat.udps_opackets++); - error = ip_output(so, m); return (error); @@ -67,32 +67,12 @@ struct udpiphdr { #define ui_ulen ui_u.uh_ulen #define ui_sum ui_u.uh_sum -#ifdef LOG_ENABLED -struct udpstat { - /* input statistics: */ - u_long udps_ipackets; /* total input packets */ - u_long udps_hdrops; /* packet shorter than header */ - u_long udps_badsum; /* checksum error */ - u_long udps_badlen; /* data length larger than packet */ - u_long udps_noport; /* no socket on port */ - u_long udps_noportbcast; /* of above, arrived as broadcast */ - u_long udps_fullsock; /* not delivered, input socket full */ - u_long udpps_pcbcachemiss; /* input packets missing pcb cache */ - /* output statistics: */ - u_long udps_opackets; /* total output packets */ -}; -#endif - /* * Names for UDP sysctl objects */ #define UDPCTL_CHECKSUM 1 /* checksum UDP packets */ #define UDPCTL_MAXID 2 -#ifdef LOG_ENABLED -extern struct udpstat udpstat; -#endif - extern struct socket udb; struct mbuf; |