msuraev has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-sccp/+/29167 )

Change subject: SIGTRAN: don't advance FSM on failed connection request
......................................................................

SIGTRAN: don't advance FSM on failed connection request

Return proper error code from packet encoding routine and check for it before 
switching FSM state as it creates
confusing mismatch with actual protocol state.

Related: OS#5579
Change-Id: I8431c77632014e2551d1da779afddffcd1bb541c
---
M src/sccp_scoc.c
1 file changed, 14 insertions(+), 6 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, approved
  laforge: Looks good to me, but someone else must approve



diff --git a/src/sccp_scoc.c b/src/sccp_scoc.c
index c209bd7..b85eeb9 100644
--- a/src/sccp_scoc.c
+++ b/src/sccp_scoc.c
@@ -46,6 +46,7 @@
  *  * use of multiple Routing Contexts in SUA case
  */

+#include <errno.h>
 #include <string.h>

 #include <osmocom/core/utils.h>
@@ -687,7 +688,9 @@
        return NULL;
 }

-/* generate xua_msg, encode it and send it to SCRC */
+/* generate xua_msg, encode it and send it to SCRC
+ * returns 0 on success, negative on error
+ */
 static int xua_gen_encode_and_send(struct sccp_connection *conn, uint32_t 
event,
                                   const struct osmo_scu_prim *prim, int 
msg_type)
 {
@@ -695,7 +698,7 @@

        xua = xua_gen_msg_co(conn, event, prim, msg_type);
        if (!xua)
-               return -1;
+               return -ENOMEM;

        /* amend this with point code information; Many CO msgs
         * includes neither called nor calling party address! */
@@ -817,6 +820,7 @@
        struct osmo_scu_prim *prim = NULL;
        struct osmo_scu_connect_param *uconp;
        struct xua_msg *xua = NULL;
+       int rc;

        switch (event) {
        case SCOC_E_SCU_N_CONN_REQ:
@@ -827,10 +831,14 @@
                conn->calling_addr = uconp->calling_addr;
                conn->sccp_class = uconp->sccp_class;
                /* generate + send CR PDU to SCRC */
-               xua_gen_encode_and_send(conn, event, prim, SUA_CO_CORE);
-               /* start connection timer */
-               conn_start_connect_timer(conn);
-               osmo_fsm_inst_state_chg(fi, S_CONN_PEND_OUT, 0, 0);
+               rc = xua_gen_encode_and_send(conn, event, prim, SUA_CO_CORE);
+               if (rc < 0)
+                       LOGPFSML(fi, LOGL_ERROR, "Failed to initiate 
connection: %s\n", strerror(-rc));
+               else {
+                       /* start connection timer */
+                       conn_start_connect_timer(conn);
+                       osmo_fsm_inst_state_chg(fi, S_CONN_PEND_OUT, 0, 0);
+               }
                break;
 #if 0
        case SCOC_E_SCU_N_TYPE1_REQ:



2 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted 
one.
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/29167
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I8431c77632014e2551d1da779afddffcd1bb541c
Gerrit-Change-Number: 29167
Gerrit-PatchSet: 3
Gerrit-Owner: msuraev <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: msuraev <[email protected]>
Gerrit-MessageType: merged

Reply via email to