Change in osmo-hnodeb[master]: iuh: Improve logging of SCTP notifications

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/.

pespin gerrit-no-reply at lists.osmocom.org
Tue Nov 23 13:21:21 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-hnodeb/+/26343 )


Change subject: iuh: Improve logging of SCTP notifications
......................................................................

iuh: Improve logging of SCTP notifications

Change-Id: I08842665effec6e70a3c7f6b93ea62c45549d69d
---
M TODO-RELEASE
M src/osmo-hnodeb/iuh.c
2 files changed, 50 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-hnodeb refs/changes/43/26343/1

diff --git a/TODO-RELEASE b/TODO-RELEASE
index d0852fc..9e75c9a 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -7,3 +7,4 @@
 # If any interfaces have been added since the last public release: c:r:a + 1.
 # If any interfaces have been removed or changed since the last public release: c:r:0.
 #library	what		description / commit summary line
+libosmo-netif >1.1.0            use of netif/sctp.h
diff --git a/src/osmo-hnodeb/iuh.c b/src/osmo-hnodeb/iuh.c
index 595181b..71d805d 100644
--- a/src/osmo-hnodeb/iuh.c
+++ b/src/osmo-hnodeb/iuh.c
@@ -31,12 +31,59 @@
 #include <osmocom/core/socket.h>
 #include <osmocom/core/talloc.h>
 #include <osmocom/netif/stream.h>
+#include <osmocom/netif/sctp.h>
 
 #include <osmocom/hnodeb/iuh.h>
 #include <osmocom/hnodeb/hnbap.h>
 #include <osmocom/hnodeb/rua.h>
 #include <osmocom/hnodeb/hnodeb.h>
 
+static int get_logevel_by_sn_type(int sn_type)
+{
+	switch (sn_type) {
+	case SCTP_ADAPTATION_INDICATION:
+	case SCTP_PEER_ADDR_CHANGE:
+#ifdef SCTP_AUTHENTICATION_INDICATION
+	case SCTP_AUTHENTICATION_INDICATION:
+#endif
+#ifdef SCTP_SENDER_DRY_EVENT
+	case SCTP_SENDER_DRY_EVENT:
+#endif
+		return LOGL_INFO;
+	case SCTP_ASSOC_CHANGE:
+		return LOGL_NOTICE;
+	case SCTP_SHUTDOWN_EVENT:
+	case SCTP_PARTIAL_DELIVERY_EVENT:
+		return LOGL_NOTICE;
+	case SCTP_SEND_FAILED:
+	case SCTP_REMOTE_ERROR:
+		return LOGL_ERROR;
+	default:
+		return LOGL_NOTICE;
+	}
+}
+
+static void log_sctp_notification(union sctp_notification *notif)
+{
+	int log_level;
+
+	LOGP(DIUH, LOGL_INFO, "Iuh SCTP NOTIFICATION %u flags=0x%0x\n",
+	     notif->sn_header.sn_type, notif->sn_header.sn_flags);
+
+	log_level = get_logevel_by_sn_type(notif->sn_header.sn_type);
+
+	switch (notif->sn_header.sn_type) {
+	case SCTP_ASSOC_CHANGE:
+		LOGP(DIUH, log_level, "Iuh SCTP_ASSOC_CHANGE: %s\n",
+		     osmo_sctp_assoc_chg_str(notif->sn_assoc_change.sac_state));
+		break;
+	default:
+		LOGP(DIUH, log_level, "Iuh %s\n",
+		     osmo_sctp_sn_type_str(notif->sn_header.sn_type));
+		break;
+	}
+}
+
 static int hnb_iuh_read_cb(struct osmo_stream_cli *conn)
 {
 	struct osmo_fd *fd = osmo_stream_cli_get_ofd(conn);
@@ -66,7 +113,8 @@
 	}
 
 	if (flags & MSG_NOTIFICATION) {
-		LOGP(DIUH, LOGL_DEBUG, "Ignoring SCTP notification\n");
+		union sctp_notification *notif = (union sctp_notification *) msgb_data(msg);
+		log_sctp_notification(notif);
 		rc = 0;
 		goto free_ret;
 	}

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-hnodeb/+/26343
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hnodeb
Gerrit-Branch: master
Gerrit-Change-Id: I08842665effec6e70a3c7f6b93ea62c45549d69d
Gerrit-Change-Number: 26343
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20211123/84f3dae2/attachment.htm>


More information about the gerrit-log mailing list