summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2016-06-29 16:24:42 +0200
committerDaniel Willmann <dwillmann@sysmocom.de>2016-06-29 19:04:12 +0200
commitc616c54d5f669d99f74bd68a3cf8c24e1e95be82 (patch)
tree1abfb62e2d78b3b2ef3c010a53a1258b4369f1e2
parent95cce409584a0543f982df7e997720a3054d456d (diff)
osmux: Add negotiation state so race conditions can't disable osmux
-rw-r--r--openbsc/include/openbsc/osmux.h1
-rw-r--r--openbsc/src/libmgcp/mgcp_protocol.c6
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c5
3 files changed, 7 insertions, 5 deletions
diff --git a/openbsc/include/openbsc/osmux.h b/openbsc/include/openbsc/osmux.h
index 82b8fa35b..0b64a7f1e 100644
--- a/openbsc/include/openbsc/osmux.h
+++ b/openbsc/include/openbsc/osmux.h
@@ -28,6 +28,7 @@ int osmux_used_cid(void);
enum osmux_state {
OSMUX_STATE_DISABLED = 0,
+ OSMUX_STATE_NEGOTIATING,
OSMUX_STATE_ACTIVATING,
OSMUX_STATE_ENABLED,
};
diff --git a/openbsc/src/libmgcp/mgcp_protocol.c b/openbsc/src/libmgcp/mgcp_protocol.c
index 1819ceaf9..ff0fc3e7e 100644
--- a/openbsc/src/libmgcp/mgcp_protocol.c
+++ b/openbsc/src/libmgcp/mgcp_protocol.c
@@ -277,7 +277,7 @@ static struct msgb *create_response_with_sdp(struct mgcp_endpoint *endp,
if (!addr)
addr = mgcp_net_src_addr(endp);
- if (endp->osmux.state == OSMUX_STATE_ACTIVATING)
+ if (endp->osmux.state == OSMUX_STATE_NEGOTIATING)
sprintf(osmux_extension, "\nX-Osmux: %u", endp->osmux.cid);
else
osmux_extension[0] = '\0';
@@ -811,13 +811,13 @@ mgcp_header_done:
if (endp->ci == CI_UNUSED)
goto error2;
- /* Annotate Osmux circuit ID and set it to activating state until this
+ /* Annotate Osmux circuit ID and set it to negotiating state until this
* is fully set up from the dummy load.
*/
endp->osmux.state = OSMUX_STATE_DISABLED;
if (osmux_cid >= 0) {
endp->osmux.cid = osmux_cid;
- endp->osmux.state = OSMUX_STATE_ACTIVATING;
+ endp->osmux.state = OSMUX_STATE_NEGOTIATING;
} else if(endp->cfg->osmux == OSMUX_USAGE_ONLY) {
LOGP(DMGCP, LOGL_ERROR,
"Osmux only and no osmux offered on 0x%x\n", ENDPOINT_NUMBER(endp));
diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
index 9fd99677a..48847865c 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
@@ -590,7 +590,7 @@ static int bsc_mgcp_policy_cb(struct mgcp_trunk_config *tcfg, int endpoint, int
*/
if (mgcp_endp->osmux.allocated_cid >= 0 &&
mgcp_endp->osmux.state != OSMUX_STATE_ENABLED) {
- mgcp_endp->osmux.state = OSMUX_STATE_ACTIVATING;
+ mgcp_endp->osmux.state = OSMUX_STATE_NEGOTIATING;
mgcp_endp->osmux.cid = mgcp_endp->osmux.allocated_cid;
}
@@ -680,6 +680,7 @@ static void bsc_mgcp_osmux_confirm(struct mgcp_endpoint *endp, const char *str)
LOGP(DMGCP, LOGL_NOTICE, "bsc accepted to use Osmux (cid=%u)\n",
osmux_cid);
+ endp->osmux.state = OSMUX_STATE_ACTIVATING;
return;
err:
osmux_release_cid(endp);
@@ -747,7 +748,7 @@ void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg)
return;
}
- if (endp->osmux.state == OSMUX_STATE_ACTIVATING)
+ if (endp->osmux.state == OSMUX_STATE_NEGOTIATING)
bsc_mgcp_osmux_confirm(endp, (const char *) msg->l2h);
/* If we require osmux and it is disabled.. fail */