l1sap: Avoid re-(de)activating already (de)active lchans

This avoids triggering all sorts of unexpected paths where one tries to
release an already released lchan, etc.
This can happen for instance if BTS shuts down due to BSC link going
down, and hence resets all lchans, announcing it to the PCU. Then the
PCU may try to deactivate the channel sending act_req (disable), but the
BTS already unilaterally dropped the channels.
That code path seems to trigger some crash, probably because something
in lchan has been freed.

Related: SYS#4971
Change-Id: I093e4d4e23b527b10bf5d6ff538460626c30a8f8
This commit is contained in:
Pau Espin 2021-10-26 18:00:17 +02:00
parent c2ae1df890
commit 887fa01977
1 changed files with 13 additions and 0 deletions

View File

@ -1961,6 +1961,12 @@ int l1sap_chan_act(struct gsm_bts_trx *trx, uint8_t chan_nr, struct tlv_parsed *
struct gsm_lchan *lchan = get_lchan_by_chan_nr(trx, chan_nr);
int rc;
if (lchan->state == LCHAN_S_ACTIVE) {
LOGPLCHAN(lchan, DL1C, LOGL_ERROR, "Trying to activate already active channel %s\n",
rsl_chan_nr_str(chan_nr));
return -1;
}
LOGPLCHAN(lchan, DL1C, LOGL_INFO, "Activating channel %s\n", rsl_chan_nr_str(chan_nr));
lchan->s = trx->bts->radio_link_timeout.current;
@ -1994,6 +2000,13 @@ int l1sap_chan_act(struct gsm_bts_trx *trx, uint8_t chan_nr, struct tlv_parsed *
int l1sap_chan_rel(struct gsm_bts_trx *trx, uint8_t chan_nr)
{
struct gsm_lchan *lchan = get_lchan_by_chan_nr(trx, chan_nr);
if (lchan->state == LCHAN_S_NONE) {
LOGPLCHAN(lchan, DL1C, LOGL_ERROR, "Trying to deactivate already deactivated channel %s\n",
rsl_chan_nr_str(chan_nr));
return -1;
}
LOGPLCHAN(lchan, DL1C, LOGL_INFO, "Deactivating channel %s\n",
rsl_chan_nr_str(chan_nr));