mirror of
				https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
				synced 2025-11-03 21:43:32 +00:00 
			
		
		
		
	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
This commit is contained in:
		@@ -817,7 +817,6 @@ static struct msgb *handle_create_con(struct mgcp_request_data *rq)
 | 
				
			|||||||
	struct mgcp_parse_hdr_pars *hpars = &pdata->hpars;
 | 
						struct mgcp_parse_hdr_pars *hpars = &pdata->hpars;
 | 
				
			||||||
	struct rate_ctr_group *rate_ctrs;
 | 
						struct rate_ctr_group *rate_ctrs;
 | 
				
			||||||
	int error_code = 400;
 | 
						int error_code = 400;
 | 
				
			||||||
	int remote_osmux_cid;
 | 
					 | 
				
			||||||
	struct mgcp_conn *conn = NULL;
 | 
						struct mgcp_conn *conn = NULL;
 | 
				
			||||||
	struct mgcp_conn_rtp *conn_rtp = NULL;
 | 
						struct mgcp_conn_rtp *conn_rtp = NULL;
 | 
				
			||||||
	char conn_name[512];
 | 
						char conn_name[512];
 | 
				
			||||||
@@ -892,13 +891,22 @@ static struct msgb *handle_create_con(struct mgcp_request_data *rq)
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	remote_osmux_cid = hpars->remote_osmux_cid;
 | 
						/* Reject osmux if disabled by config */
 | 
				
			||||||
	/* If osmux is disabled, just skip setting it up */
 | 
						if (trunk->cfg->osmux.usage == OSMUX_USAGE_OFF &&
 | 
				
			||||||
	if (trunk->cfg->osmux.usage == OSMUX_USAGE_OFF)
 | 
						    hpars->remote_osmux_cid != MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET) {
 | 
				
			||||||
		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: */
 | 
						/* 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);
 | 
							mgcp_trunk_osmux_init_if_needed(trunk);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Check if we are able to accept the creation of another connection */
 | 
						/* Check if we are able to accept the creation of another connection */
 | 
				
			||||||
@@ -970,21 +978,16 @@ static struct msgb *handle_create_con(struct mgcp_request_data *rq)
 | 
				
			|||||||
	conn_rtp = mgcp_conn_get_conn_rtp(conn);
 | 
						conn_rtp = mgcp_conn_get_conn_rtp(conn);
 | 
				
			||||||
	OSMO_ASSERT(conn_rtp);
 | 
						OSMO_ASSERT(conn_rtp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* If X-Osmux (remote CID) was received (-1 is wilcard), alloc next avail CID as local CID */
 | 
						/* If X-Osmux (remote CID) was received, alloc next avail CID as local CID */
 | 
				
			||||||
	if (remote_osmux_cid >= -1) {
 | 
						if (hpars->remote_osmux_cid != MGCP_PARSE_HDR_PARS_OSMUX_CID_UNSET) {
 | 
				
			||||||
		if (osmux_init_conn(conn_rtp) < 0) {
 | 
							if (osmux_init_conn(conn_rtp) < 0) {
 | 
				
			||||||
			rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_NO_OSMUX));
 | 
								rate_ctr_inc(rate_ctr_group_get_ctr(rate_ctrs, MGCP_CRCX_FAIL_NO_OSMUX));
 | 
				
			||||||
			goto error2;
 | 
								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_present = true;
 | 
				
			||||||
			conn_rtp->osmux.remote_cid = remote_osmux_cid;
 | 
								conn_rtp->osmux.remote_cid = hpars->remote_osmux_cid;
 | 
				
			||||||
		}
 | 
							} /* else: -1 (wildcard) */
 | 
				
			||||||
	} 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;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Set local connection options, if present */
 | 
						/* Set local connection options, if present */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user