pespin submitted this change.

View Change

Approvals: Jenkins Builder: Verified osmith: Looks good to me, approved
xua_snm: Validate Affected PCs follow configured formatting

Avoid handling unexpected point codes being out of range regarding the
point code formatting configured at the SS/ instance.

In the case of DAUD, simply answer stating the unexpected PC is
unavailable.

Change-Id: I4cb19d11e0ca885dd6d717b5fb67be92bc01fd13
---
M include/osmocom/sigtran/osmo_ss7.h
M src/ss7_instance.c
M src/xua_snm.c
3 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h
index 074027f..594cbae 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -67,6 +67,7 @@
int osmo_ss7_find_free_rctx(struct osmo_ss7_instance *inst);

bool osmo_ss7_pc_is_local(const struct osmo_ss7_instance *inst, uint32_t pc);
+bool osmo_ss7_pointcode_is_valid(const struct osmo_ss7_instance *inst, uint32_t pc);
int osmo_ss7_pointcode_parse(const struct osmo_ss7_instance *inst, const char *str);
int osmo_ss7_pointcode_parse_mask_or_len(const struct osmo_ss7_instance *inst, const char *in);
const char *osmo_ss7_pointcode_print_buf(char *buf, size_t buf_len, const struct osmo_ss7_instance *inst, uint32_t pc);
diff --git a/src/ss7_instance.c b/src/ss7_instance.c
index b349974..61b0a2c 100644
--- a/src/ss7_instance.c
+++ b/src/ss7_instance.c
@@ -240,6 +240,16 @@
return false;
}

+/*! Whether the PC is valid according to SS7 instance point code format configuration
+ * \param[in] inst SS7 Instance on which we operate
+ * \param[in] pc Point Code to validate
+ * \returns true if valid, false if not valid (out of range)
+ */
+bool osmo_ss7_pointcode_is_valid(const struct osmo_ss7_instance *inst, uint32_t pc)
+{
+ return !(pc & ~ss7_pc_full_mask(&inst->cfg.pc_fmt));
+}
+
/* Next RCTX, skipping special value "0" meaning no context. */
static inline uint32_t rctx_inc(uint32_t rctx)
{
diff --git a/src/xua_snm.c b/src/xua_snm.c
index 6befecc..3aa067e 100644
--- a/src/xua_snm.c
+++ b/src/xua_snm.c
@@ -161,6 +161,13 @@
uint32_t pc = _aff_pc & 0xffffff;
uint8_t mask = mask_from_affected_pc(s7i, _aff_pc);

+ if (!osmo_ss7_pointcode_is_valid(s7i, pc)) {
+ LOGSS7(s7i, LOGL_ERROR,
+ "Ignoring unexpected invalid Affected Point Code pc=%u=%s/%u\n",
+ pc, osmo_ss7_pointcode_print(s7i, pc), _aff_pc >> 24);
+ continue;
+ }
+
if (!mask) {
if (available)
mtp_resume_ind_up_to_all_users(s7i, pc);
@@ -224,6 +231,13 @@
uint32_t pc = _aff_pc & 0xffffff;
uint8_t mask = mask_from_affected_pc(s7i, _aff_pc);

+ if (!osmo_ss7_pointcode_is_valid(s7i, pc)) {
+ LOGPAS(as, DLSS7, LOGL_ERROR,
+ "Ignoring unexpected invalid Affected Point Code pc=%u=%s/%u\n",
+ pc, osmo_ss7_pointcode_print(s7i, pc), _aff_pc >> 24);
+ continue;
+ }
+
if (!mask) {
xua_snm_srm_pc_available_single(as, pc, available);
} else {
@@ -368,6 +382,13 @@
uint32_t pc = _aff_pc & 0xffffff;
uint8_t mask = mask_from_affected_pc(s7i, _aff_pc);

+ if (!osmo_ss7_pointcode_is_valid(s7i, pc)) {
+ LOGSS7(s7i, LOGL_ERROR,
+ "Ignoring unexpected invalid Affected Point Code pc=%u=%s/%u\n",
+ pc, osmo_ss7_pointcode_print(s7i, pc), _aff_pc >> 24);
+ continue;
+ }
+
if (!mask) {
mtp_status_ind_up_to_all_users(s7i, pc, MTP_UNAVAIL_C_CONGESTED,
cong_level_present, cong_level);
@@ -450,6 +471,15 @@
uint8_t mask = mask_from_affected_pc(s7i, _aff_pc);
bool is_available;

+ if (!osmo_ss7_pointcode_is_valid(s7i, pc)) {
+ LOGPASP(asp, DLSS7, LOGL_ERROR,
+ "Rejecting unexpected invalid Affected Point Code pc=%u=%s/%u\n",
+ pc, osmo_ss7_pointcode_print(s7i, pc), _aff_pc >> 24);
+ xua_tx_snm_available(asp, rctx, num_rctx, &aff_pc[i], 1, "Response to DAUD",
+ false);
+ continue;
+ }
+
if (mask == 0) {
/* one single point code */
/* Check if there's an "active" route available: */

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

Gerrit-MessageType: merged
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I4cb19d11e0ca885dd6d717b5fb67be92bc01fd13
Gerrit-Change-Number: 43419
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>