Index: qemu/slirp/debug.c =================================================================== --- qemu.orig/slirp/debug.c 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/debug.c 2007-10-24 19:38:20.000000000 +0000 @@ -20,6 +20,7 @@ /* Carry over one item from main.c so that the tty's restored. * Only done when the tty being used is /dev/tty --RedWolf */ +#ifndef CONFIG_QEMU extern struct termios slirp_tty_settings; extern int slirp_tty_restore; @@ -70,7 +71,9 @@ } } #endif +#endif +#ifdef LOG_ENABLED #if 0 /* * Statistic routines @@ -80,7 +83,7 @@ * the link as well. */ -void +static void ttystats(ttyp) struct ttys *ttyp; { @@ -119,8 +122,8 @@ lprint(" %6d bad input packets\r\n", is->in_mbad); } -void -allttystats() +static void +allttystats(void) { struct ttys *ttyp; @@ -129,8 +132,8 @@ } #endif -void -ipstats() +static void +ipstats(void) { lprint(" \r\n"); @@ -153,9 +156,9 @@ lprint(" %6d total packets delivered\r\n", ipstat.ips_delivered); } -#if 0 -void -vjstats() +#ifndef CONFIG_QEMU +static void +vjstats(void) { lprint(" \r\n"); @@ -172,8 +175,8 @@ } #endif -void -tcpstats() +static void +tcpstats(void) { lprint(" \r\n"); @@ -240,8 +243,8 @@ } -void -udpstats() +static void +udpstats(void) { lprint(" \r\n"); @@ -254,8 +257,8 @@ lprint(" %6d datagrams sent\r\n", udpstat.udps_opackets); } -void -icmpstats() +static void +icmpstats(void) { lprint(" \r\n"); lprint("ICMP stats:\r\n"); @@ -267,8 +270,8 @@ lprint(" %6d ICMP packets sent in reply\r\n", icmpstat.icps_reflect); } -void -mbufstats() +static void +mbufstats(void) { struct mbuf *m; int i; @@ -291,8 +294,8 @@ lprint(" %6d mbufs queued as packets\r\n\r\n", if_queued); } -void -sockstats() +static void +sockstats(void) { char buff[256]; int n; @@ -331,8 +334,9 @@ so->so_rcv.sb_cc, so->so_snd.sb_cc); } } +#endif -#if 0 +#ifndef CONFIG_QEMU void slirp_exit(exit_status) int exit_status; @@ -374,3 +378,18 @@ exit(exit_status); } #endif + +void +slirp_stats(void) +{ +#ifdef LOG_ENABLED + ipstats(); + tcpstats(); + udpstats(); + icmpstats(); + mbufstats(); + sockstats(); +#else + lprint("SLIRP statistics not compiled\n"); +#endif +} Index: qemu/slirp/debug.h =================================================================== --- qemu.orig/slirp/debug.h 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/debug.h 2007-10-24 18:45:42.000000000 +0000 @@ -37,14 +37,4 @@ #endif void debug_init _P((char *, int)); -//void ttystats _P((struct ttys *)); -void allttystats _P((void)); -void ipstats _P((void)); -void vjstats _P((void)); -void tcpstats _P((void)); -void udpstats _P((void)); -void icmpstats _P((void)); -void mbufstats _P((void)); -void sockstats _P((void)); -void slirp_exit _P((int)); Index: qemu/slirp/icmp_var.h =================================================================== --- qemu.orig/slirp/icmp_var.h 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/icmp_var.h 2007-10-24 18:45:42.000000000 +0000 @@ -64,6 +64,8 @@ { "stats", CTLTYPE_STRUCT }, \ } +#ifdef LOG_ENABLED extern struct icmpstat icmpstat; +#endif #endif Index: qemu/slirp/ip.h =================================================================== --- qemu.orig/slirp/ip.h 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/ip.h 2007-10-24 18:51:06.000000000 +0000 @@ -272,6 +272,7 @@ 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. @@ -306,8 +307,9 @@ }; extern struct ipstat ipstat; +#endif + extern struct ipq ipq; /* ip reass. queue */ extern u_int16_t ip_id; /* ip packet ctr, for ids */ -extern int ip_defttl; /* default IP ttl */ #endif Index: qemu/slirp/ip_icmp.c =================================================================== --- qemu.orig/slirp/ip_icmp.c 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/ip_icmp.c 2007-10-24 19:38:20.000000000 +0000 @@ -37,7 +37,9 @@ #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 psuedo-ping packet */ @@ -83,14 +85,14 @@ DEBUG_ARG("m = %lx", (long )m); DEBUG_ARG("m_len = %d", m->m_len); - icmpstat.icps_received++; + 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 */ - icmpstat.icps_tooshort++; + STAT(icmpstat.icps_tooshort++); freeit: m_freem(m); goto end_error; @@ -100,7 +102,7 @@ m->m_data += hlen; icp = mtod(m, struct icmp *); if (cksum(m, icmplen)) { - icmpstat.icps_checksum++; + STAT(icmpstat.icps_checksum++); goto freeit; } m->m_len += hlen; @@ -170,12 +172,12 @@ case ICMP_TSTAMP: case ICMP_MASKREQ: case ICMP_REDIRECT: - icmpstat.icps_notsupp++; + STAT(icmpstat.icps_notsupp++); m_freem(m); break; default: - icmpstat.icps_badtype++; + STAT(icmpstat.icps_badtype++); m_freem(m); } /* swith */ @@ -314,7 +316,7 @@ (void ) ip_output((struct socket *)NULL, m); - icmpstat.icps_reflect++; + STAT(icmpstat.icps_reflect++); end_error: return; @@ -371,5 +373,5 @@ (void ) ip_output((struct socket *)NULL, m); - icmpstat.icps_reflect++; + STAT(icmpstat.icps_reflect++); } Index: qemu/slirp/ip_input.c =================================================================== --- qemu.orig/slirp/ip_input.c 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/ip_input.c 2007-10-24 19:38:20.000000000 +0000 @@ -46,7 +46,11 @@ #include "ip_icmp.h" int ip_defttl; + +#ifdef LOG_ENABLED struct ipstat ipstat; +#endif + struct ipq ipq; /* @@ -78,23 +82,23 @@ DEBUG_ARG("m = %lx", (long)m); DEBUG_ARG("m_len = %d", m->m_len); - ipstat.ips_total++; + STAT(ipstat.ips_total++); if (m->m_len < sizeof (struct ip)) { - ipstat.ips_toosmall++; + STAT(ipstat.ips_toosmall++); return; } ip = mtod(m, struct ip *); if (ip->ip_v != IPVERSION) { - ipstat.ips_badvers++; + STAT(ipstat.ips_badvers++); goto bad; } hlen = ip->ip_hl << 2; if (hlenm->m_len) {/* min header length */ - ipstat.ips_badhlen++; /* or packet too short */ + STAT(ipstat.ips_badhlen++); /* or packet too short */ goto bad; } @@ -103,7 +107,7 @@ * if (ip->ip_sum) { */ if(cksum(m,hlen)) { - ipstat.ips_badsum++; + STAT(ipstat.ips_badsum++); goto bad; } @@ -112,7 +116,7 @@ */ NTOHS(ip->ip_len); if (ip->ip_len < hlen) { - ipstat.ips_badlen++; + STAT(ipstat.ips_badlen++); goto bad; } NTOHS(ip->ip_id); @@ -125,7 +129,7 @@ * Drop packet if shorter than we expect. */ if (m->m_len < ip->ip_len) { - ipstat.ips_tooshort++; + STAT(ipstat.ips_tooshort++); goto bad; } /* Should drop packet if mbuf too long? hmmm... */ @@ -192,11 +196,11 @@ * attempt reassembly; if it succeeds, proceed. */ if (((struct ipasfrag *)ip)->ipf_mff & 1 || ip->ip_off) { - ipstat.ips_fragments++; + STAT(ipstat.ips_fragments++); ip = ip_reass((struct ipasfrag *)ip, fp); if (ip == 0) return; - ipstat.ips_reassembled++; + STAT(ipstat.ips_reassembled++); m = dtom(ip); } else if (fp) @@ -208,7 +212,7 @@ /* * Switch out to protocol's input routine. */ - ipstat.ips_delivered++; + STAT(ipstat.ips_delivered++); switch (ip->ip_p) { case IPPROTO_TCP: tcp_input(m, hlen, (struct socket *)NULL); @@ -220,7 +224,7 @@ icmp_input(m, hlen); break; default: - ipstat.ips_noproto++; + STAT(ipstat.ips_noproto++); m_free(m); } return; @@ -385,7 +389,7 @@ return ((struct ip *)ip); dropfrag: - ipstat.ips_fragdropped++; + STAT(ipstat.ips_fragdropped++); m_freem(m); return (0); } @@ -457,7 +461,7 @@ --fp->ipq_ttl; fp = (struct ipq *) fp->next; if (((struct ipq *)(fp->prev))->ipq_ttl == 0) { - ipstat.ips_fragtimeout++; + STAT(ipstat.ips_fragtimeout++); ip_freef((struct ipq *) fp->prev); } } @@ -664,7 +668,7 @@ /* Not yet */ icmp_error(m, type, code, 0, 0); - ipstat.ips_badoptions++; + STAT(ipstat.ips_badoptions++); return (1); } Index: qemu/slirp/ip_output.c =================================================================== --- qemu.orig/slirp/ip_output.c 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/ip_output.c 2007-10-24 19:38:20.000000000 +0000 @@ -80,7 +80,7 @@ ip->ip_off &= IP_DF; ip->ip_id = htons(ip_id++); ip->ip_hl = hlen >> 2; - ipstat.ips_localout++; + STAT(ipstat.ips_localout++); /* * Verify that we have any chance at all of being able to queue @@ -112,7 +112,7 @@ */ if (ip->ip_off & IP_DF) { error = -1; - ipstat.ips_cantfrag++; + STAT(ipstat.ips_cantfrag++); goto bad; } @@ -137,7 +137,7 @@ m = m_get(); if (m == 0) { error = -1; - ipstat.ips_odropped++; + STAT(ipstat.ips_odropped++); goto sendorfree; } m->m_data += if_maxlinkhdr; @@ -170,7 +170,7 @@ mhip->ip_sum = cksum(m, mhlen); *mnext = m; mnext = &m->m_nextpkt; - ipstat.ips_ofragments++; + STAT(ipstat.ips_ofragments++); } /* * Update first fragment by trimming what's been copied out @@ -193,7 +193,7 @@ } if (error == 0) - ipstat.ips_fragmented++; + STAT(ipstat.ips_fragmented++); } done: Index: qemu/slirp/misc.c =================================================================== --- qemu.orig/slirp/misc.c 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/misc.c 2007-10-24 19:38:20.000000000 +0000 @@ -603,6 +603,7 @@ } #endif +#ifndef CONFIG_QEMU int (*lprint_print) _P((void *, const char *, va_list)); char *lprint_ptr, *lprint_ptr2, **lprint_arg; @@ -754,6 +755,7 @@ lprint("Adding emulation for %s to port %d/%d\r\n", buff1, emup->lport, emup->fport); } +#endif #ifdef BAD_SPRINTF Index: qemu/slirp/slirp.h =================================================================== --- qemu.orig/slirp/slirp.h 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/slirp.h 2007-10-24 19:38:20.000000000 +0000 @@ -3,7 +3,16 @@ #define CONFIG_QEMU -#define DEBUG 1 +//#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 #ifndef CONFIG_QEMU #include "version.h" @@ -253,7 +262,19 @@ long gethostid _P((void)); #endif +#ifdef CONFIG_QEMU +static inline void lprint(const char *format, ...) +{ +#ifdef LOG_ENABLED + va_list args; + va_start(args, format); + term_vprintf(format, args); + va_end(args); +#endif +} +#else void lprint _P((const char *, ...)); +#endif extern int do_echo; Index: qemu/slirp/tcp_input.c =================================================================== --- qemu.orig/slirp/tcp_input.c 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/tcp_input.c 2007-10-24 19:38:20.000000000 +0000 @@ -79,8 +79,8 @@ tp->t_flags |= TF_DELACK; \ (tp)->rcv_nxt += (ti)->ti_len; \ flags = (ti)->ti_flags & TH_FIN; \ - tcpstat.tcps_rcvpack++;\ - tcpstat.tcps_rcvbyte += (ti)->ti_len;\ + STAT(tcpstat.tcps_rcvpack++); \ + STAT(tcpstat.tcps_rcvbyte += (ti)->ti_len); \ if (so->so_emu) { \ if (tcp_emu((so),(m))) sbappend((so), (m)); \ } else \ @@ -99,8 +99,8 @@ tp->t_flags |= TF_DELACK; \ (tp)->rcv_nxt += (ti)->ti_len; \ flags = (ti)->ti_flags & TH_FIN; \ - tcpstat.tcps_rcvpack++;\ - tcpstat.tcps_rcvbyte += (ti)->ti_len;\ + STAT(tcpstat.tcps_rcvpack++); \ + STAT(tcpstat.tcps_rcvbyte += (ti)->ti_len); \ if (so->so_emu) { \ if (tcp_emu((so),(m))) sbappend(so, (m)); \ } else \ @@ -150,8 +150,8 @@ i = q->ti_seq + q->ti_len - ti->ti_seq; if (i > 0) { if (i >= ti->ti_len) { - tcpstat.tcps_rcvduppack++; - tcpstat.tcps_rcvdupbyte += ti->ti_len; + STAT(tcpstat.tcps_rcvduppack++); + STAT(tcpstat.tcps_rcvdupbyte += ti->ti_len); m_freem(m); /* * Try to present any queued data @@ -167,8 +167,8 @@ } q = (struct tcpiphdr *)(q->ti_next); } - tcpstat.tcps_rcvoopack++; - tcpstat.tcps_rcvoobyte += ti->ti_len; + STAT(tcpstat.tcps_rcvoopack++); + STAT(tcpstat.tcps_rcvoobyte += ti->ti_len); REASS_MBUF(ti) = (mbufp_32) m; /* XXX */ /* @@ -275,7 +275,7 @@ } - tcpstat.tcps_rcvtotal++; + STAT(tcpstat.tcps_rcvtotal++); /* * Get IP and TCP header together in first mbuf. * Note: IP leaves IP header in first mbuf. @@ -308,7 +308,7 @@ * ti->ti_sum = cksum(m, len); * if (ti->ti_sum) { */ if(cksum(m, len)) { - tcpstat.tcps_rcvbadsum++; + STAT(tcpstat.tcps_rcvbadsum++); goto drop; } @@ -318,7 +318,7 @@ */ off = ti->ti_off << 2; if (off < sizeof (struct tcphdr) || off > tlen) { - tcpstat.tcps_rcvbadoff++; + STAT(tcpstat.tcps_rcvbadoff++); goto drop; } tlen -= off; @@ -375,7 +375,7 @@ ti->ti_dst, ti->ti_dport); if (so) tcp_last_so = so; - ++tcpstat.tcps_socachemiss; + STAT(tcpstat.tcps_socachemiss++); } /* @@ -503,7 +503,7 @@ /* * this is a pure ack for outstanding data. */ - ++tcpstat.tcps_predack; + STAT(tcpstat.tcps_predack++); /* if (ts_present) * tcp_xmit_timer(tp, tcp_now-ts_ecr+1); * else @@ -511,8 +511,8 @@ SEQ_GT(ti->ti_ack, tp->t_rtseq)) tcp_xmit_timer(tp, tp->t_rtt); acked = ti->ti_ack - tp->snd_una; - tcpstat.tcps_rcvackpack++; - tcpstat.tcps_rcvackbyte += acked; + STAT(tcpstat.tcps_rcvackpack++); + STAT(tcpstat.tcps_rcvackbyte += acked); sbdrop(&so->so_snd, acked); tp->snd_una = ti->ti_ack; m_freem(m); @@ -556,10 +556,10 @@ * with nothing on the reassembly queue and * we have enough buffer space to take it. */ - ++tcpstat.tcps_preddat; + STAT(tcpstat.tcps_preddat++); tp->rcv_nxt += ti->ti_len; - tcpstat.tcps_rcvpack++; - tcpstat.tcps_rcvbyte += ti->ti_len; + STAT(tcpstat.tcps_rcvpack++); + STAT(tcpstat.tcps_rcvbyte += ti->ti_len); /* * Add data to socket buffer. */ @@ -726,7 +726,7 @@ tp->t_flags |= TF_ACKNOW; tp->t_state = TCPS_SYN_RECEIVED; tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; - tcpstat.tcps_accepts++; + STAT(tcpstat.tcps_accepts++); goto trimthenstep6; } /* case TCPS_LISTEN */ @@ -767,7 +767,7 @@ tcp_rcvseqinit(tp); tp->t_flags |= TF_ACKNOW; if (tiflags & TH_ACK && SEQ_GT(tp->snd_una, tp->iss)) { - tcpstat.tcps_connects++; + STAT(tcpstat.tcps_connects++); soisfconnected(so); tp->t_state = TCPS_ESTABLISHED; @@ -801,8 +801,8 @@ m_adj(m, -todrop); ti->ti_len = tp->rcv_wnd; tiflags &= ~TH_FIN; - tcpstat.tcps_rcvpackafterwin++; - tcpstat.tcps_rcvbyteafterwin += todrop; + STAT(tcpstat.tcps_rcvpackafterwin++); + STAT(tcpstat.tcps_rcvbyteafterwin += todrop); } tp->snd_wl1 = ti->ti_seq - 1; tp->rcv_up = ti->ti_seq; @@ -873,11 +873,11 @@ */ tp->t_flags |= TF_ACKNOW; todrop = ti->ti_len; - tcpstat.tcps_rcvduppack++; - tcpstat.tcps_rcvdupbyte += todrop; + STAT(tcpstat.tcps_rcvduppack++); + STAT(tcpstat.tcps_rcvdupbyte += todrop); } else { - tcpstat.tcps_rcvpartduppack++; - tcpstat.tcps_rcvpartdupbyte += todrop; + STAT(tcpstat.tcps_rcvpartduppack++); + STAT(tcpstat.tcps_rcvpartdupbyte += todrop); } m_adj(m, todrop); ti->ti_seq += todrop; @@ -896,7 +896,7 @@ if ((so->so_state & SS_NOFDREF) && tp->t_state > TCPS_CLOSE_WAIT && ti->ti_len) { tp = tcp_close(tp); - tcpstat.tcps_rcvafterclose++; + STAT(tcpstat.tcps_rcvafterclose++); goto dropwithreset; } @@ -906,9 +906,9 @@ */ todrop = (ti->ti_seq+ti->ti_len) - (tp->rcv_nxt+tp->rcv_wnd); if (todrop > 0) { - tcpstat.tcps_rcvpackafterwin++; + STAT(tcpstat.tcps_rcvpackafterwin++); if (todrop >= ti->ti_len) { - tcpstat.tcps_rcvbyteafterwin += 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 @@ -931,11 +931,11 @@ */ if (tp->rcv_wnd == 0 && ti->ti_seq == tp->rcv_nxt) { tp->t_flags |= TF_ACKNOW; - tcpstat.tcps_rcvwinprobe++; + STAT(tcpstat.tcps_rcvwinprobe++); } else goto dropafterack; } else - tcpstat.tcps_rcvbyteafterwin += todrop; + STAT(tcpstat.tcps_rcvbyteafterwin += todrop); m_adj(m, -todrop); ti->ti_len -= todrop; tiflags &= ~(TH_PUSH|TH_FIN); @@ -976,7 +976,7 @@ /* so->so_error = ECONNRESET; */ close: tp->t_state = TCPS_CLOSED; - tcpstat.tcps_drops++; + STAT(tcpstat.tcps_drops++); tp = tcp_close(tp); goto drop; @@ -1015,7 +1015,7 @@ if (SEQ_GT(tp->snd_una, ti->ti_ack) || SEQ_GT(ti->ti_ack, tp->snd_max)) goto dropwithreset; - tcpstat.tcps_connects++; + STAT(tcpstat.tcps_connects++); tp->t_state = TCPS_ESTABLISHED; /* * The sent SYN is ack'ed with our sequence number +1 @@ -1072,7 +1072,7 @@ if (SEQ_LEQ(ti->ti_ack, tp->snd_una)) { if (ti->ti_len == 0 && tiwin == tp->snd_wnd) { - tcpstat.tcps_rcvdupack++; + STAT(tcpstat.tcps_rcvdupack++); DEBUG_MISC((dfd," dup ack m = %lx so = %lx \n", (long )m, (long )so)); /* @@ -1140,12 +1140,12 @@ tp->snd_cwnd = tp->snd_ssthresh; tp->t_dupacks = 0; if (SEQ_GT(ti->ti_ack, tp->snd_max)) { - tcpstat.tcps_rcvacktoomuch++; + STAT(tcpstat.tcps_rcvacktoomuch++); goto dropafterack; } acked = ti->ti_ack - tp->snd_una; - tcpstat.tcps_rcvackpack++; - tcpstat.tcps_rcvackbyte += acked; + STAT(tcpstat.tcps_rcvackpack++); + STAT(tcpstat.tcps_rcvackbyte += acked); /* * If we have a timestamp reply, update smoothed @@ -1284,7 +1284,7 @@ /* keep track of pure window updates */ if (ti->ti_len == 0 && tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd) - tcpstat.tcps_rcvwinupd++; + STAT(tcpstat.tcps_rcvwinupd++); tp->snd_wnd = tiwin; tp->snd_wl1 = ti->ti_seq; tp->snd_wl2 = ti->ti_ack; @@ -1616,7 +1616,7 @@ DEBUG_ARG("tp = %lx", (long)tp); DEBUG_ARG("rtt = %d", rtt); - tcpstat.tcps_rttupdated++; + STAT(tcpstat.tcps_rttupdated++); if (tp->t_srtt != 0) { /* * srtt is stored as fixed point with 3 bits after the Index: qemu/slirp/tcp_output.c =================================================================== --- qemu.orig/slirp/tcp_output.c 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/tcp_output.c 2007-10-24 19:38:20.000000000 +0000 @@ -263,7 +263,7 @@ /* * No reason to send a segment, just return. */ - tcpstat.tcps_didnuttin++; + STAT(tcpstat.tcps_didnuttin++); return (0); @@ -339,13 +339,13 @@ */ if (len) { if (tp->t_force && len == 1) - tcpstat.tcps_sndprobe++; + STAT(tcpstat.tcps_sndprobe++); else if (SEQ_LT(tp->snd_nxt, tp->snd_max)) { - tcpstat.tcps_sndrexmitpack++; - tcpstat.tcps_sndrexmitbyte += len; + STAT(tcpstat.tcps_sndrexmitpack++); + STAT(tcpstat.tcps_sndrexmitbyte += len); } else { - tcpstat.tcps_sndpack++; - tcpstat.tcps_sndbyte += len; + STAT(tcpstat.tcps_sndpack++); + STAT(tcpstat.tcps_sndbyte += len); } m = m_get(); @@ -382,13 +382,13 @@ flags |= TH_PUSH; } else { if (tp->t_flags & TF_ACKNOW) - tcpstat.tcps_sndacks++; + STAT(tcpstat.tcps_sndacks++); else if (flags & (TH_SYN|TH_FIN|TH_RST)) - tcpstat.tcps_sndctrl++; + STAT(tcpstat.tcps_sndctrl++); else if (SEQ_GT(tp->snd_up, tp->snd_una)) - tcpstat.tcps_sndurg++; + STAT(tcpstat.tcps_sndurg++); else - tcpstat.tcps_sndwinup++; + STAT(tcpstat.tcps_sndwinup++); m = m_get(); if (m == NULL) { @@ -500,7 +500,7 @@ if (tp->t_rtt == 0) { tp->t_rtt = 1; tp->t_rtseq = startseq; - tcpstat.tcps_segstimed++; + STAT(tcpstat.tcps_segstimed++); } } @@ -567,7 +567,7 @@ */ return (error); } - tcpstat.tcps_sndtotal++; + STAT(tcpstat.tcps_sndtotal++); /* * Data sent (as far as we can tell). Index: qemu/slirp/tcp_subr.c =================================================================== --- qemu.orig/slirp/tcp_subr.c 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/tcp_subr.c 2007-10-24 19:38:20.000000000 +0000 @@ -255,9 +255,9 @@ if (TCPS_HAVERCVDSYN(tp->t_state)) { tp->t_state = TCPS_CLOSED; (void) tcp_output(tp); - tcpstat.tcps_drops++; + STAT(tcpstat.tcps_drops++); } else - tcpstat.tcps_conndrops++; + STAT(tcpstat.tcps_conndrops++); /* if (errno == ETIMEDOUT && tp->t_softerror) * errno = tp->t_softerror; */ @@ -305,7 +305,7 @@ sbfree(&so->so_rcv); sbfree(&so->so_snd); sofree(so); - tcpstat.tcps_closed++; + STAT(tcpstat.tcps_closed++); return ((struct tcpcb *)0); } @@ -528,7 +528,7 @@ */ /* soisconnecting(so); */ /* NOFDREF used instead */ - tcpstat.tcps_connattempt++; + STAT(tcpstat.tcps_connattempt++); tp->t_state = TCPS_SYN_SENT; tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; @@ -857,7 +857,7 @@ /*soisfconnecting(ns);*/ - tcpstat.tcps_connattempt++; + STAT(tcpstat.tcps_connattempt++); tp->t_state = TCPS_SYN_SENT; tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; Index: qemu/slirp/if.h =================================================================== --- qemu.orig/slirp/if.h 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/if.h 2007-10-24 19:38:20.000000000 +0000 @@ -29,6 +29,7 @@ #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 */ @@ -46,5 +47,6 @@ u_int in_mbad; /* Bad incoming packets */ }; +#endif #endif Index: qemu/slirp/tcp_timer.c =================================================================== --- qemu.orig/slirp/tcp_timer.c 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/tcp_timer.c 2007-10-24 19:38:20.000000000 +0000 @@ -41,7 +41,10 @@ int tcp_maxidle; int so_options = DO_KEEPALIVE; +#ifdef LOG_ENABLED struct tcpstat tcpstat; /* tcp statistics */ +#endif + u_int32_t tcp_now; /* for RFC 1323 timestamps */ /* @@ -62,7 +65,7 @@ (tp->t_flags & TF_DELACK)) { tp->t_flags &= ~TF_DELACK; tp->t_flags |= TF_ACKNOW; - tcpstat.tcps_delack++; + STAT(tcpstat.tcps_delack++); (void) tcp_output(tp); } } @@ -192,7 +195,7 @@ * We tried our best, now the connection must die! */ tp->t_rxtshift = TCP_MAXRXTSHIFT; - tcpstat.tcps_timeoutdrop++; + STAT(tcpstat.tcps_timeoutdrop++); tp = tcp_drop(tp, tp->t_softerror); /* tp->t_softerror : ETIMEDOUT); */ /* XXX */ return (tp); /* XXX */ @@ -204,7 +207,7 @@ */ tp->t_rxtshift = 6; } - tcpstat.tcps_rexmttimeo++; + 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 */ @@ -267,7 +270,7 @@ * Force a byte to be output, if possible. */ case TCPT_PERSIST: - tcpstat.tcps_persisttimeo++; + STAT(tcpstat.tcps_persisttimeo++); tcp_setpersist(tp); tp->t_force = 1; (void) tcp_output(tp); @@ -279,7 +282,7 @@ * or drop connection if idle for too long. */ case TCPT_KEEP: - tcpstat.tcps_keeptimeo++; + STAT(tcpstat.tcps_keeptimeo++); if (tp->t_state < TCPS_ESTABLISHED) goto dropit; @@ -299,7 +302,7 @@ * by the protocol spec, this requires the * correspondent TCP to respond. */ - tcpstat.tcps_keepprobe++; + STAT(tcpstat.tcps_keepprobe++); #ifdef TCP_COMPAT_42 /* * The keepalive packet must have nonzero length @@ -317,7 +320,7 @@ break; dropit: - tcpstat.tcps_keepdrops++; + STAT(tcpstat.tcps_keepdrops++); tp = tcp_drop(tp, 0); /* ETIMEDOUT); */ break; } Index: qemu/slirp/tcp_var.h =================================================================== --- qemu.orig/slirp/tcp_var.h 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/tcp_var.h 2007-10-24 18:45:42.000000000 +0000 @@ -185,6 +185,7 @@ #endif #define REASS_MBUF(ti) (*(mbufp_32 *)&((ti)->ti_t)) +#ifdef LOG_ENABLED /* * TCP statistics. * Many of these should be kept per connection, @@ -247,6 +248,8 @@ }; extern struct tcpstat tcpstat; /* tcp statistics */ +#endif + extern u_int32_t tcp_now; /* for RFC 1323 timestamps */ #endif Index: qemu/slirp/udp.h =================================================================== --- qemu.orig/slirp/udp.h 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/udp.h 2007-10-24 19:38:20.000000000 +0000 @@ -72,6 +72,7 @@ #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 */ @@ -85,6 +86,7 @@ /* output statistics: */ u_long udps_opackets; /* total output packets */ }; +#endif /* * Names for UDP sysctl objects @@ -92,7 +94,10 @@ #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; Index: qemu/slirp/udp.c =================================================================== --- qemu.orig/slirp/udp.c 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/udp.c 2007-10-24 19:42:14.000000000 +0000 @@ -45,7 +45,9 @@ #include #include "ip_icmp.h" +#ifdef LOG_ENABLED struct udpstat udpstat; +#endif struct socket udb; @@ -86,7 +88,7 @@ DEBUG_ARG("m = %lx", (long)m); DEBUG_ARG("iphlen = %d", iphlen); - udpstat.udps_ipackets++; + STAT(udpstat.udps_ipackets++); /* * Strip IP options, if any; should skip this, @@ -113,7 +115,7 @@ if (ip->ip_len != len) { if (len > ip->ip_len) { - udpstat.udps_badlen++; + STAT(udpstat.udps_badlen++); goto bad; } m_adj(m, len - ip->ip_len); @@ -140,7 +142,7 @@ * if (uh->uh_sum) { */ if(cksum(m, len + sizeof(struct ip))) { - udpstat.udps_badsum++; + STAT(udpstat.udps_badsum++); goto bad; } } @@ -181,7 +183,7 @@ if (tmp == &udb) { so = NULL; } else { - udpstat.udpps_pcbcachemiss++; + STAT(udpstat.udpps_pcbcachemiss++); udp_last_so = so; } } @@ -299,7 +301,7 @@ ((struct ip *)ui)->ip_ttl = ip_defttl; ((struct ip *)ui)->ip_tos = iptos; - udpstat.udps_opackets++; + STAT(udpstat.udps_opackets++); error = ip_output(so, m); Index: qemu/monitor.c =================================================================== --- qemu.orig/monitor.c 2007-10-24 18:23:09.000000000 +0000 +++ qemu/monitor.c 2007-10-24 18:45:42.000000000 +0000 @@ -1365,6 +1365,10 @@ { "cpustats", "", do_info_cpu_stats, "", "show CPU statistics", }, #endif +#if defined(CONFIG_SLIRP) + { "slirp", "", do_info_slirp, + "", "show SLIRP statistics", }, +#endif { NULL, NULL, }, }; Index: qemu/slirp/libslirp.h =================================================================== --- qemu.orig/slirp/libslirp.h 2007-10-24 18:23:09.000000000 +0000 +++ qemu/slirp/libslirp.h 2007-10-24 18:45:42.000000000 +0000 @@ -26,6 +26,8 @@ extern const char *tftp_prefix; extern char slirp_hostname[33]; +void slirp_stats(void); + #ifdef __cplusplus } #endif Index: qemu/vl.c =================================================================== --- qemu.orig/vl.c 2007-10-24 18:23:09.000000000 +0000 +++ qemu/vl.c 2007-10-24 18:45:42.000000000 +0000 @@ -3781,6 +3781,10 @@ } #endif /* !defined(_WIN32) */ +void do_info_slirp(void) +{ + slirp_stats(); +} #endif /* CONFIG_SLIRP */ Index: qemu/vl.h =================================================================== --- qemu.orig/vl.h 2007-10-24 18:23:09.000000000 +0000 +++ qemu/vl.h 2007-10-24 18:45:42.000000000 +0000 @@ -439,6 +439,9 @@ extern int nb_nics; extern NICInfo nd_table[MAX_NICS]; +/* SLIRP */ +void do_info_slirp(void); + /* timers */ typedef struct QEMUClock QEMUClock;