[M] Change in libosmo-sigtran[master]: xua_rkm: Add function helpers to set routes for AS route-key
pespin has uploaded this change for review. ( 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 M tests/vty/osmo_stp_route_prio.vty 4 files changed, 80 insertions(+), 23 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/30/43830/1 diff --git a/src/ss7_as.c b/src/ss7_as.c index 7ad105a..cae0d6d 100644 --- a/src/ss7_as.c +++ b/src/ss7_as.c @@ -741,3 +741,58 @@ return false; } + +/* Add a fully qualified route in 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; + + rt->cfg.match_as_routing_key = true; + + 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 in 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; + + if (!rt->cfg.match_as_routing_key) { + LOGPAS(as, DLSS7, LOGL_NOTICE, + "Skip removing route %s without match-routing-key field!\n", + osmo_ss7_route_name(rt, false)); + return 0; + } + + /* 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); diff --git a/tests/vty/osmo_stp_route_prio.vty b/tests/vty/osmo_stp_route_prio.vty index 54c9475..2422043 100644 --- a/tests/vty/osmo_stp_route_prio.vty +++ b/tests/vty/osmo_stp_route_prio.vty @@ -94,9 +94,12 @@ Destination C Q P Linkset Name Linkset Non-adj Route ---------------------- - - - ------------------- ------- ------- ------- -3.2.1/14 INACC 0 2 as3 UNAVAIL allowed UNAVAIL -3.2.1/14 INACC 0 5 as2 UNAVAIL allowed UNAVAIL -3.2.1/14 INACC 7 6 as1 UNAVAIL allowed UNAVAIL +3.2.1/14 INACC 0 2 as3 UNAVAIL allowed UNAVAIL +0.1.2/14 INACC 0 5 as1 UNAVAIL allowed UNAVAIL dyn match-routing-key +0.1.3/14 INACC 0 5 as2 UNAVAIL allowed UNAVAIL dyn match-routing-key +0.1.4/14 INACC 0 5 as3 UNAVAIL allowed UNAVAIL dyn match-routing-key +3.2.1/14 INACC 0 5 as2 UNAVAIL allowed UNAVAIL +3.2.1/14 INACC 7 6 as1 UNAVAIL allowed UNAVAIL OsmoSTP(config-cs7-rt)# ! NOW ADD MORE GENERIC ROUTES (SMALLER BITMASK LENGTH) OsmoSTP(config-cs7-rt)# update route 3.2.0 7.255.0 linkset as3 priority 3 @@ -124,14 +127,17 @@ Destination C Q P Linkset Name Linkset Non-adj Route ---------------------- - - - ------------------- ------- ------- ------- -3.2.1/14 INACC 0 2 as3 UNAVAIL allowed UNAVAIL -3.2.1/14 INACC 0 5 as2 UNAVAIL allowed UNAVAIL -3.2.1/14 INACC 7 6 as1 UNAVAIL allowed UNAVAIL -3.2.0/11 INACC 0 1 as1 UNAVAIL allowed UNAVAIL - 0 1 as2 UNAVAIL allowed UNAVAIL - 0 1 as3 UNAVAIL allowed UNAVAIL -3.2.0/11 INACC 0 2 as3 UNAVAIL allowed UNAVAIL -3.2.0/11 INACC 0 3 as3 UNAVAIL allowed UNAVAIL +3.2.1/14 INACC 0 2 as3 UNAVAIL allowed UNAVAIL +0.1.2/14 INACC 0 5 as1 UNAVAIL allowed UNAVAIL dyn match-routing-key +0.1.3/14 INACC 0 5 as2 UNAVAIL allowed UNAVAIL dyn match-routing-key +0.1.4/14 INACC 0 5 as3 UNAVAIL allowed UNAVAIL dyn match-routing-key +3.2.1/14 INACC 0 5 as2 UNAVAIL allowed UNAVAIL +3.2.1/14 INACC 7 6 as1 UNAVAIL allowed UNAVAIL +3.2.0/11 INACC 0 1 as1 UNAVAIL allowed UNAVAIL + 0 1 as2 UNAVAIL allowed UNAVAIL + 0 1 as3 UNAVAIL allowed UNAVAIL +3.2.0/11 INACC 0 2 as3 UNAVAIL allowed UNAVAIL +3.2.0/11 INACC 0 3 as3 UNAVAIL allowed UNAVAIL OsmoSTP(config-cs7-rt)# do show cs7 instance 0 route binding-table 3.2.1 -- 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: newchange Gerrit-Project: libosmo-sigtran Gerrit-Branch: master Gerrit-Change-Id: I1dd83ae2b0d23c92304476692ef6bd9c2417e454 Gerrit-Change-Number: 43830 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin@sysmocom.de>
participants (1)
-
pespin