"", "show CPU statistics", },
#endif
#if defined(CONFIG_SLIRP)
- { "slirp", "", do_info_slirp,
- "", "show SLIRP statistics", },
{ "usernet", "", do_info_usernet,
"", "show user network stack connection states", },
#endif
#endif /* !defined(_WIN32) */
-void do_info_slirp(Monitor *mon)
-{
- slirp_stats();
-}
-
struct GuestFwd {
CharDriverState *hd;
struct in_addr server;
show the current VM UUID
@item info cpustats
show CPU statistics
-@item info slirp
-show SLIRP statistics (if available)
@item info usernet
show user network stack connection states
@item info migrate
FILE *dfd = NULL;
int slirp_debug = 0;
-
-#ifdef LOG_ENABLED
-static void
-ipstats(void)
-{
- lprint(" \r\n");
-
- lprint("IP stats:\r\n");
- lprint(" %6d total packets received (%d were unaligned)\r\n",
- ipstat.ips_total, ipstat.ips_unaligned);
- lprint(" %6d with incorrect version\r\n", ipstat.ips_badvers);
- lprint(" %6d with bad header checksum\r\n", ipstat.ips_badsum);
- lprint(" %6d with length too short (len < sizeof(iphdr))\r\n", ipstat.ips_tooshort);
- lprint(" %6d with length too small (len < ip->len)\r\n", ipstat.ips_toosmall);
- lprint(" %6d with bad header length\r\n", ipstat.ips_badhlen);
- lprint(" %6d with bad packet length\r\n", ipstat.ips_badlen);
- lprint(" %6d fragments received\r\n", ipstat.ips_fragments);
- lprint(" %6d fragments dropped\r\n", ipstat.ips_fragdropped);
- lprint(" %6d fragments timed out\r\n", ipstat.ips_fragtimeout);
- lprint(" %6d packets reassembled ok\r\n", ipstat.ips_reassembled);
- lprint(" %6d outgoing packets fragmented\r\n", ipstat.ips_fragmented);
- lprint(" %6d total outgoing fragments\r\n", ipstat.ips_ofragments);
- lprint(" %6d with bad protocol field\r\n", ipstat.ips_noproto);
- lprint(" %6d total packets delivered\r\n", ipstat.ips_delivered);
-}
-
-static void
-tcpstats(void)
-{
- lprint(" \r\n");
-
- lprint("TCP stats:\r\n");
-
- lprint(" %6d packets sent\r\n", tcpstat.tcps_sndtotal);
- lprint(" %6d data packets (%d bytes)\r\n",
- tcpstat.tcps_sndpack, tcpstat.tcps_sndbyte);
- lprint(" %6d data packets retransmitted (%d bytes)\r\n",
- tcpstat.tcps_sndrexmitpack, tcpstat.tcps_sndrexmitbyte);
- lprint(" %6d ack-only packets (%d delayed)\r\n",
- tcpstat.tcps_sndacks, tcpstat.tcps_delack);
- lprint(" %6d URG only packets\r\n", tcpstat.tcps_sndurg);
- lprint(" %6d window probe packets\r\n", tcpstat.tcps_sndprobe);
- lprint(" %6d window update packets\r\n", tcpstat.tcps_sndwinup);
- lprint(" %6d control (SYN/FIN/RST) packets\r\n", tcpstat.tcps_sndctrl);
- lprint(" %6d times tcp_output did nothing\r\n", tcpstat.tcps_didnuttin);
-
- lprint(" %6d packets received\r\n", tcpstat.tcps_rcvtotal);
- lprint(" %6d acks (for %d bytes)\r\n",
- tcpstat.tcps_rcvackpack, tcpstat.tcps_rcvackbyte);
- lprint(" %6d duplicate acks\r\n", tcpstat.tcps_rcvdupack);
- lprint(" %6d acks for unsent data\r\n", tcpstat.tcps_rcvacktoomuch);
- lprint(" %6d packets received in sequence (%d bytes)\r\n",
- tcpstat.tcps_rcvpack, tcpstat.tcps_rcvbyte);
- lprint(" %6d completely duplicate packets (%d bytes)\r\n",
- tcpstat.tcps_rcvduppack, tcpstat.tcps_rcvdupbyte);
-
- lprint(" %6d packets with some duplicate data (%d bytes duped)\r\n",
- tcpstat.tcps_rcvpartduppack, tcpstat.tcps_rcvpartdupbyte);
- lprint(" %6d out-of-order packets (%d bytes)\r\n",
- tcpstat.tcps_rcvoopack, tcpstat.tcps_rcvoobyte);
- lprint(" %6d packets of data after window (%d bytes)\r\n",
- tcpstat.tcps_rcvpackafterwin, tcpstat.tcps_rcvbyteafterwin);
- lprint(" %6d window probes\r\n", tcpstat.tcps_rcvwinprobe);
- lprint(" %6d window update packets\r\n", tcpstat.tcps_rcvwinupd);
- lprint(" %6d packets received after close\r\n", tcpstat.tcps_rcvafterclose);
- lprint(" %6d discarded for bad checksums\r\n", tcpstat.tcps_rcvbadsum);
- lprint(" %6d discarded for bad header offset fields\r\n",
- tcpstat.tcps_rcvbadoff);
-
- lprint(" %6d connection requests\r\n", tcpstat.tcps_connattempt);
- lprint(" %6d connection accepts\r\n", tcpstat.tcps_accepts);
- lprint(" %6d connections established (including accepts)\r\n", tcpstat.tcps_connects);
- lprint(" %6d connections closed (including %d drop)\r\n",
- tcpstat.tcps_closed, tcpstat.tcps_drops);
- lprint(" %6d embryonic connections dropped\r\n", tcpstat.tcps_conndrops);
- lprint(" %6d segments we tried to get rtt (%d succeeded)\r\n",
- tcpstat.tcps_segstimed, tcpstat.tcps_rttupdated);
- lprint(" %6d retransmit timeouts\r\n", tcpstat.tcps_rexmttimeo);
- lprint(" %6d connections dropped by rxmt timeout\r\n",
- tcpstat.tcps_timeoutdrop);
- lprint(" %6d persist timeouts\r\n", tcpstat.tcps_persisttimeo);
- lprint(" %6d keepalive timeouts\r\n", tcpstat.tcps_keeptimeo);
- lprint(" %6d keepalive probes sent\r\n", tcpstat.tcps_keepprobe);
- lprint(" %6d connections dropped by keepalive\r\n", tcpstat.tcps_keepdrops);
- lprint(" %6d correct ACK header predictions\r\n", tcpstat.tcps_predack);
- lprint(" %6d correct data packet header predictions\n", tcpstat.tcps_preddat);
- lprint(" %6d TCP cache misses\r\n", tcpstat.tcps_socachemiss);
-}
-
-static void
-udpstats(void)
-{
- lprint(" \r\n");
-
- lprint("UDP stats:\r\n");
- lprint(" %6d datagrams received\r\n", udpstat.udps_ipackets);
- lprint(" %6d with packets shorter than header\r\n", udpstat.udps_hdrops);
- lprint(" %6d with bad checksums\r\n", udpstat.udps_badsum);
- lprint(" %6d with data length larger than packet\r\n", udpstat.udps_badlen);
- lprint(" %6d UDP socket cache misses\r\n", udpstat.udpps_pcbcachemiss);
- lprint(" %6d datagrams sent\r\n", udpstat.udps_opackets);
-}
-
-static void
-icmpstats(void)
-{
- lprint(" \r\n");
- lprint("ICMP stats:\r\n");
- lprint(" %6d ICMP packets received\r\n", icmpstat.icps_received);
- lprint(" %6d were too short\r\n", icmpstat.icps_tooshort);
- lprint(" %6d with bad checksums\r\n", icmpstat.icps_checksum);
- lprint(" %6d with type not supported\r\n", icmpstat.icps_notsupp);
- lprint(" %6d with bad type feilds\r\n", icmpstat.icps_badtype);
- lprint(" %6d ICMP packets sent in reply\r\n", icmpstat.icps_reflect);
-}
-
-static void
-mbufstats(void)
-{
- struct mbuf *m;
- int i;
-
- lprint(" \r\n");
-
- lprint("Mbuf stats:\r\n");
-
- lprint(" %6d mbufs allocated (%d max)\r\n", mbuf_alloced, mbuf_max);
-
- i = 0;
- for (m = m_freelist.m_next; m != &m_freelist; m = m->m_next)
- i++;
- lprint(" %6d mbufs on free list\r\n", i);
-
- i = 0;
- for (m = m_usedlist.m_next; m != &m_usedlist; m = m->m_next)
- i++;
- lprint(" %6d mbufs on used list\r\n", i);
- lprint(" %6d mbufs queued as packets\r\n\r\n", if_queued);
-}
-#endif
-
-void
-slirp_stats(void)
-{
-#ifdef LOG_ENABLED
- ipstats();
- tcpstats();
- udpstats();
- icmpstats();
- mbufstats();
-#else
- lprint("SLIRP statistics code not compiled.\n");
-#endif
-}
#ifndef _NETINET_ICMP_VAR_H_
#define _NETINET_ICMP_VAR_H_
-/*
- * Variables related to this implementation
- * of the internet control message protocol.
- */
-struct icmpstat {
-/* statistics related to input messages processed */
- u_long icps_received; /* #ICMP packets received */
- u_long icps_tooshort; /* packet < ICMP_MINLEN */
- u_long icps_checksum; /* bad checksum */
- u_long icps_notsupp; /* #ICMP packets not supported */
- u_long icps_badtype; /* #with bad type feild */
- u_long icps_reflect; /* number of responses */
-};
-
/*
* Names for ICMP sysctl objects
*/
{ "stats", CTLTYPE_STRUCT }, \
}
-#ifdef LOG_ENABLED
-extern struct icmpstat icmpstat;
-#endif
-
#endif
#define ifs_init(ifm) ((ifm)->ifs_next = (ifm)->ifs_prev = (ifm))
-#ifdef LOG_ENABLED
-/* Interface statistics */
-struct slirp_ifstats {
- u_int out_pkts; /* Output packets */
- u_int out_bytes; /* Output bytes */
- u_int out_errpkts; /* Output Error Packets */
- u_int out_errbytes; /* Output Error Bytes */
- u_int in_pkts; /* Input packets */
- u_int in_bytes; /* Input bytes */
- u_int in_errpkts; /* Input Error Packets */
- u_int in_errbytes; /* Input Error Bytes */
-
- u_int bytes_saved; /* Number of bytes that compression "saved" */
- /* ie: number of bytes that didn't need to be sent over the link
- * because of compression */
-
- u_int in_mbad; /* Bad incoming packets */
-};
-#endif
-
#endif
int8_t ipopt_list[MAX_IPOPTLEN]; /* options proper */
};
-#ifdef LOG_ENABLED
-/*
- * Structure attached to inpcb.ip_moptions and
- * passed to ip_output when IP multicast options are in use.
- */
-
-struct ipstat {
- u_long ips_total; /* total packets received */
- u_long ips_badsum; /* checksum bad */
- u_long ips_tooshort; /* packet too short */
- u_long ips_toosmall; /* not enough data */
- u_long ips_badhlen; /* ip header length < data size */
- u_long ips_badlen; /* ip length < ip header length */
- u_long ips_fragments; /* fragments received */
- u_long ips_fragdropped; /* frags dropped (dups, out of space) */
- u_long ips_fragtimeout; /* fragments timed out */
- u_long ips_forward; /* packets forwarded */
- u_long ips_cantforward; /* packets rcvd for unreachable dest */
- u_long ips_redirectsent; /* packets forwarded on same net */
- u_long ips_noproto; /* unknown or unsupported protocol */
- u_long ips_delivered; /* datagrams delivered to upper level*/
- u_long ips_localout; /* total ip packets generated here */
- u_long ips_odropped; /* lost packets due to nobufs, etc. */
- u_long ips_reassembled; /* total packets reassembled ok */
- u_long ips_fragmented; /* datagrams successfully fragmented */
- u_long ips_ofragments; /* output fragments created */
- u_long ips_cantfrag; /* don't fragment flag was set, etc. */
- u_long ips_badoptions; /* error in option processing */
- u_long ips_noroute; /* packets discarded due to no route */
- u_long ips_badvers; /* ip version != 4 */
- u_long ips_rawout; /* total raw ip packets generated */
- u_long ips_unaligned; /* times the ip packet was not aligned */
-};
-
-extern struct ipstat ipstat;
-#endif
-
extern struct ipq ipq; /* ip reass. queue */
extern u_int16_t ip_id; /* ip packet ctr, for ids */
#include "slirp.h"
#include "ip_icmp.h"
-#ifdef LOG_ENABLED
-struct icmpstat icmpstat;
-#endif
-
/* The message sent when emulating PING */
/* Be nice and tell them it's just a pseudo-ping packet */
static const char icmp_ping_msg[] = "This is a pseudo-PING packet used by Slirp to emulate ICMP ECHO-REQUEST packets.\n";
DEBUG_ARG("m = %lx", (long )m);
DEBUG_ARG("m_len = %d", m->m_len);
- STAT(icmpstat.icps_received++);
-
/*
* Locate icmp structure in mbuf, and check
* that its not corrupted and of at least minimum length.
*/
if (icmplen < ICMP_MINLEN) { /* min 8 bytes payload */
- STAT(icmpstat.icps_tooshort++);
freeit:
m_freem(m);
goto end_error;
m->m_data += hlen;
icp = mtod(m, struct icmp *);
if (cksum(m, icmplen)) {
- STAT(icmpstat.icps_checksum++);
goto freeit;
}
m->m_len += hlen;
case ICMP_TSTAMP:
case ICMP_MASKREQ:
case ICMP_REDIRECT:
- STAT(icmpstat.icps_notsupp++);
m_freem(m);
break;
default:
- STAT(icmpstat.icps_badtype++);
m_freem(m);
} /* swith */
(void ) ip_output((struct socket *)NULL, m);
- STAT(icmpstat.icps_reflect++);
-
end_error:
return;
}
}
(void ) ip_output((struct socket *)NULL, m);
-
- STAT(icmpstat.icps_reflect++);
}
#include <osdep.h>
#include "ip_icmp.h"
-#ifdef LOG_ENABLED
-struct ipstat ipstat;
-#endif
-
struct ipq ipq;
static struct ip *ip_reass(register struct ip *ip,
DEBUG_ARG("m = %lx", (long)m);
DEBUG_ARG("m_len = %d", m->m_len);
- STAT(ipstat.ips_total++);
-
if (m->m_len < sizeof (struct ip)) {
- STAT(ipstat.ips_toosmall++);
return;
}
ip = mtod(m, struct ip *);
if (ip->ip_v != IPVERSION) {
- STAT(ipstat.ips_badvers++);
goto bad;
}
hlen = ip->ip_hl << 2;
if (hlen<sizeof(struct ip ) || hlen>m->m_len) {/* min header length */
- STAT(ipstat.ips_badhlen++); /* or packet too short */
- goto bad;
+ goto bad; /* or packet too short */
}
/* keep ip header intact for ICMP reply
* if (ip->ip_sum) {
*/
if(cksum(m,hlen)) {
- STAT(ipstat.ips_badsum++);
goto bad;
}
*/
NTOHS(ip->ip_len);
if (ip->ip_len < hlen) {
- STAT(ipstat.ips_badlen++);
goto bad;
}
NTOHS(ip->ip_id);
* Drop packet if shorter than we expect.
*/
if (m->m_len < ip->ip_len) {
- STAT(ipstat.ips_tooshort++);
goto bad;
}
* attempt reassembly; if it succeeds, proceed.
*/
if (ip->ip_tos & 1 || ip->ip_off) {
- STAT(ipstat.ips_fragments++);
ip = ip_reass(ip, fp);
if (ip == NULL)
return;
- STAT(ipstat.ips_reassembled++);
m = dtom(ip);
} else
if (fp)
/*
* Switch out to protocol's input routine.
*/
- STAT(ipstat.ips_delivered++);
switch (ip->ip_p) {
case IPPROTO_TCP:
tcp_input(m, hlen, (struct socket *)NULL);
icmp_input(m, hlen);
break;
default:
- STAT(ipstat.ips_noproto++);
m_free(m);
}
return;
return ip;
dropfrag:
- STAT(ipstat.ips_fragdropped++);
m_freem(m);
return NULL;
}
struct ipq *fp = container_of(l, struct ipq, ip_link);
l = l->next;
if (--fp->ipq_ttl == 0) {
- STAT(ipstat.ips_fragtimeout++);
ip_freef(fp);
}
}
bad:
icmp_error(m, type, code, 0, 0);
- STAT(ipstat.ips_badoptions++);
return (1);
}
ip->ip_off &= IP_DF;
ip->ip_id = htons(ip_id++);
ip->ip_hl = hlen >> 2;
- STAT(ipstat.ips_localout++);
/*
* If small enough for interface, can just send directly.
*/
if (ip->ip_off & IP_DF) {
error = -1;
- STAT(ipstat.ips_cantfrag++);
goto bad;
}
m = m_get();
if (m == NULL) {
error = -1;
- STAT(ipstat.ips_odropped++);
goto sendorfree;
}
m->m_data += IF_MAXLINKHDR;
mhip->ip_sum = cksum(m, mhlen);
*mnext = m;
mnext = &m->m_nextpkt;
- STAT(ipstat.ips_ofragments++);
}
/*
* Update first fragment by trimming what's been copied out
else
m_freem(m);
}
-
- if (error == 0)
- STAT(ipstat.ips_fragmented++);
}
done:
int slirp_add_exec(int do_pty, const void *args, struct in_addr guest_addr,
int guest_port);
-void slirp_stats(void);
void slirp_connection_info(Monitor *mon);
void slirp_socket_recv(struct in_addr guest_addr, int guest_port,
#include <slirp.h>
-int mbuf_alloced = 0;
+static int mbuf_alloced;
struct mbuf m_freelist, m_usedlist;
#define MBUF_THRESH 30
-int mbuf_max = 0;
/*
* Find a nice value for msize
mbuf_alloced++;
if (mbuf_alloced > MBUF_THRESH)
flags = M_DOFREE;
- if (mbuf_alloced > mbuf_max)
- mbuf_max = mbuf_alloced;
} else {
m = m_freelist.m_next;
remque(m);
#define M_DOFREE 0x08 /* when m_free is called on the mbuf, free()
* it rather than putting it on the free list */
-/*
- * Mbuf statistics. XXX
- */
-
-struct mbstat {
- int mbs_alloced; /* Number of mbufs allocated */
-
-};
-
-extern struct mbstat mbstat;
-extern int mbuf_alloced;
extern struct mbuf m_freelist, m_usedlist;
-extern int mbuf_max;
void m_init _P((void));
struct mbuf * m_get _P((void));
//#define DEBUG 1
-// Uncomment the following line to enable SLIRP statistics printing in Qemu
-//#define LOG_ENABLED
-
-#ifdef LOG_ENABLED
-#define STAT(expr) expr
-#else
-#define STAT(expr) do { } while(0)
-#endif
-
#include "config-host.h"
#include "slirp_config.h"
tp->t_flags |= TF_DELACK; \
(tp)->rcv_nxt += (ti)->ti_len; \
flags = (ti)->ti_flags & TH_FIN; \
- STAT(tcpstat.tcps_rcvpack++); \
- STAT(tcpstat.tcps_rcvbyte += (ti)->ti_len); \
if (so->so_emu) { \
if (tcp_emu((so),(m))) sbappend((so), (m)); \
} else \
tp->t_flags |= TF_DELACK; \
(tp)->rcv_nxt += (ti)->ti_len; \
flags = (ti)->ti_flags & TH_FIN; \
- STAT(tcpstat.tcps_rcvpack++); \
- STAT(tcpstat.tcps_rcvbyte += (ti)->ti_len); \
if (so->so_emu) { \
if (tcp_emu((so),(m))) sbappend(so, (m)); \
} else \
i = q->ti_seq + q->ti_len - ti->ti_seq;
if (i > 0) {
if (i >= ti->ti_len) {
- STAT(tcpstat.tcps_rcvduppack++);
- STAT(tcpstat.tcps_rcvdupbyte += ti->ti_len);
m_freem(m);
/*
* Try to present any queued data
}
q = tcpiphdr_next(q);
}
- STAT(tcpstat.tcps_rcvoopack++);
- STAT(tcpstat.tcps_rcvoobyte += ti->ti_len);
ti->ti_mbuf = m;
/*
goto cont_conn;
}
-
- STAT(tcpstat.tcps_rcvtotal++);
/*
* Get IP and TCP header together in first mbuf.
* Note: IP leaves IP header in first mbuf.
ti->ti_len = htons((u_int16_t)tlen);
len = sizeof(struct ip ) + tlen;
if(cksum(m, len)) {
- STAT(tcpstat.tcps_rcvbadsum++);
goto drop;
}
*/
off = ti->ti_off << 2;
if (off < sizeof (struct tcphdr) || off > tlen) {
- STAT(tcpstat.tcps_rcvbadoff++);
goto drop;
}
tlen -= off;
ti->ti_dst, ti->ti_dport);
if (so)
tcp_last_so = so;
- STAT(tcpstat.tcps_socachemiss++);
}
/*
/*
* this is a pure ack for outstanding data.
*/
- STAT(tcpstat.tcps_predack++);
if (tp->t_rtt &&
SEQ_GT(ti->ti_ack, tp->t_rtseq))
tcp_xmit_timer(tp, tp->t_rtt);
acked = ti->ti_ack - tp->snd_una;
- STAT(tcpstat.tcps_rcvackpack++);
- STAT(tcpstat.tcps_rcvackbyte += acked);
sbdrop(&so->so_snd, acked);
tp->snd_una = ti->ti_ack;
m_freem(m);
* with nothing on the reassembly queue and
* we have enough buffer space to take it.
*/
- STAT(tcpstat.tcps_preddat++);
tp->rcv_nxt += ti->ti_len;
- STAT(tcpstat.tcps_rcvpack++);
- STAT(tcpstat.tcps_rcvbyte += ti->ti_len);
/*
* Add data to socket buffer.
*/
tp->t_flags |= TF_ACKNOW;
tp->t_state = TCPS_SYN_RECEIVED;
tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
- STAT(tcpstat.tcps_accepts++);
goto trimthenstep6;
} /* case TCPS_LISTEN */
tcp_rcvseqinit(tp);
tp->t_flags |= TF_ACKNOW;
if (tiflags & TH_ACK && SEQ_GT(tp->snd_una, tp->iss)) {
- STAT(tcpstat.tcps_connects++);
soisfconnected(so);
tp->t_state = TCPS_ESTABLISHED;
m_adj(m, -todrop);
ti->ti_len = tp->rcv_wnd;
tiflags &= ~TH_FIN;
- STAT(tcpstat.tcps_rcvpackafterwin++);
- STAT(tcpstat.tcps_rcvbyteafterwin += todrop);
}
tp->snd_wl1 = ti->ti_seq - 1;
tp->rcv_up = ti->ti_seq;
*/
tp->t_flags |= TF_ACKNOW;
todrop = ti->ti_len;
- STAT(tcpstat.tcps_rcvduppack++);
- STAT(tcpstat.tcps_rcvdupbyte += todrop);
- } else {
- STAT(tcpstat.tcps_rcvpartduppack++);
- STAT(tcpstat.tcps_rcvpartdupbyte += todrop);
}
m_adj(m, todrop);
ti->ti_seq += todrop;
if ((so->so_state & SS_NOFDREF) &&
tp->t_state > TCPS_CLOSE_WAIT && ti->ti_len) {
tp = tcp_close(tp);
- STAT(tcpstat.tcps_rcvafterclose++);
goto dropwithreset;
}
*/
todrop = (ti->ti_seq+ti->ti_len) - (tp->rcv_nxt+tp->rcv_wnd);
if (todrop > 0) {
- STAT(tcpstat.tcps_rcvpackafterwin++);
if (todrop >= ti->ti_len) {
- STAT(tcpstat.tcps_rcvbyteafterwin += ti->ti_len);
/*
* If a new connection request is received
* while in TIME_WAIT, drop the old connection
*/
if (tp->rcv_wnd == 0 && ti->ti_seq == tp->rcv_nxt) {
tp->t_flags |= TF_ACKNOW;
- STAT(tcpstat.tcps_rcvwinprobe++);
- } else
+ } else {
goto dropafterack;
- } else
- STAT(tcpstat.tcps_rcvbyteafterwin += todrop);
+ }
+ }
m_adj(m, -todrop);
ti->ti_len -= todrop;
tiflags &= ~(TH_PUSH|TH_FIN);
case TCPS_FIN_WAIT_2:
case TCPS_CLOSE_WAIT:
tp->t_state = TCPS_CLOSED;
- STAT(tcpstat.tcps_drops++);
tp = tcp_close(tp);
goto drop;
if (SEQ_GT(tp->snd_una, ti->ti_ack) ||
SEQ_GT(ti->ti_ack, tp->snd_max))
goto dropwithreset;
- STAT(tcpstat.tcps_connects++);
tp->t_state = TCPS_ESTABLISHED;
/*
* The sent SYN is ack'ed with our sequence number +1
if (SEQ_LEQ(ti->ti_ack, tp->snd_una)) {
if (ti->ti_len == 0 && tiwin == tp->snd_wnd) {
- STAT(tcpstat.tcps_rcvdupack++);
DEBUG_MISC((dfd," dup ack m = %lx so = %lx \n",
(long )m, (long )so));
/*
tp->snd_cwnd = tp->snd_ssthresh;
tp->t_dupacks = 0;
if (SEQ_GT(ti->ti_ack, tp->snd_max)) {
- STAT(tcpstat.tcps_rcvacktoomuch++);
goto dropafterack;
}
acked = ti->ti_ack - tp->snd_una;
- STAT(tcpstat.tcps_rcvackpack++);
- STAT(tcpstat.tcps_rcvackbyte += acked);
/*
* If transmit timer is running and timed sequence
(SEQ_LT(tp->snd_wl1, ti->ti_seq) ||
(tp->snd_wl1 == ti->ti_seq && (SEQ_LT(tp->snd_wl2, ti->ti_ack) ||
(tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd))))) {
- /* keep track of pure window updates */
- if (ti->ti_len == 0 &&
- tp->snd_wl2 == ti->ti_ack && tiwin > tp->snd_wnd)
- STAT(tcpstat.tcps_rcvwinupd++);
tp->snd_wnd = tiwin;
tp->snd_wl1 = ti->ti_seq;
tp->snd_wl2 = ti->ti_ack;
DEBUG_ARG("tp = %lx", (long)tp);
DEBUG_ARG("rtt = %d", rtt);
- STAT(tcpstat.tcps_rttupdated++);
if (tp->t_srtt != 0) {
/*
* srtt is stored as fixed point with 3 bits after the
/*
* No reason to send a segment, just return.
*/
- STAT(tcpstat.tcps_didnuttin++);
-
return (0);
send:
* the template for sends on this connection.
*/
if (len) {
- if (tp->t_force && len == 1)
- STAT(tcpstat.tcps_sndprobe++);
- else if (SEQ_LT(tp->snd_nxt, tp->snd_max)) {
- STAT(tcpstat.tcps_sndrexmitpack++);
- STAT(tcpstat.tcps_sndrexmitbyte += len);
- } else {
- STAT(tcpstat.tcps_sndpack++);
- STAT(tcpstat.tcps_sndbyte += len);
- }
-
m = m_get();
if (m == NULL) {
error = 1;
if (off + len == so->so_snd.sb_cc)
flags |= TH_PUSH;
} else {
- if (tp->t_flags & TF_ACKNOW)
- STAT(tcpstat.tcps_sndacks++);
- else if (flags & (TH_SYN|TH_FIN|TH_RST))
- STAT(tcpstat.tcps_sndctrl++);
- else if (SEQ_GT(tp->snd_up, tp->snd_una))
- STAT(tcpstat.tcps_sndurg++);
- else
- STAT(tcpstat.tcps_sndwinup++);
-
m = m_get();
if (m == NULL) {
error = 1;
if (tp->t_rtt == 0) {
tp->t_rtt = 1;
tp->t_rtseq = startseq;
- STAT(tcpstat.tcps_segstimed++);
}
}
out:
return (error);
}
- STAT(tcpstat.tcps_sndtotal++);
/*
* Data sent (as far as we can tell).
if (TCPS_HAVERCVDSYN(tp->t_state)) {
tp->t_state = TCPS_CLOSED;
(void) tcp_output(tp);
- STAT(tcpstat.tcps_drops++);
- } else
- STAT(tcpstat.tcps_conndrops++);
+ }
return (tcp_close(tp));
}
sbfree(&so->so_rcv);
sbfree(&so->so_snd);
sofree(so);
- STAT(tcpstat.tcps_closed++);
return ((struct tcpcb *)0);
}
tcp_template(tp);
- STAT(tcpstat.tcps_connattempt++);
-
tp->t_state = TCPS_SYN_SENT;
tp->t_timer[TCPT_KEEP] = TCPTV_KEEP_INIT;
tp->iss = tcp_iss;
#include <slirp.h>
-#ifdef LOG_ENABLED
-struct tcpstat tcpstat; /* tcp statistics */
-#endif
-
u_int32_t tcp_now; /* for RFC 1323 timestamps */
static struct tcpcb *tcp_timers(register struct tcpcb *tp, int timer);
(tp->t_flags & TF_DELACK)) {
tp->t_flags &= ~TF_DELACK;
tp->t_flags |= TF_ACKNOW;
- STAT(tcpstat.tcps_delack++);
(void) tcp_output(tp);
}
}
* We tried our best, now the connection must die!
*/
tp->t_rxtshift = TCP_MAXRXTSHIFT;
- STAT(tcpstat.tcps_timeoutdrop++);
tp = tcp_drop(tp, tp->t_softerror);
/* tp->t_softerror : ETIMEDOUT); */ /* XXX */
return (tp); /* XXX */
*/
tp->t_rxtshift = 6;
}
- STAT(tcpstat.tcps_rexmttimeo++);
rexmt = TCP_REXMTVAL(tp) * tcp_backoff[tp->t_rxtshift];
TCPT_RANGESET(tp->t_rxtcur, rexmt,
(short)tp->t_rttmin, TCPTV_REXMTMAX); /* XXX */
* Force a byte to be output, if possible.
*/
case TCPT_PERSIST:
- STAT(tcpstat.tcps_persisttimeo++);
tcp_setpersist(tp);
tp->t_force = 1;
(void) tcp_output(tp);
* or drop connection if idle for too long.
*/
case TCPT_KEEP:
- STAT(tcpstat.tcps_keeptimeo++);
if (tp->t_state < TCPS_ESTABLISHED)
goto dropit;
* by the protocol spec, this requires the
* correspondent TCP to respond.
*/
- STAT(tcpstat.tcps_keepprobe++);
tcp_respond(tp, &tp->t_template, (struct mbuf *)NULL,
tp->rcv_nxt, tp->snd_una - 1, 0);
tp->t_timer[TCPT_KEEP] = TCPTV_KEEPINTVL;
break;
dropit:
- STAT(tcpstat.tcps_keepdrops++);
tp = tcp_drop(tp, 0);
break;
}
#define TCP_REXMTVAL(tp) \
(((tp)->t_srtt >> TCP_RTT_SHIFT) + (tp)->t_rttvar)
-#ifdef LOG_ENABLED
-/*
- * TCP statistics.
- * Many of these should be kept per connection,
- * but that's inconvenient at the moment.
- */
-struct tcpstat {
- u_long tcps_connattempt; /* connections initiated */
- u_long tcps_accepts; /* connections accepted */
- u_long tcps_connects; /* connections established */
- u_long tcps_drops; /* connections dropped */
- u_long tcps_conndrops; /* embryonic connections dropped */
- u_long tcps_closed; /* conn. closed (includes drops) */
- u_long tcps_segstimed; /* segs where we tried to get rtt */
- u_long tcps_rttupdated; /* times we succeeded */
- u_long tcps_delack; /* delayed acks sent */
- u_long tcps_timeoutdrop; /* conn. dropped in rxmt timeout */
- u_long tcps_rexmttimeo; /* retransmit timeouts */
- u_long tcps_persisttimeo; /* persist timeouts */
- u_long tcps_keeptimeo; /* keepalive timeouts */
- u_long tcps_keepprobe; /* keepalive probes sent */
- u_long tcps_keepdrops; /* connections dropped in keepalive */
-
- u_long tcps_sndtotal; /* total packets sent */
- u_long tcps_sndpack; /* data packets sent */
- u_long tcps_sndbyte; /* data bytes sent */
- u_long tcps_sndrexmitpack; /* data packets retransmitted */
- u_long tcps_sndrexmitbyte; /* data bytes retransmitted */
- u_long tcps_sndacks; /* ack-only packets sent */
- u_long tcps_sndprobe; /* window probes sent */
- u_long tcps_sndurg; /* packets sent with URG only */
- u_long tcps_sndwinup; /* window update-only packets sent */
- u_long tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */
-
- u_long tcps_rcvtotal; /* total packets received */
- u_long tcps_rcvpack; /* packets received in sequence */
- u_long tcps_rcvbyte; /* bytes received in sequence */
- u_long tcps_rcvbadsum; /* packets received with ccksum errs */
- u_long tcps_rcvbadoff; /* packets received with bad offset */
- u_long tcps_rcvduppack; /* duplicate-only packets received */
- u_long tcps_rcvdupbyte; /* duplicate-only bytes received */
- u_long tcps_rcvpartduppack; /* packets with some duplicate data */
- u_long tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */
- u_long tcps_rcvoopack; /* out-of-order packets received */
- u_long tcps_rcvoobyte; /* out-of-order bytes received */
- u_long tcps_rcvpackafterwin; /* packets with data after window */
- u_long tcps_rcvbyteafterwin; /* bytes rcvd after window */
- u_long tcps_rcvafterclose; /* packets rcvd after "close" */
- u_long tcps_rcvwinprobe; /* rcvd window probe packets */
- u_long tcps_rcvdupack; /* rcvd duplicate acks */
- u_long tcps_rcvacktoomuch; /* rcvd acks for unsent data */
- u_long tcps_rcvackpack; /* rcvd ack packets */
- u_long tcps_rcvackbyte; /* bytes acked by rcvd acks */
- u_long tcps_rcvwinupd; /* rcvd window update packets */
- u_long tcps_predack; /* times hdr predict ok for acks */
- u_long tcps_preddat; /* times hdr predict ok for data pkts */
- u_long tcps_socachemiss; /* tcp_last_so misses */
- u_long tcps_didnuttin; /* Times tcp_output didn't do anything XXX */
-};
-
-extern struct tcpstat tcpstat; /* tcp statistics */
-#endif
-
extern u_int32_t tcp_now; /* for RFC 1323 timestamps */
#endif
#include <slirp.h>
#include "ip_icmp.h"
-#ifdef LOG_ENABLED
-struct udpstat udpstat;
-#endif
-
struct socket udb;
static u_int8_t udp_tos(struct socket *so);
DEBUG_ARG("m = %lx", (long)m);
DEBUG_ARG("iphlen = %d", iphlen);
- STAT(udpstat.udps_ipackets++);
-
/*
* Strip IP options, if any; should skip this,
* make available to user, and use on returned packets,
if (ip->ip_len != len) {
if (len > ip->ip_len) {
- STAT(udpstat.udps_badlen++);
goto bad;
}
m_adj(m, len - ip->ip_len);
((struct ipovly *)ip)->ih_x1 = 0;
((struct ipovly *)ip)->ih_len = uh->uh_ulen;
if(cksum(m, len + sizeof(struct ip))) {
- STAT(udpstat.udps_badsum++);
goto bad;
}
}
if (tmp == &udb) {
so = NULL;
} else {
- STAT(udpstat.udpps_pcbcachemiss++);
udp_last_so = so;
}
}
((struct ip *)ui)->ip_ttl = IPDEFTTL;
((struct ip *)ui)->ip_tos = iptos;
- STAT(udpstat.udps_opackets++);
-
error = ip_output(so, m);
return (error);
#define ui_ulen ui_u.uh_ulen
#define ui_sum ui_u.uh_sum
-#ifdef LOG_ENABLED
-struct udpstat {
- /* input statistics: */
- u_long udps_ipackets; /* total input packets */
- u_long udps_hdrops; /* packet shorter than header */
- u_long udps_badsum; /* checksum error */
- u_long udps_badlen; /* data length larger than packet */
- u_long udps_noport; /* no socket on port */
- u_long udps_noportbcast; /* of above, arrived as broadcast */
- u_long udps_fullsock; /* not delivered, input socket full */
- u_long udpps_pcbcachemiss; /* input packets missing pcb cache */
- /* output statistics: */
- u_long udps_opackets; /* total output packets */
-};
-#endif
-
/*
* Names for UDP sysctl objects
*/
#define UDPCTL_CHECKSUM 1 /* checksum UDP packets */
#define UDPCTL_MAXID 2
-#ifdef LOG_ENABLED
-extern struct udpstat udpstat;
-#endif
-
extern struct socket udb;
struct mbuf;