This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
dexter gerrit-no-reply at lists.osmocom.orgdexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/25008 ) Change subject: mgcp_client: allow to reset endpoints on startup ...................................................................... mgcp_client: allow to reset endpoints on startup Depending on the usecase of osmo_mpcg_client it may be helpful to send a DLCX to certain endpoints. Usually this would be a wildcarded endpoint that resets the entire trunk to drop lingering RTP flows which may still present after a restart/crash, but it might be also a group of specific endpoints. The user may specify an arbitrary amount of endpoints where the mgcp client will send a DLCX to. It does not matter if the endpoints are wildcarded or not. Change-Id: I47e7ff858d5067b46d52329be5f362ff61c0dff8 Related: SYS#5535 --- M include/osmocom/mgcp_client/mgcp_client.h M src/libosmo-mgcp-client/mgcp_client.c M src/libosmo-mgcp-client/mgcp_client_vty.c 3 files changed, 131 insertions(+), 19 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/08/25008/1 diff --git a/include/osmocom/mgcp_client/mgcp_client.h b/include/osmocom/mgcp_client/mgcp_client.h index 02996a7..95c25b1 100644 --- a/include/osmocom/mgcp_client/mgcp_client.h +++ b/include/osmocom/mgcp_client/mgcp_client.h @@ -17,6 +17,12 @@ struct vty; struct mgcp_client; +/* Struct that holds one endpoint name */ +struct reset_ep { + struct llist_head list; + char *name; +}; + struct mgcp_client_conf { const char *local_addr; int local_port; @@ -26,6 +32,12 @@ /* By default, we are always addressing the MGW with e.g. 'rtpbridge/123 at mgw'. * If this is nonempty, the contained name will be used instead of 'mgw'. */ char endpoint_domain_name[MGCP_ENDPOINT_MAXLEN]; + + /* The user may configure certain endpoint names that are reset via DLCX + * on startup. Usually this will be one wildcarded endpoint e.g. + * 'rtpbridge/(wildcard)' or a number of specific E1 like e.g. + * 'ds/e1-0/s-3/su16-4' */ + struct llist_head reset_epnames; }; typedef unsigned int mgcp_trans_id_t; diff --git a/src/libosmo-mgcp-client/mgcp_client.c b/src/libosmo-mgcp-client/mgcp_client.c index 9d60ee8..3320ad7 100644 --- a/src/libosmo-mgcp-client/mgcp_client.c +++ b/src/libosmo-mgcp-client/mgcp_client.c @@ -201,6 +201,8 @@ .remote_addr = NULL, .remote_port = -1, }; + + INIT_LLIST_HEAD(&conf->reset_epnames); } static void mgcp_client_handle_response(struct mgcp_client *mgcp, @@ -754,6 +756,8 @@ struct mgcp_client_conf *conf) { struct mgcp_client *mgcp; + struct reset_ep *reset_ep; + struct reset_ep *actual_reset_ep; mgcp = talloc_zero(ctx, struct mgcp_client); if (!mgcp) @@ -784,6 +788,12 @@ } LOGP(DLMGCP, LOGL_NOTICE, "MGCP client: using endpoint domain '@%s'\n", mgcp_client_endpoint_domain(mgcp)); + INIT_LLIST_HEAD(&mgcp->actual.reset_epnames); + llist_for_each_entry(reset_ep, &conf->reset_epnames, list) { + actual_reset_ep = talloc_memdup (ctx, reset_ep, sizeof(*reset_ep)); + llist_add_tail(&actual_reset_ep->list, &mgcp->actual.reset_epnames); + } + return mgcp; } @@ -823,6 +833,42 @@ return -EINVAL; } +static const char *_mgcp_client_name_append_domain(const struct mgcp_client *mgcp, char *name) +{ + static char endpoint[MGCP_ENDPOINT_MAXLEN]; + int rc; + + rc = snprintf(endpoint, sizeof(endpoint), "%s@%s", name, mgcp_client_endpoint_domain(mgcp)); + if (rc > sizeof(endpoint) - 1) { + LOGP(DLMGCP, LOGL_ERROR, "MGCP endpoint exceeds maximum length of %zu: '%s@%s'\n", + sizeof(endpoint) - 1, name, mgcp_client_endpoint_domain(mgcp)); + return NULL; + } + if (rc < 1) { + LOGP(DLMGCP, LOGL_ERROR, "Cannot compose MGCP endpoint name\n"); + return NULL; + } + return endpoint; +} + +/* Safely ignore the MGCP response to the DLCX sent via _mgcp_client_send_dlcx() */ +void _ignore_mgcp_response(struct mgcp_response *response, void *priv) +{ + return; +} + +/* Fromat DLCX message (fire and forget) and send it off to the MGW */ +static void _mgcp_client_send_dlcx(struct mgcp_client *mgcp, const char *epname) { + struct msgb *msgb_dlcx; + struct mgcp_msg mgcp_msg_dlcx = { + .verb = MGCP_VERB_DLCX, + .presence = MGCP_MSG_PRESENCE_ENDPOINT, + }; + osmo_strlcpy(mgcp_msg_dlcx.endpoint, epname, sizeof(mgcp_msg_dlcx.endpoint)); + msgb_dlcx = mgcp_msg_gen(mgcp, &mgcp_msg_dlcx); + mgcp_client_tx(mgcp, msgb_dlcx, &_ignore_mgcp_response, NULL); +} + /*! Initalize client connection (opens socket only, no request is sent yet) * \param[in,out] mgcp MGCP client descriptor. * \returns 0 on success, -EINVAL on error. */ @@ -830,6 +876,7 @@ { struct osmo_wqueue *wq; int rc; + struct reset_ep *reset_ep; if (!mgcp) { LOGP(DLMGCP, LOGL_FATAL, "MGCPGW client not initialized properly\n"); @@ -852,9 +899,14 @@ goto error_close_fd; } - LOGP(DLMGCP, LOGL_INFO, "MGCP GW connection: %s\n", osmo_sock_get_name2(wq->bfd.fd)); + /* If configured, send a DLCX message to the endpoints that are configured to + * be reset on startup. Usually this is a wildcarded endpoint. */ + llist_for_each_entry(reset_ep, &mgcp->actual.reset_epnames, list) { + LOGP(DLMGCP, LOGL_INFO, "MGCP GW sending DLCX to: %s\n", _mgcp_client_name_append_domain(mgcp, reset_ep->name)); + _mgcp_client_send_dlcx(mgcp, _mgcp_client_name_append_domain(mgcp, reset_ep->name)); + } return 0; error_close_fd: close(wq->bfd.fd); @@ -894,24 +946,6 @@ return mgcp->actual.endpoint_domain_name[0] ? mgcp->actual.endpoint_domain_name : "mgw"; } -static const char *_mgcp_client_name_append_domain(const struct mgcp_client *mgcp, char *name) -{ - static char endpoint[MGCP_ENDPOINT_MAXLEN]; - int rc; - - rc = snprintf(endpoint, sizeof(endpoint), "%s@%s", name, mgcp_client_endpoint_domain(mgcp)); - if (rc > sizeof(endpoint) - 1) { - LOGP(DLMGCP, LOGL_ERROR, "MGCP endpoint exceeds maximum length of %zu: '%s@%s'\n", - sizeof(endpoint) - 1, name, mgcp_client_endpoint_domain(mgcp)); - return NULL; - } - if (rc < 1) { - LOGP(DLMGCP, LOGL_ERROR, "Cannot compose MGCP endpoint name\n"); - return NULL; - } - return endpoint; -} - /*! Compose endpoint name for a wildcarded request to the virtual trunk * \param[in] mgcp MGCP client descriptor. * \returns string containing the endpoint name (e.g. rtpbridge\*@mgw) */ diff --git a/src/libosmo-mgcp-client/mgcp_client_vty.c b/src/libosmo-mgcp-client/mgcp_client_vty.c index cc8db5d..cd12776 100644 --- a/src/libosmo-mgcp-client/mgcp_client_vty.c +++ b/src/libosmo-mgcp-client/mgcp_client_vty.c @@ -155,10 +155,71 @@ return CMD_SUCCESS; } +DEFUN(cfg_mgw_reset_ep_name, + cfg_mgw_reset_ep_name_cmd, + "mgw reset-endpoint NAME", + MGW_STR "Set an eindpoint name that should be reset (DLCX) on startup, e.g. 'rtpbridge/*'\n" + "Endpoint name, e.g. 'rtpbridge/*' or 'ds/e1-0/s-3/su16-4'.\n") +{ + struct reset_ep *reset_ep; + unsigned int i; + + /* stop when the address is already in the list */ + llist_for_each_entry(reset_ep, &global_mgcp_client_conf->reset_epnames, list) { + if (strcmp(argv[0], reset_ep->name) == 0) { + vty_out(vty, "%% duplicate endpoint name configured ('%s')%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + } + + /* the domain name is not part of the actual endpoint name */ + for (i = 0; i < strlen(argv[0]); i++) { + if (argv[0][i] == '@') { + vty_out(vty, "%% the endpoint name must be given without domain name ('%s')%s", + argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + } + + reset_ep = talloc_zero(global_mgcp_client_ctx, struct reset_ep); + OSMO_ASSERT(reset_ep); + reset_ep->name = talloc_strdup(reset_ep, argv[0]); + OSMO_ASSERT(reset_ep->name); + llist_add_tail(&reset_ep->list, &global_mgcp_client_conf->reset_epnames); + + return CMD_SUCCESS; +} + +DEFUN(cfg_mgw_no_reset_ep_name, + cfg_mgw_no_reset_ep_name_cmd, + "no mgw reset-endpoint NAME", + MGW_STR "Do not reset (DLCX) endpoint on startup, e.g. 'rtpbridge/*'\n" + "Endpoint name, e.g. 'rtpbridge/*' or 'ds/e1-0/s-3/su16-4'.\n") +{ + struct reset_ep *reset_ep; + struct reset_ep *reset_ep_del = NULL; + + llist_for_each_entry(reset_ep, &global_mgcp_client_conf->reset_epnames, list) { + if (strcmp(argv[0], reset_ep->name) == 0) + reset_ep_del = reset_ep; + } + + if (reset_ep_del) { + llist_del(&reset_ep_del->list); + talloc_free(reset_ep_del); + } else { + vty_out(vty, "%% no such endpoint name configured ('%s')%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + + return CMD_SUCCESS; +} + int mgcp_client_config_write(struct vty *vty, const char *indent) { const char *addr; int port; + struct reset_ep *reset_ep; addr = global_mgcp_client_conf->local_addr; if (addr) @@ -182,6 +243,9 @@ vty_out(vty, "%smgw endpoint-domain %s%s", indent, global_mgcp_client_conf->endpoint_domain_name, VTY_NEWLINE); + llist_for_each_entry(reset_ep, &global_mgcp_client_conf->reset_epnames, list) + vty_out(vty, "%smgw reset-endpoint %s%s", indent, reset_ep->name, VTY_NEWLINE); + return CMD_SUCCESS; } @@ -197,6 +261,8 @@ install_lib_element(node, &cfg_mgw_endpoint_range_cmd); install_lib_element(node, &cfg_mgw_rtp_bts_base_port_cmd); install_lib_element(node, &cfg_mgw_endpoint_domain_name_cmd); + install_lib_element(node, &cfg_mgw_reset_ep_name_cmd); + install_lib_element(node, &cfg_mgw_no_reset_ep_name_cmd); /* deprecated 'mgcpgw' commands */ install_lib_element(node, &cfg_mgcpgw_local_ip_cmd); -- To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/25008 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-mgw Gerrit-Branch: master Gerrit-Change-Id: I47e7ff858d5067b46d52329be5f362ff61c0dff8 Gerrit-Change-Number: 25008 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pmaier at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210722/9fa35d47/attachment.htm>