Browse code

sctp: new module for SCTP transport

- moved the sctp specific code from core to a module to make it easy to
enable/disable sctp by loading/not loading the module instead of
recompiling

Daniel-Constantin Mierla authored on 25/05/2013 07:33:39
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,123 +0,0 @@
1
-/* 
2
- * $Id$
3
- * 
4
- * Copyright (C) 2010 iptelorg GmbH
5
- *
6
- * Permission to use, copy, modify, and distribute this software for any
7
- * purpose with or without fee is hereby granted, provided that the above
8
- * copyright notice and this permission notice appear in all copies.
9
- *
10
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
- */
18
-/** sctp statistics.
19
- * @file sctp_stats.c
20
- * @ingroup:  core (sctp)
21
- */
22
-/*
23
- * History:
24
- * --------
25
- *  2010-08-09  initial version (andrei)
26
-*/
27
-
28
-#ifdef USE_SCTP
29
-
30
-#include "sctp_stats.h"
31
-
32
-#ifdef USE_SCTP_STATS
33
-
34
-#include "counters.h"
35
-#include "sctp_server.h"
36
-
37
-struct sctp_counters_h sctp_cnts_h;
38
-
39
-
40
-enum sctp_info_req { SCTP_INFO_NONE, SCTP_INFO_CONN_NO, SCTP_INFO_TRACKED_NO };
41
-static counter_val_t sctp_info(counter_handle_t h, void* what);
42
-
43
-
44
-
45
-/* sctp counters definitions */
46
-counter_def_t sctp_cnt_defs[] =  {
47
-	{&sctp_cnts_h.established, "established", 0, 0, 0,
48
-		"incremented each time a new association is established."},
49
-	{&sctp_cnts_h.connect_failed, "connect_failed", 0, 0, 0,
50
-		"incremented each time a new outgoing connection fails."},
51
-	{&sctp_cnts_h.local_reject, "local_reject", 0, 0, 0,
52
-		"number of rejected incoming connections."},
53
-	{&sctp_cnts_h.remote_shutdown, "remote_shutdown", 0, 0, 0,
54
-		"incremented each time an association is closed by the peer."},
55
-	{&sctp_cnts_h.assoc_shutdown, "assoc_shutdown", 0, 0, 0,
56
-		"incremented each time an association is shutdown."},
57
-	{&sctp_cnts_h.comm_lost, "comm_lost", 0, 0, 0,
58
-		"incremented each time an established connection is close due to"
59
-			"some error."},
60
-	{&sctp_cnts_h.sendq_full, "sendq_full", 0, 0, 0,
61
-		"number of failed send attempt due to exceeded buffering capacity"
62
-	    " (full kernel buffers)."},
63
-	{&sctp_cnts_h.send_failed, "send_failed", 0, 0, 0,
64
-		"number of failed send attempt for any reason except full buffers."},
65
-	{&sctp_cnts_h.send_force_retry, "send_force_retry", 0, 0, 0,
66
-		"incremented each time a failed send is force-retried"
67
-			"(possible only if sctp_send_retries ! = 0"},
68
-	{0, "current_opened_connections", 0,
69
-		sctp_info, (void*)(long)SCTP_INFO_CONN_NO,
70
-		"number of currently opened associations."},
71
-	{0, "current_tracked_connections", 0,
72
-		sctp_info, (void*)(long)SCTP_INFO_TRACKED_NO,
73
-		"number of currently tracked associations."},
74
-	{0, 0, 0, 0, 0, 0 }
75
-};
76
-
77
-
78
-
79
-/** helper function for some stats (which are kept internally inside sctp).
80
- */
81
-static counter_val_t sctp_info(counter_handle_t h, void* what)
82
-{
83
-	enum sctp_info_req w;
84
-	struct sctp_gen_info i;
85
-
86
-	if (sctp_disable)
87
-		return 0;
88
-	w = (int)(long)what;
89
-	sctp_get_info(&i);
90
-	switch(w) {
91
-		case SCTP_INFO_CONN_NO:
92
-			return i.sctp_connections_no;
93
-		case SCTP_INFO_TRACKED_NO:
94
-			return i.sctp_tracked_no;
95
-		case SCTP_INFO_NONE:
96
-			break;
97
-	};
98
-	return 0;
99
-}
100
-
101
-/** intialize sctp statistics.
102
- *  Must be called before forking.
103
- * @return < 0 on errror, 0 on success.
104
- */
105
-int sctp_stats_init()
106
-{
107
-	if (counter_register_array("sctp", sctp_cnt_defs) < 0)
108
-		goto error;
109
-	return 0;
110
-error:
111
-	return -1;
112
-}
113
-
114
-
115
-void sctp_stats_destroy()
116
-{
117
-	/* do nothing */
118
-}
119
-
120
-#endif /* USE_SCTP_STATS */
121
-#endif /* USE_SCTP */
122
-
123
-/* vi: set ts=4 sw=4 tw=79:ai:cindent: */
Browse code

sctp: switched to counter arrays + more stats

- use counters arrays
- added counters descriptions
- don't attempt to compile if sctp support or sctp stats support
are disabled
- more stats: current_opened_connections and
current_tracked_connections.

Andrei Pelinescu-Onciul authored on 09/08/2010 15:04:41
Showing 1 changed files
... ...
@@ -25,29 +25,87 @@
25 25
  *  2010-08-09  initial version (andrei)
26 26
 */
27 27
 
28
+#ifdef USE_SCTP
29
+
28 30
 #include "sctp_stats.h"
31
+
32
+#ifdef USE_SCTP_STATS
33
+
29 34
 #include "counters.h"
35
+#include "sctp_server.h"
30 36
 
31 37
 struct sctp_counters_h sctp_cnts_h;
32 38
 
39
+
40
+enum sctp_info_req { SCTP_INFO_NONE, SCTP_INFO_CONN_NO, SCTP_INFO_TRACKED_NO };
41
+static counter_val_t sctp_info(counter_handle_t h, void* what);
42
+
43
+
44
+
45
+/* sctp counters definitions */
46
+counter_def_t sctp_cnt_defs[] =  {
47
+	{&sctp_cnts_h.established, "established", 0, 0, 0,
48
+		"incremented each time a new association is established."},
49
+	{&sctp_cnts_h.connect_failed, "connect_failed", 0, 0, 0,
50
+		"incremented each time a new outgoing connection fails."},
51
+	{&sctp_cnts_h.local_reject, "local_reject", 0, 0, 0,
52
+		"number of rejected incoming connections."},
53
+	{&sctp_cnts_h.remote_shutdown, "remote_shutdown", 0, 0, 0,
54
+		"incremented each time an association is closed by the peer."},
55
+	{&sctp_cnts_h.assoc_shutdown, "assoc_shutdown", 0, 0, 0,
56
+		"incremented each time an association is shutdown."},
57
+	{&sctp_cnts_h.comm_lost, "comm_lost", 0, 0, 0,
58
+		"incremented each time an established connection is close due to"
59
+			"some error."},
60
+	{&sctp_cnts_h.sendq_full, "sendq_full", 0, 0, 0,
61
+		"number of failed send attempt due to exceeded buffering capacity"
62
+	    " (full kernel buffers)."},
63
+	{&sctp_cnts_h.send_failed, "send_failed", 0, 0, 0,
64
+		"number of failed send attempt for any reason except full buffers."},
65
+	{&sctp_cnts_h.send_force_retry, "send_force_retry", 0, 0, 0,
66
+		"incremented each time a failed send is force-retried"
67
+			"(possible only if sctp_send_retries ! = 0"},
68
+	{0, "current_opened_connections", 0,
69
+		sctp_info, (void*)(long)SCTP_INFO_CONN_NO,
70
+		"number of currently opened associations."},
71
+	{0, "current_tracked_connections", 0,
72
+		sctp_info, (void*)(long)SCTP_INFO_TRACKED_NO,
73
+		"number of currently tracked associations."},
74
+	{0, 0, 0, 0, 0, 0 }
75
+};
76
+
77
+
78
+
79
+/** helper function for some stats (which are kept internally inside sctp).
80
+ */
81
+static counter_val_t sctp_info(counter_handle_t h, void* what)
82
+{
83
+	enum sctp_info_req w;
84
+	struct sctp_gen_info i;
85
+
86
+	if (sctp_disable)
87
+		return 0;
88
+	w = (int)(long)what;
89
+	sctp_get_info(&i);
90
+	switch(w) {
91
+		case SCTP_INFO_CONN_NO:
92
+			return i.sctp_connections_no;
93
+		case SCTP_INFO_TRACKED_NO:
94
+			return i.sctp_tracked_no;
95
+		case SCTP_INFO_NONE:
96
+			break;
97
+	};
98
+	return 0;
99
+}
100
+
33 101
 /** intialize sctp statistics.
34 102
  *  Must be called before forking.
35 103
  * @return < 0 on errror, 0 on success.
36 104
  */
37 105
 int sctp_stats_init()
38 106
 {
39
-#define SCTP_REG_COUNTER(name) \
40
-	if (counter_register(&sctp_cnts_h.name, "sctp", # name, 0, 0, 0, 0) < 0) \
107
+	if (counter_register_array("sctp", sctp_cnt_defs) < 0)
41 108
 		goto error;
42
-
43
-	SCTP_REG_COUNTER(established);
44
-	SCTP_REG_COUNTER(connect_failed);
45
-	SCTP_REG_COUNTER(local_reject);
46
-	SCTP_REG_COUNTER(remote_shutdown);
47
-	SCTP_REG_COUNTER(assoc_shutdown);
48
-	SCTP_REG_COUNTER(comm_lost);
49
-	SCTP_REG_COUNTER(sendq_full);
50
-	SCTP_REG_COUNTER(send_force_retry);
51 109
 	return 0;
52 110
 error:
53 111
 	return -1;
... ...
@@ -59,4 +117,7 @@ void sctp_stats_destroy()
59 117
 	/* do nothing */
60 118
 }
61 119
 
120
+#endif /* USE_SCTP_STATS */
121
+#endif /* USE_SCTP */
122
+
62 123
 /* vi: set ts=4 sw=4 tw=79:ai:cindent: */
Browse code

sctp: enable statistics

sctp statistics implemented using the counters api.
Enabled by default (unless compiles with -DNO_SCTP_STATS).
E.g.:
$ sercmd cnt.grp_get_all sctp
{
assoc_shutdown: 1
comm_lost: 0
connect_failed: 1
established: 1
local_reject: 0
remote_shutdown: 1
send_force_retry: 0
sendq_full: 0
}

Andrei Pelinescu-Onciul authored on 08/08/2010 22:35:04
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,62 @@
1
+/* 
2
+ * $Id$
3
+ * 
4
+ * Copyright (C) 2010 iptelorg GmbH
5
+ *
6
+ * Permission to use, copy, modify, and distribute this software for any
7
+ * purpose with or without fee is hereby granted, provided that the above
8
+ * copyright notice and this permission notice appear in all copies.
9
+ *
10
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
+ */
18
+/** sctp statistics.
19
+ * @file sctp_stats.c
20
+ * @ingroup:  core (sctp)
21
+ */
22
+/*
23
+ * History:
24
+ * --------
25
+ *  2010-08-09  initial version (andrei)
26
+*/
27
+
28
+#include "sctp_stats.h"
29
+#include "counters.h"
30
+
31
+struct sctp_counters_h sctp_cnts_h;
32
+
33
+/** intialize sctp statistics.
34
+ *  Must be called before forking.
35
+ * @return < 0 on errror, 0 on success.
36
+ */
37
+int sctp_stats_init()
38
+{
39
+#define SCTP_REG_COUNTER(name) \
40
+	if (counter_register(&sctp_cnts_h.name, "sctp", # name, 0, 0, 0, 0) < 0) \
41
+		goto error;
42
+
43
+	SCTP_REG_COUNTER(established);
44
+	SCTP_REG_COUNTER(connect_failed);
45
+	SCTP_REG_COUNTER(local_reject);
46
+	SCTP_REG_COUNTER(remote_shutdown);
47
+	SCTP_REG_COUNTER(assoc_shutdown);
48
+	SCTP_REG_COUNTER(comm_lost);
49
+	SCTP_REG_COUNTER(sendq_full);
50
+	SCTP_REG_COUNTER(send_force_retry);
51
+	return 0;
52
+error:
53
+	return -1;
54
+}
55
+
56
+
57
+void sctp_stats_destroy()
58
+{
59
+	/* do nothing */
60
+}
61
+
62
+/* vi: set ts=4 sw=4 tw=79:ai:cindent: */