pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmo-sccp/+/15784 )


Change subject: Defer xua server binding until exit of VTY node
......................................................................

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
---
M include/osmocom/sigtran/osmo_ss7.h
M src/osmo_ss7.c
M src/osmo_ss7_vty.c
M stp/stp_main.c
4 files changed, 3 insertions(+), 44 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-sccp refs/changes/84/15784/1

diff --git a/include/osmocom/sigtran/osmo_ss7.h 
b/include/osmocom/sigtran/osmo_ss7.h
index f448ce7..b1d4dab 100644
--- a/include/osmocom/sigtran/osmo_ss7.h
+++ b/include/osmocom/sigtran/osmo_ss7.h
@@ -108,8 +108,6 @@
 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 053feca..1312cf3 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -425,42 +425,6 @@
        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 cc53b05..56263ee 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -470,10 +470,7 @@
        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;
 }

@@ -1692,6 +1689,8 @@
                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 @@
                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");

--
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/15784
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I2cff17b5e2e2fbfd4591e23a416e510e94e173d6
Gerrit-Change-Number: 15784
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to