Change in libosmo-sccp[master]: stp: Add basic RX/TX rate counters on AS and ASP level

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Mon Nov 15 17:11:05 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/26234 )

Change subject: stp: Add basic RX/TX rate counters on AS and ASP level
......................................................................

stp: Add basic RX/TX rate counters on AS and ASP level

This adds some very basic rx/px rate counters to the SS7 AS and ASP

OsmoSTP> show rate-counters
SIGTRAN Application Server 0 (as-rkm-1):
             rx:msu:total:      86078 (1888/s 86078/m 0/h 0/d)
             tx:msu:total:          0 (0/s 0/m 0/h 0/d)
SIGTRAN Application Server Process 0 (asp-dyn-0):
         rx:packets:total:      86081 (1888/s 86081/m 0/h 0/d)
         tx:packets:total:          5 (0/s 5/m 0/h 0/d)

Change-Id: Idb811ca81adfe47152d484f6b981e661dc569e15
---
M include/osmocom/sigtran/osmo_ss7.h
M src/ipa.c
M src/m3ua.c
M src/osmo_ss7.c
M src/osmo_ss7_hmrt.c
M src/ss7_internal.h
M src/sua.c
M stp/stp_main.c
8 files changed, 83 insertions(+), 0 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h
index 3d13b6a..1755859 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -9,6 +9,7 @@
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/prim.h>
 #include <osmocom/core/socket.h>
+#include <osmocom/core/rate_ctr.h>
 
 extern struct llist_head osmo_ss7_instances;
 
@@ -310,6 +311,9 @@
 	/*! Were we allocated by "simple client" support? */
 	bool simple_client_allocated;
 
+	/*! Rate Counter Group */
+	struct rate_ctr_group *ctrg;
+
 	struct {
 		char *name;
 		char *description;
@@ -412,6 +416,9 @@
 	/*! Were we allocated by "simple client" support? */
 	bool simple_client_allocated;
 
+	/*! Rate Counter Group */
+	struct rate_ctr_group *ctrg;
+
 	/*! Pending message for non-blocking IPA read */
 	struct msgb *pending_msg;
 
diff --git a/src/ipa.c b/src/ipa.c
index 93edef8..5b1eb54 100644
--- a/src/ipa.c
+++ b/src/ipa.c
@@ -47,6 +47,7 @@
 #include <osmocom/sigtran/protocol/mtp.h>
 
 #include "xua_internal.h"
+#include "ss7_internal.h"
 #include "xua_asp_fsm.h"
 
 
@@ -224,6 +225,8 @@
 		return -1;
 	}
 
+	rate_ctr_inc2(as->ctrg, SS7_AS_CTR_RX_MSU_TOTAL);
+
 	/* pull the IPA header */
 	msgb_pull_to_l2(msg);
 
diff --git a/src/m3ua.c b/src/m3ua.c
index 607813f..26acc1b 100644
--- a/src/m3ua.c
+++ b/src/m3ua.c
@@ -44,6 +44,7 @@
 #include "xua_as_fsm.h"
 #include "xua_asp_fsm.h"
 #include "xua_internal.h"
+#include "ss7_internal.h"
 
 #define M3UA_MSGB_SIZE 1500
 
@@ -553,6 +554,8 @@
 	if (rc)
 		return rc;
 
+	rate_ctr_inc2(as->ctrg, SS7_AS_CTR_RX_MSU_TOTAL);
+
 	/* FIXME: check for AS state == ACTIVE */
 
 	/* store the MTP-level information in the xua_msg for use by
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index 38206fb..5dd4a26 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -48,6 +48,7 @@
 
 #include "sccp_internal.h"
 #include "xua_internal.h"
+#include "ss7_internal.h"
 #include "xua_asp_fsm.h"
 #include "xua_as_fsm.h"
 
@@ -895,6 +896,19 @@
  * SS7 Application Server
  ***********************************************************************/
 
+static const struct rate_ctr_desc ss7_as_rcd[] = {
+	[SS7_AS_CTR_RX_MSU_TOTAL] = { "rx.msu.total", "Total number of MSU received" },
+	[SS7_AS_CTR_TX_MSU_TOTAL] = { "tx.msu.total", "Total number of MSU transmitted" },
+};
+
+static const struct rate_ctr_group_desc ss7_as_rcgd = {
+	.group_name_prefix = "sigtran.as",
+	.group_description = "SIGTRAN Application Server",
+	.num_ctr = ARRAY_SIZE(ss7_as_rcd),
+	.ctr_desc = ss7_as_rcd,
+};
+static unsigned int g_ss7_as_rcg_idx;
+
 /*! \brief Find Application Server by given name
  *  \param[in] inst SS7 Instance on which we operate
  *  \param[in] name Name of AS
@@ -1002,6 +1016,12 @@
 		as = talloc_zero(inst, struct osmo_ss7_as);
 		if (!as)
 			return NULL;
+		as->ctrg = rate_ctr_group_alloc(as, &ss7_as_rcgd, g_ss7_as_rcg_idx++);
+		if (!as->ctrg) {
+			talloc_free(as);
+			return NULL;
+		}
+		rate_ctr_group_set_name(as->ctrg, name);
 		as->inst = inst;
 		as->cfg.name = talloc_strdup(as, name);
 		as->cfg.proto = proto;
@@ -1125,6 +1145,26 @@
  * SS7 Application Server Process
  ***********************************************************************/
 
+enum ss7_asp_ctr {
+	SS7_ASP_CTR_PKT_RX_TOTAL,
+	SS7_ASP_CTR_PKT_RX_UNKNOWN,
+	SS7_ASP_CTR_PKT_TX_TOTAL,
+};
+
+static const struct rate_ctr_desc ss7_asp_rcd[] = {
+	[SS7_ASP_CTR_PKT_RX_TOTAL] = { "rx.packets.total", "Total number of packets received" },
+	[SS7_ASP_CTR_PKT_RX_UNKNOWN] = { "rx.packets.unknown", "Number of packets received for unknown PPID" },
+	[SS7_ASP_CTR_PKT_TX_TOTAL] = { "tx.packets.total", "Total number of packets transmitted" },
+};
+
+static const struct rate_ctr_group_desc ss7_asp_rcgd = {
+	.group_name_prefix = "sigtran.asp",
+	.group_description = "SIGTRAN Application Server Process",
+	.num_ctr = ARRAY_SIZE(ss7_asp_rcd),
+	.ctr_desc = ss7_asp_rcd,
+};
+static unsigned int g_ss7_asp_rcg_idx;
+
 int osmo_ss7_asp_peer_snprintf(char* buf, size_t buf_len, struct osmo_ss7_asp_peer *peer)
 {
 	int len = 0, offset = 0, rem = buf_len;
@@ -1485,6 +1525,12 @@
 	if (!asp) {
 		/* FIXME: check if local port has SCTP? */
 		asp = talloc_zero(inst, struct osmo_ss7_asp);
+		asp->ctrg = rate_ctr_group_alloc(asp, &ss7_asp_rcgd, g_ss7_asp_rcg_idx++);
+		if (!asp->ctrg) {
+			talloc_free(asp);
+			return NULL;
+		}
+		rate_ctr_group_set_name(asp->ctrg, name);
 		asp->inst = inst;
 		asp->cfg.remote.port = remote_port;
 		asp->cfg.local.port = local_port;
@@ -1781,6 +1827,8 @@
 	msgb_sctp_stream(msg) = sinfo.sinfo_stream;
 	msg->dst = asp;
 
+	rate_ctr_inc2(asp->ctrg, SS7_ASP_CTR_PKT_RX_TOTAL);
+
 	if (ppid == SUA_PPID && asp->cfg.proto == OSMO_SS7_ASP_PROT_SUA)
 		rc = sua_rx_msg(asp, msg);
 	else if (ppid == M3UA_PPID && asp->cfg.proto == OSMO_SS7_ASP_PROT_M3UA)
@@ -1860,6 +1908,7 @@
 		return -1;
 	}
 	msg->dst = asp;
+	rate_ctr_inc2(asp->ctrg, SS7_ASP_CTR_PKT_RX_TOTAL);
 	return ipa_rx_msg(asp, msg);
 }
 
@@ -1918,6 +1967,8 @@
 	msgb_sctp_stream(msg) = sinfo.sinfo_stream;
 	msg->dst = asp;
 
+	rate_ctr_inc2(asp->ctrg, SS7_ASP_CTR_PKT_RX_TOTAL);
+
 	if (ppid == SUA_PPID && asp->cfg.proto == OSMO_SS7_ASP_PROT_SUA)
 		rc = sua_rx_msg(asp, msg);
 	else if (ppid == M3UA_PPID && asp->cfg.proto == OSMO_SS7_ASP_PROT_M3UA)
@@ -2086,6 +2137,8 @@
 		OSMO_ASSERT(0);
 	}
 
+	rate_ctr_inc2(asp->ctrg, SS7_ASP_CTR_PKT_TX_TOTAL);
+
 	if (asp->cfg.is_server) {
 		if (!asp->server) {
 			LOGPASP(asp, DLSS7, LOGL_ERROR, "Cannot transmit, no asp->server\n");
@@ -2361,6 +2414,8 @@
 
 int ss7_asp_rx_unknown(struct osmo_ss7_asp *asp, int ppid_mux, struct msgb *msg)
 {
+	rate_ctr_inc2(asp->ctrg, SS7_ASP_CTR_PKT_RX_UNKNOWN);
+
 	if (g_osmo_ss7_asp_rx_unknown_cb)
 		return (*g_osmo_ss7_asp_rx_unknown_cb)(asp, ppid_mux, msg);
 
diff --git a/src/osmo_ss7_hmrt.c b/src/osmo_ss7_hmrt.c
index 882d85d..f5fcd64 100644
--- a/src/osmo_ss7_hmrt.c
+++ b/src/osmo_ss7_hmrt.c
@@ -35,6 +35,7 @@
 #include <osmocom/sigtran/protocol/m3ua.h>
 
 #include "xua_internal.h"
+#include "ss7_internal.h"
 
 /* convert from M3UA message to MTP-TRANSFER.ind osmo_mtp_prim */
 struct osmo_mtp_prim *m3ua_to_xfer_ind(struct xua_msg *xua)
@@ -227,6 +228,8 @@
 				       dpc, osmo_ss7_pointcode_print(inst, dpc), rt_name);
 			}
 
+			rate_ctr_inc2(as->ctrg, SS7_AS_CTR_TX_MSU_TOTAL);
+
 			switch (as->cfg.proto) {
 			case OSMO_SS7_ASP_PROT_M3UA:
 				DEBUGP(DLSS7, "rt->dest.as proto is M3UA for dpc=%u=%s\n",
diff --git a/src/ss7_internal.h b/src/ss7_internal.h
index 28e239c..712a6ed 100644
--- a/src/ss7_internal.h
+++ b/src/ss7_internal.h
@@ -7,3 +7,8 @@
 
 bool osmo_ss7_asp_set_default_peer_hosts(struct osmo_ss7_asp *asp);
 bool osmo_ss7_xua_server_set_default_local_hosts(struct osmo_xua_server *oxs);
+
+enum ss7_as_ctr {
+	SS7_AS_CTR_RX_MSU_TOTAL,
+	SS7_AS_CTR_TX_MSU_TOTAL,
+};
diff --git a/src/sua.c b/src/sua.c
index 8415fa3..000f064 100644
--- a/src/sua.c
+++ b/src/sua.c
@@ -46,6 +46,7 @@
 #include "xua_asp_fsm.h"
 #include "xua_internal.h"
 #include "sccp_internal.h"
+#include "ss7_internal.h"
 
 /* Appendix C.4 of Q.714 (all in milliseconds) */
 #define CONNECTION_TIMER	( 1 * 60 * 100)
@@ -521,6 +522,8 @@
 	if (rc)
 		return rc;
 
+	rate_ctr_inc2(as->ctrg, SS7_AS_CTR_RX_MSU_TOTAL);
+
 	switch (xua->hdr.msg_type) {
 	case 0: /* Reserved, permitted by ETSI TS 101 592 5.2.3.2 */
 	case SUA_CL_CLDT:
@@ -549,6 +552,8 @@
 	if (rc)
 		return rc;
 
+	rate_ctr_inc2(as->ctrg, SS7_AS_CTR_RX_MSU_TOTAL);
+
 	switch (xua->hdr.msg_type) {
 	case 0: /* Reserved, permitted by ETSI TS 101 592 5.2.3.2 */
 	case SUA_CO_CORE:
diff --git a/stp/stp_main.c b/stp/stp_main.c
index 1e83615..569cf8e 100644
--- a/stp/stp_main.c
+++ b/stp/stp_main.c
@@ -32,6 +32,7 @@
 #include <osmocom/core/utils.h>
 #include <osmocom/core/logging.h>
 #include <osmocom/core/application.h>
+#include <osmocom/core/rate_ctr.h>
 #include <osmocom/core/fsm.h>
 #include <osmocom/vty/vty.h>
 #include <osmocom/vty/stats.h>
@@ -254,6 +255,7 @@
 	signal(SIGUSR1, &signal_handler);
 	signal(SIGUSR2, &signal_handler);
 	osmo_init_ignore_signals();
+	rate_ctr_init(tall_stp_ctx);
 
 	if (cmdline_config.daemonize) {
 		rc = osmo_daemonize();

-- 
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/26234
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: Idb811ca81adfe47152d484f6b981e661dc569e15
Gerrit-Change-Number: 26234
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-CC: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211115/f9838180/attachment.htm>


More information about the gerrit-log mailing list