pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/40573?usp=email )
Change subject: xua_rkm: Improve handling of newly_assigned_as array
......................................................................
xua_rkm: Improve handling of newly_assigned_as array
* Make sure we don't end up with duplicated AS in the array, to avoid
signalling the same event multiple times.
* Once finished filling the array, no need to iterate the full allocated
array, but only the amount of elements filled in.
Change-Id: I4fbac8ff61541c6804e2f01a9c965ec630d59080
---
M src/xua_rkm.c
1 file changed, 29 insertions(+), 19 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/73/40573/1
diff --git a/src/xua_rkm.c b/src/xua_rkm.c
index d4d1aa3..1009d18 100644
--- a/src/xua_rkm.c
+++ b/src/xua_rkm.c
@@ -151,6 +151,19 @@
* RKM REG request */
#define MAX_NEW_AS 16
+/* Lookup "as" pointer in array "newly_assigned_as" with "num_newly_assigned_as" elements. */
+static bool newly_assigned_as_in_array(struct osmo_ss7_as * const *newly_assigned_as,
+ unsigned int num_newly_assigned_as,
+ const struct osmo_ss7_as *as)
+{
+ unsigned int i;
+ for (i = 0; i < num_newly_assigned_as; i++) {
+ if (as == newly_assigned_as[i])
+ return true;
+ }
+ return false;
+}
+
/* SG: handle a single registration request IE (nested IEs in 'innner' */
static int handle_rkey_reg(struct osmo_ss7_asp *asp, struct xua_msg *inner,
struct msgb *resp, struct osmo_ss7_as **newly_assigned_as,
@@ -161,6 +174,7 @@
struct osmo_ss7_as *as;
struct osmo_ss7_route *rt;
char namebuf[32];
+ bool as_already_in_array;
/* mandatory local routing key ID */
rk_id = xua_msg_get_u32(inner, M3UA_IEI_LOC_RKEY_ID);
@@ -228,15 +242,18 @@
return -1;
}
+ /* Early return before allocating stuff if no space left.
+ * If AS didn't exist before, it can't be already in the array:*/
+ as_already_in_array = as && newly_assigned_as_in_array(newly_assigned_as, *nas_idx, as);
+ if (!as_already_in_array && *nas_idx >= max_nas_idx) {
+ LOGPASP(asp, DLSS7, LOGL_ERROR, "RKM: not enough room for newly assigned AS (max %u AS)\n",
+ max_nas_idx+1);
+ msgb_append_reg_res(resp, rk_id, M3UA_RKM_REG_ERR_INSUFF_RESRC, 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: */
- if (*nas_idx >= max_nas_idx) {
- LOGPASP(asp, DLSS7, LOGL_ERROR, "RKM: not enough room for newly assigned AS (max %u AS)\n",
- max_nas_idx+1);
- msgb_append_reg_res(resp, rk_id, M3UA_RKM_REG_ERR_INSUFF_RESRC, 0);
- return -1;
- }
if (as->cfg.routing_key.pc != dpc) {
LOGPASP(asp, DLSS7, LOGL_ERROR, "RKM: DPC doesn't match, rejecting AS (%u != %u)\n",
@@ -261,14 +278,6 @@
as->cfg.mode_set_by_peer = true;
}
} 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",
- max_nas_idx+1);
- msgb_append_reg_res(resp, rk_id, M3UA_RKM_REG_ERR_INSUFF_RESRC, 0);
- return -1;
- }
-
/* Create an AS for this routing key */
snprintf(namebuf, sizeof(namebuf), "as-rkm-%u", rctx);
as = osmo_ss7_as_find_or_create(asp->inst, namebuf, OSMO_SS7_ASP_PROT_M3UA);
@@ -303,7 +312,8 @@
ss7_as_add_asp(as, asp);
msgb_append_reg_res(resp, rk_id, M3UA_RKM_REG_SUCCESS, rctx);
/* append to list of newly assigned as */
- newly_assigned_as[(*nas_idx)++] = as;
+ if (!as_already_in_array)
+ newly_assigned_as[(*nas_idx)++] = as;
return 0;
}
@@ -313,7 +323,7 @@
struct xua_msg_part *part;
struct msgb *resp = m3ua_msgb_alloc(__func__);
struct osmo_ss7_as *newly_assigned_as[MAX_NEW_AS];
- unsigned int i, nas_idx = 0;
+ unsigned int i, num_newly_assigned_as = 0;
memset(newly_assigned_as, 0, sizeof(newly_assigned_as));
@@ -333,7 +343,7 @@
/* handle single registration and append result to
* 'resp' */
handle_rkey_reg(asp, inner, resp, newly_assigned_as,
- ARRAY_SIZE(newly_assigned_as), &nas_idx);
+ ARRAY_SIZE(newly_assigned_as), &num_newly_assigned_as);
xua_msg_free(inner);
}
@@ -344,7 +354,7 @@
/* and *after* the RKM REG Response inform the newly assigned
* ASs about the fact that there's an INACTIVE ASP for them,
* which will cause them to send NOTIFY to the client */
- for (i = 0; i < ARRAY_SIZE(newly_assigned_as); i++) {
+ for (i = 0; i < num_newly_assigned_as; i++) {
struct osmo_ss7_as *as = newly_assigned_as[i];
if (!as)
continue;
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/40573?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: I4fbac8ff61541c6804e2f01a9c965ec630d59080
Gerrit-Change-Number: 40573
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/40574?usp=email )
Change subject: xua_rkm: Reply RKM RKEY REG with err insufficient resources
......................................................................
xua_rkm: Reply RKM RKEY REG with err insufficient resources
If a user tries to add more than 16 ASPs to an AS, it will fail
internally. In that scenario, inform the peer.
Change-Id: I352dbc0a1319348b127e173599a1d967ef7bcb26
---
M src/xua_rkm.c
1 file changed, 5 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/74/40574/1
diff --git a/src/xua_rkm.c b/src/xua_rkm.c
index 1009d18..19cd6a1 100644
--- a/src/xua_rkm.c
+++ b/src/xua_rkm.c
@@ -309,7 +309,11 @@
}
/* Success: Add just-create AS to connected ASP + report success */
- ss7_as_add_asp(as, asp);
+ if (ss7_as_add_asp(as, asp) < 0) {
+ msgb_append_reg_res(resp, rk_id, M3UA_RKM_REG_ERR_INSUFF_RESRC, 0);
+ return -1;
+ }
+
msgb_append_reg_res(resp, rk_id, M3UA_RKM_REG_SUCCESS, rctx);
/* append to list of newly assigned as */
if (!as_already_in_array)
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/40574?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: I352dbc0a1319348b127e173599a1d967ef7bcb26
Gerrit-Change-Number: 40574
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40568?usp=email )
Change subject: remsim: bankd: add TC for creating a mapping with a busy client
......................................................................
remsim: bankd: add TC for creating a mapping with a busy client
Test if a busy client is implicit removed when creating a new mapping
for the same client with a different bankd slot.
After a desynchronisation between the server and bankd happen (e.g. restart the server),
the server might request a mapping between a client slot and a bankd slot
while the bankd still has a different mapping for the same client slot.
Example before this commit:
* server -> bankd: New Mapping (client 1/0, bankd 1/0)
* server <- bankd: Ack
* Restart server
* server -> bankd: New Mapping (client 1/0, bankd 2/0)
* server <- bankd: Ack (implicit remove mapping to bankd 1/0)
Related: SYS#7470
Change-Id: I57112758167c2a29fae9df0cf1e2691c5a8e7bed
---
M remsim/RemsimBankd_Tests.ttcn
1 file changed, 16 insertions(+), 0 deletions(-)
Approvals:
pespin: Looks good to me, but someone else must approve
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/remsim/RemsimBankd_Tests.ttcn b/remsim/RemsimBankd_Tests.ttcn
index a2686d3..637cb0f 100644
--- a/remsim/RemsimBankd_Tests.ttcn
+++ b/remsim/RemsimBankd_Tests.ttcn
@@ -118,6 +118,21 @@
Misc_Helpers.f_shutdown(__BFILE__, __LINE__, pass);
}
+/* attempt to create a mapping for a client that already has a mapping to a different slot */
+testcase TC_createMapping_busyClient() runs on bankd_test_CT {
+ f_init();
+ as_connectBankReq(bid := mp_bank_id, nslots := mp_num_slots);
+ f_rspro_srv_reset_state(ok);
+ var BankSlot bs0 := { bankId := mp_bank_id, slotNr := 0 };
+ var BankSlot bs1 := { bankId := mp_bank_id, slotNr := 1 };
+ var ClientSlot cs := { clientId := 23, slotNr := 42 };
+ /* create the mapping the first time */
+ f_rspro_srv_create_slotmap(cs, bs0);
+ /* re-create the mapping a second time */
+ f_rspro_srv_create_slotmap(cs, bs1);
+ Misc_Helpers.f_shutdown(__BFILE__, __LINE__, pass);
+}
+
/* attempt to create a mapping for an out-of-range slot number */
testcase TC_createMapping_invalidSlot() runs on bankd_test_CT {
f_init();
@@ -415,6 +430,7 @@
execute( TC_createMapping() );
execute( TC_createMapping_busySlot() );
+ execute( TC_createMapping_busyClient() );
execute( TC_createMapping_invalidSlot() );
execute( TC_createMapping_invalidBank() );
--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40568?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I57112758167c2a29fae9df0cf1e2691c5a8e7bed
Gerrit-Change-Number: 40568
Gerrit-PatchSet: 2
Gerrit-Owner: lynxis lazus <lynxis(a)fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>