[option:--live-port='URL'] [option:--output='DIR'] [option:--group='GROUP']
[option:--verbose]... [option:--working-directory='DIR']
[option:--group-output-by-host | option:--group-output-by-session] [option:--disallow-clear]
+ [option:--dynamic-port-allocation]
DESCRIPTION
+
Specify this option up to three times to get more levels of verbosity.
+option:--dynamic-port-allocation::
+ When specific any of the control, data, and live ports not specifically
+ given, or which are given a value of '0' will have the port choice delegated
+ to the operating system.
++
+lttng-relayd will write `control.port`, `data.port`, and `live.port` files to
+its run-time directory.
Output
~~~~~~
/* command line options */
char *opt_output_path, *opt_working_directory;
-static int opt_daemon, opt_background, opt_print_version, opt_allow_clear = 1;
+static int opt_daemon, opt_background, opt_print_version, opt_allow_clear = 1, opt_dynamic_port_allocation = 0;
enum relay_group_output_by opt_group_output_by = RELAYD_GROUP_OUTPUT_BY_UNKNOWN;
/* Argument variables */
'p',
},
{ "disallow-clear", 0, nullptr, 'x' },
+ { "dynamic-port-allocation", 0, nullptr, '\0' },
{
nullptr,
0,
goto end;
}
lttng_opt_fd_pool_size = (unsigned int) v;
+ } else if (!strcmp(optname, "dynamic-port-allocation")) {
+ opt_dynamic_port_allocation = 1;
} else {
fprintf(stderr, "unknown option %s", optname);
if (arg) {
ERR("Invalid control URI specified");
goto end;
}
- if (control_uri->port == 0) {
+ if (control_uri->port == 0 && !opt_dynamic_port_allocation) {
control_uri->port = DEFAULT_NETWORK_CONTROL_PORT;
}
}
ERR("Invalid data URI specified");
goto end;
}
- if (data_uri->port == 0) {
+ if (data_uri->port == 0 && !opt_dynamic_port_allocation) {
data_uri->port = DEFAULT_NETWORK_DATA_PORT;
}
}
ERR("Invalid live URI specified");
goto end;
}
- if (live_uri->port == 0) {
+ if (live_uri->port == 0 && !opt_dynamic_port_allocation) {
live_uri->port = DEFAULT_NETWORK_VIEWER_PORT;
}
}
if (control_uri == nullptr) {
ret = asprintf(&default_address,
"tcp://" DEFAULT_NETWORK_CONTROL_BIND_ADDRESS ":%d",
- DEFAULT_NETWORK_CONTROL_PORT);
+ opt_dynamic_port_allocation ? 0 : DEFAULT_NETWORK_CONTROL_PORT);
if (ret < 0) {
PERROR("asprintf default data address");
retval = -1;
if (data_uri == nullptr) {
ret = asprintf(&default_address,
"tcp://" DEFAULT_NETWORK_DATA_BIND_ADDRESS ":%d",
- DEFAULT_NETWORK_DATA_PORT);
+ (opt_dynamic_port_allocation) ? 0 : DEFAULT_NETWORK_DATA_PORT);
if (ret < 0) {
PERROR("asprintf default data address");
retval = -1;
if (live_uri == nullptr) {
ret = asprintf(&default_address,
"tcp://" DEFAULT_NETWORK_VIEWER_BIND_ADDRESS ":%d",
- DEFAULT_NETWORK_VIEWER_PORT);
+ (opt_dynamic_port_allocation) ? 0 : DEFAULT_NETWORK_VIEWER_PORT);
if (ret < 0) {
PERROR("asprintf default viewer control address");
retval = -1;
PERROR("Failed to open \"%s\" relay socket", formated_name ?: "Unknown");
goto error;
}
- DBG("Listening on %s socket %d", name, sock->fd);
+ DBG("Listening on %s socket %d", name, sock->fd);
ret = sock->ops->bind(sock);
if (ret < 0) {
PERROR("Failed to bind socket");
goto error;
}
+ DBG("Bound %s socket fd %d to port %d", name, sock->fd, ntohs(sock->sockaddr.addr.sin.sin_port));
ret = sock->ops->listen(sock, -1);
if (ret < 0) {
goto error;