[S] Change in osmo-mgw[master]: mgw: Early reject CRCX with X-Osmux if disabled by config
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/39714?usp=email ) Change subject: mgw: Early reject CRCX with X-Osmux if disabled by config ...................................................................... mgw: Early reject CRCX with X-Osmux if disabled by config This new behavior rejects the CRCX before creating a conn, simplifying the code and also allows getting rid of the remote_osmux_cid local variable. Change-Id: I0245b6c02bf7a3452532e8bf0d7c33479999ce9f --- M src/libosmo-mgcp/mgcp_protocol.c 1 file changed, 19 insertions(+), 16 deletions(-) Approvals: fixeria: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/src/libosmo-mgcp/mgcp_protocol.c b/src/libosmo-mgcp/mgcp_protocol.c index 916a284..ce397c8 100644 --- a/src/libosmo-mgcp/mgcp_protocol.c +++ b/src/libosmo-mgcp/mgcp_protocol.c @@ -817,7 +817,6 @@ struct mgcp_parse_hdr_pars *hpars = &pdata->hpars; struct rate_ctr_group *rate_ctrs; int error_code = 400; - int remote_osmux_cid; struct mgcp_conn *conn = NULL; struct mgcp_conn_rtp *conn_rtp = NULL; char conn_name[512]; @@ -892,13 +891,22 @@ } } - remote_osmux_cid = hpars->remote_osmux_cid; - /* If osmux is disabled, just skip setting it up */ - if (trunk->cfg->osmux.usage == OSMUX_USAGE_OFF) - remote_osmux_cid = MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET; + /* Reject osmux if disabled by config */ + if (trunk->cfg->osmux.usage == OSMUX_USAGE_OFF && + hpars->remote_osmux_cid != MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET) { + LOGPENDP(endp, DLMGCP, LOGL_ERROR, "CRCX: Request with Osmux but it is disabled by config!\n"); + rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_NO_OSMUX)); + return create_err_response(endp, endp, 511, "CRCX", pdata->trans); + } + /* Reject non-osmux if required by config */ + if (trunk->cfg->osmux.usage == OSMUX_USAGE_ONLY && + hpars->remote_osmux_cid == MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET) { + LOGPENDP(endp, DLMGCP, LOGL_ERROR, "CRCX: Request without Osmux but it is required by config!\n"); + return create_err_response(endp, endp, 517, "CRCX", pdata->trans); + } /* Make sure osmux is setup: */ - if (remote_osmux_cid != MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET) + if (hpars->remote_osmux_cid != MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET) mgcp_trunk_osmux_init_if_needed(trunk); /* Check if we are able to accept the creation of another connection */ @@ -970,21 +978,16 @@ conn_rtp = mgcp_conn_get_conn_rtp(conn); OSMO_ASSERT(conn_rtp); - /* If X-Osmux (remote CID) was received (-1 is wilcard), alloc next avail CID as local CID */ - if (remote_osmux_cid >= -1) { + /* If X-Osmux (remote CID) was received, alloc next avail CID as local CID */ + if (hpars->remote_osmux_cid != MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET) { if (osmux_init_conn(conn_rtp) < 0) { rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_NO_OSMUX)); goto error2; } - if (remote_osmux_cid >= 0) { + if (hpars->remote_osmux_cid >= 0) { conn_rtp->osmux.remote_cid_present = true; - conn_rtp->osmux.remote_cid = remote_osmux_cid; - } - } else if (endp->trunk->cfg->osmux.usage == OSMUX_USAGE_ONLY) { - LOGPCONN(conn, DLMGCP, LOGL_ERROR, - "CRCX: osmux only and no osmux offered\n"); - rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_NO_OSMUX)); - goto error2; + conn_rtp->osmux.remote_cid = hpars->remote_osmux_cid; + } /* else: -1 (wildcard) */ } /* Set local connection options, if present */ -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/39714?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: I0245b6c02bf7a3452532e8bf0d7c33479999ce9f Gerrit-Change-Number: 39714 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> Gerrit-Reviewer: osmith <osmith@sysmocom.de> Gerrit-Reviewer: pespin <pespin@sysmocom.de>
participants (1)
-
pespin