<p>Pau Espin Pedrol has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/11957">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Fix ts_for_each_lchan iteration for dynamic TS in process of being PDCH deactivated<br><br>In general PDCH channels are not handled as lchans in BTS (lchan_fsm.c),<br>and so when a TS is in ts->pchan_is=GSM_PCHAN_PDCH, no lchan slot is<br>being used.<br><br>However, during Dynamic TS PDCH Deactivation being in progress (state<br>WAIT_PDCH_DEACT in timeslot_fsm.c), ts->pchan_is =GSM_PCHAN_PDCH, but<br>an lchan slot of that TS is actually already being used by a TCH lchan:<br>it's the one who initiated the deactivate in order to be able to use the TS.<br><br>While being in WAIT_PDCH_DEACT state and receiving a PDCH DEACT NACK,<br>ts_fsm_error() was called in order to kill the TS and it was expected<br>that it would kill any lchan using it (or willing to start using it). In<br>order to do that, it calls ts_lchans_dispatch() which in turns iterates<br>over all lchans attached to the TS using ts_for_each_lchan().<br><br>However, when the NACK arrived we still had ts->pchan_is=GSM_PCHAN_PDCH,<br>ts_for_each_lchan ends up calling<br>ts_as_pchan_for_each_lchan(GSM_PCHAN_PDCH), which in turns calls<br>pchan_subslots(GSM_PCHAN_PDCH) which returns 0, because we don't manage<br>lchans in that mode as explained in first paragraph. This means in this<br>case ts_for_each_lchan() is actually an empty loop while still any of<br>the TCH channels may be in use, and won't be advertised about the TS<br>entering in a broken state.<br><br>As a result, the lchan won't be released for a while, only after T23001<br>expires.<br><br>In ts_for_each_lchan(), as its name indicates, we want to iterate over<br>all lchans, and then if needed check if they are in use.<br><br>Other users of ts_for_each_lchan() have checks like<br>lchan_state_is(lchan, LCHAN_ST_UNUSED) or are fine about this<br>scenarios anyway.<br><br>Related: OS#3708<br>Change-Id: I9cedb77d6578597f1febab36c54b2ee427c7a4a2<br>---<br>M include/osmocom/bsc/gsm_data.h<br>M src/osmo-bsc/timeslot_fsm.c<br>2 files changed, 5 insertions(+), 3 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/57/11957/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h</span><br><span>index 15158cd..d4318ad 100644</span><br><span>--- a/include/osmocom/bsc/gsm_data.h</span><br><span>+++ b/include/osmocom/bsc/gsm_data.h</span><br><span>@@ -461,8 +461,10 @@</span><br><span>  * ts_for_each_lchan(lchan, ts) {</span><br><span>  *     LOGPLCHAN(DMAIN, LOGL_DEBUG, "hello world\n");</span><br><span>  * }</span><br><span style="color: hsl(0, 100%, 40%);">- * Iterate only those lchans that have an FSM allocated. */</span><br><span style="color: hsl(0, 100%, 40%);">-#define ts_for_each_lchan(lchan, ts) ts_as_pchan_for_each_lchan(lchan, ts, (ts)->pchan_is)</span><br><span style="color: hsl(120, 100%, 40%);">+ * Iterate only those lchans that have an FSM allocated.</span><br><span style="color: hsl(120, 100%, 40%);">+ * ts->pchan_on_init containing dynamic TS type is passed in order to calculate</span><br><span style="color: hsl(120, 100%, 40%);">+ * max amount of lchans available in any of the possible modes. */</span><br><span style="color: hsl(120, 100%, 40%);">+#define ts_for_each_lchan(lchan, ts) ts_as_pchan_for_each_lchan(lchan, ts, (ts)->pchan_on_init)</span><br><span> </span><br><span> /* Same as ts_for_each_lchan() but with an explicit pchan kind (GSM_PCHAN_* constant).</span><br><span>  * Iterate only those lchans that have an FSM allocated. */</span><br><span>diff --git a/src/osmo-bsc/timeslot_fsm.c b/src/osmo-bsc/timeslot_fsm.c</span><br><span>index 659c645..f55633f 100644</span><br><span>--- a/src/osmo-bsc/timeslot_fsm.c</span><br><span>+++ b/src/osmo-bsc/timeslot_fsm.c</span><br><span>@@ -550,7 +550,7 @@</span><br><span>   ts->pdch_act_allowed = true;</span><br><span> </span><br><span>  /* For static TS, check validity. For dyn TS, figure out which PCHAN this should become. */</span><br><span style="color: hsl(0, 100%, 40%);">-     ts_as_pchan_for_each_lchan(lchan, ts, ts->pchan_on_init) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ts_for_each_lchan(lchan, ts) {</span><br><span>               if (lchan_state_is(lchan, LCHAN_ST_UNUSED))</span><br><span>                  continue;</span><br><span> </span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/11957">change 11957</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/11957"/><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-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I9cedb77d6578597f1febab36c54b2ee427c7a4a2 </div>
<div style="display:none"> Gerrit-Change-Number: 11957 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Pau Espin Pedrol <pespin@sysmocom.de> </div>