Browse Source

MT#55283 allow allocation of out-of-pool ports

Different instances of rtpengine may be configured with different port
ranges. If HA requests usage of a port not part of our pool, allow it.

Change-Id: Ib4ace6c4facac35ea44948720fa46bcbdaf441d3
pull/1981/head
Richard Fuchs 5 months ago
parent
commit
052f16da56
1 changed files with 10 additions and 5 deletions
  1. +10
    -5
      daemon/media_socket.c

+ 10
- 5
daemon/media_socket.c View File

@ -1167,9 +1167,6 @@ void append_thread_lpr_to_glob_lpr(void) {
}
static struct socket_port_link get_one_port_link(unsigned int port, struct intf_spec *spec) {
if (!port_is_in_range(&spec->port_pool, port))
return (struct socket_port_link) {};
__auto_type links = get_port_links(&spec->port_pool, port);
return (struct socket_port_link) { .links = links, .pp = &spec->port_pool, .socket = { .fd = -1 }};
}
@ -1217,7 +1214,14 @@ static bool open_port_link_sockets(socket_port_q *out, struct intf_spec *spec, c
struct socket_port_link get_specific_port(unsigned int port,
struct intf_spec *spec, const str *label)
{
ilog(LOG_DEBUG, "A specific port value is requested: '%d'", port);
if (!port_is_in_range(&spec->port_pool, port)) {
ilog(LOG_DEBUG, "A specific out-of-pool port is requested: '%d'", port);
struct socket_port_link spl = {0};
add_socket(&spl.socket, port, spec, label);
return spl;
}
ilog(LOG_DEBUG, "A specific in-pool port is requested: '%d'", port);
__auto_type spl = get_one_port_link(port, spec);
if (spl.links.length) {
if (add_socket(&spl.socket, port, spec, label))
@ -1307,7 +1311,8 @@ new_cycle:
port = GPOINTER_TO_UINT(spl.links.head->data); /* RTP */
/* ports for RTP must be even, if there is an additional port for RTCP */
if (num_ports > 1 && (port & 1)) {
// also bail if end port is out of range of the pool
if ((num_ports > 1 && (port & 1)) || port + num_ports - 1 > spec->port_pool.max) {
/* return port for RTP back and try again */
release_reserved_port(pp, &spl.links, port);
continue;


Loading…
Cancel
Save