<p>pespin has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-bsc/+/15408">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">bsc_subscr_conn_fsm: Cleanly clear BSSAP conn if associated channel closed during WAIT_CC<br><br>TTCN3 BSC_Tests.TC_ms_rel_ind_does_not_cause_bssmap_reset seems to<br>sometimes run into a race condition on the order of messages received by<br>osmo-bsc comming from MSC and BTS.<br><br>Usual (expected) scenario):<br>BTS->BSC      EST IND<br>     BSC->MSC CL3 Info<br>     BSC<-MSC CC<br>BTS->BSC      REL IND<br>BTS<-BSC      DEACT SACCH<br>     BSC->MSC ClearRequest<br>     BSC<-MSC ClearCommand<br>     BSC->MSC ClearComplete<br>BTS<-BSC      RF Chan Release<br>BTS->BSC      RF Chan Release ACK<br><br>Sometimes CC message and REL IND message are received swapped (because they<br>are sent by different components asynchronously in TTCN3).<br><br>As a result, osmo-bsc was failing to go into CLEARING state and was<br>unable to send the ClearRequest because CC was still not received.<br>So the idea is to stay in WAIT_CC until CC is received, then check if<br>the lchan was dropped and in that case go into clearing state.<br><br>Change-Id: Id1abf5ee44c60925b478123409f26bd29006202b<br>---<br>M src/osmo-bsc/bsc_subscr_conn_fsm.c<br>1 file changed, 24 insertions(+), 8 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/08/15408/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/osmo-bsc/bsc_subscr_conn_fsm.c b/src/osmo-bsc/bsc_subscr_conn_fsm.c</span><br><span>index f8784f9..b5edeb8 100644</span><br><span>--- a/src/osmo-bsc/bsc_subscr_conn_fsm.c</span><br><span>+++ b/src/osmo-bsc/bsc_subscr_conn_fsm.c</span><br><span>@@ -99,6 +99,12 @@</span><br><span>                                conn->network->T_defs, \</span><br><span>                               -1)</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static bool gscon_is_active(struct gsm_subscriber_connection *conn)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  enum gscon_fsm_states st = conn->fi->state;</span><br><span style="color: hsl(120, 100%, 40%);">+     return st == ST_ACTIVE || st == ST_ASSIGNMENT || st == ST_HANDOVER;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* forward MT DTAP from BSSAP side to RSL side */</span><br><span> static inline void submit_dtap(struct gsm_subscriber_connection *conn, struct msgb *msg)</span><br><span> {</span><br><span>@@ -333,10 +339,19 @@</span><br><span>       switch (event) {</span><br><span>     case GSCON_EV_A_CONN_CFM:</span><br><span>            /* MSC has confirmed the connection, we now change into the</span><br><span style="color: hsl(0, 100%, 40%);">-              * active state and wait there for further operations */</span><br><span style="color: hsl(0, 100%, 40%);">-                conn_fsm_state_chg(ST_ACTIVE);</span><br><span style="color: hsl(0, 100%, 40%);">-          /* if there's user payload, forward it just like EV_MT_DTAP */</span><br><span style="color: hsl(0, 100%, 40%);">-              /* FIXME: Question: if there's user payload attached to the CC, forward it like EV_MT_DTAP? */</span><br><span style="color: hsl(120, 100%, 40%);">+             * active state and wait there for further operations. */</span><br><span style="color: hsl(120, 100%, 40%);">+             if (conn->lchan) {</span><br><span style="color: hsl(120, 100%, 40%);">+                 conn_fsm_state_chg(ST_ACTIVE);</span><br><span style="color: hsl(120, 100%, 40%);">+                        /* if there's user payload, forward it just like EV_MT_DTAP */</span><br><span style="color: hsl(120, 100%, 40%);">+                    /* FIXME: Question: if there's user payload attached to the CC, forward it like EV_MT_DTAP? */</span><br><span style="color: hsl(120, 100%, 40%);">+            } else {</span><br><span style="color: hsl(120, 100%, 40%);">+                      /* If associated lchan was released while we were</span><br><span style="color: hsl(120, 100%, 40%);">+                      * waiting for the confirmed connection, then instead</span><br><span style="color: hsl(120, 100%, 40%);">+                  * simply drop the connection */</span><br><span style="color: hsl(120, 100%, 40%);">+                      LOGPFSML(fi, LOGL_INFO, "Connection confirmed but lchan was dropped before, clearing conn\n");</span><br><span style="color: hsl(120, 100%, 40%);">+                      osmo_fsm_inst_state_chg(conn->fi, ST_CLEARING, 60, 999);</span><br><span style="color: hsl(120, 100%, 40%);">+                   gscon_bssmap_clear(conn, GSM0808_CAUSE_EQUIPMENT_FAILURE);</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span>            break;</span><br><span>       default:</span><br><span>             OSMO_ASSERT(false);</span><br><span>@@ -589,7 +604,7 @@</span><br><span>    [ST_WAIT_CC] = {</span><br><span>             .name = "WAIT_CC",</span><br><span>                 .in_event_mask = S(GSCON_EV_A_CONN_CFM),</span><br><span style="color: hsl(0, 100%, 40%);">-                .out_state_mask = S(ST_ACTIVE),</span><br><span style="color: hsl(120, 100%, 40%);">+               .out_state_mask = S(ST_ACTIVE) | S(ST_CLEARING),</span><br><span>             .action = gscon_fsm_wait_cc,</span><br><span>         },</span><br><span>   [ST_ACTIVE] = {</span><br><span>@@ -651,9 +666,10 @@</span><br><span>               lchan_forget_conn(conn->lchan);</span><br><span>           conn->lchan = NULL;</span><br><span>       }</span><br><span style="color: hsl(0, 100%, 40%);">-       if (!conn->lchan) {</span><br><span style="color: hsl(0, 100%, 40%);">-          if (conn->fi->state != ST_CLEARING)</span><br><span style="color: hsl(0, 100%, 40%);">-                       osmo_fsm_inst_state_chg(conn->fi, ST_CLEARING, 60, 999);</span><br><span style="color: hsl(120, 100%, 40%);">+   /* if conn is not active we cannot send bssap. If on WAIT_CC, then let's</span><br><span style="color: hsl(120, 100%, 40%);">+   * wait until CC is received to tear down */</span><br><span style="color: hsl(120, 100%, 40%);">+  if (!conn->lchan && gscon_is_active(conn)) {</span><br><span style="color: hsl(120, 100%, 40%);">+               osmo_fsm_inst_state_chg(conn->fi, ST_CLEARING, 60, 999);</span><br><span>          gscon_bssmap_clear(conn, GSM0808_CAUSE_EQUIPMENT_FAILURE);</span><br><span>   }</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-bsc/+/15408">change 15408</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-bsc/+/15408"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-bsc </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Id1abf5ee44c60925b478123409f26bd29006202b </div>
<div style="display:none"> Gerrit-Change-Number: 15408 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>