pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmo-sigtran/+/40572?usp=email )
Change subject: xua_rkm: Simplify handle_rkey_reg() with early return path
......................................................................
xua_rkm: Simplify handle_rkey_reg() with early return path
Change-Id: I6f848716e9239dc4a4f0b35297462dd3915502c2
---
M src/xua_rkm.c
1 file changed, 10 insertions(+), 7 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/72/40572/1
diff --git a/src/xua_rkm.c b/src/xua_rkm.c
index f03397c..d4d1aa3 100644
--- a/src/xua_rkm.c
+++ b/src/xua_rkm.c
@@ -219,6 +219,15 @@
/* check if there is already an AS for this routing key */
as = osmo_ss7_as_find_by_rctx(asp->inst, rctx);
+
+ if (!as && !asp->inst->cfg.permit_dyn_rkm_alloc) {
+ /* not permitted to create dynamic RKM entries */
+ LOGPASP(asp, DLSS7, LOGL_NOTICE, "RKM: RCTX %u not found in configuration, and
"
+ "dynamic RKM allocation not permitted; permission denied\n", rctx);
+ msgb_append_reg_res(resp, rk_id, M3UA_RKM_REG_ERR_PERM_DENIED, 0);
+ return -1;
+ }
+
if (as) {
LOGPASP(asp, DLSS7, LOGL_NOTICE, "RKM: Found existing AS for RCTX %u\n",
rctx);
/* Early return before allocating stuff if no space left: */
@@ -251,7 +260,7 @@
}
as->cfg.mode_set_by_peer = true;
}
- } else if (asp->inst->cfg.permit_dyn_rkm_alloc) {
+ } else {
/* Early return before allocating stuff if no space left: */
if (*nas_idx >= max_nas_idx) {
LOGPASP(asp, DLSS7, LOGL_ERROR, "RKM: not enough room for newly assigned AS (max
%u AS)\n",
@@ -288,12 +297,6 @@
msgb_append_reg_res(resp, rk_id, M3UA_RKM_REG_ERR_CANT_SUPP_UNQ_RT, 0);
return -1;
}
- } else {
- /* not permitted to create dynamic RKM entries */
- LOGPASP(asp, DLSS7, LOGL_NOTICE, "RKM: RCTX %u not found in configuration, and
"
- "dynamic RKM allocation not permitted; permission denied\n", rctx);
- msgb_append_reg_res(resp, rk_id, M3UA_RKM_REG_ERR_PERM_DENIED, 0);
- return -1;
}
/* Success: Add just-create AS to connected ASP + report success */
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sigtran/+/40572?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: I6f848716e9239dc4a4f0b35297462dd3915502c2
Gerrit-Change-Number: 40572
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>