aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMichele Baldessari <michele@acksyn.org>2012-11-30 23:49:42 -0500
committerDavid S. Miller <davem@davemloft.net>2012-12-03 13:32:15 -0500
commit196d67593439b03088913227093e374235596e33 (patch)
treed8d1580673e3cf878d6db230bf86b71187bf3550 /include
parent96070ae4d08eefe62ac534904ce21a01e1a5c9c4 (diff)
sctp: Add support to per-association statistics via a new SCTP_GET_ASSOC_STATS call
The current SCTP stack is lacking a mechanism to have per association statistics. This is an implementation modeled after OpenSolaris' SCTP_GET_ASSOC_STATS. Userspace part will follow on lksctp if/when there is a general ACK on this. V4: - Move ipackets++ before q->immediate.func() for consistency reasons - Move sctp_max_rto() at the end of sctp_transport_update_rto() to avoid returning bogus RTO values - return asoc->rto_min when max_obs_rto value has not changed V3: - Increase ictrlchunks in sctp_assoc_bh_rcv() as well - Move ipackets++ to sctp_inq_push() - return 0 when no rto updates took place since the last call V2: - Implement partial retrieval of stat struct to cope for future expansion - Kill the rtxpackets counter as it cannot be precise anyway - Rename outseqtsns to outofseqtsns to make it clearer that these are out of sequence unexpected TSNs - Move asoc->ipackets++ under a lock to avoid potential miscounts - Fold asoc->opackets++ into the already existing asoc check - Kill unneeded (q->asoc) test when increasing rtxchunks - Do not count octrlchunks if sending failed (SCTP_XMIT_OK != 0) - Don't count SHUTDOWNs as SACKs - Move SCTP_GET_ASSOC_STATS to the private space API - Adjust the len check in sctp_getsockopt_assoc_stats() to allow for future struct growth - Move association statistics in their own struct - Update idupchunks when we send a SACK with dup TSNs - return min_rto in max_rto when RTO has not changed. Also return the transport when max_rto last changed. Signed-off: Michele Baldessari <michele@acksyn.org> Acked-by: Vlad Yasevich <vyasevich@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/sctp/sctp.h12
-rw-r--r--include/net/sctp/structs.h36
-rw-r--r--include/net/sctp/user.h27
3 files changed, 75 insertions, 0 deletions
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
index 9c6414f553f9..7fdf298a47ef 100644
--- a/include/net/sctp/sctp.h
+++ b/include/net/sctp/sctp.h
@@ -272,6 +272,18 @@ struct sctp_mib {
272 unsigned long mibs[SCTP_MIB_MAX]; 272 unsigned long mibs[SCTP_MIB_MAX];
273}; 273};
274 274
275/* helper function to track stats about max rto and related transport */
276static inline void sctp_max_rto(struct sctp_association *asoc,
277 struct sctp_transport *trans)
278{
279 if (asoc->stats.max_obs_rto < (__u64)trans->rto) {
280 asoc->stats.max_obs_rto = trans->rto;
281 memset(&asoc->stats.obs_rto_ipaddr, 0,
282 sizeof(struct sockaddr_storage));
283 memcpy(&asoc->stats.obs_rto_ipaddr, &trans->ipaddr,
284 trans->af_specific->sockaddr_len);
285 }
286}
275 287
276/* Print debugging messages. */ 288/* Print debugging messages. */
277#if SCTP_DEBUG 289#if SCTP_DEBUG
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
index 2b2f61dd4036..c2521016d646 100644
--- a/include/net/sctp/structs.h
+++ b/include/net/sctp/structs.h
@@ -1312,6 +1312,40 @@ struct sctp_inithdr_host {
1312 __u32 initial_tsn; 1312 __u32 initial_tsn;
1313}; 1313};
1314 1314
1315/* SCTP_GET_ASSOC_STATS counters */
1316struct sctp_priv_assoc_stats {
1317 /* Maximum observed rto in the association during subsequent
1318 * observations. Value is set to 0 if no RTO measurement took place
1319 * The transport where the max_rto was observed is returned in
1320 * obs_rto_ipaddr
1321 */
1322 struct sockaddr_storage obs_rto_ipaddr;
1323 __u64 max_obs_rto;
1324 /* Total In and Out SACKs received and sent */
1325 __u64 isacks;
1326 __u64 osacks;
1327 /* Total In and Out packets received and sent */
1328 __u64 opackets;
1329 __u64 ipackets;
1330 /* Total retransmitted chunks */
1331 __u64 rtxchunks;
1332 /* TSN received > next expected */
1333 __u64 outofseqtsns;
1334 /* Duplicate Chunks received */
1335 __u64 idupchunks;
1336 /* Gap Ack Blocks received */
1337 __u64 gapcnt;
1338 /* Unordered data chunks sent and received */
1339 __u64 ouodchunks;
1340 __u64 iuodchunks;
1341 /* Ordered data chunks sent and received */
1342 __u64 oodchunks;
1343 __u64 iodchunks;
1344 /* Control chunks sent and received */
1345 __u64 octrlchunks;
1346 __u64 ictrlchunks;
1347};
1348
1315/* RFC2960 1349/* RFC2960
1316 * 1350 *
1317 * 12. Recommended Transmission Control Block (TCB) Parameters 1351 * 12. Recommended Transmission Control Block (TCB) Parameters
@@ -1830,6 +1864,8 @@ struct sctp_association {
1830 1864
1831 __u8 need_ecne:1, /* Need to send an ECNE Chunk? */ 1865 __u8 need_ecne:1, /* Need to send an ECNE Chunk? */
1832 temp:1; /* Is it a temporary association? */ 1866 temp:1; /* Is it a temporary association? */
1867
1868 struct sctp_priv_assoc_stats stats;
1833}; 1869};
1834 1870
1835 1871
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h
index 1b02d7ad453b..9a0ae091366d 100644
--- a/include/net/sctp/user.h
+++ b/include/net/sctp/user.h
@@ -107,6 +107,7 @@ typedef __s32 sctp_assoc_t;
107#define SCTP_GET_LOCAL_ADDRS 109 /* Get all local address. */ 107#define SCTP_GET_LOCAL_ADDRS 109 /* Get all local address. */
108#define SCTP_SOCKOPT_CONNECTX 110 /* CONNECTX requests. */ 108#define SCTP_SOCKOPT_CONNECTX 110 /* CONNECTX requests. */
109#define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */ 109#define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */
110#define SCTP_GET_ASSOC_STATS 112 /* Read only */
110 111
111/* 112/*
112 * 5.2.1 SCTP Initiation Structure (SCTP_INIT) 113 * 5.2.1 SCTP Initiation Structure (SCTP_INIT)
@@ -719,6 +720,32 @@ struct sctp_getaddrs {
719 __u8 addrs[0]; /*output, variable size*/ 720 __u8 addrs[0]; /*output, variable size*/
720}; 721};
721 722
723/* A socket user request obtained via SCTP_GET_ASSOC_STATS that retrieves
724 * association stats. All stats are counts except sas_maxrto and
725 * sas_obs_rto_ipaddr. maxrto is the max observed rto + transport since
726 * the last call. Will return 0 when RTO was not update since last call
727 */
728struct sctp_assoc_stats {
729 sctp_assoc_t sas_assoc_id; /* Input */
730 /* Transport of observed max RTO */
731 struct sockaddr_storage sas_obs_rto_ipaddr;
732 __u64 sas_maxrto; /* Maximum Observed RTO for period */
733 __u64 sas_isacks; /* SACKs received */
734 __u64 sas_osacks; /* SACKs sent */
735 __u64 sas_opackets; /* Packets sent */
736 __u64 sas_ipackets; /* Packets received */
737 __u64 sas_rtxchunks; /* Retransmitted Chunks */
738 __u64 sas_outofseqtsns;/* TSN received > next expected */
739 __u64 sas_idupchunks; /* Dups received (ordered+unordered) */
740 __u64 sas_gapcnt; /* Gap Acknowledgements Received */
741 __u64 sas_ouodchunks; /* Unordered data chunks sent */
742 __u64 sas_iuodchunks; /* Unordered data chunks received */
743 __u64 sas_oodchunks; /* Ordered data chunks sent */
744 __u64 sas_iodchunks; /* Ordered data chunks received */
745 __u64 sas_octrlchunks; /* Control chunks sent */
746 __u64 sas_ictrlchunks; /* Control chunks received */
747};
748
722/* These are bit fields for msghdr->msg_flags. See section 5.1. */ 749/* These are bit fields for msghdr->msg_flags. See section 5.1. */
723/* On user space Linux, these live in <bits/socket.h> as an enum. */ 750/* On user space Linux, these live in <bits/socket.h> as an enum. */
724enum sctp_msg_flags { 751enum sctp_msg_flags {