[M] Change in libosmo-sigtran[master]: xua_rkm: Add function helpers to set routes for AS route-key
pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sigtran/+/43830?usp=email ) Change subject: xua_rkm: Add function helpers to set routes for AS route-key ...................................................................... xua_rkm: Add function helpers to set routes for AS route-key Those will be used in follow-up commit introducing automatic AS route-key full qualified routes for statically configured AS. Related: OS#7070 Change-Id: I1dd83ae2b0d23c92304476692ef6bd9c2417e454 --- M src/ss7_as.c M src/ss7_as.h M src/xua_rkm.c 3 files changed, 54 insertions(+), 12 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved diff --git a/src/ss7_as.c b/src/ss7_as.c index 7ad105a..605a646 100644 --- a/src/ss7_as.c +++ b/src/ss7_as.c @@ -741,3 +741,49 @@ return false; } + +/* Add a fully qualified route to routing table based on configured AS routing-key: */ +struct osmo_ss7_route *ss7_as_routing_key_create_route(struct osmo_ss7_as *as) +{ + struct osmo_ss7_route *rt; + int rc; + + rt = ss7_route_alloc(as->inst->rtable_system, + as->cfg.routing_key.pc, + 0xFFFFFF, + true); + if (!rt) + goto ret_free; + if (ss7_route_set_linkset(rt, as->cfg.name) < 0) + goto ret_free; + + rc = ss7_route_insert(rt); + if (rc == -EADDRINUSE) { + talloc_free(rt); + return ss7_route_table_find_route_by_dpc_mask(as->inst->rtable_system, + as->cfg.routing_key.pc, + 0xFFFFFF, + true); + } + + return rt; + +ret_free: + talloc_free(rt); + return NULL; +} + +/* Remove fully qualified route from routing table based on configured AS routing-key: */ +int ss7_as_routing_key_delete_route(struct osmo_ss7_as *as) +{ + struct osmo_ss7_route *rt; + rt = ss7_route_table_find_route_by_dpc_mask(as->inst->rtable_system, + as->cfg.routing_key.pc, 0xffffff, + true); + if (!rt) + return -ENOENT; + + /* Release the associated route */ + ss7_route_destroy(rt); + return 0; +} diff --git a/src/ss7_as.h b/src/ss7_as.h index 3d36102..329350b 100644 --- a/src/ss7_as.h +++ b/src/ss7_as.h @@ -200,6 +200,9 @@ const struct osmo_ss7_asp *excl_asp); void ss7_as_loadshare_binding_table_reset(struct osmo_ss7_as *as); +struct osmo_ss7_route *ss7_as_routing_key_create_route(struct osmo_ss7_as *as); +int ss7_as_routing_key_delete_route(struct osmo_ss7_as *as); + void ss7_as_del_asp_update_llist_round_robin(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp, struct ss7_as_asp_assoc **state); #define ss7_as_asp_assoc_llist_round_robin(as, state) \ ss7_llist_round_robin(&(as)->assoc_asp_list, (void **)state, struct ss7_as_asp_assoc, as_entry) diff --git a/src/xua_rkm.c b/src/xua_rkm.c index 61f9dc6..72581a6 100644 --- a/src/xua_rkm.c +++ b/src/xua_rkm.c @@ -330,7 +330,7 @@ as->cfg.routing_key.ssn = OSSMO_SS7_RKEY_SSN_UNSET; /* add dynamic route for that routing key */ - rt = ss7_route_create(as->inst->rtable_system, dpc, 0xFFFFFF, true, namebuf); + rt = ss7_as_routing_key_create_route(as); if (!rt) { LOGPASP(asp, DLSS7, LOGL_ERROR, "RKM: Cannot insert route for DPC %s / as %s\n", osmo_ss7_pointcode_print(asp->inst, dpc), namebuf); @@ -431,7 +431,6 @@ { struct osmo_ss7_instance *inst = asp->inst; struct osmo_ss7_as *as; - struct osmo_ss7_route *rt; as = ss7_asp_find_as_by_rctx(asp, rctx); if (!as) { @@ -451,19 +450,13 @@ return -1; } - rt = ss7_route_table_find_route_by_dpc_mask(inst->rtable_system, - as->cfg.routing_key.pc, 0xffffff, - true); - if (!rt) { - msgb_append_dereg_res(resp, M3UA_RKM_DEREG_ERR_UNKNOWN, 0); - return -1; - } - LOGPASP(asp, DLSS7, LOGL_INFO, "RKM: De-Registering rctx %u for DPC %s\n", rctx, osmo_ss7_pointcode_print(inst, as->cfg.routing_key.pc)); - /* Release the associated route */ - ss7_route_destroy(rt); + if (ss7_as_routing_key_delete_route(as) < 0) { + msgb_append_dereg_res(resp, M3UA_RKM_DEREG_ERR_UNKNOWN, 0); + return -1; + } /* Dissassociate the ASP from the dynamically allocated AS. * The AS may be freed if it is serving no more ASPs. */ ss7_as_del_asp(as, asp); -- To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/43830?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: I1dd83ae2b0d23c92304476692ef6bd9c2417e454 Gerrit-Change-Number: 43830 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <pespin@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> Gerrit-Reviewer: laforge <laforge@osmocom.org> Gerrit-Reviewer: pespin <pespin@sysmocom.de>
participants (1)
-
pespin