This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgHarald Welte has submitted this change and it was merged. Change subject: ss7: Re-bind xUA server socket after setting new IP ...................................................................... ss7: Re-bind xUA server socket after setting new IP In osmo-stp, cmd "local-ip" inside node "listen m3ua 2905" was actually not being applied, because the server was created + bound at "listen" command time using NULL as IP, and at "local-ip" time the IP was changed but the server was not re-bound using the new IP, so it kept listening at 0.0.0.0. With this patch, we defer binding the socket to "local-ip" cmd time, after the IP has been applied. As a result, if no "local-ip" command is provided, then the bind never happens, which means it is now mandatory that users of osmo_ss7_xua_server_create API not using osmo_ss7_xua_server_set_local_host call new provided API osmo_ss7_xua_server_bind. Another new API osmo_ss7_bind_all_instances is provided to easily make sure all servers are bound after configuration process. This is specially important for servers which doesn't contain the "local-ip" parameter. Users of osmo_sccp_simple_server API are not affected by this change, and they not requrie to call any new API. Furthermore, using osmo_ss7_xua_server_bind in VTY code ensures the xUA server is automatically bound to the new address if the operator changes the "local-ip" cmd at runtime. Related: OS#2647 Change-Id: I79738963d633bec70705ff159c5b2127cd498aa2 --- M include/osmocom/sigtran/osmo_ss7.h M src/osmo_ss7.c M src/osmo_ss7_vty.c M src/sccp_user.c M stp/stp_main.c 5 files changed, 66 insertions(+), 9 deletions(-) Approvals: Harald Welte: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index 71c2022..94d5e8a 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -108,6 +108,8 @@ 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(); /*********************************************************************** * MTP Users (Users of MTP, such as SCCP or ISUP) @@ -441,6 +443,9 @@ uint16_t local_port, const char *local_host); int +osmo_ss7_xua_server_bind(struct osmo_xua_server *xs); + +int osmo_ss7_xua_server_set_local_host(struct osmo_xua_server *xs, const char *local_host); void osmo_ss7_xua_server_destroy(struct osmo_xua_server *xs); diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index 86fb45c..7f82f6e 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -423,6 +423,42 @@ 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; +} + /*********************************************************************** * MTP Users (Users of MTP, such as SCCP or ISUP) ***********************************************************************/ @@ -1745,7 +1781,7 @@ return NULL; } -/*! \brief create a new xUA server listening to given ip/port +/*! \brief create a new xUA server configured with given ip/port * \param[in] ctx talloc allocation context * \param[in] proto protocol (xUA variant) to use * \param[in] local_port local SCTP port to bind/listen to @@ -1757,7 +1793,6 @@ uint16_t local_port, const char *local_host) { struct osmo_xua_server *oxs = talloc_zero(inst, struct osmo_xua_server); - int rc; OSMO_ASSERT(ss7_initialized); if (!oxs) @@ -1781,13 +1816,6 @@ osmo_stream_srv_link_set_port(oxs->server, oxs->cfg.local.port); osmo_stream_srv_link_set_proto(oxs->server, asp_proto_to_ip_proto(proto)); - rc = osmo_stream_srv_link_open(oxs->server); - if (rc < 0) { - osmo_stream_srv_link_destroy(oxs->server); - oxs->server = NULL; - talloc_free(oxs); - } - oxs->inst = inst; llist_add_tail(&oxs->list, &inst->xua_servers); @@ -1798,6 +1826,19 @@ return oxs; } +/*! \brief Set the xUA server to bind/listen to the currently configured ip/port + * \param[in] xs xUA server to operate + * \returns 0 on success, negative value on error. + */ +int +osmo_ss7_xua_server_bind(struct osmo_xua_server *xs) +{ + LOGP(DLSS7, LOGL_INFO, "(Re)binding %s Server to %s:%u\n", + get_value_string(osmo_ss7_asp_protocol_vals, xs->cfg.proto), + xs->cfg.local.host, xs->cfg.local.port); + return osmo_stream_srv_link_open(xs->server); +} + int osmo_ss7_xua_server_set_local_host(struct osmo_xua_server *xs, const char *local_host) { diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c index 403a9ac..ea06b02 100644 --- a/src/osmo_ss7_vty.c +++ b/src/osmo_ss7_vty.c @@ -467,6 +467,10 @@ 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; } diff --git a/src/sccp_user.c b/src/sccp_user.c index d9de8d7..cd89c88 100644 --- a/src/sccp_user.c +++ b/src/sccp_user.c @@ -521,6 +521,7 @@ { struct osmo_ss7_instance *ss7; struct osmo_xua_server *xs; + int rc; if (local_port < 0) local_port = osmo_ss7_asp_protocol_port(prot); @@ -535,6 +536,10 @@ if (!xs) goto out_ss7; + rc = osmo_ss7_xua_server_bind(xs); + if (rc < 0) + goto out_xs; + /* Allocate SCCP stack */ ss7->sccp = osmo_sccp_instance_create(ss7, NULL); if (!ss7->sccp) diff --git a/stp/stp_main.c b/stp/stp_main.c index 69d26b5..3216101 100644 --- a/stp/stp_main.c +++ b/stp/stp_main.c @@ -183,6 +183,8 @@ exit(1); } + osmo_ss7_bind_all_instances(); + rc = telnet_init_dynif(NULL, NULL, vty_get_bind_addr(), OSMO_VTY_PORT_STP); if (rc < 0) { perror("Erro binding VTY port\n"); -- To view, visit https://gerrit.osmocom.org/4893 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I79738963d633bec70705ff159c5b2127cd498aa2 Gerrit-PatchSet: 5 Gerrit-Project: libosmo-sccp Gerrit-Branch: master Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de> Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de> Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>