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