PERFORCE change 166614 for review

Gabor Pali pgj at FreeBSD.org
Mon Jul 27 13:11:05 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=166614

Change 166614 by pgj at petymeg-current on 2009/07/27 13:10:48

	Standardize struct tcpstat and add a general header structure for
	protocol-dependent statistics to support exporting information.

Affected files ...

.. //depot/projects/soc2009/pgj_libstat/src/sys/netinet/tcp_input.c#2 edit
.. //depot/projects/soc2009/pgj_libstat/src/sys/netinet/tcp_var.h#2 edit

Differences ...

==== //depot/projects/soc2009/pgj_libstat/src/sys/netinet/tcp_input.c#2 (text+ko) ====

@@ -105,6 +105,10 @@
 static const int tcprexmtthresh = 3;
 
 #ifdef VIMAGE_GLOBALS
+struct	stat_header tcpstat_header = {
+	.sth_version = TCPSTAT_VERSION,
+	.sth_len = sizeof(struct tcpstat)
+};
 struct	tcpstat tcpstat;
 int	blackhole;
 int	tcp_delack_enabled;
@@ -125,6 +129,9 @@
     CTLFLAG_RW, tcpstat , tcpstat,
     "TCP statistics (struct tcpstat, netinet/tcp_var.h)");
 
+SYSCTL_V_STRUCT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, stats_header,
+    CTLFLAG_RD, tcpstat_header, stat_header, "TCP statistics header");
+
 int tcp_log_in_vain = 0;
 SYSCTL_INT(_net_inet_tcp, OID_AUTO, log_in_vain, CTLFLAG_RW,
     &tcp_log_in_vain, 0, "Log all incoming TCP segments to closed ports");

==== //depot/projects/soc2009/pgj_libstat/src/sys/netinet/tcp_var.h#2 (text+ko) ====

@@ -352,114 +352,123 @@
 	max((tp)->t_rttmin, (((tp)->t_srtt >> (TCP_RTT_SHIFT - TCP_DELTA_SHIFT))  \
 	  + (tp)->t_rttvar) >> TCP_DELTA_SHIFT)
 
+/* XXX: should be moved to somewhere else. */
+struct stat_header {
+	const u_int32_t	sth_version;
+	const u_int32_t	sth_len;
+};
+
 /*
  * 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_minmssdrops;	/* average minmss too low drops */
-	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 */
+
+#define	TCPSTAT_VERSION	    0x00000001
+
+struct tcpstat {
+	u_int64_t	tcps_connattempt;	/* connections initiated */
+	u_int64_t	tcps_accepts;		/* connections accepted */
+	u_int64_t	tcps_connects;		/* connections established */
+	u_int64_t	tcps_drops;		/* connections dropped */
+	u_int64_t	tcps_conndrops;		/* embryonic connections dropped */
+	u_int64_t	tcps_minmssdrops;	/* average minmss too low drops */
+	u_int64_t	tcps_closed;		/* conn. closed (includes drops) */
+	u_int64_t	tcps_segstimed;		/* segs where we tried to get rtt */
+	u_int64_t	tcps_rttupdated;	/* times we succeeded */
+	u_int64_t	tcps_delack;		/* delayed acks sent */
+	u_int64_t	tcps_timeoutdrop;	/* conn. dropped in rxmt timeout */
+	u_int64_t	tcps_rexmttimeo;	/* retransmit timeouts */
+	u_int64_t	tcps_persisttimeo;	/* persist timeouts */
+	u_int64_t	tcps_keeptimeo;		/* keepalive timeouts */
+	u_int64_t	tcps_keepprobe;		/* keepalive probes sent */
+	u_int64_t	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_sndrexmitbad;	/* unnecessary packet retransmissions */
-	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_int64_t	tcps_sndtotal;		/* total packets sent */
+	u_int64_t	tcps_sndpack;		/* data packets sent */
+	u_int64_t	tcps_sndbyte;		/* data bytes sent */
+	u_int64_t	tcps_sndrexmitpack;	/* data packets retransmitted */
+	u_int64_t	tcps_sndrexmitbyte;	/* data bytes retransmitted */
+	u_int64_t	tcps_sndrexmitbad;	/* unnecessary packet retransmissions */
+	u_int64_t	tcps_sndacks;		/* ack-only packets sent */
+	u_int64_t	tcps_sndprobe;		/* window probes sent */
+	u_int64_t	tcps_sndurg;		/* packets sent with URG only */
+	u_int64_t	tcps_sndwinup;		/* window update-only packets sent */
+	u_int64_t	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_rcvmemdrop;	/* packets dropped for lack of memory */
-	u_long	tcps_rcvshort;		/* packets received too short */
-	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_pawsdrop;		/* segments dropped due to PAWS */
-	u_long	tcps_predack;		/* times hdr predict ok for acks */
-	u_long	tcps_preddat;		/* times hdr predict ok for data pkts */
-	u_long	tcps_pcbcachemiss;
-	u_long	tcps_cachedrtt;		/* times cached RTT in route updated */
-	u_long	tcps_cachedrttvar;	/* times cached rttvar updated */
-	u_long	tcps_cachedssthresh;	/* times cached ssthresh updated */
-	u_long	tcps_usedrtt;		/* times RTT initialized from route */
-	u_long	tcps_usedrttvar;	/* times RTTVAR initialized from rt */
-	u_long	tcps_usedssthresh;	/* times ssthresh initialized from rt*/
-	u_long	tcps_persistdrop;	/* timeout in persist state */
-	u_long	tcps_badsyn;		/* bogus SYN, e.g. premature ACK */
-	u_long	tcps_mturesent;		/* resends due to MTU discovery */
-	u_long	tcps_listendrop;	/* listen queue overflows */
-	u_long	tcps_badrst;		/* ignored RSTs in the window */
+	u_int64_t	tcps_rcvtotal;		/* total packets received */
+	u_int64_t	tcps_rcvpack;		/* packets received in sequence */
+	u_int64_t	tcps_rcvbyte;		/* bytes received in sequence */
+	u_int64_t	tcps_rcvbadsum;		/* packets received with ccksum errs */
+	u_int64_t	tcps_rcvbadoff;		/* packets received with bad offset */
+	u_int64_t	tcps_rcvmemdrop;	/* packets dropped for lack of memory */
+	u_int64_t	tcps_rcvshort;		/* packets received too short */
+	u_int64_t	tcps_rcvduppack;	/* duplicate-only packets received */
+	u_int64_t	tcps_rcvdupbyte;	/* duplicate-only bytes received */
+	u_int64_t	tcps_rcvpartduppack;	/* packets with some duplicate data */
+	u_int64_t	tcps_rcvpartdupbyte;	/* dup. bytes in part-dup. packets */
+	u_int64_t	tcps_rcvoopack;		/* out-of-order packets received */
+	u_int64_t	tcps_rcvoobyte;		/* out-of-order bytes received */
+	u_int64_t	tcps_rcvpackafterwin;	/* packets with data after window */
+	u_int64_t	tcps_rcvbyteafterwin;	/* bytes rcvd after window */
+	u_int64_t	tcps_rcvafterclose;	/* packets rcvd after "close" */
+	u_int64_t	tcps_rcvwinprobe;	/* rcvd window probe packets */
+	u_int64_t	tcps_rcvdupack;		/* rcvd duplicate acks */
+	u_int64_t	tcps_rcvacktoomuch;	/* rcvd acks for unsent data */
+	u_int64_t	tcps_rcvackpack;	/* rcvd ack packets */
+	u_int64_t	tcps_rcvackbyte;	/* bytes acked by rcvd acks */
+	u_int64_t	tcps_rcvwinupd;		/* rcvd window update packets */
+	u_int64_t	tcps_pawsdrop;		/* segments dropped due to PAWS */
+	u_int64_t	tcps_predack;		/* times hdr predict ok for acks */
+	u_int64_t	tcps_preddat;		/* times hdr predict ok for data pkts */
+	u_int64_t	tcps_pcbcachemiss;
+	u_int64_t	tcps_cachedrtt;		/* times cached RTT in route updated */
+	u_int64_t	tcps_cachedrttvar;	/* times cached rttvar updated */
+	u_int64_t	tcps_cachedssthresh;	/* times cached ssthresh updated */
+	u_int64_t	tcps_usedrtt;		/* times RTT initialized from route */
+	u_int64_t	tcps_usedrttvar;	/* times RTTVAR initialized from rt */
+	u_int64_t	tcps_usedssthresh;	/* times ssthresh initialized from rt*/
+	u_int64_t	tcps_persistdrop;	/* timeout in persist state */
+	u_int64_t	tcps_badsyn;		/* bogus SYN, e.g. premature ACK */
+	u_int64_t	tcps_mturesent;		/* resends due to MTU discovery */
+	u_int64_t	tcps_listendrop;	/* listen queue overflows */
+	u_int64_t	tcps_badrst;		/* ignored RSTs in the window */
 
-	u_long	tcps_sc_added;		/* entry added to syncache */
-	u_long	tcps_sc_retransmitted;	/* syncache entry was retransmitted */
-	u_long	tcps_sc_dupsyn;		/* duplicate SYN packet */
-	u_long	tcps_sc_dropped;	/* could not reply to packet */
-	u_long	tcps_sc_completed;	/* successful extraction of entry */
-	u_long	tcps_sc_bucketoverflow;	/* syncache per-bucket limit hit */
-	u_long	tcps_sc_cacheoverflow;	/* syncache cache limit hit */
-	u_long	tcps_sc_reset;		/* RST removed entry from syncache */
-	u_long	tcps_sc_stale;		/* timed out or listen socket gone */
-	u_long	tcps_sc_aborted;	/* syncache entry aborted */
-	u_long	tcps_sc_badack;		/* removed due to bad ACK */
-	u_long	tcps_sc_unreach;	/* ICMP unreachable received */
-	u_long	tcps_sc_zonefail;	/* zalloc() failed */
-	u_long	tcps_sc_sendcookie;	/* SYN cookie sent */
-	u_long	tcps_sc_recvcookie;	/* SYN cookie received */
+	u_int64_t	tcps_sc_added;		/* entry added to syncache */
+	u_int64_t	tcps_sc_retransmitted;	/* syncache entry was retransmitted */
+	u_int64_t	tcps_sc_dupsyn;		/* duplicate SYN packet */
+	u_int64_t	tcps_sc_dropped;	/* could not reply to packet */
+	u_int64_t	tcps_sc_completed;	/* successful extraction of entry */
+	u_int64_t	tcps_sc_bucketoverflow;	/* syncache per-bucket limit hit */
+	u_int64_t	tcps_sc_cacheoverflow;	/* syncache cache limit hit */
+	u_int64_t	tcps_sc_reset;		/* RST removed entry from syncache */
+	u_int64_t	tcps_sc_stale;		/* timed out or listen socket gone */
+	u_int64_t	tcps_sc_aborted;	/* syncache entry aborted */
+	u_int64_t	tcps_sc_badack;		/* removed due to bad ACK */
+	u_int64_t	tcps_sc_unreach;	/* ICMP unreachable received */
+	u_int64_t	tcps_sc_zonefail;	/* zalloc() failed */
+	u_int64_t	tcps_sc_sendcookie;	/* SYN cookie sent */
+	u_int64_t	tcps_sc_recvcookie;	/* SYN cookie received */
 
-	u_long	tcps_hc_added;		/* entry added to hostcache */
-	u_long	tcps_hc_bucketoverflow;	/* hostcache per bucket limit hit */
+	u_int64_t	tcps_hc_added;		/* entry added to hostcache */
+	u_int64_t	tcps_hc_bucketoverflow;	/* hostcache per bucket limit hit */
 
-	u_long  tcps_finwait2_drops;    /* Drop FIN_WAIT_2 connection after time limit */
+	u_int64_t  tcps_finwait2_drops;    /* Drop FIN_WAIT_2 connection after time limit */
 
 	/* SACK related stats */
-	u_long	tcps_sack_recovery_episode; /* SACK recovery episodes */
-	u_long  tcps_sack_rexmits;	    /* SACK rexmit segments   */
-	u_long  tcps_sack_rexmit_bytes;	    /* SACK rexmit bytes      */
-	u_long  tcps_sack_rcv_blocks;	    /* SACK blocks (options) received */
-	u_long  tcps_sack_send_blocks;	    /* SACK blocks (options) sent     */
-	u_long  tcps_sack_sboverflow; 	    /* times scoreboard overflowed */
+	u_int64_t  tcps_sack_recovery_episode; /* SACK recovery episodes */
+	u_int64_t  tcps_sack_rexmits;	    /* SACK rexmit segments   */
+	u_int64_t  tcps_sack_rexmit_bytes;	    /* SACK rexmit bytes      */
+	u_int64_t  tcps_sack_rcv_blocks;	    /* SACK blocks (options) received */
+	u_int64_t  tcps_sack_send_blocks;	    /* SACK blocks (options) sent     */
+	u_int64_t  tcps_sack_sboverflow; 	    /* times scoreboard overflowed */
 	
 	/* ECN related stats */
-	u_long	tcps_ecn_ce;		/* ECN Congestion Experienced */
-	u_long	tcps_ecn_ect0;		/* ECN Capable Transport */
-	u_long	tcps_ecn_ect1;		/* ECN Capable Transport */
-	u_long	tcps_ecn_shs;		/* ECN successful handshakes */
-	u_long	tcps_ecn_rcwnd;		/* # times ECN reduced the cwnd */
+	u_int64_t	tcps_ecn_ce;		/* ECN Congestion Experienced */
+	u_int64_t	tcps_ecn_ect0;		/* ECN Capable Transport */
+	u_int64_t	tcps_ecn_ect1;		/* ECN Capable Transport */
+	u_int64_t	tcps_ecn_shs;		/* ECN successful handshakes */
+	u_int64_t	tcps_ecn_rcwnd;		/* # times ECN reduced the cwnd */
 };
 
 #ifdef _KERNEL


More information about the p4-projects mailing list