aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2007-10-26 18:42:59 +0000
committerblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2007-10-26 18:42:59 +0000
commit31a60e22752d3daaa248ca10930f3cf4bc5f02e8 (patch)
tree18f5bd36118d98e2004fc0e5af866a280667278c
parent7d294b61edc6bd1be15739a11dce1414080dbb9b (diff)
downloadqemu-arm-31a60e22752d3daaa248ca10930f3cf4bc5f02e8.tar.gz
Make Slirp statistics gathering and output conditional to LOG_ENABLED
Add 'info slirp' command to monitor to display statistics Disable Slirp debugging code by default git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3451 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--monitor.c4
-rw-r--r--slirp/debug.c57
-rw-r--r--slirp/debug.h10
-rw-r--r--slirp/icmp_var.h2
-rw-r--r--slirp/if.h2
-rw-r--r--slirp/ip.h4
-rw-r--r--slirp/ip_icmp.c16
-rw-r--r--slirp/ip_input.c32
-rw-r--r--slirp/ip_output.c10
-rw-r--r--slirp/libslirp.h2
-rw-r--r--slirp/misc.c11
-rw-r--r--slirp/slirp.c11
-rw-r--r--slirp/slirp.h11
-rw-r--r--slirp/tcp_input.c78
-rw-r--r--slirp/tcp_output.c24
-rw-r--r--slirp/tcp_subr.c10
-rw-r--r--slirp/tcp_timer.c17
-rw-r--r--slirp/tcp_var.h3
-rw-r--r--slirp/udp.c12
-rw-r--r--slirp/udp.h5
-rw-r--r--vl.c4
-rw-r--r--vl.h3
22 files changed, 203 insertions, 125 deletions
diff --git a/monitor.c b/monitor.c
index 65f23b4e99..ac0c8e8728 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1365,6 +1365,10 @@ static term_cmd_t info_cmds[] = {
{ "cpustats", "", do_info_cpu_stats,
"", "show CPU statistics", },
#endif
+#if defined(CONFIG_SLIRP)
+ { "slirp", "", do_info_slirp,
+ "", "show SLIRP statistics", },
+#endif
{ NULL, NULL, },
};
diff --git a/slirp/debug.c b/slirp/debug.c
index e312445505..77d5044525 100644
--- a/slirp/debug.c
+++ b/slirp/debug.c
@@ -20,6 +20,7 @@ extern char *strerror _P((int));
/* 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 @@ dump_packet(dat, n)
}
}
#endif
+#endif
+#ifdef LOG_ENABLED
#if 0
/*
* Statistic routines
@@ -80,7 +83,7 @@ dump_packet(dat, n)
* the link as well.
*/
-void
+static void
ttystats(ttyp)
struct ttys *ttyp;
{
@@ -119,8 +122,8 @@ ttystats(ttyp)
lprint(" %6d bad input packets\r\n", is->in_mbad);
}
-void
-allttystats()
+static void
+allttystats(void)
{
struct ttys *ttyp;
@@ -129,8 +132,8 @@ allttystats()
}
#endif
-void
-ipstats()
+static void
+ipstats(void)
{
lprint(" \r\n");
@@ -153,9 +156,9 @@ ipstats()
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 @@ vjstats()
}
#endif
-void
-tcpstats()
+static void
+tcpstats(void)
{
lprint(" \r\n");
@@ -240,8 +243,8 @@ tcpstats()
}
-void
-udpstats()
+static void
+udpstats(void)
{
lprint(" \r\n");
@@ -254,8 +257,8 @@ udpstats()
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 @@ icmpstats()
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 @@ mbufstats()
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 @@ sockstats()
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 @@ slirp_exit(exit_status)
exit(exit_status);
}
#endif
+
+void
+slirp_stats(void)
+{
+#ifdef LOG_ENABLED
+ ipstats();
+ tcpstats();
+ udpstats();
+ icmpstats();
+ mbufstats();
+ sockstats();
+#else
+ lprint("SLIRP statistics code not compiled.\n");
+#endif
+}
diff --git a/slirp/debug.h b/slirp/debug.h
index fa62cb9fe9..8a523b2ed6 100644
--- a/slirp/debug.h
+++ b/slirp/debug.h
@@ -37,14 +37,4 @@ extern int slirp_debug;
#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));
diff --git a/slirp/icmp_var.h b/slirp/icmp_var.h
index 03fc8c3ac7..cd865b7971 100644
--- a/slirp/icmp_var.h
+++ b/slirp/icmp_var.h
@@ -64,6 +64,8 @@ struct icmpstat {
{ "stats", CTLTYPE_STRUCT }, \
}
+#ifdef LOG_ENABLED
extern struct icmpstat icmpstat;
+#endif
#endif
diff --git a/slirp/if.h b/slirp/if.h
index bf24174a69..8f78ce7b69 100644
--- a/slirp/if.h
+++ b/slirp/if.h
@@ -29,6 +29,7 @@ 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 */
@@ -46,5 +47,6 @@ struct slirp_ifstats {
u_int in_mbad; /* Bad incoming packets */
};
+#endif
#endif
diff --git a/slirp/ip.h b/slirp/ip.h
index 371537d485..007facf3ff 100644
--- a/slirp/ip.h
+++ b/slirp/ip.h
@@ -272,6 +272,7 @@ 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.
@@ -306,8 +307,11 @@ struct ipstat {
};
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
diff --git a/slirp/ip_icmp.c b/slirp/ip_icmp.c
index ae5a321185..4cf14c8e3a 100644
--- a/slirp/ip_icmp.c
+++ b/slirp/ip_icmp.c
@@ -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 @@ icmp_input(m, hlen)
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 @@ icmp_input(m, hlen)
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 @@ icmp_input(m, hlen)
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 @@ icmp_error(msrc, type, code, minsize, message)
(void ) ip_output((struct socket *)NULL, m);
- icmpstat.icps_reflect++;
+ STAT(icmpstat.icps_reflect++);
end_error:
return;
@@ -371,5 +373,5 @@ icmp_reflect(m)
(void ) ip_output((struct socket *)NULL, m);
- icmpstat.icps_reflect++;
+ STAT(icmpstat.icps_reflect++);
}
diff --git a/slirp/ip_input.c b/slirp/ip_input.c
index a7d6e31818..629745fba2 100644
--- a/slirp/ip_input.c
+++ b/slirp/ip_input.c
@@ -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 @@ ip_input(m)
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 (hlen<sizeof(struct ip ) || hlen>m->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 @@ ip_input(m)
* if (ip->ip_sum) {
*/
if(cksum(m,hlen)) {
- ipstat.ips_badsum++;
+ STAT(ipstat.ips_badsum++);
goto bad;
}
@@ -112,7 +116,7 @@ ip_input(m)
*/
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 @@ ip_input(m)
* 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 @@ ip_input(m)
* 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 @@ ip_input(m)
/*
* 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 @@ ip_input(m)
icmp_input(m, hlen);
break;
default:
- ipstat.ips_noproto++;
+ STAT(ipstat.ips_noproto++);
m_free(m);
}
return;
@@ -385,7 +389,7 @@ insert:
return ((struct ip *)ip);
dropfrag:
- ipstat.ips_fragdropped++;
+ STAT(ipstat.ips_fragdropped++);
m_freem(m);
return (0);
}
@@ -457,7 +461,7 @@ ip_slowtimo()
--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 @@ bad:
/* Not yet */
icmp_error(m, type, code, 0, 0);
- ipstat.ips_badoptions++;
+ STAT(ipstat.ips_badoptions++);
return (1);
}
diff --git a/slirp/ip_output.c b/slirp/ip_output.c
index b1a8484026..b41d0627c6 100644
--- a/slirp/ip_output.c
+++ b/slirp/ip_output.c
@@ -80,7 +80,7 @@ ip_output(so, m0)
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 @@ ip_output(so, m0)
*/
if (ip->ip_off & IP_DF) {
error = -1;
- ipstat.ips_cantfrag++;
+ STAT(ipstat.ips_cantfrag++);
goto bad;
}
@@ -137,7 +137,7 @@ ip_output(so, m0)
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 @@ ip_output(so, m0)
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 @@ sendorfree:
}
if (error == 0)
- ipstat.ips_fragmented++;
+ STAT(ipstat.ips_fragmented++);
}
done:
diff --git a/slirp/libslirp.h b/slirp/libslirp.h
index 639f5f2226..7e4cfa98a2 100644
--- a/slirp/libslirp.h
+++ b/slirp/libslirp.h
@@ -26,6 +26,8 @@ int slirp_add_exec(int do_pty, const char *args, int addr_low_byte,
extern const char *tftp_prefix;
extern char slirp_hostname[33];
+void slirp_stats(void);
+
#ifdef __cplusplus
}
#endif
diff --git a/slirp/misc.c b/slirp/misc.c
index a41dd769b2..d40fd629f1 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -603,6 +603,16 @@ relay(s)
}
#endif
+#ifdef CONFIG_QEMU
+void lprint(const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ term_vprintf(format, args);
+ va_end(args);
+}
+#else
int (*lprint_print) _P((void *, const char *, va_list));
char *lprint_ptr, *lprint_ptr2, **lprint_arg;
@@ -754,6 +764,7 @@ add_emu(buff)
lprint("Adding emulation for %s to port %d/%d\r\n", buff1, emup->lport, emup->fport);
}
+#endif
#ifdef BAD_SPRINTF
diff --git a/slirp/slirp.c b/slirp/slirp.c
index f535db12b0..28f6c0ceca 100644
--- a/slirp/slirp.c
+++ b/slirp/slirp.c
@@ -93,7 +93,9 @@ static int get_dns_addr(struct in_addr *pdns_addr)
if (!f)
return -1;
+#ifdef DEBUG
lprint("IP address of your DNS(s): ");
+#endif
while (fgets(buff, 512, f) != NULL) {
if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) {
if (!inet_aton(buff2, &tmp_addr))
@@ -103,13 +105,20 @@ static int get_dns_addr(struct in_addr *pdns_addr)
/* If it's the first one, set it to dns_addr */
if (!found)
*pdns_addr = tmp_addr;
+#ifdef DEBUG
else
lprint(", ");
+#endif
if (++found > 3) {
+#ifdef DEBUG
lprint("(more)");
+#endif
break;
- } else
+ }
+#ifdef DEBUG
+ else
lprint("%s", inet_ntoa(tmp_addr));
+#endif
}
}
fclose(f);
diff --git a/slirp/slirp.h b/slirp/slirp.h
index 1ff68cb0b4..ecff1d2584 100644
--- a/slirp/slirp.h
+++ b/slirp/slirp.h
@@ -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"
diff --git a/slirp/tcp_input.c b/slirp/tcp_input.c
index 04f6553127..abd827ebbb 100644
--- a/slirp/tcp_input.c
+++ b/slirp/tcp_input.c
@@ -79,8 +79,8 @@ 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; \
- 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 @@ 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; \
- 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 @@ tcp_reass(tp, ti, m)
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 @@ tcp_reass(tp, ti, m)
}
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 @@ tcp_input(m, iphlen, inso)
}
- 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 @@ tcp_input(m, iphlen, inso)
* 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 @@ tcp_input(m, iphlen, inso)
*/
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 @@ findso:
ti->ti_dst, ti->ti_dport);
if (so)
tcp_last_so = so;
- ++tcpstat.tcps_socachemiss;
+ STAT(tcpstat.tcps_socachemiss++);
}
/*
@@ -503,7 +503,7 @@ findso:
/*
* 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 @@ findso:
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 @@ findso:
* 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 @@ findso:
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 @@ findso:
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 @@ trimthenstep6:
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 @@ trimthenstep6:
*/
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 @@ trimthenstep6:
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 @@ trimthenstep6:
*/
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 @@ trimthenstep6:
*/
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 @@ trimthenstep6:
/* 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 @@ trimthenstep6:
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 @@ trimthenstep6:
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 @@ trimthenstep6:
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 @@ step6:
/* 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 @@ tcp_xmit_timer(tp, rtt)
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
diff --git a/slirp/tcp_output.c b/slirp/tcp_output.c
index 3eddfd38e2..f4986516a3 100644
--- a/slirp/tcp_output.c
+++ b/slirp/tcp_output.c
@@ -263,7 +263,7 @@ again:
/*
* No reason to send a segment, just return.
*/
- tcpstat.tcps_didnuttin++;
+ STAT(tcpstat.tcps_didnuttin++);
return (0);
@@ -339,13 +339,13 @@ send:
*/
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 @@ send:
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 @@ send:
if (tp->t_rtt == 0) {
tp->t_rtt = 1;
tp->t_rtseq = startseq;
- tcpstat.tcps_segstimed++;
+ STAT(tcpstat.tcps_segstimed++);
}
}
@@ -567,7 +567,7 @@ out:
*/
return (error);
}
- tcpstat.tcps_sndtotal++;
+ STAT(tcpstat.tcps_sndtotal++);
/*
* Data sent (as far as we can tell).
diff --git a/slirp/tcp_subr.c b/slirp/tcp_subr.c
index 3814ec19b2..a20a0880b3 100644
--- a/slirp/tcp_subr.c
+++ b/slirp/tcp_subr.c
@@ -255,9 +255,9 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err)
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 @@ tcp_close(tp)
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 @@ tcp_connect(inso)
*/
/* 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 @@ tcp_emu(so, m)
/*soisfconnecting(ns);*/
- tcpstat.tcps_connattempt++;
+ STAT(tcpstat.tcps_connattempt++);
tp->t_state = TCPS_SYN_SENT;
tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
diff --git a/slirp/tcp_timer.c b/slirp/tcp_timer.c
index cc1bd50c07..3e865977ce 100644
--- a/slirp/tcp_timer.c
+++ b/slirp/tcp_timer.c
@@ -41,7 +41,10 @@ int tcp_keepintvl = TCPTV_KEEPINTVL;
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 @@ tcp_fasttimo()
(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 @@ tcp_timers(tp, timer)
* 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 @@ tcp_timers(tp, timer)
*/
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 @@ tcp_timers(tp, timer)
* 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 @@ tcp_timers(tp, timer)
* 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 @@ tcp_timers(tp, timer)
* 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 @@ tcp_timers(tp, timer)
break;
dropit:
- tcpstat.tcps_keepdrops++;
+ STAT(tcpstat.tcps_keepdrops++);
tp = tcp_drop(tp, 0); /* ETIMEDOUT); */
break;
}
diff --git a/slirp/tcp_var.h b/slirp/tcp_var.h
index 0d6cd245e6..82380f9365 100644
--- a/slirp/tcp_var.h
+++ b/slirp/tcp_var.h
@@ -185,6 +185,7 @@ typedef u_int32_t mbufp_32;
#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 @@ struct tcpstat {
};
extern struct tcpstat tcpstat; /* tcp statistics */
+#endif
+
extern u_int32_t tcp_now; /* for RFC 1323 timestamps */
#endif
diff --git a/slirp/udp.c b/slirp/udp.c
index 44900ff144..8510380949 100644
--- a/slirp/udp.c
+++ b/slirp/udp.c
@@ -45,7 +45,9 @@
#include <slirp.h>
#include "ip_icmp.h"
+#ifdef LOG_ENABLED
struct udpstat udpstat;
+#endif
struct socket udb;
@@ -86,7 +88,7 @@ udp_input(m, iphlen)
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 @@ udp_input(m, iphlen)
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 @@ udp_input(m, iphlen)
* if (uh->uh_sum) {
*/
if(cksum(m, len + sizeof(struct ip))) {
- udpstat.udps_badsum++;
+ STAT(udpstat.udps_badsum++);
goto bad;
}
}
@@ -181,7 +183,7 @@ udp_input(m, iphlen)
if (tmp == &udb) {
so = NULL;
} else {
- udpstat.udpps_pcbcachemiss++;
+ STAT(udpstat.udpps_pcbcachemiss++);
udp_last_so = so;
}
}
@@ -299,7 +301,7 @@ int udp_output2(struct socket *so, struct mbuf *m,
((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);
diff --git a/slirp/udp.h b/slirp/udp.h
index 67da6cd731..12435eb82c 100644
--- a/slirp/udp.h
+++ b/slirp/udp.h
@@ -72,6 +72,7 @@ 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 */
@@ -85,6 +86,7 @@ struct udpstat {
/* output statistics: */
u_long udps_opackets; /* total output packets */
};
+#endif
/*
* Names for UDP sysctl objects
@@ -92,7 +94,10 @@ struct udpstat {
#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;
diff --git a/vl.c b/vl.c
index 094afb3196..f9500a9679 100644
--- a/vl.c
+++ b/vl.c
@@ -3782,6 +3782,10 @@ void net_slirp_smb(const char *exported_dir)
}
#endif /* !defined(_WIN32) */
+void do_info_slirp(void)
+{
+ slirp_stats();
+}
#endif /* CONFIG_SLIRP */
diff --git a/vl.h b/vl.h
index adf6004a70..681dd91abf 100644
--- a/vl.h
+++ b/vl.h
@@ -439,6 +439,9 @@ typedef struct NICInfo {
extern int nb_nics;
extern NICInfo nd_table[MAX_NICS];
+/* SLIRP */
+void do_info_slirp(void);
+
/* timers */
typedef struct QEMUClock QEMUClock;