Review at  https://gerrit.osmocom.org/8019

bsc_api/GSCON: prevent unnecessary channel mode modifys

gsm0808_assign_req() checks if the new channel mode is compatible
with the new mode. If it is, it does a gsm48_lchan_modify(), but
it does not actually check if the new mode is equal to the current
mode.

- skip when the channel is compatible and the new mode is equal to
  the old mode.

- send the ASSIGNMENT COMPLETE directly from ST_ACTIVE when no
  mode modify was necessary.

Change-Id: I86a2d52836c54d2dbd77441b182f757327ec7262
Related: OS#2936
---
M src/libbsc/bsc_api.c
M src/libbsc/bsc_subscr_conn_fsm.c
2 files changed, 10 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/19/8019/1

diff --git a/src/libbsc/bsc_api.c b/src/libbsc/bsc_api.c
index 142efef..1c4dc6b 100644
--- a/src/libbsc/bsc_api.c
+++ b/src/libbsc/bsc_api.c
@@ -313,6 +313,11 @@
                if (handle_new_assignment(conn, chan_mode, full_rate) != 0)
                        goto error;
        } else {
+               /* Check if the channel is already in the requested mode, if
+                * yes, we skip unnecessary channel mode modify operations. */
+               if (conn->lchan->tch_mode == chan_mode)
+                       return 1;
+
                if (chan_mode == GSM48_CMODE_SPEECH_AMR)
                        handle_mr_config(conn, conn->lchan, full_rate);
 
diff --git a/src/libbsc/bsc_subscr_conn_fsm.c b/src/libbsc/bsc_subscr_conn_fsm.c
index b5e7e7d..7f53f1b 100644
--- a/src/libbsc/bsc_subscr_conn_fsm.c
+++ b/src/libbsc/bsc_subscr_conn_fsm.c
@@ -438,7 +438,11 @@
                         * change back to ST_ACTIVE (here) immediately. */
                        rc = gsm0808_assign_req(conn, 
conn->user_plane.chan_mode,
                                                conn->user_plane.full_rate);
-                       if (rc != 0) {
+
+                       if (rc == 1) {
+                               send_ass_compl(conn->lchan, fi, false);
+                               return;
+                       } else if (rc != 0) {
                                resp = 
gsm0808_create_assignment_failure(GSM0808_CAUSE_EQUIPMENT_FAILURE, NULL);
                                sigtran_send(conn, resp, fi);
                                return;

-- 
To view, visit https://gerrit.osmocom.org/8019
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I86a2d52836c54d2dbd77441b182f757327ec7262
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: dexter <pma...@sysmocom.de>

Reply via email to