[SCTP]: Extend /proc/net/sctp/snmp to provide more statistics.
authorSridhar Samudrala <sri@us.ibm.com>
Tue, 22 Aug 2006 07:15:33 +0000 (00:15 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Fri, 22 Sep 2006 21:55:16 +0000 (14:55 -0700)
This patch adds more statistics info under /proc/net/sctp/snmp
that should be useful for debugging. The additional events that
are counted now include timer expirations, retransmits, packet
and data chunk discards.

The Data chunk discards include all the cases where a data chunk
is discarded including high tsn, bad stream, dup tsn and the most
useful one(out of receive buffer/rwnd).

Also moved the SCTP MIB data structures from the generic include
directories to include/sctp/sctp.h.

Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/snmp.h
include/net/sctp/sctp.h
include/net/snmp.h
net/sctp/input.c
net/sctp/inqueue.c
net/sctp/outqueue.c
net/sctp/proc.c
net/sctp/sm_statefuns.c

index 3015655..854aa6b 100644 (file)
@@ -160,39 +160,6 @@ enum
        __UDP_MIB_MAX
 };
 
-/* sctp mib definitions */
-/*
- * draft-ietf-sigtran-sctp-mib-07.txt
- */
-enum
-{
-       SCTP_MIB_NUM = 0,
-       SCTP_MIB_CURRESTAB,                     /* CurrEstab */
-       SCTP_MIB_ACTIVEESTABS,                  /* ActiveEstabs */
-       SCTP_MIB_PASSIVEESTABS,                 /* PassiveEstabs */
-       SCTP_MIB_ABORTEDS,                      /* Aborteds */
-       SCTP_MIB_SHUTDOWNS,                     /* Shutdowns */
-       SCTP_MIB_OUTOFBLUES,                    /* OutOfBlues */
-       SCTP_MIB_CHECKSUMERRORS,                /* ChecksumErrors */
-       SCTP_MIB_OUTCTRLCHUNKS,                 /* OutCtrlChunks */
-       SCTP_MIB_OUTORDERCHUNKS,                /* OutOrderChunks */
-       SCTP_MIB_OUTUNORDERCHUNKS,              /* OutUnorderChunks */
-       SCTP_MIB_INCTRLCHUNKS,                  /* InCtrlChunks */
-       SCTP_MIB_INORDERCHUNKS,                 /* InOrderChunks */
-       SCTP_MIB_INUNORDERCHUNKS,               /* InUnorderChunks */
-       SCTP_MIB_FRAGUSRMSGS,                   /* FragUsrMsgs */
-       SCTP_MIB_REASMUSRMSGS,                  /* ReasmUsrMsgs */
-       SCTP_MIB_OUTSCTPPACKS,                  /* OutSCTPPacks */
-       SCTP_MIB_INSCTPPACKS,                   /* InSCTPPacks */
-       SCTP_MIB_RTOALGORITHM,                  /* RtoAlgorithm */
-       SCTP_MIB_RTOMIN,                        /* RtoMin */
-       SCTP_MIB_RTOMAX,                        /* RtoMax */
-       SCTP_MIB_RTOINITIAL,                    /* RtoInitial */
-       SCTP_MIB_VALCOOKIELIFE,                 /* ValCookieLife */
-       SCTP_MIB_MAXINITRETR,                   /* MaxInitRetr */
-       __SCTP_MIB_MAX
-};
-
 /* linux mib definitions */
 enum
 {
index 1c1abce..e274fd4 100644 (file)
@@ -216,6 +216,50 @@ DECLARE_SNMP_STAT(struct sctp_mib, sctp_statistics);
 
 #endif /* !TEST_FRAME */
 
+/* sctp mib definitions */
+enum
+{
+       SCTP_MIB_NUM = 0,
+       SCTP_MIB_CURRESTAB,                     /* CurrEstab */
+       SCTP_MIB_ACTIVEESTABS,                  /* ActiveEstabs */
+       SCTP_MIB_PASSIVEESTABS,                 /* PassiveEstabs */
+       SCTP_MIB_ABORTEDS,                      /* Aborteds */
+       SCTP_MIB_SHUTDOWNS,                     /* Shutdowns */
+       SCTP_MIB_OUTOFBLUES,                    /* OutOfBlues */
+       SCTP_MIB_CHECKSUMERRORS,                /* ChecksumErrors */
+       SCTP_MIB_OUTCTRLCHUNKS,                 /* OutCtrlChunks */
+       SCTP_MIB_OUTORDERCHUNKS,                /* OutOrderChunks */
+       SCTP_MIB_OUTUNORDERCHUNKS,              /* OutUnorderChunks */
+       SCTP_MIB_INCTRLCHUNKS,                  /* InCtrlChunks */
+       SCTP_MIB_INORDERCHUNKS,                 /* InOrderChunks */
+       SCTP_MIB_INUNORDERCHUNKS,               /* InUnorderChunks */
+       SCTP_MIB_FRAGUSRMSGS,                   /* FragUsrMsgs */
+       SCTP_MIB_REASMUSRMSGS,                  /* ReasmUsrMsgs */
+       SCTP_MIB_OUTSCTPPACKS,                  /* OutSCTPPacks */
+       SCTP_MIB_INSCTPPACKS,                   /* InSCTPPacks */
+       SCTP_MIB_T1_INIT_EXPIREDS,
+       SCTP_MIB_T1_COOKIE_EXPIREDS,
+       SCTP_MIB_T2_SHUTDOWN_EXPIREDS,
+       SCTP_MIB_T3_RTX_EXPIREDS,
+       SCTP_MIB_T4_RTO_EXPIREDS,
+       SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS,
+       SCTP_MIB_DELAY_SACK_EXPIREDS,
+       SCTP_MIB_AUTOCLOSE_EXPIREDS,
+       SCTP_MIB_T3_RETRANSMITS,
+       SCTP_MIB_PMTUD_RETRANSMITS,
+       SCTP_MIB_FAST_RETRANSMITS,
+       SCTP_MIB_IN_PKT_SOFTIRQ,
+       SCTP_MIB_IN_PKT_BACKLOG,
+       SCTP_MIB_IN_PKT_DISCARDS,
+       SCTP_MIB_IN_DATA_CHUNK_DISCARDS,
+       __SCTP_MIB_MAX
+};
+
+#define SCTP_MIB_MAX    __SCTP_MIB_MAX
+struct sctp_mib {
+        unsigned long   mibs[SCTP_MIB_MAX];
+} __SNMP_MIB_ALIGN__;
+
 
 /* Print debugging messages.  */
 #if SCTP_DEBUG
index a36bed8..464970e 100644 (file)
@@ -100,12 +100,6 @@ struct udp_mib {
        unsigned long   mibs[UDP_MIB_MAX];
 } __SNMP_MIB_ALIGN__;
 
-/* SCTP */
-#define SCTP_MIB_MAX   __SCTP_MIB_MAX
-struct sctp_mib {
-       unsigned long   mibs[SCTP_MIB_MAX];
-} __SNMP_MIB_ALIGN__;
-
 /* Linux */
 #define LINUX_MIB_MAX  __LINUX_MIB_MAX
 struct linux_mib {
index 42b66e7..8a34d95 100644 (file)
@@ -255,10 +255,13 @@ int sctp_rcv(struct sk_buff *skb)
         */
        sctp_bh_lock_sock(sk);
 
-       if (sock_owned_by_user(sk))
+       if (sock_owned_by_user(sk)) {
+               SCTP_INC_STATS_BH(SCTP_MIB_IN_PKT_BACKLOG);
                sctp_add_backlog(sk, skb);
-       else
+       } else {
+               SCTP_INC_STATS_BH(SCTP_MIB_IN_PKT_SOFTIRQ);
                sctp_inq_push(&chunk->rcvr->inqueue, chunk);
+       }
 
        sctp_bh_unlock_sock(sk);
 
@@ -271,6 +274,7 @@ int sctp_rcv(struct sk_buff *skb)
        return 0;
 
 discard_it:
+       SCTP_INC_STATS_BH(SCTP_MIB_IN_PKT_DISCARDS);
        kfree_skb(skb);
        return 0;
 
index cf0c767..cf6deed 100644 (file)
@@ -87,7 +87,7 @@ void sctp_inq_free(struct sctp_inq *queue)
 /* Put a new packet in an SCTP inqueue.
  * We assume that packet->sctp_hdr is set and in host byte order.
  */
-void sctp_inq_push(struct sctp_inq *q, struct sctp_chunk *packet)
+void sctp_inq_push(struct sctp_inq *q, struct sctp_chunk *chunk)
 {
        /* Directly call the packet handling routine. */
 
@@ -96,7 +96,7 @@ void sctp_inq_push(struct sctp_inq *q, struct sctp_chunk *packet)
         * Eventually, we should clean up inqueue to not rely
         * on the BH related data structures.
         */
-       list_add_tail(&packet->list, &q->in_chunk_list);
+       list_add_tail(&chunk->list, &q->in_chunk_list);
        q->immediate.func(q->immediate.data);
 }
 
index 30b710c..37074a3 100644 (file)
@@ -467,6 +467,7 @@ void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport,
 
        switch(reason) {
        case SCTP_RTXR_T3_RTX:
+               SCTP_INC_STATS(SCTP_MIB_T3_RETRANSMITS);
                sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_T3_RTX);
                /* Update the retran path if the T3-rtx timer has expired for
                 * the current retran path.
@@ -475,12 +476,15 @@ void sctp_retransmit(struct sctp_outq *q, struct sctp_transport *transport,
                        sctp_assoc_update_retran_path(transport->asoc);
                break;
        case SCTP_RTXR_FAST_RTX:
+               SCTP_INC_STATS(SCTP_MIB_FAST_RETRANSMITS);
                sctp_transport_lower_cwnd(transport, SCTP_LOWER_CWND_FAST_RTX);
                fast_retransmit = 1;
                break;
        case SCTP_RTXR_PMTUD:
-       default:
+               SCTP_INC_STATS(SCTP_MIB_PMTUD_RETRANSMITS);
                break;
+       default:
+               BUG();
        }
 
        sctp_retransmit_mark(q, transport, fast_retransmit);
index 5b3b0e0..a356d8d 100644 (file)
@@ -57,6 +57,21 @@ static struct snmp_mib sctp_snmp_list[] = {
        SNMP_MIB_ITEM("SctpReasmUsrMsgs", SCTP_MIB_REASMUSRMSGS),
        SNMP_MIB_ITEM("SctpOutSCTPPacks", SCTP_MIB_OUTSCTPPACKS),
        SNMP_MIB_ITEM("SctpInSCTPPacks", SCTP_MIB_INSCTPPACKS),
+       SNMP_MIB_ITEM("SctpT1InitExpireds", SCTP_MIB_T1_INIT_EXPIREDS),
+       SNMP_MIB_ITEM("SctpT1CookieExpireds", SCTP_MIB_T1_COOKIE_EXPIREDS),
+       SNMP_MIB_ITEM("SctpT2ShutdownExpireds", SCTP_MIB_T2_SHUTDOWN_EXPIREDS),
+       SNMP_MIB_ITEM("SctpT3RtxExpireds", SCTP_MIB_T3_RTX_EXPIREDS),
+       SNMP_MIB_ITEM("SctpT4RtoExpireds", SCTP_MIB_T4_RTO_EXPIREDS),
+       SNMP_MIB_ITEM("SctpT5ShutdownGuardExpireds", SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS),
+       SNMP_MIB_ITEM("SctpDelaySackExpireds", SCTP_MIB_DELAY_SACK_EXPIREDS),
+       SNMP_MIB_ITEM("SctpAutocloseExpireds", SCTP_MIB_AUTOCLOSE_EXPIREDS),
+       SNMP_MIB_ITEM("SctpT3Retransmits", SCTP_MIB_T3_RETRANSMITS),
+       SNMP_MIB_ITEM("SctpPmtudRetransmits", SCTP_MIB_PMTUD_RETRANSMITS),
+       SNMP_MIB_ITEM("SctpFastRetransmits", SCTP_MIB_FAST_RETRANSMITS),
+       SNMP_MIB_ITEM("SctpInPktSoftirq", SCTP_MIB_IN_PKT_SOFTIRQ),
+       SNMP_MIB_ITEM("SctpInPktBacklog", SCTP_MIB_IN_PKT_BACKLOG),
+       SNMP_MIB_ITEM("SctpInPktDiscards", SCTP_MIB_IN_PKT_DISCARDS),
+       SNMP_MIB_ITEM("SctpInDataChunkDiscards", SCTP_MIB_IN_DATA_CHUNK_DISCARDS),
        SNMP_MIB_SENTINEL
 };
 
@@ -328,8 +343,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
                           "%8p %8p %-3d %-3d %-2d %-4d %4d %8d %8d %7d %5lu %-5d %5d ",
                           assoc, sk, sctp_sk(sk)->type, sk->sk_state,
                           assoc->state, hash, assoc->assoc_id,
-                          (sk->sk_rcvbuf - assoc->rwnd),
                           assoc->sndbuf_used,
+                          (sk->sk_rcvbuf - assoc->rwnd),
                           sock_i_uid(sk), sock_i_ino(sk),
                           epb->bind_addr.port,
                           assoc->peer.port);
index 5b5ae79..32f57f4 100644 (file)
@@ -2663,9 +2663,11 @@ sctp_disposition_t sctp_sf_eat_data_6_2(const struct sctp_endpoint *ep,
                break;
        case SCTP_IERROR_HIGH_TSN:
        case SCTP_IERROR_BAD_STREAM:
+               SCTP_INC_STATS(SCTP_MIB_IN_DATA_CHUNK_DISCARDS);
                goto discard_noforce;
        case SCTP_IERROR_DUP_TSN:
        case SCTP_IERROR_IGNORE_TSN:
+               SCTP_INC_STATS(SCTP_MIB_IN_DATA_CHUNK_DISCARDS);
                goto discard_force;
        case SCTP_IERROR_NO_DATA:
                goto consume;
@@ -3652,6 +3654,7 @@ sctp_disposition_t sctp_sf_pdiscard(const struct sctp_endpoint *ep,
                                    void *arg,
                                    sctp_cmd_seq_t *commands)
 {
+       SCTP_INC_STATS(SCTP_MIB_IN_PKT_DISCARDS);
        sctp_add_cmd_sf(commands, SCTP_CMD_DISCARD_PACKET, SCTP_NULL());
 
        return SCTP_DISPOSITION_CONSUME;
@@ -4548,6 +4551,8 @@ sctp_disposition_t sctp_sf_do_6_3_3_rtx(const struct sctp_endpoint *ep,
 {
        struct sctp_transport *transport = arg;
 
+       SCTP_INC_STATS(SCTP_MIB_T3_RTX_EXPIREDS);
+
        if (asoc->overall_error_count >= asoc->max_retrans) {
                sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
                                SCTP_ERROR(ETIMEDOUT));
@@ -4616,6 +4621,7 @@ sctp_disposition_t sctp_sf_do_6_2_sack(const struct sctp_endpoint *ep,
                                       void *arg,
                                       sctp_cmd_seq_t *commands)
 {
+       SCTP_INC_STATS(SCTP_MIB_DELAY_SACK_EXPIREDS);
        sctp_add_cmd_sf(commands, SCTP_CMD_GEN_SACK, SCTP_FORCE());
        return SCTP_DISPOSITION_CONSUME;
 }
@@ -4650,6 +4656,7 @@ sctp_disposition_t sctp_sf_t1_init_timer_expire(const struct sctp_endpoint *ep,
        int attempts = asoc->init_err_counter + 1;
 
        SCTP_DEBUG_PRINTK("Timer T1 expired (INIT).\n");
+       SCTP_INC_STATS(SCTP_MIB_T1_INIT_EXPIREDS);
 
        if (attempts <= asoc->max_init_attempts) {
                bp = (struct sctp_bind_addr *) &asoc->base.bind_addr;
@@ -4709,6 +4716,7 @@ sctp_disposition_t sctp_sf_t1_cookie_timer_expire(const struct sctp_endpoint *ep
        int attempts = asoc->init_err_counter + 1;
 
        SCTP_DEBUG_PRINTK("Timer T1 expired (COOKIE-ECHO).\n");
+       SCTP_INC_STATS(SCTP_MIB_T1_COOKIE_EXPIREDS);
 
        if (attempts <= asoc->max_init_attempts) {
                repl = sctp_make_cookie_echo(asoc, NULL);
@@ -4753,6 +4761,8 @@ sctp_disposition_t sctp_sf_t2_timer_expire(const struct sctp_endpoint *ep,
        struct sctp_chunk *reply = NULL;
 
        SCTP_DEBUG_PRINTK("Timer T2 expired.\n");
+       SCTP_INC_STATS(SCTP_MIB_T2_SHUTDOWN_EXPIREDS);
+
        if (asoc->overall_error_count >= asoc->max_retrans) {
                sctp_add_cmd_sf(commands, SCTP_CMD_SET_SK_ERR,
                                SCTP_ERROR(ETIMEDOUT));
@@ -4814,6 +4824,8 @@ sctp_disposition_t sctp_sf_t4_timer_expire(
        struct sctp_chunk *chunk = asoc->addip_last_asconf;
        struct sctp_transport *transport = chunk->transport;
 
+       SCTP_INC_STATS(SCTP_MIB_T4_RTO_EXPIREDS);
+
        /* ADDIP 4.1 B1) Increment the error counters and perform path failure
         * detection on the appropriate destination address as defined in
         * RFC2960 [5] section 8.1 and 8.2.
@@ -4880,6 +4892,7 @@ sctp_disposition_t sctp_sf_t5_timer_expire(const struct sctp_endpoint *ep,
        struct sctp_chunk *reply = NULL;
 
        SCTP_DEBUG_PRINTK("Timer T5 expired.\n");
+       SCTP_INC_STATS(SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS);
 
        reply = sctp_make_abort(asoc, NULL, 0);
        if (!reply)
@@ -4910,6 +4923,8 @@ sctp_disposition_t sctp_sf_autoclose_timer_expire(
 {
        int disposition;
 
+       SCTP_INC_STATS(SCTP_MIB_AUTOCLOSE_EXPIREDS);
+
        /* From 9.2 Shutdown of an Association
         * Upon receipt of the SHUTDOWN primitive from its upper
         * layer, the endpoint enters SHUTDOWN-PENDING state and