From b4f1b2cb8bd404f08601dc8ca700b672a455846c Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Wed, 16 Jun 2021 17:44:21 +0200 Subject: osmo_ss7_vty: automatically create routes for routing key Operators may set up a routing key in each AS node. However, this does not mean that there is also a route added to the routing table. If the default route is not sufficient (e.g. if multiple AS are defined), then operators are epected to put matching routes into the routing table. However, when libosmo-sigtran runs in ASP role, the VTY commands that allow to routing table changes are not present. In an ASP role we are in an endpoint situation, so no complex routing is required, in most cases (single AS) even the default route is enough but to ensure that each AS will get a route, add routing tables automatically when running in ASP role. Change-Id: Ic60b36983232308250e591dbad576aaafdd6b586 Related: SYS#5392 --- src/osmo_ss7_vty.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 63625a8..bd15070 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -1050,6 +1050,7 @@ static int _rout_key(struct vty *vty, { struct osmo_ss7_as *as = vty->index; struct osmo_ss7_routing_key *rkey = &as->cfg.routing_key; + struct osmo_ss7_route *rt; int pc; if (as->cfg.proto == OSMO_SS7_ASP_PROT_IPA && atoi(rcontext) != 0) { @@ -1063,12 +1064,33 @@ static int _rout_key(struct vty *vty, vty_out(vty, "Invalid point code (%s)%s", dpc, VTY_NEWLINE); return CMD_WARNING; } + + /* When libosmo-sigtran is used in ASP role, the VTY routing table node + * (config-cs7-rt) is not available. However, when we add a routing key + * to an AS we still have to put a matching route into the routing + * table. This is done automatically by first removing the old route + * (users may change the routing key via VTY during runtime) and then + * putting a new route (see below). */ + if (cs7_role == CS7_ROLE_ASP) { + rt = osmo_ss7_route_find_dpc_mask(as->inst->rtable_system, rkey->pc, 0xffffff); + if (rt) + osmo_ss7_route_destroy(rt); + } + rkey->pc = pc; rkey->context = atoi(rcontext); /* FIXME: input validation */ rkey->si = si ? get_string_value(mtp_si_vals, si) : 0; /* FIXME: input validation */ rkey->ssn = ssn ? atoi(ssn) : 0; /* FIXME: input validation */ + /* automatically add new route (see also comment above) */ + if (cs7_role == CS7_ROLE_ASP) { + if (!osmo_ss7_route_create(as->inst->rtable_system, rkey->pc, 0xffffff, as->cfg.name)) { + vty_out(vty, "Cannot crate route (pc=%s, linkset=%s) to linkset %s", dpc, as->cfg.name, VTY_NEWLINE); + return CMD_WARNING; + } + } + return CMD_SUCCESS; } -- cgit v1.2.3