Commit 31a60e22752d3daaa248ca10930f3cf4bc5f02e8
1 parent
7d294b61
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
Showing
22 changed files
with
203 additions
and
125 deletions
monitor.c
| @@ -1365,6 +1365,10 @@ static term_cmd_t info_cmds[] = { | @@ -1365,6 +1365,10 @@ static term_cmd_t info_cmds[] = { | ||
| 1365 | { "cpustats", "", do_info_cpu_stats, | 1365 | { "cpustats", "", do_info_cpu_stats, |
| 1366 | "", "show CPU statistics", }, | 1366 | "", "show CPU statistics", }, |
| 1367 | #endif | 1367 | #endif |
| 1368 | +#if defined(CONFIG_SLIRP) | ||
| 1369 | + { "slirp", "", do_info_slirp, | ||
| 1370 | + "", "show SLIRP statistics", }, | ||
| 1371 | +#endif | ||
| 1368 | { NULL, NULL, }, | 1372 | { NULL, NULL, }, |
| 1369 | }; | 1373 | }; |
| 1370 | 1374 |
slirp/debug.c
| @@ -20,6 +20,7 @@ extern char *strerror _P((int)); | @@ -20,6 +20,7 @@ extern char *strerror _P((int)); | ||
| 20 | 20 | ||
| 21 | /* Carry over one item from main.c so that the tty's restored. | 21 | /* Carry over one item from main.c so that the tty's restored. |
| 22 | * Only done when the tty being used is /dev/tty --RedWolf */ | 22 | * Only done when the tty being used is /dev/tty --RedWolf */ |
| 23 | +#ifndef CONFIG_QEMU | ||
| 23 | extern struct termios slirp_tty_settings; | 24 | extern struct termios slirp_tty_settings; |
| 24 | extern int slirp_tty_restore; | 25 | extern int slirp_tty_restore; |
| 25 | 26 | ||
| @@ -70,7 +71,9 @@ dump_packet(dat, n) | @@ -70,7 +71,9 @@ dump_packet(dat, n) | ||
| 70 | } | 71 | } |
| 71 | } | 72 | } |
| 72 | #endif | 73 | #endif |
| 74 | +#endif | ||
| 73 | 75 | ||
| 76 | +#ifdef LOG_ENABLED | ||
| 74 | #if 0 | 77 | #if 0 |
| 75 | /* | 78 | /* |
| 76 | * Statistic routines | 79 | * Statistic routines |
| @@ -80,7 +83,7 @@ dump_packet(dat, n) | @@ -80,7 +83,7 @@ dump_packet(dat, n) | ||
| 80 | * the link as well. | 83 | * the link as well. |
| 81 | */ | 84 | */ |
| 82 | 85 | ||
| 83 | -void | 86 | +static void |
| 84 | ttystats(ttyp) | 87 | ttystats(ttyp) |
| 85 | struct ttys *ttyp; | 88 | struct ttys *ttyp; |
| 86 | { | 89 | { |
| @@ -119,8 +122,8 @@ ttystats(ttyp) | @@ -119,8 +122,8 @@ ttystats(ttyp) | ||
| 119 | lprint(" %6d bad input packets\r\n", is->in_mbad); | 122 | lprint(" %6d bad input packets\r\n", is->in_mbad); |
| 120 | } | 123 | } |
| 121 | 124 | ||
| 122 | -void | ||
| 123 | -allttystats() | 125 | +static void |
| 126 | +allttystats(void) | ||
| 124 | { | 127 | { |
| 125 | struct ttys *ttyp; | 128 | struct ttys *ttyp; |
| 126 | 129 | ||
| @@ -129,8 +132,8 @@ allttystats() | @@ -129,8 +132,8 @@ allttystats() | ||
| 129 | } | 132 | } |
| 130 | #endif | 133 | #endif |
| 131 | 134 | ||
| 132 | -void | ||
| 133 | -ipstats() | 135 | +static void |
| 136 | +ipstats(void) | ||
| 134 | { | 137 | { |
| 135 | lprint(" \r\n"); | 138 | lprint(" \r\n"); |
| 136 | 139 | ||
| @@ -153,9 +156,9 @@ ipstats() | @@ -153,9 +156,9 @@ ipstats() | ||
| 153 | lprint(" %6d total packets delivered\r\n", ipstat.ips_delivered); | 156 | lprint(" %6d total packets delivered\r\n", ipstat.ips_delivered); |
| 154 | } | 157 | } |
| 155 | 158 | ||
| 156 | -#if 0 | ||
| 157 | -void | ||
| 158 | -vjstats() | 159 | +#ifndef CONFIG_QEMU |
| 160 | +static void | ||
| 161 | +vjstats(void) | ||
| 159 | { | 162 | { |
| 160 | lprint(" \r\n"); | 163 | lprint(" \r\n"); |
| 161 | 164 | ||
| @@ -172,8 +175,8 @@ vjstats() | @@ -172,8 +175,8 @@ vjstats() | ||
| 172 | } | 175 | } |
| 173 | #endif | 176 | #endif |
| 174 | 177 | ||
| 175 | -void | ||
| 176 | -tcpstats() | 178 | +static void |
| 179 | +tcpstats(void) | ||
| 177 | { | 180 | { |
| 178 | lprint(" \r\n"); | 181 | lprint(" \r\n"); |
| 179 | 182 | ||
| @@ -240,8 +243,8 @@ tcpstats() | @@ -240,8 +243,8 @@ tcpstats() | ||
| 240 | 243 | ||
| 241 | } | 244 | } |
| 242 | 245 | ||
| 243 | -void | ||
| 244 | -udpstats() | 246 | +static void |
| 247 | +udpstats(void) | ||
| 245 | { | 248 | { |
| 246 | lprint(" \r\n"); | 249 | lprint(" \r\n"); |
| 247 | 250 | ||
| @@ -254,8 +257,8 @@ udpstats() | @@ -254,8 +257,8 @@ udpstats() | ||
| 254 | lprint(" %6d datagrams sent\r\n", udpstat.udps_opackets); | 257 | lprint(" %6d datagrams sent\r\n", udpstat.udps_opackets); |
| 255 | } | 258 | } |
| 256 | 259 | ||
| 257 | -void | ||
| 258 | -icmpstats() | 260 | +static void |
| 261 | +icmpstats(void) | ||
| 259 | { | 262 | { |
| 260 | lprint(" \r\n"); | 263 | lprint(" \r\n"); |
| 261 | lprint("ICMP stats:\r\n"); | 264 | lprint("ICMP stats:\r\n"); |
| @@ -267,8 +270,8 @@ icmpstats() | @@ -267,8 +270,8 @@ icmpstats() | ||
| 267 | lprint(" %6d ICMP packets sent in reply\r\n", icmpstat.icps_reflect); | 270 | lprint(" %6d ICMP packets sent in reply\r\n", icmpstat.icps_reflect); |
| 268 | } | 271 | } |
| 269 | 272 | ||
| 270 | -void | ||
| 271 | -mbufstats() | 273 | +static void |
| 274 | +mbufstats(void) | ||
| 272 | { | 275 | { |
| 273 | struct mbuf *m; | 276 | struct mbuf *m; |
| 274 | int i; | 277 | int i; |
| @@ -291,8 +294,8 @@ mbufstats() | @@ -291,8 +294,8 @@ mbufstats() | ||
| 291 | lprint(" %6d mbufs queued as packets\r\n\r\n", if_queued); | 294 | lprint(" %6d mbufs queued as packets\r\n\r\n", if_queued); |
| 292 | } | 295 | } |
| 293 | 296 | ||
| 294 | -void | ||
| 295 | -sockstats() | 297 | +static void |
| 298 | +sockstats(void) | ||
| 296 | { | 299 | { |
| 297 | char buff[256]; | 300 | char buff[256]; |
| 298 | int n; | 301 | int n; |
| @@ -331,8 +334,9 @@ sockstats() | @@ -331,8 +334,9 @@ sockstats() | ||
| 331 | so->so_rcv.sb_cc, so->so_snd.sb_cc); | 334 | so->so_rcv.sb_cc, so->so_snd.sb_cc); |
| 332 | } | 335 | } |
| 333 | } | 336 | } |
| 337 | +#endif | ||
| 334 | 338 | ||
| 335 | -#if 0 | 339 | +#ifndef CONFIG_QEMU |
| 336 | void | 340 | void |
| 337 | slirp_exit(exit_status) | 341 | slirp_exit(exit_status) |
| 338 | int exit_status; | 342 | int exit_status; |
| @@ -374,3 +378,18 @@ slirp_exit(exit_status) | @@ -374,3 +378,18 @@ slirp_exit(exit_status) | ||
| 374 | exit(exit_status); | 378 | exit(exit_status); |
| 375 | } | 379 | } |
| 376 | #endif | 380 | #endif |
| 381 | + | ||
| 382 | +void | ||
| 383 | +slirp_stats(void) | ||
| 384 | +{ | ||
| 385 | +#ifdef LOG_ENABLED | ||
| 386 | + ipstats(); | ||
| 387 | + tcpstats(); | ||
| 388 | + udpstats(); | ||
| 389 | + icmpstats(); | ||
| 390 | + mbufstats(); | ||
| 391 | + sockstats(); | ||
| 392 | +#else | ||
| 393 | + lprint("SLIRP statistics code not compiled.\n"); | ||
| 394 | +#endif | ||
| 395 | +} |
slirp/debug.h
| @@ -37,14 +37,4 @@ extern int slirp_debug; | @@ -37,14 +37,4 @@ extern int slirp_debug; | ||
| 37 | #endif | 37 | #endif |
| 38 | 38 | ||
| 39 | void debug_init _P((char *, int)); | 39 | void debug_init _P((char *, int)); |
| 40 | -//void ttystats _P((struct ttys *)); | ||
| 41 | -void allttystats _P((void)); | ||
| 42 | -void ipstats _P((void)); | ||
| 43 | -void vjstats _P((void)); | ||
| 44 | -void tcpstats _P((void)); | ||
| 45 | -void udpstats _P((void)); | ||
| 46 | -void icmpstats _P((void)); | ||
| 47 | -void mbufstats _P((void)); | ||
| 48 | -void sockstats _P((void)); | ||
| 49 | -void slirp_exit _P((int)); | ||
| 50 | 40 |
slirp/icmp_var.h
slirp/if.h
| @@ -29,6 +29,7 @@ extern struct mbuf *next_m; | @@ -29,6 +29,7 @@ extern struct mbuf *next_m; | ||
| 29 | 29 | ||
| 30 | #define ifs_init(ifm) ((ifm)->ifs_next = (ifm)->ifs_prev = (ifm)) | 30 | #define ifs_init(ifm) ((ifm)->ifs_next = (ifm)->ifs_prev = (ifm)) |
| 31 | 31 | ||
| 32 | +#ifdef LOG_ENABLED | ||
| 32 | /* Interface statistics */ | 33 | /* Interface statistics */ |
| 33 | struct slirp_ifstats { | 34 | struct slirp_ifstats { |
| 34 | u_int out_pkts; /* Output packets */ | 35 | u_int out_pkts; /* Output packets */ |
| @@ -46,5 +47,6 @@ struct slirp_ifstats { | @@ -46,5 +47,6 @@ struct slirp_ifstats { | ||
| 46 | 47 | ||
| 47 | u_int in_mbad; /* Bad incoming packets */ | 48 | u_int in_mbad; /* Bad incoming packets */ |
| 48 | }; | 49 | }; |
| 50 | +#endif | ||
| 49 | 51 | ||
| 50 | #endif | 52 | #endif |
slirp/ip.h
| @@ -272,6 +272,7 @@ struct ipoption { | @@ -272,6 +272,7 @@ struct ipoption { | ||
| 272 | int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */ | 272 | int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */ |
| 273 | }; | 273 | }; |
| 274 | 274 | ||
| 275 | +#ifdef LOG_ENABLED | ||
| 275 | /* | 276 | /* |
| 276 | * Structure attached to inpcb.ip_moptions and | 277 | * Structure attached to inpcb.ip_moptions and |
| 277 | * passed to ip_output when IP multicast options are in use. | 278 | * passed to ip_output when IP multicast options are in use. |
| @@ -306,8 +307,11 @@ struct ipstat { | @@ -306,8 +307,11 @@ struct ipstat { | ||
| 306 | }; | 307 | }; |
| 307 | 308 | ||
| 308 | extern struct ipstat ipstat; | 309 | extern struct ipstat ipstat; |
| 310 | +#endif | ||
| 311 | + | ||
| 309 | extern struct ipq ipq; /* ip reass. queue */ | 312 | extern struct ipq ipq; /* ip reass. queue */ |
| 310 | extern u_int16_t ip_id; /* ip packet ctr, for ids */ | 313 | extern u_int16_t ip_id; /* ip packet ctr, for ids */ |
| 314 | + | ||
| 311 | extern int ip_defttl; /* default IP ttl */ | 315 | extern int ip_defttl; /* default IP ttl */ |
| 312 | 316 | ||
| 313 | #endif | 317 | #endif |
slirp/ip_icmp.c
| @@ -37,7 +37,9 @@ | @@ -37,7 +37,9 @@ | ||
| 37 | #include "slirp.h" | 37 | #include "slirp.h" |
| 38 | #include "ip_icmp.h" | 38 | #include "ip_icmp.h" |
| 39 | 39 | ||
| 40 | +#ifdef LOG_ENABLED | ||
| 40 | struct icmpstat icmpstat; | 41 | struct icmpstat icmpstat; |
| 42 | +#endif | ||
| 41 | 43 | ||
| 42 | /* The message sent when emulating PING */ | 44 | /* The message sent when emulating PING */ |
| 43 | /* Be nice and tell them it's just a psuedo-ping packet */ | 45 | /* Be nice and tell them it's just a psuedo-ping packet */ |
| @@ -83,14 +85,14 @@ icmp_input(m, hlen) | @@ -83,14 +85,14 @@ icmp_input(m, hlen) | ||
| 83 | DEBUG_ARG("m = %lx", (long )m); | 85 | DEBUG_ARG("m = %lx", (long )m); |
| 84 | DEBUG_ARG("m_len = %d", m->m_len); | 86 | DEBUG_ARG("m_len = %d", m->m_len); |
| 85 | 87 | ||
| 86 | - icmpstat.icps_received++; | 88 | + STAT(icmpstat.icps_received++); |
| 87 | 89 | ||
| 88 | /* | 90 | /* |
| 89 | * Locate icmp structure in mbuf, and check | 91 | * Locate icmp structure in mbuf, and check |
| 90 | * that its not corrupted and of at least minimum length. | 92 | * that its not corrupted and of at least minimum length. |
| 91 | */ | 93 | */ |
| 92 | if (icmplen < ICMP_MINLEN) { /* min 8 bytes payload */ | 94 | if (icmplen < ICMP_MINLEN) { /* min 8 bytes payload */ |
| 93 | - icmpstat.icps_tooshort++; | 95 | + STAT(icmpstat.icps_tooshort++); |
| 94 | freeit: | 96 | freeit: |
| 95 | m_freem(m); | 97 | m_freem(m); |
| 96 | goto end_error; | 98 | goto end_error; |
| @@ -100,7 +102,7 @@ icmp_input(m, hlen) | @@ -100,7 +102,7 @@ icmp_input(m, hlen) | ||
| 100 | m->m_data += hlen; | 102 | m->m_data += hlen; |
| 101 | icp = mtod(m, struct icmp *); | 103 | icp = mtod(m, struct icmp *); |
| 102 | if (cksum(m, icmplen)) { | 104 | if (cksum(m, icmplen)) { |
| 103 | - icmpstat.icps_checksum++; | 105 | + STAT(icmpstat.icps_checksum++); |
| 104 | goto freeit; | 106 | goto freeit; |
| 105 | } | 107 | } |
| 106 | m->m_len += hlen; | 108 | m->m_len += hlen; |
| @@ -170,12 +172,12 @@ icmp_input(m, hlen) | @@ -170,12 +172,12 @@ icmp_input(m, hlen) | ||
| 170 | case ICMP_TSTAMP: | 172 | case ICMP_TSTAMP: |
| 171 | case ICMP_MASKREQ: | 173 | case ICMP_MASKREQ: |
| 172 | case ICMP_REDIRECT: | 174 | case ICMP_REDIRECT: |
| 173 | - icmpstat.icps_notsupp++; | 175 | + STAT(icmpstat.icps_notsupp++); |
| 174 | m_freem(m); | 176 | m_freem(m); |
| 175 | break; | 177 | break; |
| 176 | 178 | ||
| 177 | default: | 179 | default: |
| 178 | - icmpstat.icps_badtype++; | 180 | + STAT(icmpstat.icps_badtype++); |
| 179 | m_freem(m); | 181 | m_freem(m); |
| 180 | } /* swith */ | 182 | } /* swith */ |
| 181 | 183 | ||
| @@ -314,7 +316,7 @@ icmp_error(msrc, type, code, minsize, message) | @@ -314,7 +316,7 @@ icmp_error(msrc, type, code, minsize, message) | ||
| 314 | 316 | ||
| 315 | (void ) ip_output((struct socket *)NULL, m); | 317 | (void ) ip_output((struct socket *)NULL, m); |
| 316 | 318 | ||
| 317 | - icmpstat.icps_reflect++; | 319 | + STAT(icmpstat.icps_reflect++); |
| 318 | 320 | ||
| 319 | end_error: | 321 | end_error: |
| 320 | return; | 322 | return; |
| @@ -371,5 +373,5 @@ icmp_reflect(m) | @@ -371,5 +373,5 @@ icmp_reflect(m) | ||
| 371 | 373 | ||
| 372 | (void ) ip_output((struct socket *)NULL, m); | 374 | (void ) ip_output((struct socket *)NULL, m); |
| 373 | 375 | ||
| 374 | - icmpstat.icps_reflect++; | 376 | + STAT(icmpstat.icps_reflect++); |
| 375 | } | 377 | } |
slirp/ip_input.c
| @@ -46,7 +46,11 @@ | @@ -46,7 +46,11 @@ | ||
| 46 | #include "ip_icmp.h" | 46 | #include "ip_icmp.h" |
| 47 | 47 | ||
| 48 | int ip_defttl; | 48 | int ip_defttl; |
| 49 | + | ||
| 50 | +#ifdef LOG_ENABLED | ||
| 49 | struct ipstat ipstat; | 51 | struct ipstat ipstat; |
| 52 | +#endif | ||
| 53 | + | ||
| 50 | struct ipq ipq; | 54 | struct ipq ipq; |
| 51 | 55 | ||
| 52 | /* | 56 | /* |
| @@ -78,23 +82,23 @@ ip_input(m) | @@ -78,23 +82,23 @@ ip_input(m) | ||
| 78 | DEBUG_ARG("m = %lx", (long)m); | 82 | DEBUG_ARG("m = %lx", (long)m); |
| 79 | DEBUG_ARG("m_len = %d", m->m_len); | 83 | DEBUG_ARG("m_len = %d", m->m_len); |
| 80 | 84 | ||
| 81 | - ipstat.ips_total++; | 85 | + STAT(ipstat.ips_total++); |
| 82 | 86 | ||
| 83 | if (m->m_len < sizeof (struct ip)) { | 87 | if (m->m_len < sizeof (struct ip)) { |
| 84 | - ipstat.ips_toosmall++; | 88 | + STAT(ipstat.ips_toosmall++); |
| 85 | return; | 89 | return; |
| 86 | } | 90 | } |
| 87 | 91 | ||
| 88 | ip = mtod(m, struct ip *); | 92 | ip = mtod(m, struct ip *); |
| 89 | 93 | ||
| 90 | if (ip->ip_v != IPVERSION) { | 94 | if (ip->ip_v != IPVERSION) { |
| 91 | - ipstat.ips_badvers++; | 95 | + STAT(ipstat.ips_badvers++); |
| 92 | goto bad; | 96 | goto bad; |
| 93 | } | 97 | } |
| 94 | 98 | ||
| 95 | hlen = ip->ip_hl << 2; | 99 | hlen = ip->ip_hl << 2; |
| 96 | if (hlen<sizeof(struct ip ) || hlen>m->m_len) {/* min header length */ | 100 | if (hlen<sizeof(struct ip ) || hlen>m->m_len) {/* min header length */ |
| 97 | - ipstat.ips_badhlen++; /* or packet too short */ | 101 | + STAT(ipstat.ips_badhlen++); /* or packet too short */ |
| 98 | goto bad; | 102 | goto bad; |
| 99 | } | 103 | } |
| 100 | 104 | ||
| @@ -103,7 +107,7 @@ ip_input(m) | @@ -103,7 +107,7 @@ ip_input(m) | ||
| 103 | * if (ip->ip_sum) { | 107 | * if (ip->ip_sum) { |
| 104 | */ | 108 | */ |
| 105 | if(cksum(m,hlen)) { | 109 | if(cksum(m,hlen)) { |
| 106 | - ipstat.ips_badsum++; | 110 | + STAT(ipstat.ips_badsum++); |
| 107 | goto bad; | 111 | goto bad; |
| 108 | } | 112 | } |
| 109 | 113 | ||
| @@ -112,7 +116,7 @@ ip_input(m) | @@ -112,7 +116,7 @@ ip_input(m) | ||
| 112 | */ | 116 | */ |
| 113 | NTOHS(ip->ip_len); | 117 | NTOHS(ip->ip_len); |
| 114 | if (ip->ip_len < hlen) { | 118 | if (ip->ip_len < hlen) { |
| 115 | - ipstat.ips_badlen++; | 119 | + STAT(ipstat.ips_badlen++); |
| 116 | goto bad; | 120 | goto bad; |
| 117 | } | 121 | } |
| 118 | NTOHS(ip->ip_id); | 122 | NTOHS(ip->ip_id); |
| @@ -125,7 +129,7 @@ ip_input(m) | @@ -125,7 +129,7 @@ ip_input(m) | ||
| 125 | * Drop packet if shorter than we expect. | 129 | * Drop packet if shorter than we expect. |
| 126 | */ | 130 | */ |
| 127 | if (m->m_len < ip->ip_len) { | 131 | if (m->m_len < ip->ip_len) { |
| 128 | - ipstat.ips_tooshort++; | 132 | + STAT(ipstat.ips_tooshort++); |
| 129 | goto bad; | 133 | goto bad; |
| 130 | } | 134 | } |
| 131 | /* Should drop packet if mbuf too long? hmmm... */ | 135 | /* Should drop packet if mbuf too long? hmmm... */ |
| @@ -192,11 +196,11 @@ ip_input(m) | @@ -192,11 +196,11 @@ ip_input(m) | ||
| 192 | * attempt reassembly; if it succeeds, proceed. | 196 | * attempt reassembly; if it succeeds, proceed. |
| 193 | */ | 197 | */ |
| 194 | if (((struct ipasfrag *)ip)->ipf_mff & 1 || ip->ip_off) { | 198 | if (((struct ipasfrag *)ip)->ipf_mff & 1 || ip->ip_off) { |
| 195 | - ipstat.ips_fragments++; | 199 | + STAT(ipstat.ips_fragments++); |
| 196 | ip = ip_reass((struct ipasfrag *)ip, fp); | 200 | ip = ip_reass((struct ipasfrag *)ip, fp); |
| 197 | if (ip == 0) | 201 | if (ip == 0) |
| 198 | return; | 202 | return; |
| 199 | - ipstat.ips_reassembled++; | 203 | + STAT(ipstat.ips_reassembled++); |
| 200 | m = dtom(ip); | 204 | m = dtom(ip); |
| 201 | } else | 205 | } else |
| 202 | if (fp) | 206 | if (fp) |
| @@ -208,7 +212,7 @@ ip_input(m) | @@ -208,7 +212,7 @@ ip_input(m) | ||
| 208 | /* | 212 | /* |
| 209 | * Switch out to protocol's input routine. | 213 | * Switch out to protocol's input routine. |
| 210 | */ | 214 | */ |
| 211 | - ipstat.ips_delivered++; | 215 | + STAT(ipstat.ips_delivered++); |
| 212 | switch (ip->ip_p) { | 216 | switch (ip->ip_p) { |
| 213 | case IPPROTO_TCP: | 217 | case IPPROTO_TCP: |
| 214 | tcp_input(m, hlen, (struct socket *)NULL); | 218 | tcp_input(m, hlen, (struct socket *)NULL); |
| @@ -220,7 +224,7 @@ ip_input(m) | @@ -220,7 +224,7 @@ ip_input(m) | ||
| 220 | icmp_input(m, hlen); | 224 | icmp_input(m, hlen); |
| 221 | break; | 225 | break; |
| 222 | default: | 226 | default: |
| 223 | - ipstat.ips_noproto++; | 227 | + STAT(ipstat.ips_noproto++); |
| 224 | m_free(m); | 228 | m_free(m); |
| 225 | } | 229 | } |
| 226 | return; | 230 | return; |
| @@ -385,7 +389,7 @@ insert: | @@ -385,7 +389,7 @@ insert: | ||
| 385 | return ((struct ip *)ip); | 389 | return ((struct ip *)ip); |
| 386 | 390 | ||
| 387 | dropfrag: | 391 | dropfrag: |
| 388 | - ipstat.ips_fragdropped++; | 392 | + STAT(ipstat.ips_fragdropped++); |
| 389 | m_freem(m); | 393 | m_freem(m); |
| 390 | return (0); | 394 | return (0); |
| 391 | } | 395 | } |
| @@ -457,7 +461,7 @@ ip_slowtimo() | @@ -457,7 +461,7 @@ ip_slowtimo() | ||
| 457 | --fp->ipq_ttl; | 461 | --fp->ipq_ttl; |
| 458 | fp = (struct ipq *) fp->next; | 462 | fp = (struct ipq *) fp->next; |
| 459 | if (((struct ipq *)(fp->prev))->ipq_ttl == 0) { | 463 | if (((struct ipq *)(fp->prev))->ipq_ttl == 0) { |
| 460 | - ipstat.ips_fragtimeout++; | 464 | + STAT(ipstat.ips_fragtimeout++); |
| 461 | ip_freef((struct ipq *) fp->prev); | 465 | ip_freef((struct ipq *) fp->prev); |
| 462 | } | 466 | } |
| 463 | } | 467 | } |
| @@ -664,7 +668,7 @@ bad: | @@ -664,7 +668,7 @@ bad: | ||
| 664 | /* Not yet */ | 668 | /* Not yet */ |
| 665 | icmp_error(m, type, code, 0, 0); | 669 | icmp_error(m, type, code, 0, 0); |
| 666 | 670 | ||
| 667 | - ipstat.ips_badoptions++; | 671 | + STAT(ipstat.ips_badoptions++); |
| 668 | return (1); | 672 | return (1); |
| 669 | } | 673 | } |
| 670 | 674 |
slirp/ip_output.c
| @@ -80,7 +80,7 @@ ip_output(so, m0) | @@ -80,7 +80,7 @@ ip_output(so, m0) | ||
| 80 | ip->ip_off &= IP_DF; | 80 | ip->ip_off &= IP_DF; |
| 81 | ip->ip_id = htons(ip_id++); | 81 | ip->ip_id = htons(ip_id++); |
| 82 | ip->ip_hl = hlen >> 2; | 82 | ip->ip_hl = hlen >> 2; |
| 83 | - ipstat.ips_localout++; | 83 | + STAT(ipstat.ips_localout++); |
| 84 | 84 | ||
| 85 | /* | 85 | /* |
| 86 | * Verify that we have any chance at all of being able to queue | 86 | * Verify that we have any chance at all of being able to queue |
| @@ -112,7 +112,7 @@ ip_output(so, m0) | @@ -112,7 +112,7 @@ ip_output(so, m0) | ||
| 112 | */ | 112 | */ |
| 113 | if (ip->ip_off & IP_DF) { | 113 | if (ip->ip_off & IP_DF) { |
| 114 | error = -1; | 114 | error = -1; |
| 115 | - ipstat.ips_cantfrag++; | 115 | + STAT(ipstat.ips_cantfrag++); |
| 116 | goto bad; | 116 | goto bad; |
| 117 | } | 117 | } |
| 118 | 118 | ||
| @@ -137,7 +137,7 @@ ip_output(so, m0) | @@ -137,7 +137,7 @@ ip_output(so, m0) | ||
| 137 | m = m_get(); | 137 | m = m_get(); |
| 138 | if (m == 0) { | 138 | if (m == 0) { |
| 139 | error = -1; | 139 | error = -1; |
| 140 | - ipstat.ips_odropped++; | 140 | + STAT(ipstat.ips_odropped++); |
| 141 | goto sendorfree; | 141 | goto sendorfree; |
| 142 | } | 142 | } |
| 143 | m->m_data += if_maxlinkhdr; | 143 | m->m_data += if_maxlinkhdr; |
| @@ -170,7 +170,7 @@ ip_output(so, m0) | @@ -170,7 +170,7 @@ ip_output(so, m0) | ||
| 170 | mhip->ip_sum = cksum(m, mhlen); | 170 | mhip->ip_sum = cksum(m, mhlen); |
| 171 | *mnext = m; | 171 | *mnext = m; |
| 172 | mnext = &m->m_nextpkt; | 172 | mnext = &m->m_nextpkt; |
| 173 | - ipstat.ips_ofragments++; | 173 | + STAT(ipstat.ips_ofragments++); |
| 174 | } | 174 | } |
| 175 | /* | 175 | /* |
| 176 | * Update first fragment by trimming what's been copied out | 176 | * Update first fragment by trimming what's been copied out |
| @@ -193,7 +193,7 @@ sendorfree: | @@ -193,7 +193,7 @@ sendorfree: | ||
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | if (error == 0) | 195 | if (error == 0) |
| 196 | - ipstat.ips_fragmented++; | 196 | + STAT(ipstat.ips_fragmented++); |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | done: | 199 | done: |
slirp/libslirp.h
| @@ -26,6 +26,8 @@ int slirp_add_exec(int do_pty, const char *args, int addr_low_byte, | @@ -26,6 +26,8 @@ int slirp_add_exec(int do_pty, const char *args, int addr_low_byte, | ||
| 26 | extern const char *tftp_prefix; | 26 | extern const char *tftp_prefix; |
| 27 | extern char slirp_hostname[33]; | 27 | extern char slirp_hostname[33]; |
| 28 | 28 | ||
| 29 | +void slirp_stats(void); | ||
| 30 | + | ||
| 29 | #ifdef __cplusplus | 31 | #ifdef __cplusplus |
| 30 | } | 32 | } |
| 31 | #endif | 33 | #endif |
slirp/misc.c
| @@ -603,6 +603,16 @@ relay(s) | @@ -603,6 +603,16 @@ relay(s) | ||
| 603 | } | 603 | } |
| 604 | #endif | 604 | #endif |
| 605 | 605 | ||
| 606 | +#ifdef CONFIG_QEMU | ||
| 607 | +void lprint(const char *format, ...) | ||
| 608 | +{ | ||
| 609 | + va_list args; | ||
| 610 | + | ||
| 611 | + va_start(args, format); | ||
| 612 | + term_vprintf(format, args); | ||
| 613 | + va_end(args); | ||
| 614 | +} | ||
| 615 | +#else | ||
| 606 | int (*lprint_print) _P((void *, const char *, va_list)); | 616 | int (*lprint_print) _P((void *, const char *, va_list)); |
| 607 | char *lprint_ptr, *lprint_ptr2, **lprint_arg; | 617 | char *lprint_ptr, *lprint_ptr2, **lprint_arg; |
| 608 | 618 | ||
| @@ -754,6 +764,7 @@ add_emu(buff) | @@ -754,6 +764,7 @@ add_emu(buff) | ||
| 754 | 764 | ||
| 755 | lprint("Adding emulation for %s to port %d/%d\r\n", buff1, emup->lport, emup->fport); | 765 | lprint("Adding emulation for %s to port %d/%d\r\n", buff1, emup->lport, emup->fport); |
| 756 | } | 766 | } |
| 767 | +#endif | ||
| 757 | 768 | ||
| 758 | #ifdef BAD_SPRINTF | 769 | #ifdef BAD_SPRINTF |
| 759 | 770 |
slirp/slirp.c
| @@ -93,7 +93,9 @@ static int get_dns_addr(struct in_addr *pdns_addr) | @@ -93,7 +93,9 @@ static int get_dns_addr(struct in_addr *pdns_addr) | ||
| 93 | if (!f) | 93 | if (!f) |
| 94 | return -1; | 94 | return -1; |
| 95 | 95 | ||
| 96 | +#ifdef DEBUG | ||
| 96 | lprint("IP address of your DNS(s): "); | 97 | lprint("IP address of your DNS(s): "); |
| 98 | +#endif | ||
| 97 | while (fgets(buff, 512, f) != NULL) { | 99 | while (fgets(buff, 512, f) != NULL) { |
| 98 | if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) { | 100 | if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) { |
| 99 | if (!inet_aton(buff2, &tmp_addr)) | 101 | if (!inet_aton(buff2, &tmp_addr)) |
| @@ -103,13 +105,20 @@ static int get_dns_addr(struct in_addr *pdns_addr) | @@ -103,13 +105,20 @@ static int get_dns_addr(struct in_addr *pdns_addr) | ||
| 103 | /* If it's the first one, set it to dns_addr */ | 105 | /* If it's the first one, set it to dns_addr */ |
| 104 | if (!found) | 106 | if (!found) |
| 105 | *pdns_addr = tmp_addr; | 107 | *pdns_addr = tmp_addr; |
| 108 | +#ifdef DEBUG | ||
| 106 | else | 109 | else |
| 107 | lprint(", "); | 110 | lprint(", "); |
| 111 | +#endif | ||
| 108 | if (++found > 3) { | 112 | if (++found > 3) { |
| 113 | +#ifdef DEBUG | ||
| 109 | lprint("(more)"); | 114 | lprint("(more)"); |
| 115 | +#endif | ||
| 110 | break; | 116 | break; |
| 111 | - } else | 117 | + } |
| 118 | +#ifdef DEBUG | ||
| 119 | + else | ||
| 112 | lprint("%s", inet_ntoa(tmp_addr)); | 120 | lprint("%s", inet_ntoa(tmp_addr)); |
| 121 | +#endif | ||
| 113 | } | 122 | } |
| 114 | } | 123 | } |
| 115 | fclose(f); | 124 | fclose(f); |
slirp/slirp.h
| @@ -3,7 +3,16 @@ | @@ -3,7 +3,16 @@ | ||
| 3 | 3 | ||
| 4 | #define CONFIG_QEMU | 4 | #define CONFIG_QEMU |
| 5 | 5 | ||
| 6 | -#define DEBUG 1 | 6 | +//#define DEBUG 1 |
| 7 | + | ||
| 8 | +// Uncomment the following line to enable SLIRP statistics printing in Qemu | ||
| 9 | +//#define LOG_ENABLED | ||
| 10 | + | ||
| 11 | +#ifdef LOG_ENABLED | ||
| 12 | +#define STAT(expr) expr | ||
| 13 | +#else | ||
| 14 | +#define STAT(expr) do { } while(0) | ||
| 15 | +#endif | ||
| 7 | 16 | ||
| 8 | #ifndef CONFIG_QEMU | 17 | #ifndef CONFIG_QEMU |
| 9 | #include "version.h" | 18 | #include "version.h" |
slirp/tcp_input.c
| @@ -79,8 +79,8 @@ tcp_seq tcp_iss; /* tcp initial send seq # */ | @@ -79,8 +79,8 @@ tcp_seq tcp_iss; /* tcp initial send seq # */ | ||
| 79 | tp->t_flags |= TF_DELACK; \ | 79 | tp->t_flags |= TF_DELACK; \ |
| 80 | (tp)->rcv_nxt += (ti)->ti_len; \ | 80 | (tp)->rcv_nxt += (ti)->ti_len; \ |
| 81 | flags = (ti)->ti_flags & TH_FIN; \ | 81 | flags = (ti)->ti_flags & TH_FIN; \ |
| 82 | - tcpstat.tcps_rcvpack++;\ | ||
| 83 | - tcpstat.tcps_rcvbyte += (ti)->ti_len;\ | 82 | + STAT(tcpstat.tcps_rcvpack++); \ |
| 83 | + STAT(tcpstat.tcps_rcvbyte += (ti)->ti_len); \ | ||
| 84 | if (so->so_emu) { \ | 84 | if (so->so_emu) { \ |
| 85 | if (tcp_emu((so),(m))) sbappend((so), (m)); \ | 85 | if (tcp_emu((so),(m))) sbappend((so), (m)); \ |
| 86 | } else \ | 86 | } else \ |
| @@ -99,8 +99,8 @@ tcp_seq tcp_iss; /* tcp initial send seq # */ | @@ -99,8 +99,8 @@ tcp_seq tcp_iss; /* tcp initial send seq # */ | ||
| 99 | tp->t_flags |= TF_DELACK; \ | 99 | tp->t_flags |= TF_DELACK; \ |
| 100 | (tp)->rcv_nxt += (ti)->ti_len; \ | 100 | (tp)->rcv_nxt += (ti)->ti_len; \ |
| 101 | flags = (ti)->ti_flags & TH_FIN; \ | 101 | flags = (ti)->ti_flags & TH_FIN; \ |
| 102 | - tcpstat.tcps_rcvpack++;\ | ||
| 103 | - tcpstat.tcps_rcvbyte += (ti)->ti_len;\ | 102 | + STAT(tcpstat.tcps_rcvpack++); \ |
| 103 | + STAT(tcpstat.tcps_rcvbyte += (ti)->ti_len); \ | ||
| 104 | if (so->so_emu) { \ | 104 | if (so->so_emu) { \ |
| 105 | if (tcp_emu((so),(m))) sbappend(so, (m)); \ | 105 | if (tcp_emu((so),(m))) sbappend(so, (m)); \ |
| 106 | } else \ | 106 | } else \ |
| @@ -150,8 +150,8 @@ tcp_reass(tp, ti, m) | @@ -150,8 +150,8 @@ tcp_reass(tp, ti, m) | ||
| 150 | i = q->ti_seq + q->ti_len - ti->ti_seq; | 150 | i = q->ti_seq + q->ti_len - ti->ti_seq; |
| 151 | if (i > 0) { | 151 | if (i > 0) { |
| 152 | if (i >= ti->ti_len) { | 152 | if (i >= ti->ti_len) { |
| 153 | - tcpstat.tcps_rcvduppack++; | ||
| 154 | - tcpstat.tcps_rcvdupbyte += ti->ti_len; | 153 | + STAT(tcpstat.tcps_rcvduppack++); |
| 154 | + STAT(tcpstat.tcps_rcvdupbyte += ti->ti_len); | ||
| 155 | m_freem(m); | 155 | m_freem(m); |
| 156 | /* | 156 | /* |
| 157 | * Try to present any queued data | 157 | * Try to present any queued data |
| @@ -167,8 +167,8 @@ tcp_reass(tp, ti, m) | @@ -167,8 +167,8 @@ tcp_reass(tp, ti, m) | ||
| 167 | } | 167 | } |
| 168 | q = (struct tcpiphdr *)(q->ti_next); | 168 | q = (struct tcpiphdr *)(q->ti_next); |
| 169 | } | 169 | } |
| 170 | - tcpstat.tcps_rcvoopack++; | ||
| 171 | - tcpstat.tcps_rcvoobyte += ti->ti_len; | 170 | + STAT(tcpstat.tcps_rcvoopack++); |
| 171 | + STAT(tcpstat.tcps_rcvoobyte += ti->ti_len); | ||
| 172 | REASS_MBUF(ti) = (mbufp_32) m; /* XXX */ | 172 | REASS_MBUF(ti) = (mbufp_32) m; /* XXX */ |
| 173 | 173 | ||
| 174 | /* | 174 | /* |
| @@ -275,7 +275,7 @@ tcp_input(m, iphlen, inso) | @@ -275,7 +275,7 @@ tcp_input(m, iphlen, inso) | ||
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | 277 | ||
| 278 | - tcpstat.tcps_rcvtotal++; | 278 | + STAT(tcpstat.tcps_rcvtotal++); |
| 279 | /* | 279 | /* |
| 280 | * Get IP and TCP header together in first mbuf. | 280 | * Get IP and TCP header together in first mbuf. |
| 281 | * Note: IP leaves IP header in first mbuf. | 281 | * Note: IP leaves IP header in first mbuf. |
| @@ -308,7 +308,7 @@ tcp_input(m, iphlen, inso) | @@ -308,7 +308,7 @@ tcp_input(m, iphlen, inso) | ||
| 308 | * ti->ti_sum = cksum(m, len); | 308 | * ti->ti_sum = cksum(m, len); |
| 309 | * if (ti->ti_sum) { */ | 309 | * if (ti->ti_sum) { */ |
| 310 | if(cksum(m, len)) { | 310 | if(cksum(m, len)) { |
| 311 | - tcpstat.tcps_rcvbadsum++; | 311 | + STAT(tcpstat.tcps_rcvbadsum++); |
| 312 | goto drop; | 312 | goto drop; |
| 313 | } | 313 | } |
| 314 | 314 | ||
| @@ -318,7 +318,7 @@ tcp_input(m, iphlen, inso) | @@ -318,7 +318,7 @@ tcp_input(m, iphlen, inso) | ||
| 318 | */ | 318 | */ |
| 319 | off = ti->ti_off << 2; | 319 | off = ti->ti_off << 2; |
| 320 | if (off < sizeof (struct tcphdr) || off > tlen) { | 320 | if (off < sizeof (struct tcphdr) || off > tlen) { |
| 321 | - tcpstat.tcps_rcvbadoff++; | 321 | + STAT(tcpstat.tcps_rcvbadoff++); |
| 322 | goto drop; | 322 | goto drop; |
| 323 | } | 323 | } |
| 324 | tlen -= off; | 324 | tlen -= off; |
| @@ -375,7 +375,7 @@ findso: | @@ -375,7 +375,7 @@ findso: | ||
| 375 | ti->ti_dst, ti->ti_dport); | 375 | ti->ti_dst, ti->ti_dport); |
| 376 | if (so) | 376 | if (so) |
| 377 | tcp_last_so = so; | 377 | tcp_last_so = so; |
| 378 | - ++tcpstat.tcps_socachemiss; | 378 | + STAT(tcpstat.tcps_socachemiss++); |
| 379 | } | 379 | } |
| 380 | 380 | ||
| 381 | /* | 381 | /* |
| @@ -503,7 +503,7 @@ findso: | @@ -503,7 +503,7 @@ findso: | ||
| 503 | /* | 503 | /* |
| 504 | * this is a pure ack for outstanding data. | 504 | * this is a pure ack for outstanding data. |
| 505 | */ | 505 | */ |
| 506 | - ++tcpstat.tcps_predack; | 506 | + STAT(tcpstat.tcps_predack++); |
| 507 | /* if (ts_present) | 507 | /* if (ts_present) |
| 508 | * tcp_xmit_timer(tp, tcp_now-ts_ecr+1); | 508 | * tcp_xmit_timer(tp, tcp_now-ts_ecr+1); |
| 509 | * else | 509 | * else |
| @@ -511,8 +511,8 @@ findso: | @@ -511,8 +511,8 @@ findso: | ||
| 511 | SEQ_GT(ti->ti_ack, tp->t_rtseq)) | 511 | SEQ_GT(ti->ti_ack, tp->t_rtseq)) |
| 512 | tcp_xmit_timer(tp, tp->t_rtt); | 512 | tcp_xmit_timer(tp, tp->t_rtt); |
| 513 | acked = ti->ti_ack - tp->snd_una; | 513 | acked = ti->ti_ack - tp->snd_una; |
| 514 | - tcpstat.tcps_rcvackpack++; | ||
| 515 | - tcpstat.tcps_rcvackbyte += acked; | 514 | + STAT(tcpstat.tcps_rcvackpack++); |
| 515 | + STAT(tcpstat.tcps_rcvackbyte += acked); | ||
| 516 | sbdrop(&so->so_snd, acked); | 516 | sbdrop(&so->so_snd, acked); |
| 517 | tp->snd_una = ti->ti_ack; | 517 | tp->snd_una = ti->ti_ack; |
| 518 | m_freem(m); | 518 | m_freem(m); |
| @@ -556,10 +556,10 @@ findso: | @@ -556,10 +556,10 @@ findso: | ||
| 556 | * with nothing on the reassembly queue and | 556 | * with nothing on the reassembly queue and |
| 557 | * we have enough buffer space to take it. | 557 | * we have enough buffer space to take it. |
| 558 | */ | 558 | */ |
| 559 | - ++tcpstat.tcps_preddat; | 559 | + STAT(tcpstat.tcps_preddat++); |
| 560 | tp->rcv_nxt += ti->ti_len; | 560 | tp->rcv_nxt += ti->ti_len; |
| 561 | - tcpstat.tcps_rcvpack++; | ||
| 562 | - tcpstat.tcps_rcvbyte += ti->ti_len; | 561 | + STAT(tcpstat.tcps_rcvpack++); |
| 562 | + STAT(tcpstat.tcps_rcvbyte += ti->ti_len); | ||
| 563 | /* | 563 | /* |
| 564 | * Add data to socket buffer. | 564 | * Add data to socket buffer. |
| 565 | */ | 565 | */ |
| @@ -726,7 +726,7 @@ findso: | @@ -726,7 +726,7 @@ findso: | ||
| 726 | tp->t_flags |= TF_ACKNOW; | 726 | tp->t_flags |= TF_ACKNOW; |
| 727 | tp->t_state = TCPS_SYN_RECEIVED; | 727 | tp->t_state = TCPS_SYN_RECEIVED; |
| 728 | tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; | 728 | tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; |
| 729 | - tcpstat.tcps_accepts++; | 729 | + STAT(tcpstat.tcps_accepts++); |
| 730 | goto trimthenstep6; | 730 | goto trimthenstep6; |
| 731 | } /* case TCPS_LISTEN */ | 731 | } /* case TCPS_LISTEN */ |
| 732 | 732 | ||
| @@ -767,7 +767,7 @@ findso: | @@ -767,7 +767,7 @@ findso: | ||
| 767 | tcp_rcvseqinit(tp); | 767 | tcp_rcvseqinit(tp); |
| 768 | tp->t_flags |= TF_ACKNOW; | 768 | tp->t_flags |= TF_ACKNOW; |
| 769 | if (tiflags & TH_ACK && SEQ_GT(tp->snd_una, tp->iss)) { | 769 | if (tiflags & TH_ACK && SEQ_GT(tp->snd_una, tp->iss)) { |
| 770 | - tcpstat.tcps_connects++; | 770 | + STAT(tcpstat.tcps_connects++); |
| 771 | soisfconnected(so); | 771 | soisfconnected(so); |
| 772 | tp->t_state = TCPS_ESTABLISHED; | 772 | tp->t_state = TCPS_ESTABLISHED; |
| 773 | 773 | ||
| @@ -801,8 +801,8 @@ trimthenstep6: | @@ -801,8 +801,8 @@ trimthenstep6: | ||
| 801 | m_adj(m, -todrop); | 801 | m_adj(m, -todrop); |
| 802 | ti->ti_len = tp->rcv_wnd; | 802 | ti->ti_len = tp->rcv_wnd; |
| 803 | tiflags &= ~TH_FIN; | 803 | tiflags &= ~TH_FIN; |
| 804 | - tcpstat.tcps_rcvpackafterwin++; | ||
| 805 | - tcpstat.tcps_rcvbyteafterwin += todrop; | 804 | + STAT(tcpstat.tcps_rcvpackafterwin++); |
| 805 | + STAT(tcpstat.tcps_rcvbyteafterwin += todrop); | ||
| 806 | } | 806 | } |
| 807 | tp->snd_wl1 = ti->ti_seq - 1; | 807 | tp->snd_wl1 = ti->ti_seq - 1; |
| 808 | tp->rcv_up = ti->ti_seq; | 808 | tp->rcv_up = ti->ti_seq; |
| @@ -873,11 +873,11 @@ trimthenstep6: | @@ -873,11 +873,11 @@ trimthenstep6: | ||
| 873 | */ | 873 | */ |
| 874 | tp->t_flags |= TF_ACKNOW; | 874 | tp->t_flags |= TF_ACKNOW; |
| 875 | todrop = ti->ti_len; | 875 | todrop = ti->ti_len; |
| 876 | - tcpstat.tcps_rcvduppack++; | ||
| 877 | - tcpstat.tcps_rcvdupbyte += todrop; | 876 | + STAT(tcpstat.tcps_rcvduppack++); |
| 877 | + STAT(tcpstat.tcps_rcvdupbyte += todrop); | ||
| 878 | } else { | 878 | } else { |
| 879 | - tcpstat.tcps_rcvpartduppack++; | ||
| 880 | - tcpstat.tcps_rcvpartdupbyte += todrop; | 879 | + STAT(tcpstat.tcps_rcvpartduppack++); |
| 880 | + STAT(tcpstat.tcps_rcvpartdupbyte += todrop); | ||
| 881 | } | 881 | } |
| 882 | m_adj(m, todrop); | 882 | m_adj(m, todrop); |
| 883 | ti->ti_seq += todrop; | 883 | ti->ti_seq += todrop; |
| @@ -896,7 +896,7 @@ trimthenstep6: | @@ -896,7 +896,7 @@ trimthenstep6: | ||
| 896 | if ((so->so_state & SS_NOFDREF) && | 896 | if ((so->so_state & SS_NOFDREF) && |
| 897 | tp->t_state > TCPS_CLOSE_WAIT && ti->ti_len) { | 897 | tp->t_state > TCPS_CLOSE_WAIT && ti->ti_len) { |
| 898 | tp = tcp_close(tp); | 898 | tp = tcp_close(tp); |
| 899 | - tcpstat.tcps_rcvafterclose++; | 899 | + STAT(tcpstat.tcps_rcvafterclose++); |
| 900 | goto dropwithreset; | 900 | goto dropwithreset; |
| 901 | } | 901 | } |
| 902 | 902 | ||
| @@ -906,9 +906,9 @@ trimthenstep6: | @@ -906,9 +906,9 @@ trimthenstep6: | ||
| 906 | */ | 906 | */ |
| 907 | todrop = (ti->ti_seq+ti->ti_len) - (tp->rcv_nxt+tp->rcv_wnd); | 907 | todrop = (ti->ti_seq+ti->ti_len) - (tp->rcv_nxt+tp->rcv_wnd); |
| 908 | if (todrop > 0) { | 908 | if (todrop > 0) { |
| 909 | - tcpstat.tcps_rcvpackafterwin++; | 909 | + STAT(tcpstat.tcps_rcvpackafterwin++); |
| 910 | if (todrop >= ti->ti_len) { | 910 | if (todrop >= ti->ti_len) { |
| 911 | - tcpstat.tcps_rcvbyteafterwin += ti->ti_len; | 911 | + STAT(tcpstat.tcps_rcvbyteafterwin += ti->ti_len); |
| 912 | /* | 912 | /* |
| 913 | * If a new connection request is received | 913 | * If a new connection request is received |
| 914 | * while in TIME_WAIT, drop the old connection | 914 | * while in TIME_WAIT, drop the old connection |
| @@ -931,11 +931,11 @@ trimthenstep6: | @@ -931,11 +931,11 @@ trimthenstep6: | ||
| 931 | */ | 931 | */ |
| 932 | if (tp->rcv_wnd == 0 && ti->ti_seq == tp->rcv_nxt) { | 932 | if (tp->rcv_wnd == 0 && ti->ti_seq == tp->rcv_nxt) { |
| 933 | tp->t_flags |= TF_ACKNOW; | 933 | tp->t_flags |= TF_ACKNOW; |
| 934 | - tcpstat.tcps_rcvwinprobe++; | 934 | + STAT(tcpstat.tcps_rcvwinprobe++); |
| 935 | } else | 935 | } else |
| 936 | goto dropafterack; | 936 | goto dropafterack; |
| 937 | } else | 937 | } else |
| 938 | - tcpstat.tcps_rcvbyteafterwin += todrop; | 938 | + STAT(tcpstat.tcps_rcvbyteafterwin += todrop); |
| 939 | m_adj(m, -todrop); | 939 | m_adj(m, -todrop); |
| 940 | ti->ti_len -= todrop; | 940 | ti->ti_len -= todrop; |
| 941 | tiflags &= ~(TH_PUSH|TH_FIN); | 941 | tiflags &= ~(TH_PUSH|TH_FIN); |
| @@ -976,7 +976,7 @@ trimthenstep6: | @@ -976,7 +976,7 @@ trimthenstep6: | ||
| 976 | /* so->so_error = ECONNRESET; */ | 976 | /* so->so_error = ECONNRESET; */ |
| 977 | close: | 977 | close: |
| 978 | tp->t_state = TCPS_CLOSED; | 978 | tp->t_state = TCPS_CLOSED; |
| 979 | - tcpstat.tcps_drops++; | 979 | + STAT(tcpstat.tcps_drops++); |
| 980 | tp = tcp_close(tp); | 980 | tp = tcp_close(tp); |
| 981 | goto drop; | 981 | goto drop; |
| 982 | 982 | ||
| @@ -1015,7 +1015,7 @@ trimthenstep6: | @@ -1015,7 +1015,7 @@ trimthenstep6: | ||
| 1015 | if (SEQ_GT(tp->snd_una, ti->ti_ack) || | 1015 | if (SEQ_GT(tp->snd_una, ti->ti_ack) || |
| 1016 | SEQ_GT(ti->ti_ack, tp->snd_max)) | 1016 | SEQ_GT(ti->ti_ack, tp->snd_max)) |
| 1017 | goto dropwithreset; | 1017 | goto dropwithreset; |
| 1018 | - tcpstat.tcps_connects++; | 1018 | + STAT(tcpstat.tcps_connects++); |
| 1019 | tp->t_state = TCPS_ESTABLISHED; | 1019 | tp->t_state = TCPS_ESTABLISHED; |
| 1020 | /* | 1020 | /* |
| 1021 | * The sent SYN is ack'ed with our sequence number +1 | 1021 | * The sent SYN is ack'ed with our sequence number +1 |
| @@ -1072,7 +1072,7 @@ trimthenstep6: | @@ -1072,7 +1072,7 @@ trimthenstep6: | ||
| 1072 | 1072 | ||
| 1073 | if (SEQ_LEQ(ti->ti_ack, tp->snd_una)) { | 1073 | if (SEQ_LEQ(ti->ti_ack, tp->snd_una)) { |
| 1074 | if (ti->ti_len == 0 && tiwin == tp->snd_wnd) { | 1074 | if (ti->ti_len == 0 && tiwin == tp->snd_wnd) { |
| 1075 | - tcpstat.tcps_rcvdupack++; | 1075 | + STAT(tcpstat.tcps_rcvdupack++); |
| 1076 | DEBUG_MISC((dfd," dup ack m = %lx so = %lx \n", | 1076 | DEBUG_MISC((dfd," dup ack m = %lx so = %lx \n", |
| 1077 | (long )m, (long )so)); | 1077 | (long )m, (long )so)); |
| 1078 | /* | 1078 | /* |
| @@ -1140,12 +1140,12 @@ trimthenstep6: | @@ -1140,12 +1140,12 @@ trimthenstep6: | ||
| 1140 | tp->snd_cwnd = tp->snd_ssthresh; | 1140 | tp->snd_cwnd = tp->snd_ssthresh; |
| 1141 | tp->t_dupacks = 0; | 1141 | tp->t_dupacks = 0; |
| 1142 | if (SEQ_GT(ti->ti_ack, tp->snd_max)) { | 1142 | if (SEQ_GT(ti->ti_ack, tp->snd_max)) { |
| 1143 | - tcpstat.tcps_rcvacktoomuch++; | 1143 | + STAT(tcpstat.tcps_rcvacktoomuch++); |
| 1144 | goto dropafterack; | 1144 | goto dropafterack; |
| 1145 | } | 1145 | } |
| 1146 | acked = ti->ti_ack - tp->snd_una; | 1146 | acked = ti->ti_ack - tp->snd_una; |
| 1147 | - tcpstat.tcps_rcvackpack++; | ||
| 1148 | - tcpstat.tcps_rcvackbyte += acked; | 1147 | + STAT(tcpstat.tcps_rcvackpack++); |
| 1148 | + STAT(tcpstat.tcps_rcvackbyte += acked); | ||
| 1149 | 1149 | ||
| 1150 | /* | 1150 | /* |
| 1151 | * If we have a timestamp reply, update smoothed | 1151 | * If we have a timestamp reply, update smoothed |
| @@ -1284,7 +1284,7 @@ step6: | @@ -1284,7 +1284,7 @@ step6: | ||
| 1284 | /* keep track of pure window updates */ | 1284 | /* keep track of pure window updates */ |
| 1285 | if (ti->ti_len == 0 && | 1285 | if (ti->ti_len == 0 && |
| 1286 | tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd) | 1286 | tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd) |
| 1287 | - tcpstat.tcps_rcvwinupd++; | 1287 | + STAT(tcpstat.tcps_rcvwinupd++); |
| 1288 | tp->snd_wnd = tiwin; | 1288 | tp->snd_wnd = tiwin; |
| 1289 | tp->snd_wl1 = ti->ti_seq; | 1289 | tp->snd_wl1 = ti->ti_seq; |
| 1290 | tp->snd_wl2 = ti->ti_ack; | 1290 | tp->snd_wl2 = ti->ti_ack; |
| @@ -1616,7 +1616,7 @@ tcp_xmit_timer(tp, rtt) | @@ -1616,7 +1616,7 @@ tcp_xmit_timer(tp, rtt) | ||
| 1616 | DEBUG_ARG("tp = %lx", (long)tp); | 1616 | DEBUG_ARG("tp = %lx", (long)tp); |
| 1617 | DEBUG_ARG("rtt = %d", rtt); | 1617 | DEBUG_ARG("rtt = %d", rtt); |
| 1618 | 1618 | ||
| 1619 | - tcpstat.tcps_rttupdated++; | 1619 | + STAT(tcpstat.tcps_rttupdated++); |
| 1620 | if (tp->t_srtt != 0) { | 1620 | if (tp->t_srtt != 0) { |
| 1621 | /* | 1621 | /* |
| 1622 | * srtt is stored as fixed point with 3 bits after the | 1622 | * srtt is stored as fixed point with 3 bits after the |
slirp/tcp_output.c
| @@ -263,7 +263,7 @@ again: | @@ -263,7 +263,7 @@ again: | ||
| 263 | /* | 263 | /* |
| 264 | * No reason to send a segment, just return. | 264 | * No reason to send a segment, just return. |
| 265 | */ | 265 | */ |
| 266 | - tcpstat.tcps_didnuttin++; | 266 | + STAT(tcpstat.tcps_didnuttin++); |
| 267 | 267 | ||
| 268 | return (0); | 268 | return (0); |
| 269 | 269 | ||
| @@ -339,13 +339,13 @@ send: | @@ -339,13 +339,13 @@ send: | ||
| 339 | */ | 339 | */ |
| 340 | if (len) { | 340 | if (len) { |
| 341 | if (tp->t_force && len == 1) | 341 | if (tp->t_force && len == 1) |
| 342 | - tcpstat.tcps_sndprobe++; | 342 | + STAT(tcpstat.tcps_sndprobe++); |
| 343 | else if (SEQ_LT(tp->snd_nxt, tp->snd_max)) { | 343 | else if (SEQ_LT(tp->snd_nxt, tp->snd_max)) { |
| 344 | - tcpstat.tcps_sndrexmitpack++; | ||
| 345 | - tcpstat.tcps_sndrexmitbyte += len; | 344 | + STAT(tcpstat.tcps_sndrexmitpack++); |
| 345 | + STAT(tcpstat.tcps_sndrexmitbyte += len); | ||
| 346 | } else { | 346 | } else { |
| 347 | - tcpstat.tcps_sndpack++; | ||
| 348 | - tcpstat.tcps_sndbyte += len; | 347 | + STAT(tcpstat.tcps_sndpack++); |
| 348 | + STAT(tcpstat.tcps_sndbyte += len); | ||
| 349 | } | 349 | } |
| 350 | 350 | ||
| 351 | m = m_get(); | 351 | m = m_get(); |
| @@ -382,13 +382,13 @@ send: | @@ -382,13 +382,13 @@ send: | ||
| 382 | flags |= TH_PUSH; | 382 | flags |= TH_PUSH; |
| 383 | } else { | 383 | } else { |
| 384 | if (tp->t_flags & TF_ACKNOW) | 384 | if (tp->t_flags & TF_ACKNOW) |
| 385 | - tcpstat.tcps_sndacks++; | 385 | + STAT(tcpstat.tcps_sndacks++); |
| 386 | else if (flags & (TH_SYN|TH_FIN|TH_RST)) | 386 | else if (flags & (TH_SYN|TH_FIN|TH_RST)) |
| 387 | - tcpstat.tcps_sndctrl++; | 387 | + STAT(tcpstat.tcps_sndctrl++); |
| 388 | else if (SEQ_GT(tp->snd_up, tp->snd_una)) | 388 | else if (SEQ_GT(tp->snd_up, tp->snd_una)) |
| 389 | - tcpstat.tcps_sndurg++; | 389 | + STAT(tcpstat.tcps_sndurg++); |
| 390 | else | 390 | else |
| 391 | - tcpstat.tcps_sndwinup++; | 391 | + STAT(tcpstat.tcps_sndwinup++); |
| 392 | 392 | ||
| 393 | m = m_get(); | 393 | m = m_get(); |
| 394 | if (m == NULL) { | 394 | if (m == NULL) { |
| @@ -500,7 +500,7 @@ send: | @@ -500,7 +500,7 @@ send: | ||
| 500 | if (tp->t_rtt == 0) { | 500 | if (tp->t_rtt == 0) { |
| 501 | tp->t_rtt = 1; | 501 | tp->t_rtt = 1; |
| 502 | tp->t_rtseq = startseq; | 502 | tp->t_rtseq = startseq; |
| 503 | - tcpstat.tcps_segstimed++; | 503 | + STAT(tcpstat.tcps_segstimed++); |
| 504 | } | 504 | } |
| 505 | } | 505 | } |
| 506 | 506 | ||
| @@ -567,7 +567,7 @@ out: | @@ -567,7 +567,7 @@ out: | ||
| 567 | */ | 567 | */ |
| 568 | return (error); | 568 | return (error); |
| 569 | } | 569 | } |
| 570 | - tcpstat.tcps_sndtotal++; | 570 | + STAT(tcpstat.tcps_sndtotal++); |
| 571 | 571 | ||
| 572 | /* | 572 | /* |
| 573 | * Data sent (as far as we can tell). | 573 | * Data sent (as far as we can tell). |
slirp/tcp_subr.c
| @@ -255,9 +255,9 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err) | @@ -255,9 +255,9 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err) | ||
| 255 | if (TCPS_HAVERCVDSYN(tp->t_state)) { | 255 | if (TCPS_HAVERCVDSYN(tp->t_state)) { |
| 256 | tp->t_state = TCPS_CLOSED; | 256 | tp->t_state = TCPS_CLOSED; |
| 257 | (void) tcp_output(tp); | 257 | (void) tcp_output(tp); |
| 258 | - tcpstat.tcps_drops++; | 258 | + STAT(tcpstat.tcps_drops++); |
| 259 | } else | 259 | } else |
| 260 | - tcpstat.tcps_conndrops++; | 260 | + STAT(tcpstat.tcps_conndrops++); |
| 261 | /* if (errno == ETIMEDOUT && tp->t_softerror) | 261 | /* if (errno == ETIMEDOUT && tp->t_softerror) |
| 262 | * errno = tp->t_softerror; | 262 | * errno = tp->t_softerror; |
| 263 | */ | 263 | */ |
| @@ -305,7 +305,7 @@ tcp_close(tp) | @@ -305,7 +305,7 @@ tcp_close(tp) | ||
| 305 | sbfree(&so->so_rcv); | 305 | sbfree(&so->so_rcv); |
| 306 | sbfree(&so->so_snd); | 306 | sbfree(&so->so_snd); |
| 307 | sofree(so); | 307 | sofree(so); |
| 308 | - tcpstat.tcps_closed++; | 308 | + STAT(tcpstat.tcps_closed++); |
| 309 | return ((struct tcpcb *)0); | 309 | return ((struct tcpcb *)0); |
| 310 | } | 310 | } |
| 311 | 311 | ||
| @@ -528,7 +528,7 @@ tcp_connect(inso) | @@ -528,7 +528,7 @@ tcp_connect(inso) | ||
| 528 | */ | 528 | */ |
| 529 | 529 | ||
| 530 | /* soisconnecting(so); */ /* NOFDREF used instead */ | 530 | /* soisconnecting(so); */ /* NOFDREF used instead */ |
| 531 | - tcpstat.tcps_connattempt++; | 531 | + STAT(tcpstat.tcps_connattempt++); |
| 532 | 532 | ||
| 533 | tp->t_state = TCPS_SYN_SENT; | 533 | tp->t_state = TCPS_SYN_SENT; |
| 534 | tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; | 534 | tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; |
| @@ -857,7 +857,7 @@ tcp_emu(so, m) | @@ -857,7 +857,7 @@ tcp_emu(so, m) | ||
| 857 | 857 | ||
| 858 | /*soisfconnecting(ns);*/ | 858 | /*soisfconnecting(ns);*/ |
| 859 | 859 | ||
| 860 | - tcpstat.tcps_connattempt++; | 860 | + STAT(tcpstat.tcps_connattempt++); |
| 861 | 861 | ||
| 862 | tp->t_state = TCPS_SYN_SENT; | 862 | tp->t_state = TCPS_SYN_SENT; |
| 863 | tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; | 863 | tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT; |
slirp/tcp_timer.c
| @@ -41,7 +41,10 @@ int tcp_keepintvl = TCPTV_KEEPINTVL; | @@ -41,7 +41,10 @@ int tcp_keepintvl = TCPTV_KEEPINTVL; | ||
| 41 | int tcp_maxidle; | 41 | int tcp_maxidle; |
| 42 | int so_options = DO_KEEPALIVE; | 42 | int so_options = DO_KEEPALIVE; |
| 43 | 43 | ||
| 44 | +#ifdef LOG_ENABLED | ||
| 44 | struct tcpstat tcpstat; /* tcp statistics */ | 45 | struct tcpstat tcpstat; /* tcp statistics */ |
| 46 | +#endif | ||
| 47 | + | ||
| 45 | u_int32_t tcp_now; /* for RFC 1323 timestamps */ | 48 | u_int32_t tcp_now; /* for RFC 1323 timestamps */ |
| 46 | 49 | ||
| 47 | /* | 50 | /* |
| @@ -62,7 +65,7 @@ tcp_fasttimo() | @@ -62,7 +65,7 @@ tcp_fasttimo() | ||
| 62 | (tp->t_flags & TF_DELACK)) { | 65 | (tp->t_flags & TF_DELACK)) { |
| 63 | tp->t_flags &= ~TF_DELACK; | 66 | tp->t_flags &= ~TF_DELACK; |
| 64 | tp->t_flags |= TF_ACKNOW; | 67 | tp->t_flags |= TF_ACKNOW; |
| 65 | - tcpstat.tcps_delack++; | 68 | + STAT(tcpstat.tcps_delack++); |
| 66 | (void) tcp_output(tp); | 69 | (void) tcp_output(tp); |
| 67 | } | 70 | } |
| 68 | } | 71 | } |
| @@ -192,7 +195,7 @@ tcp_timers(tp, timer) | @@ -192,7 +195,7 @@ tcp_timers(tp, timer) | ||
| 192 | * We tried our best, now the connection must die! | 195 | * We tried our best, now the connection must die! |
| 193 | */ | 196 | */ |
| 194 | tp->t_rxtshift = TCP_MAXRXTSHIFT; | 197 | tp->t_rxtshift = TCP_MAXRXTSHIFT; |
| 195 | - tcpstat.tcps_timeoutdrop++; | 198 | + STAT(tcpstat.tcps_timeoutdrop++); |
| 196 | tp = tcp_drop(tp, tp->t_softerror); | 199 | tp = tcp_drop(tp, tp->t_softerror); |
| 197 | /* tp->t_softerror : ETIMEDOUT); */ /* XXX */ | 200 | /* tp->t_softerror : ETIMEDOUT); */ /* XXX */ |
| 198 | return (tp); /* XXX */ | 201 | return (tp); /* XXX */ |
| @@ -204,7 +207,7 @@ tcp_timers(tp, timer) | @@ -204,7 +207,7 @@ tcp_timers(tp, timer) | ||
| 204 | */ | 207 | */ |
| 205 | tp->t_rxtshift = 6; | 208 | tp->t_rxtshift = 6; |
| 206 | } | 209 | } |
| 207 | - tcpstat.tcps_rexmttimeo++; | 210 | + STAT(tcpstat.tcps_rexmttimeo++); |
| 208 | rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift]; | 211 | rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift]; |
| 209 | TCPT_RANGESET(tp->t_rxtcur, rexmt, | 212 | TCPT_RANGESET(tp->t_rxtcur, rexmt, |
| 210 | (short)tp->t_rttmin, TCPTV_REXMTMAX); /* XXX */ | 213 | (short)tp->t_rttmin, TCPTV_REXMTMAX); /* XXX */ |
| @@ -267,7 +270,7 @@ tcp_timers(tp, timer) | @@ -267,7 +270,7 @@ tcp_timers(tp, timer) | ||
| 267 | * Force a byte to be output, if possible. | 270 | * Force a byte to be output, if possible. |
| 268 | */ | 271 | */ |
| 269 | case TCPT_PERSIST: | 272 | case TCPT_PERSIST: |
| 270 | - tcpstat.tcps_persisttimeo++; | 273 | + STAT(tcpstat.tcps_persisttimeo++); |
| 271 | tcp_setpersist(tp); | 274 | tcp_setpersist(tp); |
| 272 | tp->t_force = 1; | 275 | tp->t_force = 1; |
| 273 | (void) tcp_output(tp); | 276 | (void) tcp_output(tp); |
| @@ -279,7 +282,7 @@ tcp_timers(tp, timer) | @@ -279,7 +282,7 @@ tcp_timers(tp, timer) | ||
| 279 | * or drop connection if idle for too long. | 282 | * or drop connection if idle for too long. |
| 280 | */ | 283 | */ |
| 281 | case TCPT_KEEP: | 284 | case TCPT_KEEP: |
| 282 | - tcpstat.tcps_keeptimeo++; | 285 | + STAT(tcpstat.tcps_keeptimeo++); |
| 283 | if (tp->t_state < TCPS_ESTABLISHED) | 286 | if (tp->t_state < TCPS_ESTABLISHED) |
| 284 | goto dropit; | 287 | goto dropit; |
| 285 | 288 | ||
| @@ -299,7 +302,7 @@ tcp_timers(tp, timer) | @@ -299,7 +302,7 @@ tcp_timers(tp, timer) | ||
| 299 | * by the protocol spec, this requires the | 302 | * by the protocol spec, this requires the |
| 300 | * correspondent TCP to respond. | 303 | * correspondent TCP to respond. |
| 301 | */ | 304 | */ |
| 302 | - tcpstat.tcps_keepprobe++; | 305 | + STAT(tcpstat.tcps_keepprobe++); |
| 303 | #ifdef TCP_COMPAT_42 | 306 | #ifdef TCP_COMPAT_42 |
| 304 | /* | 307 | /* |
| 305 | * The keepalive packet must have nonzero length | 308 | * The keepalive packet must have nonzero length |
| @@ -317,7 +320,7 @@ tcp_timers(tp, timer) | @@ -317,7 +320,7 @@ tcp_timers(tp, timer) | ||
| 317 | break; | 320 | break; |
| 318 | 321 | ||
| 319 | dropit: | 322 | dropit: |
| 320 | - tcpstat.tcps_keepdrops++; | 323 | + STAT(tcpstat.tcps_keepdrops++); |
| 321 | tp = tcp_drop(tp, 0); /* ETIMEDOUT); */ | 324 | tp = tcp_drop(tp, 0); /* ETIMEDOUT); */ |
| 322 | break; | 325 | break; |
| 323 | } | 326 | } |
slirp/tcp_var.h
| @@ -185,6 +185,7 @@ typedef u_int32_t mbufp_32; | @@ -185,6 +185,7 @@ typedef u_int32_t mbufp_32; | ||
| 185 | #endif | 185 | #endif |
| 186 | #define REASS_MBUF(ti) (*(mbufp_32 *)&((ti)->ti_t)) | 186 | #define REASS_MBUF(ti) (*(mbufp_32 *)&((ti)->ti_t)) |
| 187 | 187 | ||
| 188 | +#ifdef LOG_ENABLED | ||
| 188 | /* | 189 | /* |
| 189 | * TCP statistics. | 190 | * TCP statistics. |
| 190 | * Many of these should be kept per connection, | 191 | * Many of these should be kept per connection, |
| @@ -247,6 +248,8 @@ struct tcpstat { | @@ -247,6 +248,8 @@ struct tcpstat { | ||
| 247 | }; | 248 | }; |
| 248 | 249 | ||
| 249 | extern struct tcpstat tcpstat; /* tcp statistics */ | 250 | extern struct tcpstat tcpstat; /* tcp statistics */ |
| 251 | +#endif | ||
| 252 | + | ||
| 250 | extern u_int32_t tcp_now; /* for RFC 1323 timestamps */ | 253 | extern u_int32_t tcp_now; /* for RFC 1323 timestamps */ |
| 251 | 254 | ||
| 252 | #endif | 255 | #endif |
slirp/udp.c
| @@ -45,7 +45,9 @@ | @@ -45,7 +45,9 @@ | ||
| 45 | #include <slirp.h> | 45 | #include <slirp.h> |
| 46 | #include "ip_icmp.h" | 46 | #include "ip_icmp.h" |
| 47 | 47 | ||
| 48 | +#ifdef LOG_ENABLED | ||
| 48 | struct udpstat udpstat; | 49 | struct udpstat udpstat; |
| 50 | +#endif | ||
| 49 | 51 | ||
| 50 | struct socket udb; | 52 | struct socket udb; |
| 51 | 53 | ||
| @@ -86,7 +88,7 @@ udp_input(m, iphlen) | @@ -86,7 +88,7 @@ udp_input(m, iphlen) | ||
| 86 | DEBUG_ARG("m = %lx", (long)m); | 88 | DEBUG_ARG("m = %lx", (long)m); |
| 87 | DEBUG_ARG("iphlen = %d", iphlen); | 89 | DEBUG_ARG("iphlen = %d", iphlen); |
| 88 | 90 | ||
| 89 | - udpstat.udps_ipackets++; | 91 | + STAT(udpstat.udps_ipackets++); |
| 90 | 92 | ||
| 91 | /* | 93 | /* |
| 92 | * Strip IP options, if any; should skip this, | 94 | * Strip IP options, if any; should skip this, |
| @@ -113,7 +115,7 @@ udp_input(m, iphlen) | @@ -113,7 +115,7 @@ udp_input(m, iphlen) | ||
| 113 | 115 | ||
| 114 | if (ip->ip_len != len) { | 116 | if (ip->ip_len != len) { |
| 115 | if (len > ip->ip_len) { | 117 | if (len > ip->ip_len) { |
| 116 | - udpstat.udps_badlen++; | 118 | + STAT(udpstat.udps_badlen++); |
| 117 | goto bad; | 119 | goto bad; |
| 118 | } | 120 | } |
| 119 | m_adj(m, len - ip->ip_len); | 121 | m_adj(m, len - ip->ip_len); |
| @@ -140,7 +142,7 @@ udp_input(m, iphlen) | @@ -140,7 +142,7 @@ udp_input(m, iphlen) | ||
| 140 | * if (uh->uh_sum) { | 142 | * if (uh->uh_sum) { |
| 141 | */ | 143 | */ |
| 142 | if(cksum(m, len + sizeof(struct ip))) { | 144 | if(cksum(m, len + sizeof(struct ip))) { |
| 143 | - udpstat.udps_badsum++; | 145 | + STAT(udpstat.udps_badsum++); |
| 144 | goto bad; | 146 | goto bad; |
| 145 | } | 147 | } |
| 146 | } | 148 | } |
| @@ -181,7 +183,7 @@ udp_input(m, iphlen) | @@ -181,7 +183,7 @@ udp_input(m, iphlen) | ||
| 181 | if (tmp == &udb) { | 183 | if (tmp == &udb) { |
| 182 | so = NULL; | 184 | so = NULL; |
| 183 | } else { | 185 | } else { |
| 184 | - udpstat.udpps_pcbcachemiss++; | 186 | + STAT(udpstat.udpps_pcbcachemiss++); |
| 185 | udp_last_so = so; | 187 | udp_last_so = so; |
| 186 | } | 188 | } |
| 187 | } | 189 | } |
| @@ -299,7 +301,7 @@ int udp_output2(struct socket *so, struct mbuf *m, | @@ -299,7 +301,7 @@ int udp_output2(struct socket *so, struct mbuf *m, | ||
| 299 | ((struct ip *)ui)->ip_ttl = ip_defttl; | 301 | ((struct ip *)ui)->ip_ttl = ip_defttl; |
| 300 | ((struct ip *)ui)->ip_tos = iptos; | 302 | ((struct ip *)ui)->ip_tos = iptos; |
| 301 | 303 | ||
| 302 | - udpstat.udps_opackets++; | 304 | + STAT(udpstat.udps_opackets++); |
| 303 | 305 | ||
| 304 | error = ip_output(so, m); | 306 | error = ip_output(so, m); |
| 305 | 307 |
slirp/udp.h
| @@ -72,6 +72,7 @@ struct udpiphdr { | @@ -72,6 +72,7 @@ struct udpiphdr { | ||
| 72 | #define ui_ulen ui_u.uh_ulen | 72 | #define ui_ulen ui_u.uh_ulen |
| 73 | #define ui_sum ui_u.uh_sum | 73 | #define ui_sum ui_u.uh_sum |
| 74 | 74 | ||
| 75 | +#ifdef LOG_ENABLED | ||
| 75 | struct udpstat { | 76 | struct udpstat { |
| 76 | /* input statistics: */ | 77 | /* input statistics: */ |
| 77 | u_long udps_ipackets; /* total input packets */ | 78 | u_long udps_ipackets; /* total input packets */ |
| @@ -85,6 +86,7 @@ struct udpstat { | @@ -85,6 +86,7 @@ struct udpstat { | ||
| 85 | /* output statistics: */ | 86 | /* output statistics: */ |
| 86 | u_long udps_opackets; /* total output packets */ | 87 | u_long udps_opackets; /* total output packets */ |
| 87 | }; | 88 | }; |
| 89 | +#endif | ||
| 88 | 90 | ||
| 89 | /* | 91 | /* |
| 90 | * Names for UDP sysctl objects | 92 | * Names for UDP sysctl objects |
| @@ -92,7 +94,10 @@ struct udpstat { | @@ -92,7 +94,10 @@ struct udpstat { | ||
| 92 | #define UDPCTL_CHECKSUM 1 /* checksum UDP packets */ | 94 | #define UDPCTL_CHECKSUM 1 /* checksum UDP packets */ |
| 93 | #define UDPCTL_MAXID 2 | 95 | #define UDPCTL_MAXID 2 |
| 94 | 96 | ||
| 97 | +#ifdef LOG_ENABLED | ||
| 95 | extern struct udpstat udpstat; | 98 | extern struct udpstat udpstat; |
| 99 | +#endif | ||
| 100 | + | ||
| 96 | extern struct socket udb; | 101 | extern struct socket udb; |
| 97 | struct mbuf; | 102 | struct mbuf; |
| 98 | 103 |
vl.c
| @@ -3782,6 +3782,10 @@ void net_slirp_smb(const char *exported_dir) | @@ -3782,6 +3782,10 @@ void net_slirp_smb(const char *exported_dir) | ||
| 3782 | } | 3782 | } |
| 3783 | 3783 | ||
| 3784 | #endif /* !defined(_WIN32) */ | 3784 | #endif /* !defined(_WIN32) */ |
| 3785 | +void do_info_slirp(void) | ||
| 3786 | +{ | ||
| 3787 | + slirp_stats(); | ||
| 3788 | +} | ||
| 3785 | 3789 | ||
| 3786 | #endif /* CONFIG_SLIRP */ | 3790 | #endif /* CONFIG_SLIRP */ |
| 3787 | 3791 |
vl.h
| @@ -439,6 +439,9 @@ typedef struct NICInfo { | @@ -439,6 +439,9 @@ typedef struct NICInfo { | ||
| 439 | extern int nb_nics; | 439 | extern int nb_nics; |
| 440 | extern NICInfo nd_table[MAX_NICS]; | 440 | extern NICInfo nd_table[MAX_NICS]; |
| 441 | 441 | ||
| 442 | +/* SLIRP */ | ||
| 443 | +void do_info_slirp(void); | ||
| 444 | + | ||
| 442 | /* timers */ | 445 | /* timers */ |
| 443 | 446 | ||
| 444 | typedef struct QEMUClock QEMUClock; | 447 | typedef struct QEMUClock QEMUClock; |