From 38ae954da5239a372cf40459f830c88913c08012 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Fri, 11 Oct 2019 13:31:54 +0200 Subject: Defer xua server binding until exit of VTY node Commit 10d4815bb1b4b548ec0bc97611b2e7ac45e0ebc5 already fixed the issue where binding was done during L_CS7_XUA_NODE (listen) done, meaning local-ip inside it had no effect. In that comment, binding was moved to happen during "local-ip" VTY cmd. Furthermore, that commit added a new osmo_ss7_bind_all_instances() and related APIs to allow osmo-stp to have all xua servers bound if no "local-ip" was provided. These APIs have only been used so far by osmo-stp (which lays in the same git repo that libosmo-sccp) since it's the only program using the xua server features. In the present commit, let's drop the APIs added by commit described above, and instead let libosmo-sccp code to internally bind the xua server upon exit of the VTY node. As a result, the previously introduced APIs can be dropped (not used by anyone anymore) and it will provide ways to support multiple "local-ip" commands in the future, hence supporting SCTP multi-home features. It's recommended to require libosmocore.git Ia6d88c0e63d94ba99e950da6efbc4c1871070012 since it fixes a bug where go_parent_cb was not called for nodes at the end of the file. Related: OS#3608 Change-Id: I2cff17b5e2e2fbfd4591e23a416e510e94e173d6 --- include/osmocom/sigtran/osmo_ss7.h | 2 -- src/osmo_ss7.c | 36 ------------------------------------ src/osmo_ss7_vty.c | 7 +++---- stp/stp_main.c | 2 -- 4 files changed, 3 insertions(+), 44 deletions(-) diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index d6ae1d4..9e8f2b3 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -108,8 +108,6 @@ osmo_ss7_instance_find_or_create(void *ctx, uint32_t id); void osmo_ss7_instance_destroy(struct osmo_ss7_instance *inst); int osmo_ss7_instance_set_pc_fmt(struct osmo_ss7_instance *inst, uint8_t c0, uint8_t c1, uint8_t c2); -int osmo_ss7_instance_bind(struct osmo_ss7_instance *inst); -int osmo_ss7_bind_all_instances(); struct osmo_sccp_instance *osmo_ss7_ensure_sccp(struct osmo_ss7_instance *inst); diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index 8d188fc..9b51c29 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -422,42 +422,6 @@ int osmo_ss7_instance_set_pc_fmt(struct osmo_ss7_instance *inst, return 0; } -/*! \brief bind all xUA servers belonging to an SS7 Instance - * \param[in] inst SS7 Instance to apply the socket binding (and start listening) - * \returns 0 on success; negative value on error */ -int osmo_ss7_instance_bind(struct osmo_ss7_instance *inst) -{ - struct osmo_xua_server *oxs; - int rc = 0; - - llist_for_each_entry(oxs, &inst->xua_servers, list) { - if (osmo_ss7_xua_server_bind(oxs) < 0) { - LOGSS7(inst, LOGL_ERROR, "Unable to bind xUA server %s:%u\n", - oxs->cfg.local.host, oxs->cfg.local.port); - rc = -1; - } - } - return rc; -} - -/*! \brief bind all xUA servers on each of the stored SS7 instances - * \returns 0 on success; negative value on error */ -int osmo_ss7_bind_all_instances() -{ - OSMO_ASSERT(ss7_initialized); - - struct osmo_ss7_instance *inst; - int rc = 0; - - llist_for_each_entry(inst, &osmo_ss7_instances, list) { - if (osmo_ss7_instance_bind(inst) < 0 ) { - LOGSS7(inst, LOGL_ERROR, "Unable to bind all xUA servers in ss7 instance\n"); - rc = -1; - } - } - return rc; -} - /*! Allocate an SCCP instance, if not present yet. * \returns inst->sccp. */ struct osmo_sccp_instance *osmo_ss7_ensure_sccp(struct osmo_ss7_instance *inst) diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 58a3e29..85cc695 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -470,10 +470,7 @@ DEFUN(xua_local_ip, xua_local_ip_cmd, struct osmo_xua_server *xs = vty->index; osmo_ss7_xua_server_set_local_host(xs, argv[0]); - if (osmo_ss7_xua_server_bind(xs) < 0) { - vty_out(vty, "Unable to bind xUA server to IP %s%s", argv[0], VTY_NEWLINE); - return CMD_WARNING; - } + return CMD_SUCCESS; } @@ -1725,6 +1722,8 @@ int osmo_ss7_vty_go_parent(struct vty *vty) break; case L_CS7_XUA_NODE: oxs = vty->index; + if (osmo_ss7_xua_server_bind(oxs) < 0) + vty_out(vty, "%% Unable to bind xUA server to IP(s)%s", VTY_NEWLINE); vty->node = L_CS7_NODE; vty->index = oxs->inst; break; diff --git a/stp/stp_main.c b/stp/stp_main.c index a3e3a85..4cc2586 100644 --- a/stp/stp_main.c +++ b/stp/stp_main.c @@ -191,8 +191,6 @@ int main(int argc, char **argv) exit(1); } - osmo_ss7_bind_all_instances(); - rc = telnet_init_dynif(tall_stp_ctx, NULL, vty_get_bind_addr(), OSMO_VTY_PORT_STP); if (rc < 0) { perror("Error binding VTY port\n"); -- cgit v1.2.3