From d9098703fadd46150139c717505f9032f5621b9d Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 29 Apr 2021 19:44:54 +0200 Subject: xua_as_fsm: Only delete a route for an IPA AS if we created one earlier The current code would potentially delete a route that was statically present in the configuration in the following situation: * route exists in config * identical route is attempted to be added at AS-ACTIVE time, but fails * route is unconditionally deleted at AS-DOWN time * user now does 'write file' and has lost a route Let's make sure we only delete the route if we added it previously. Change-Id: I9ad5f7ebe0790e6c186b8ea1b12f204860a00cd2 Related: SYS#5422 --- src/xua_as_fsm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/xua_as_fsm.c b/src/xua_as_fsm.c index f66ba88..2f52762 100644 --- a/src/xua_as_fsm.c +++ b/src/xua_as_fsm.c @@ -200,6 +200,7 @@ struct xua_as_fsm_priv { struct osmo_timer_list t_r; struct llist_head queued_msgs; } recovery; + bool ipa_route_created; }; /* is the given AS one with a single ASP of IPA type? */ @@ -227,9 +228,13 @@ static void ipa_add_route(struct osmo_fsm_inst *fi) struct osmo_ss7_as *as = xafp->as; struct osmo_ss7_instance *inst = as->inst; + if (osmo_ss7_route_find_dpc_mask(inst->rtable_system, as->cfg.routing_key.pc, 0xffffff)) + return; + /* As opposed to M3UA, there is no RKM and we have to implicitly * automatically add a route once an IPA connection has come up */ - osmo_ss7_route_create(inst->rtable_system, as->cfg.routing_key.pc, 0xffffff, as->cfg.name); + if (osmo_ss7_route_create(inst->rtable_system, as->cfg.routing_key.pc, 0xffffff, as->cfg.name)) + xafp->ipa_route_created = true; } static void ipa_del_route(struct osmo_fsm_inst *fi) @@ -239,6 +244,10 @@ static void ipa_del_route(struct osmo_fsm_inst *fi) struct osmo_ss7_instance *inst = as->inst; struct osmo_ss7_route *rt; + /* don't delete a route if we added none */ + if (!xafp->ipa_route_created) + return; + /* find the route which we have created if we ever reached ipa_asp_fsm_wait_id_ack2 */ rt = osmo_ss7_route_find_dpc_mask(inst->rtable_system, as->cfg.routing_key.pc, 0xffffff); /* no route found, bail out */ @@ -258,6 +267,7 @@ static void ipa_del_route(struct osmo_fsm_inst *fi) } osmo_ss7_route_destroy(rt); + xafp->ipa_route_created = false; } -- cgit v1.2.3