pespin has uploaded this change for review.

View Change

stream: Improve logging of SCTP_PEER_ADDR_CHANGE notification

Related: SYS#6113
Change-Id: Ieebc6e623874b4770ec7cd8b934244ffecaa089d
---
M include/osmocom/netif/sctp.h
M src/sctp.c
M src/stream.c
3 files changed, 45 insertions(+), 1 deletion(-)

git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/69/29769/1
diff --git a/include/osmocom/netif/sctp.h b/include/osmocom/netif/sctp.h
index 2b2e072..0b64824 100644
--- a/include/osmocom/netif/sctp.h
+++ b/include/osmocom/netif/sctp.h
@@ -7,7 +7,17 @@
static inline const char *osmo_sctp_assoc_chg_str(enum sctp_sac_state val)
{ return get_value_string(osmo_sctp_assoc_chg_strs, val); }

+enum sctp_spc_state;
+extern const struct value_string osmo_sctp_paddr_chg_strs[];
+static inline const char *osmo_sctp_paddr_chg_str(enum sctp_spc_state val)
+{ return get_value_string(osmo_sctp_paddr_chg_strs, val); }
+
enum sctp_sn_type;
extern const struct value_string osmo_sctp_sn_type_strs[];
static inline const char *osmo_sctp_sn_type_str(enum sctp_sn_type val)
{ return get_value_string(osmo_sctp_sn_type_strs, val); }
+
+enum sctp_sn_error;
+extern const struct value_string osmo_sctp_sn_error_strs[];
+static inline const char *osmo_sctp_sn_error_str(enum sctp_sn_error val)
+{ return get_value_string(osmo_sctp_sn_error_strs, val); }
diff --git a/src/sctp.c b/src/sctp.c
index c24e0f7..5441fe1 100644
--- a/src/sctp.c
+++ b/src/sctp.c
@@ -10,6 +10,17 @@
{ 0, NULL }
};

+const struct value_string osmo_sctp_paddr_chg_strs[] = {
+ { SCTP_ADDR_AVAILABLE, "ADDR_AVAILABLE" },
+ { SCTP_ADDR_UNREACHABLE, "ADDR_UNREACHABLE" },
+ { SCTP_ADDR_REMOVED, "ADDR_REMOVED" },
+ { SCTP_ADDR_ADDED, "ADDR_ADDED" },
+ { SCTP_ADDR_MADE_PRIM, "ADDR_MADE_PRIM" },
+ { SCTP_ADDR_CONFIRMED, "ADDR_CONFIRMED" },
+ { SCTP_ADDR_POTENTIALLY_FAILED, "ADDR_POTENTIALLY_FAILED" },
+ { 0, NULL }
+};
+
const struct value_string osmo_sctp_sn_type_strs[] = {
{ SCTP_ASSOC_CHANGE, "ASSOC_CHANGE" },
{ SCTP_PEER_ADDR_CHANGE, "PEER_ADDR_CHANGE" },
@@ -26,3 +37,15 @@
#endif
{ 0, NULL }
};
+
+
+const struct value_string osmo_sctp_sn_error_strs[] = {
+ { SCTP_FAILED_THRESHOLD, "FAILED_THRESHOLD" },
+ { SCTP_RECEIVED_SACK, "RECEIVED_SACK" },
+ { SCTP_HEARTBEAT_SUCCESS, "HEARTBEAT_SUCCESS" },
+ { SCTP_RESPONSE_TO_USER_REQ, "RESPONSE_TO_USER_REQ" },
+ { SCTP_INTERNAL_ERROR, "INTERNAL_ERROR" },
+ { SCTP_SHUTDOWN_GUARD_EXPIRES, "SHUTDOWN_GUARD_EXPIRES" },
+ { SCTP_PEER_FAULTY, "PEER_FAULTY" },
+ { 0, NULL }
+};
\ No newline at end of file
diff --git a/src/stream.c b/src/stream.c
index 7b41ce1..12e32eb 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -49,6 +49,8 @@
#include <netinet/sctp.h>
#endif

+#include <osmocom/netif/sctp.h>
+
#define LOGSCLI(cli, level, fmt, args...) \
LOGP(DLINP, level, "[%s] %s(): " fmt, get_value_string(stream_cli_state_names, (cli)->state), __func__, ## args)

@@ -1508,7 +1510,16 @@
LOGP(DLINP, LOGL_DEBUG, "===> SEND FAILED\n");
break;
case SCTP_PEER_ADDR_CHANGE:
- LOGP(DLINP, LOGL_DEBUG, "===> PEER ADDR CHANGE\n");
+ {
+ char addr_str[INET6_ADDRSTRLEN + 10];
+ struct sockaddr_storage sa = notif->sn_paddr_change.spc_aaddr;
+ osmo_sockaddr_to_str_buf(addr_str, sizeof(addr_str),
+ (const struct osmo_sockaddr *)&sa);
+ LOGP(DLINP, LOGL_DEBUG, "===> PEER ADDR CHANGE: %s %s err=%s\n",
+ addr_str, osmo_sctp_paddr_chg_str(notif->sn_paddr_change.spc_state),
+ (notif->sn_paddr_change.spc_state == SCTP_ADDR_UNREACHABLE) ?
+ osmo_sctp_sn_error_str(notif->sn_paddr_change.spc_error) : "None");
+ }
break;
case SCTP_SHUTDOWN_EVENT:
LOGP(DLINP, LOGL_DEBUG, "===> SHUTDOWN EVT\n");

To view, visit change 29769. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Ieebc6e623874b4770ec7cd8b934244ffecaa089d
Gerrit-Change-Number: 29769
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-MessageType: newchange