Просмотр исходного кода

Qdevice: Add advanced settings

All previously defined defaults are now configurable via -S option.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Jan Friesse 9 лет назад
Родитель
Сommit
41d6d1e438

+ 2 - 1
qdevices/Makefile.am

@@ -99,7 +99,8 @@ corosync_qdevice_SOURCES = corosync-qdevice.c \
                            qdevice-net-algo-lms.c qdevice-net-algo-lms.h \
                            qdevice-net-poll-array-user-data.h \
                            qdevice-config.h qnet-config.h qdevice-net-disconnect-reason.h \
-                           qdevice-model-type.h
+                           qdevice-model-type.h qdevice-advanced-settings.c \
+                           qdevice-advanced-settings.h dynar-getopt-lex.c dynar-getopt-lex.h
 
 corosync_qnetd_tool_SOURCES = corosync-qnetd-tool.c unix-socket.c unix-socket.h dynar.c dynar.h \
                               dynar-str.c dynar-str.h

+ 2 - 2
qdevices/corosync-qdevice-tool.c

@@ -78,7 +78,7 @@ cli_parse(int argc, char * const argv[], enum qdevice_tool_operation *operation,
 
 	*operation = QDEVICE_TOOL_OPERATION_NONE;
 	*verbose = 0;
-	*socket_path = strdup(QDEVICE_LOCAL_SOCKET_FILE);
+	*socket_path = strdup(QDEVICE_DEFAULT_LOCAL_SOCKET_FILE);
 
 	if (*socket_path == NULL) {
 		errx(QDEVICE_TOOL_EXIT_CODE_INTERNAL_ERROR,
@@ -232,7 +232,7 @@ main(int argc, char * const argv[])
 
 	cli_parse(argc, argv, &operation, &verbose, &socket_path);
 
-	dynar_init(&send_str, QDEVICE_IPC_MAX_RECEIVE_SIZE);
+	dynar_init(&send_str, QDEVICE_DEFAULT_IPC_MAX_RECEIVE_SIZE);
 
 	sock_fd = unix_socket_client_create(socket_path, 0);
 	if (sock_fd == -1) {

+ 57 - 6
qdevices/corosync-qdevice.c

@@ -32,8 +32,13 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <err.h>
 #include <signal.h>
 
+#include "dynar.h"
+#include "dynar-str.h"
+#include "dynar-getopt-lex.h"
+#include "qdevice-advanced-settings.h"
 #include "qdevice-config.h"
 #include "qdevice-cmap.h"
 #include "qdevice-ipc.h"
@@ -80,18 +85,54 @@ static void
 usage(void)
 {
 
-	printf("usage: %s [-dfh]\n", QDEVICE_PROGRAM_NAME);
+	printf("usage: %s [-dfh] [-S option=value[,option2=value2,...]]\n", QDEVICE_PROGRAM_NAME);
 }
 
 static void
-cli_parse(int argc, char * const argv[], int *foreground, int *force_debug)
+cli_parse_long_opt(struct qdevice_advanced_settings *advanced_settings, const char *long_opt)
+{
+	struct dynar_getopt_lex lex;
+	struct dynar dynar_long_opt;
+	const char *opt;
+	const char *val;
+	int res;
+
+	dynar_init(&dynar_long_opt, strlen(long_opt) + 1);
+	if (dynar_str_cpy(&dynar_long_opt, long_opt) != 0) {
+		errx(1, "Can't alloc memory for long option");
+	}
+
+	dynar_getopt_lex_init(&lex, &dynar_long_opt);
+
+	while (dynar_getopt_lex_token_next(&lex) == 0 && strcmp(dynar_data(&lex.option), "") != 0) {
+		opt = dynar_data(&lex.option);
+		val = dynar_data(&lex.value);
+
+		res = qdevice_advanced_settings_set(advanced_settings, opt, val);
+		switch (res) {
+		case -1:
+			errx(1, "Unknown option '%s'", opt);
+			break;
+		case -2:
+			errx(1, "Invalid value '%s' for option '%s'", val, opt);
+			break;
+		}
+	}
+
+	dynar_getopt_lex_destroy(&lex);
+	dynar_destroy(&dynar_long_opt);
+}
+
+static void
+cli_parse(int argc, char * const argv[], int *foreground, int *force_debug,
+    struct qdevice_advanced_settings *advanced_settings)
 {
 	int ch;
 
 	*foreground = 0;
 	*force_debug = 0;
 
-	while ((ch = getopt(argc, argv, "dfh")) != -1) {
+	while ((ch = getopt(argc, argv, "dfhS:")) != -1) {
 		switch (ch) {
 		case 'd':
 			*force_debug = 1;
@@ -99,6 +140,9 @@ cli_parse(int argc, char * const argv[], int *foreground, int *force_debug)
 		case 'f':
 			*foreground = 1;
 			break;
+		case 'S':
+			cli_parse_long_opt(advanced_settings, optarg);
+			break;
 		case 'h':
 		case '?':
 			usage();
@@ -112,14 +156,19 @@ int
 main(int argc, char * const argv[])
 {
 	struct qdevice_instance instance;
+	struct qdevice_advanced_settings advanced_settings;
 	int foreground;
 	int force_debug;
 	int lock_file;
 	int another_instance_running;
 
-	cli_parse(argc, argv, &foreground, &force_debug);
+	if (qdevice_advanced_settings_init(&advanced_settings) != 0) {
+		errx(1, "Can't alloc memory for advanced settings");
+	}
+
+	cli_parse(argc, argv, &foreground, &force_debug, &advanced_settings);
 
-	qdevice_instance_init(&instance);
+	qdevice_instance_init(&instance, &advanced_settings);
 
 	qdevice_cmap_init(&instance);
 	qdevice_log_init(&instance, force_debug);
@@ -131,7 +180,8 @@ main(int argc, char * const argv[])
 		utils_tty_detach();
 	}
 
-	if ((lock_file = utils_flock(QDEVICE_LOCK_FILE, getpid(), &another_instance_running)) == -1) {
+	if ((lock_file = utils_flock(advanced_settings.lock_file, getpid(),
+	    &another_instance_running)) == -1) {
 		if (another_instance_running) {
 			qdevice_log(LOG_ERR, "Another instance is running");
 		} else {
@@ -194,6 +244,7 @@ main(int argc, char * const argv[])
 	qdevice_cmap_destroy(&instance);
 	qdevice_log_close(&instance);
 	qdevice_instance_destroy(&instance);
+	qdevice_advanced_settings_destroy(&advanced_settings);
 
 	return (0);
 }

+ 1 - 1
qdevices/corosync-qnetd.c

@@ -352,7 +352,7 @@ usage(void)
 {
 
 	printf("usage: %s [-46dfhv] [-l listen_addr] [-p listen_port] [-s tls]\n", QNETD_PROGRAM_NAME);
-	printf("%14s[-c client_cert_required] [-m max_clients] [-S option=value]\n", "");
+	printf("%14s[-c client_cert_required] [-m max_clients] [-S option=value[,option2=value2,...]]\n", "");
 }
 
 static void

+ 267 - 0
qdevices/qdevice-advanced-settings.c

@@ -0,0 +1,267 @@
+/*
+ * Copyright (c) 2015-2016 Red Hat, Inc.
+ *
+ * All rights reserved.
+ *
+ * Author: Jan Friesse (jfriesse@redhat.com)
+ *
+ * This software licensed under BSD license, the text of which follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * - Neither the name of the Red Hat, Inc. nor the names of its
+ *   contributors may be used to endorse or promote products derived from this
+ *   software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+#include "dynar.h"
+#include "dynar-getopt-lex.h"
+#include "dynar-str.h"
+#include "qdevice-config.h"
+#include "qnet-config.h"
+#include "qdevice-advanced-settings.h"
+#include "utils.h"
+
+int
+qdevice_advanced_settings_init(struct qdevice_advanced_settings *settings)
+{
+
+	memset(settings, 0, sizeof(*settings));
+	if ((settings->lock_file = strdup(QDEVICE_DEFAULT_LOCK_FILE)) == NULL) {
+		return (-1);
+	}
+	if ((settings->local_socket_file = strdup(QDEVICE_DEFAULT_LOCAL_SOCKET_FILE)) == NULL) {
+		return (-1);
+	}
+	settings->local_socket_backlog = QDEVICE_DEFAULT_LOCAL_SOCKET_BACKLOG;
+	settings->max_cs_try_again = QDEVICE_DEFAULT_MAX_CS_TRY_AGAIN;
+	if ((settings->votequorum_device_name = strdup(QDEVICE_DEFAULT_VOTEQUORUM_DEVICE_NAME)) == NULL) {
+		return (-1);
+	}
+	settings->ipc_max_clients = QDEVICE_DEFAULT_IPC_MAX_CLIENTS;
+	settings->ipc_max_receive_size = QDEVICE_DEFAULT_IPC_MAX_RECEIVE_SIZE;
+	settings->ipc_max_send_size = QDEVICE_DEFAULT_IPC_MAX_SEND_SIZE;
+	if ((settings->net_nss_db_dir = strdup(QDEVICE_NET_DEFAULT_NSS_DB_DIR)) == NULL) {
+		return (-1);
+	}
+	settings->net_initial_msg_receive_size = QDEVICE_NET_DEFAULT_INITIAL_MSG_RECEIVE_SIZE;
+	settings->net_initial_msg_send_size = QDEVICE_NET_DEFAULT_INITIAL_MSG_SEND_SIZE;
+	settings->net_min_msg_send_size = QDEVICE_NET_DEFAULT_MIN_MSG_SEND_SIZE;
+	settings->net_max_msg_receive_size = QDEVICE_NET_DEFAULT_MAX_MSG_RECEIVE_SIZE;
+	settings->net_max_send_buffers = QDEVICE_NET_DEFAULT_MAX_SEND_BUFFERS;
+	if ((settings->net_nss_qnetd_cn = strdup(QDEVICE_NET_DEFAULT_NSS_QNETD_CN)) == NULL) {
+		return (-1);
+	}
+	if ((settings->net_nss_client_cert_nickname =
+	    strdup(QDEVICE_NET_DEFAULT_NSS_CLIENT_CERT_NICKNAME)) == NULL) {
+		return (-1);
+	}
+	settings->net_heartbeat_interval_min = QDEVICE_NET_DEFAULT_HEARTBEAT_INTERVAL_MIN;
+	settings->net_heartbeat_interval_max = QDEVICE_NET_DEFAULT_HEARTBEAT_INTERVAL_MAX;
+	settings->net_min_connect_timeout = QDEVICE_NET_DEFAULT_MIN_CONNECT_TIMEOUT;
+	settings->net_max_connect_timeout = QDEVICE_NET_DEFAULT_MAX_CONNECT_TIMEOUT;
+	settings->net_delay_before_reconnect = QDEVICE_NET_DEFAULT_DELAY_BEFORE_RECONNECT;
+	settings->net_test_algorithm_enabled = QDEVICE_NET_DEFAULT_TEST_ALGORITHM_ENABLED;
+
+	return (0);
+}
+
+void
+qdevice_advanced_settings_destroy(struct qdevice_advanced_settings *settings)
+{
+
+	free(settings->local_socket_file);
+	free(settings->lock_file);
+	free(settings->votequorum_device_name);
+	free(settings->net_nss_db_dir);
+	free(settings->net_nss_qnetd_cn);
+	free(settings->net_nss_client_cert_nickname);
+}
+
+/*
+ * 0 - No error
+ * -1 - Unknown option
+ * -2 - Incorrect value
+ */
+int
+qdevice_advanced_settings_set(struct qdevice_advanced_settings *settings,
+    const char *option, const char *value)
+{
+	long long int tmpll;
+	char *ep;
+
+	if (strcasecmp(option, "lock_file") == 0) {
+		free(settings->lock_file);
+
+		if ((settings->lock_file = strdup(value)) == NULL) {
+			return (-1);
+		}
+	} else if (strcasecmp(option, "local_socket_file") == 0) {
+		free(settings->local_socket_file);
+
+		if ((settings->local_socket_file = strdup(value)) == NULL) {
+			return (-1);
+		}
+	} else if (strcasecmp(option, "local_socket_backlog") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QDEVICE_MIN_LOCAL_SOCKET_BACKLOG || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
+		settings->local_socket_backlog = (int)tmpll;
+	} else if (strcasecmp(option, "max_cs_try_again") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QDEVICE_MIN_MAX_CS_TRY_AGAIN || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
+		settings->max_cs_try_again = (int)tmpll;
+	} else if (strcasecmp(option, "votequorum_device_name") == 0) {
+		free(settings->votequorum_device_name);
+
+		if ((settings->votequorum_device_name = strdup(value)) == NULL) {
+			return (-1);
+		}
+	} else if (strcasecmp(option, "ipc_max_clients") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QDEVICE_MIN_IPC_MAX_CLIENTS || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
+		settings->ipc_max_clients = (size_t)tmpll;
+	} else if (strcasecmp(option, "ipc_max_receive_size") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QDEVICE_MIN_IPC_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
+		settings->ipc_max_receive_size = (size_t)tmpll;
+	} else if (strcasecmp(option, "ipc_max_send_size") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QDEVICE_MIN_IPC_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
+		settings->ipc_max_send_size = (size_t)tmpll;
+	} else if (strcasecmp(option, "net_nss_db_dir") == 0) {
+		free(settings->net_nss_db_dir);
+
+		if ((settings->net_nss_db_dir = strdup(value)) == NULL) {
+			return (-1);
+		}
+	} else if (strcasecmp(option, "net_initial_msg_receive_size") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QDEVICE_NET_MIN_MSG_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
+		settings->net_initial_msg_receive_size = (size_t)tmpll;
+	} else if (strcasecmp(option, "net_initial_msg_send_size") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QDEVICE_NET_MIN_MSG_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
+		settings->net_initial_msg_send_size = (size_t)tmpll;
+	} else if (strcasecmp(option, "net_min_msg_send_size") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QDEVICE_NET_MIN_MSG_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
+		settings->net_min_msg_send_size = (size_t)tmpll;
+	} else if (strcasecmp(option, "net_max_msg_receive_size") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QDEVICE_NET_MIN_MSG_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
+		settings->net_max_msg_receive_size = (size_t)tmpll;
+	} else if (strcasecmp(option, "net_max_send_buffers") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QDEVICE_NET_MIN_MAX_SEND_BUFFERS || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
+		settings->net_max_send_buffers = (size_t)tmpll;
+	} else if (strcasecmp(option, "net_nss_qnetd_cn") == 0) {
+		free(settings->net_nss_qnetd_cn);
+
+		if ((settings->net_nss_qnetd_cn = strdup(value)) == NULL) {
+			return (-1);
+		}
+	} else if (strcasecmp(option, "net_nss_client_cert_nickname") == 0) {
+		free(settings->net_nss_client_cert_nickname);
+
+		if ((settings->net_nss_client_cert_nickname = strdup(value)) == NULL) {
+			return (-1);
+		}
+	} else if (strcasecmp(option, "net_heartbeat_interval_min") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QDEVICE_NET_MIN_HEARTBEAT_INTERVAL || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
+		settings->net_heartbeat_interval_min = (uint32_t)tmpll;
+	} else if (strcasecmp(option, "net_heartbeat_interval_max") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QDEVICE_NET_MIN_HEARTBEAT_INTERVAL || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
+		settings->net_heartbeat_interval_max = (uint32_t)tmpll;
+	} else if (strcasecmp(option, "net_min_connect_timeout") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QDEVICE_NET_MIN_CONNECT_TIMEOUT || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
+		settings->net_min_connect_timeout = (uint32_t)tmpll;
+	} else if (strcasecmp(option, "net_max_connect_timeout") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QDEVICE_NET_MIN_CONNECT_TIMEOUT || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
+		settings->net_max_connect_timeout = (uint32_t)tmpll;
+	} else if (strcasecmp(option, "net_delay_before_reconnect") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QDEVICE_NET_MIN_DELAY_BEFORE_RECONNECT || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
+		settings->net_delay_before_reconnect = (int)tmpll;
+	} else if (strcasecmp(option, "net_test_algorithm_enabled") == 0) {
+		if ((tmpll = utils_parse_bool_str(value)) == -1) {
+			return (-2);
+		}
+
+		settings->net_test_algorithm_enabled = (uint8_t)tmpll;
+	} else {
+		return (-1);
+	}
+
+	return (0);
+}

+ 82 - 0
qdevices/qdevice-advanced-settings.h

@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2015-2016 Red Hat, Inc.
+ *
+ * All rights reserved.
+ *
+ * Author: Jan Friesse (jfriesse@redhat.com)
+ *
+ * This software licensed under BSD license, the text of which follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * - Neither the name of the Red Hat, Inc. nor the names of its
+ *   contributors may be used to endorse or promote products derived from this
+ *   software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _QDEVICE_ADVANCED_SETTINGS_H_
+#define _QDEVICE_ADVANCED_SETTINGS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct qdevice_advanced_settings {
+	char *lock_file;
+	char *local_socket_file;
+	int local_socket_backlog;
+	int max_cs_try_again;
+	char *votequorum_device_name;
+	size_t ipc_max_clients;
+	size_t ipc_max_send_size;
+	size_t ipc_max_receive_size;
+
+	/*
+	 * Related to model NET
+	 */
+	char *net_nss_db_dir;
+	size_t net_initial_msg_receive_size;
+	size_t net_initial_msg_send_size;
+	size_t net_min_msg_send_size;
+	size_t net_max_msg_receive_size;
+	size_t net_max_send_buffers;
+	char *net_nss_qnetd_cn;
+	char *net_nss_client_cert_nickname;
+	uint32_t net_heartbeat_interval_min;
+	uint32_t net_heartbeat_interval_max;
+	uint32_t net_min_connect_timeout;
+	uint32_t net_max_connect_timeout;
+	int net_delay_before_reconnect;
+	uint8_t net_test_algorithm_enabled;
+};
+
+extern int		qdevice_advanced_settings_init(struct qdevice_advanced_settings *settings);
+
+extern int		qdevice_advanced_settings_set(struct qdevice_advanced_settings *settings,
+    const char *option, const char *value);
+
+extern void		qdevice_advanced_settings_destroy(struct qdevice_advanced_settings *settings);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _QDEVICE_ADVANCED_SETTINGS_H_ */

+ 1 - 1
qdevices/qdevice-cmap.c

@@ -218,7 +218,7 @@ qdevice_cmap_init(struct qdevice_instance *instance)
 	no_retries = 0;
 
 	while ((res = cmap_initialize(&instance->cmap_handle)) == CS_ERR_TRY_AGAIN &&
-	    no_retries++ < QDEVICE_MAX_CS_TRY_AGAIN) {
+	    no_retries++ < instance->advanced_settings->max_cs_try_again) {
 		(void)poll(NULL, 0, 1000);
 	}
 

+ 14 - 9
qdevices/qdevice-config.h

@@ -46,13 +46,16 @@ extern "C" {
 
 /*
  * There are "hardcoded" defines for qdevice. It's not so good
- * idea to change them as long as you are not 100% sure what you are doing.
+ * idea to change them as long as you are not 100% sure what you are doing. Also
+ * most of them can be changed in CLI via advanced_settings (-S).
  */
-#define QDEVICE_LOCK_FILE			LOCALSTATEDIR"/run/corosync-qdevice.pid"
-#define QDEVICE_LOCAL_SOCKET_FILE               LOCALSTATEDIR"/run/corosync-qdevice.sock"
-#define QDEVICE_LOCAL_SOCKET_BACKLOG		10
+#define QDEVICE_DEFAULT_LOCK_FILE		LOCALSTATEDIR"/run/corosync-qdevice.pid"
+#define QDEVICE_DEFAULT_LOCAL_SOCKET_FILE	LOCALSTATEDIR"/run/corosync-qdevice.sock"
+#define QDEVICE_DEFAULT_LOCAL_SOCKET_BACKLOG	10
+#define QDEVICE_MIN_LOCAL_SOCKET_BACKLOG	1
 
-#define QDEVICE_MAX_CS_TRY_AGAIN		10
+#define QDEVICE_DEFAULT_MAX_CS_TRY_AGAIN	10
+#define QDEVICE_MIN_MAX_CS_TRY_AGAIN		1
 
 #define QDEVICE_PROGRAM_NAME			"corosync-qdevice"
 #define QDEVICE_LOG_SUBSYS			"QDEVICE"
@@ -66,11 +69,13 @@ extern "C" {
 #define QDEVICE_LOG_DEFAULT_TIMESTAMP		0
 #define QDEVICE_LOG_DEFAULT_FUNCTION_NAME	0
 
-#define QDEVICE_VOTEQUORUM_DEVICE_NAME		"Qdevice"
+#define QDEVICE_DEFAULT_VOTEQUORUM_DEVICE_NAME	"Qdevice"
 
-#define QDEVICE_IPC_MAX_CLIENTS			10
-#define QDEVICE_IPC_MAX_RECEIVE_SIZE		(4*1024)
-#define QDEVICE_IPC_MAX_SEND_SIZE		(64*1024)
+#define QDEVICE_DEFAULT_IPC_MAX_CLIENTS		10
+#define QDEVICE_MIN_IPC_MAX_CLIENTS		0
+#define QDEVICE_DEFAULT_IPC_MAX_RECEIVE_SIZE	(4*1024)
+#define QDEVICE_DEFAULT_IPC_MAX_SEND_SIZE	(64*1024)
+#define QDEVICE_MIN_IPC_RECEIVE_SEND_SIZE	1024
 
 #define QDEVICE_TOOL_PROGRAM_NAME		"corosync-qdevice-tool"
 

+ 3 - 1
qdevices/qdevice-instance.c

@@ -37,7 +37,8 @@
 #include "qdevice-model.h"
 
 int
-qdevice_instance_init(struct qdevice_instance *instance)
+qdevice_instance_init(struct qdevice_instance *instance,
+    const struct qdevice_advanced_settings *advanced_settings)
 {
 
 	memset(instance, 0, sizeof(*instance));
@@ -45,6 +46,7 @@ qdevice_instance_init(struct qdevice_instance *instance)
 	node_list_init(&instance->config_node_list);
 
 	instance->vq_last_poll = ((time_t) -1);
+	instance->advanced_settings = advanced_settings;
 
 	return (0);
 }

+ 5 - 1
qdevices/qdevice-instance.h

@@ -43,6 +43,7 @@
 #include <cmap.h>
 #include <votequorum.h>
 
+#include "qdevice-advanced-settings.h"
 #include "qdevice-model-type.h"
 #include "node-list.h"
 #include "unix-socket-ipc.h"
@@ -100,9 +101,12 @@ struct qdevice_instance {
 	int vq_last_poll_cast_vote;
 
 	void *model_data;
+
+	const struct qdevice_advanced_settings *advanced_settings;
 };
 
-extern int	qdevice_instance_init(struct qdevice_instance *instance);
+extern int	qdevice_instance_init(struct qdevice_instance *instance,
+    const struct qdevice_advanced_settings *advanced_settings);
 
 extern int	qdevice_instance_destroy(struct qdevice_instance *instance);
 

+ 6 - 3
qdevices/qdevice-ipc.c

@@ -43,9 +43,12 @@
 int
 qdevice_ipc_init(struct qdevice_instance *instance)
 {
-	if (unix_socket_ipc_init(&instance->local_ipc, QDEVICE_LOCAL_SOCKET_FILE,
-	    QDEVICE_LOCAL_SOCKET_BACKLOG, QDEVICE_IPC_MAX_CLIENTS, QDEVICE_IPC_MAX_RECEIVE_SIZE,
-	    QDEVICE_IPC_MAX_SEND_SIZE) != 0) {
+	if (unix_socket_ipc_init(&instance->local_ipc,
+	    instance->advanced_settings->local_socket_file,
+	    instance->advanced_settings->local_socket_backlog,
+	    instance->advanced_settings->ipc_max_clients,
+	    instance->advanced_settings->ipc_max_receive_size,
+	    instance->advanced_settings->ipc_max_send_size) != 0) {
 		qdevice_log_err(LOG_ERR, "Can't create unix socket");
 
 		return (-1);

+ 3 - 2
qdevices/qdevice-model-net.c

@@ -67,7 +67,7 @@ qdevice_model_net_init(struct qdevice_instance *instance)
 
 	qdevice_log(LOG_DEBUG, "Initializing NSS");
 	if (nss_sock_init_nss((net_instance->tls_supported != TLV_TLS_UNSUPPORTED ?
-	    (char *)QDEVICE_NET_NSS_DB_DIR : NULL)) != 0) {
+	    instance->advanced_settings->net_nss_db_dir : NULL)) != 0) {
 		qdevice_log_nss(LOG_ERR, "Can't init nss");
 		return (-1);
 	}
@@ -251,7 +251,8 @@ qdevice_model_net_run(struct qdevice_instance *instance)
 			/*
 			 * Give qnetd server a little time before reconnect
 			 */
-			(void)poll(NULL, 0, random() % 1000);
+			(void)poll(NULL, 0,
+			    random() % instance->advanced_settings->net_delay_before_reconnect);
 		}
 	}
 

+ 28 - 24
qdevices/qdevice-net-instance.c

@@ -32,6 +32,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "qdevice-config.h"
 #include "qdevice-log.h"
 #include "qdevice-net-instance.h"
 #include "qnet-config.h"
@@ -45,23 +46,19 @@
 #include <private/pprio.h>
 
 int
-qdevice_net_instance_init(struct qdevice_net_instance *instance, size_t initial_receive_size,
-    size_t initial_send_size, size_t min_send_size, size_t max_send_buffers,
-    size_t max_receive_size,
+qdevice_net_instance_init(struct qdevice_net_instance *instance,
     enum tlv_tls_supported tls_supported,
     enum tlv_decision_algorithm_type decision_algorithm, uint32_t heartbeat_interval,
     uint32_t sync_heartbeat_interval, uint32_t cast_vote_timer_interval,
     const char *host_addr, uint16_t host_port, const char *cluster_name,
     const struct tlv_tie_breaker *tie_breaker, uint32_t connect_timeout,
-    int force_ip_version, int cmap_fd, int votequorum_fd, int local_socket_fd)
+    int force_ip_version, int cmap_fd, int votequorum_fd, int local_socket_fd,
+    const struct qdevice_advanced_settings *advanced_settings)
 {
 
 	memset(instance, 0, sizeof(*instance));
 
-	instance->initial_receive_size = initial_receive_size;
-	instance->initial_send_size = initial_send_size;
-	instance->min_send_size = min_send_size;
-	instance->max_receive_size = max_receive_size;
+	instance->advanced_settings = advanced_settings;
 	instance->decision_algorithm = decision_algorithm;
 	instance->heartbeat_interval = heartbeat_interval;
 	instance->sync_heartbeat_interval = sync_heartbeat_interval;
@@ -80,10 +77,10 @@ qdevice_net_instance_init(struct qdevice_net_instance *instance, size_t initial_
 
 	memcpy(&instance->tie_breaker, tie_breaker, sizeof(*tie_breaker));
 
-	dynar_init(&instance->receive_buffer, initial_receive_size);
+	dynar_init(&instance->receive_buffer, advanced_settings->net_initial_msg_receive_size);
 
-	send_buffer_list_init(&instance->send_buffer_list, max_send_buffers,
-	    initial_send_size);
+	send_buffer_list_init(&instance->send_buffer_list, advanced_settings->net_max_send_buffers,
+	    advanced_settings->net_initial_msg_send_size);
 
 	timer_list_init(&instance->main_timer_list);
 
@@ -266,15 +263,15 @@ qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance)
 	 */
 	cast_vote_timer_interval = instance->heartbeat_interval * 0.5;
 	heartbeat_interval = instance->heartbeat_interval * 0.8;
-	if (heartbeat_interval < QDEVICE_NET_HEARTBEAT_INTERVAL_MIN) {
+	if (heartbeat_interval < instance->advanced_settings->net_heartbeat_interval_min) {
 		qdevice_log(LOG_WARNING, "Heartbeat interval too small %"PRIu32". Adjusting to %"PRIu32".",
-		    heartbeat_interval, QDEVICE_NET_HEARTBEAT_INTERVAL_MIN);
-		heartbeat_interval = QDEVICE_NET_HEARTBEAT_INTERVAL_MIN;
+		    heartbeat_interval, instance->advanced_settings->net_heartbeat_interval_min);
+		heartbeat_interval = instance->advanced_settings->net_heartbeat_interval_min;
 	}
-	if (heartbeat_interval > QDEVICE_NET_HEARTBEAT_INTERVAL_MAX) {
+	if (heartbeat_interval > instance->advanced_settings->net_heartbeat_interval_max) {
 		qdevice_log(LOG_WARNING, "Heartbeat interval too big %"PRIu32". Adjusting to %"PRIu32".",
-		    heartbeat_interval, QDEVICE_NET_HEARTBEAT_INTERVAL_MAX);
-		heartbeat_interval = QDEVICE_NET_HEARTBEAT_INTERVAL_MAX;
+		    heartbeat_interval, instance->advanced_settings->net_heartbeat_interval_max);
+		heartbeat_interval = instance->advanced_settings->net_heartbeat_interval_max;
 	}
 	sync_heartbeat_interval = instance->sync_heartbeat_interval * 0.8;
 
@@ -301,6 +298,13 @@ qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance)
 		free(str);
 	}
 
+	if (decision_algorithm == TLV_DECISION_ALGORITHM_TYPE_TEST &&
+	    !instance->advanced_settings->net_test_algorithm_enabled) {
+		qdevice_log(LOG_ERR, "Test algorithm is not enabled. You can force enable it by "
+		    "passing -S net_test_algorithm_enabled=on to %s command", QDEVICE_PROGRAM_NAME);
+
+		goto error_free_cluster_name;
+	}
 	/*
 	 * Load tie_breaker mode
 	 */
@@ -335,9 +339,12 @@ qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance)
 		connect_timeout = heartbeat_interval;
 	} else {
 		li = strtol(str, &ep, 10);
-		if (li < QDEVICE_NET_MIN_CONNECT_TIMEOUT || li > QDEVICE_NET_MAX_CONNECT_TIMEOUT || *ep != '\0') {
-			qdevice_log(LOG_ERR, "connect_timeout must be valid number in range <%lu,%lu>",
-			    QDEVICE_NET_MIN_CONNECT_TIMEOUT, QDEVICE_NET_MAX_CONNECT_TIMEOUT);
+		if (li < instance->advanced_settings->net_min_connect_timeout ||
+		    li > instance->advanced_settings->net_max_connect_timeout || *ep != '\0') {
+			qdevice_log(LOG_ERR, "connect_timeout must be valid number in "
+			    "range <%"PRIu32",%"PRIu32">",
+			    instance->advanced_settings->net_min_connect_timeout,
+			    instance->advanced_settings->net_max_connect_timeout);
 			free(str);
 			goto error_free_cluster_name;
 		}
@@ -366,15 +373,12 @@ qdevice_net_instance_init_from_cmap(struct qdevice_instance *instance)
 	 * Really initialize instance
 	 */
 	if (qdevice_net_instance_init(net_instance,
-	    QDEVICE_NET_INITIAL_MSG_RECEIVE_SIZE, QDEVICE_NET_INITIAL_MSG_SEND_SIZE,
-	    QDEVICE_NET_MIN_MSG_SEND_SIZE, QDEVICE_NET_MAX_SEND_BUFFERS,
-	    QDEVICE_NET_MAX_MSG_RECEIVE_SIZE,
 	    tls_supported, decision_algorithm,
 	    heartbeat_interval, sync_heartbeat_interval, cast_vote_timer_interval,
 	    host_addr, host_port, cluster_name, &tie_breaker, connect_timeout,
 	    force_ip_version,
 	    instance->cmap_poll_fd, instance->votequorum_poll_fd,
-	    instance->local_ipc.socket) == -1) {
+	    instance->local_ipc.socket, instance->advanced_settings) == -1) {
 		qdevice_log(LOG_ERR, "Can't initialize qdevice-net instance");
 		goto error_free_instance;
 	}

+ 3 - 7
qdevices/qdevice-net-instance.h

@@ -67,10 +67,6 @@ enum qdevice_net_instance_state {
 
 struct qdevice_net_instance {
 	PRFileDesc *socket;
-	size_t initial_send_size;
-	size_t initial_receive_size;
-	size_t max_receive_size;
-	size_t min_send_size;
 	struct dynar receive_buffer;
 	struct send_buffer_list send_buffer_list;
 	int skipping_msg;
@@ -109,17 +105,17 @@ struct qdevice_net_instance {
 	struct pr_poll_array poll_array;
 	time_t last_echo_reply_received_time;
 	time_t connected_since_time;
+	const struct qdevice_advanced_settings *advanced_settings;
 };
 
 extern int		qdevice_net_instance_init(struct qdevice_net_instance *instance,
-    size_t initial_receive_size, size_t initial_send_size, size_t min_send_size,
-    size_t max_send_buffers, size_t max_receive_size,
     enum tlv_tls_supported tls_supported,
     enum tlv_decision_algorithm_type decision_algorithm, uint32_t heartbeat_interval,
     uint32_t sync_heartbeat_interval, uint32_t cast_vote_timer_interval,
     const char *host_addr, uint16_t host_port, const char *cluster_name,
     const struct tlv_tie_breaker *tie_breaker, uint32_t connect_timeout, int force_ip_version,
-    int cmap_fd, int votequorum_fd, int local_socket_fd);
+    int cmap_fd, int votequorum_fd, int local_socket_fd,
+    const struct qdevice_advanced_settings *advanced_settings);
 
 extern void		qdevice_net_instance_clean(struct qdevice_net_instance *instance);
 

+ 6 - 4
qdevices/qdevice-net-msg-received.c

@@ -308,19 +308,21 @@ qdevice_net_msg_received_init_reply(struct qdevice_net_instance *instance,
 		return (-1);
 	}
 
-	if (msg->server_maximum_request_size < instance->min_send_size) {
+	if (msg->server_maximum_request_size < instance->advanced_settings->net_min_msg_send_size) {
 		qdevice_log(LOG_ERR,
 		    "Server accepts maximum %zu bytes message but this client minimum "
-		    "is %zu bytes.", msg->server_maximum_request_size, instance->min_send_size);
+		    "is %zu bytes.", msg->server_maximum_request_size,
+		    instance->advanced_settings->net_min_msg_send_size);
 
 		instance->disconnect_reason = QDEVICE_NET_DISCONNECT_REASON_INCOMPATIBLE_MSG_SIZE;
 		return (-1);
 	}
 
-	if (msg->server_maximum_reply_size > instance->max_receive_size) {
+	if (msg->server_maximum_reply_size > instance->advanced_settings->net_max_msg_receive_size) {
 		qdevice_log(LOG_ERR,
 		    "Server may send message up to %zu bytes message but this client maximum "
-		    "is %zu bytes.", msg->server_maximum_reply_size, instance->max_receive_size);
+		    "is %zu bytes.", msg->server_maximum_reply_size,
+		    instance->advanced_settings->net_max_msg_receive_size);
 
 		instance->disconnect_reason = QDEVICE_NET_DISCONNECT_REASON_INCOMPATIBLE_MSG_SIZE;
 		return (-1);

+ 2 - 2
qdevices/qdevice-net-nss.c

@@ -69,6 +69,6 @@ qdevice_net_nss_get_client_auth_data(void *arg, PRFileDesc *sock, struct CERTDis
 
 	instance->tls_client_cert_sent = 1;
 
-	return (NSS_GetClientAuthData((void *)QDEVICE_NET_NSS_CLIENT_CERT_NICKNAME, sock, caNames,
-	    pRetCert, pRetKey));
+	return (NSS_GetClientAuthData((void *)instance->advanced_settings->net_nss_client_cert_nickname,
+	    sock, caNames, pRetCert, pRetKey));
 }

+ 1 - 1
qdevices/qdevice-net-socket.c

@@ -140,7 +140,7 @@ qdevice_net_socket_write_finished(struct qdevice_net_instance *instance)
 		 * StartTLS sent to server. Begin with TLS handshake
 		 */
 		if ((new_pr_fd = nss_sock_start_ssl_as_client(instance->socket,
-		    QDEVICE_NET_NSS_SERVER_CN,
+		    instance->advanced_settings->net_nss_qnetd_cn,
 		    qdevice_net_nss_bad_cert_hook,
 		    qdevice_net_nss_get_client_auth_data,
 		    instance, 0, NULL)) == NULL) {

+ 4 - 4
qdevices/qdevice-votequorum.c

@@ -166,7 +166,7 @@ qdevice_votequorum_init(struct qdevice_instance *instance)
 
 	while ((res = votequorum_initialize(&votequorum_handle,
 	    &votequorum_callbacks)) == CS_ERR_TRY_AGAIN &&
-	    no_retries++ < QDEVICE_MAX_CS_TRY_AGAIN) {
+	    no_retries++ < instance->advanced_settings->max_cs_try_again) {
 		(void)poll(NULL, 0, 1000);
 	}
 
@@ -176,7 +176,7 @@ qdevice_votequorum_init(struct qdevice_instance *instance)
 	}
 
 	if ((res = votequorum_qdevice_register(votequorum_handle,
-	    QDEVICE_VOTEQUORUM_DEVICE_NAME)) != CS_OK) {
+	    instance->advanced_settings->votequorum_device_name)) != CS_OK) {
 		qdevice_log(LOG_CRIT, "Can't register votequorum device. Error %s", cs_strerror(res));
 		exit(1);
 	}
@@ -220,7 +220,7 @@ qdevice_votequorum_destroy(struct qdevice_instance *instance)
 	}
 
 	res = votequorum_qdevice_unregister(instance->votequorum_handle,
-		QDEVICE_VOTEQUORUM_DEVICE_NAME);
+		instance->advanced_settings->votequorum_device_name);
 
         if (res != CS_OK) {
                 qdevice_log(LOG_WARNING, "Unable to unregister votequorum device. Error %s", cs_strerror(res));
@@ -257,7 +257,7 @@ qdevice_votequorum_poll(struct qdevice_instance *instance, int cast_vote)
 	instance->vq_last_poll_cast_vote = cast_vote;
 
 	res = votequorum_qdevice_poll(instance->votequorum_handle,
-	    QDEVICE_VOTEQUORUM_DEVICE_NAME, cast_vote,
+	    instance->advanced_settings->votequorum_device_name, cast_vote,
 	    instance->vq_node_list_ring_id);
 
 	if (res != CS_OK && res != CS_ERR_TRY_AGAIN) {

+ 59 - 46
qdevices/qnet-config.h

@@ -46,71 +46,84 @@ extern "C" {
 /*
  * There are "hardcoded" defaults for both qnetd and qdevice-net. It's not so good
  * idea to change them as long as you are not 100% sure what you are doing. Also
- * every single one can be changed in CLI via advanced_settings (-S).
+ * most of them can be changed in CLI via advanced_settings (-S).
  */
 
-#define QNETD_PROGRAM_NAME			"corosync-qnetd"
-#define QNETD_DEFAULT_HOST_PORT			5403
-#define QNETD_DEFAULT_LISTEN_BACKLOG		10
-#define QNETD_MIN_LISTEN_BACKLOG		1
-#define QNETD_DEFAULT_MAX_CLIENT_SEND_BUFFERS	10
-#define QNETD_MIN_CLIENT_SEND_BUFFERS		2
-#define QNETD_DEFAULT_MAX_CLIENT_SEND_SIZE	(1 << 15)
-#define QNETD_DEFAULT_MAX_CLIENT_RECEIVE_SIZE	(1 << 15)
-#define QNETD_MIN_CLIENT_RECEIVE_SEND_SIZE	16
-#define QNETD_DEFAULT_MAX_CLIENTS		0
+#define QNETD_PROGRAM_NAME				"corosync-qnetd"
+#define QNETD_DEFAULT_HOST_PORT				5403
+#define QNETD_DEFAULT_LISTEN_BACKLOG			10
+#define QNETD_MIN_LISTEN_BACKLOG			1
+#define QNETD_DEFAULT_MAX_CLIENT_SEND_BUFFERS		10
+#define QNETD_MIN_CLIENT_SEND_BUFFERS			2
+#define QNETD_DEFAULT_MAX_CLIENT_SEND_SIZE		(1 << 15)
+#define QNETD_DEFAULT_MAX_CLIENT_RECEIVE_SIZE		(1 << 15)
+#define QNETD_MIN_CLIENT_RECEIVE_SEND_SIZE		16
+#define QNETD_DEFAULT_MAX_CLIENTS			0
 
-#define QNETD_DEFAULT_NSS_DB_DIR		COROSYSCONFDIR "/qdevice/net/qnetd/nssdb"
-#define QNETD_DEFAULT_CERT_NICKNAME		"QNetd Cert"
+#define QNETD_DEFAULT_NSS_DB_DIR			COROSYSCONFDIR "/qdevice/net/qnetd/nssdb"
+#define QNETD_DEFAULT_CERT_NICKNAME			"QNetd Cert"
 
-#define QNETD_DEFAULT_TLS_SUPPORTED		TLV_TLS_SUPPORTED
-#define QNETD_DEFAULT_TLS_CLIENT_CERT_REQUIRED	1
+#define QNETD_DEFAULT_TLS_SUPPORTED			TLV_TLS_SUPPORTED
+#define QNETD_DEFAULT_TLS_CLIENT_CERT_REQUIRED		1
 
-#define QNETD_DEFAULT_HEARTBEAT_INTERVAL_MIN	(1*1000)
-#define QNETD_DEFAULT_HEARTBEAT_INTERVAL_MAX	(2*60*1000)
-#define QNETD_MIN_HEARTBEAT_INTERVAL		1
+#define QNETD_DEFAULT_HEARTBEAT_INTERVAL_MIN		(1*1000)
+#define QNETD_DEFAULT_HEARTBEAT_INTERVAL_MAX		(2*60*1000)
+#define QNETD_MIN_HEARTBEAT_INTERVAL			1
 
-#define QNETD_DEFAULT_DPD_ENABLED		1
-#define QNETD_DEFAULT_DPD_INTERVAL		(10*1000)
-#define QNETD_MIN_DPD_INTERVAL			1
+#define QNETD_DEFAULT_DPD_ENABLED			1
+#define QNETD_DEFAULT_DPD_INTERVAL			(10*1000)
+#define QNETD_MIN_DPD_INTERVAL				1
 
-#define QNETD_DEFAULT_LOCK_FILE			LOCALSTATEDIR"/run/corosync-qnetd.pid"
-#define QNETD_DEFAULT_LOCAL_SOCKET_FILE		LOCALSTATEDIR"/run/corosync-qnetd.sock"
-#define QNETD_DEFAULT_LOCAL_SOCKET_BACKLOG	10
-#define QNETD_MIN_LOCAL_SOCKET_BACKLOG		1
+#define QNETD_DEFAULT_LOCK_FILE				LOCALSTATEDIR"/run/corosync-qnetd.pid"
+#define QNETD_DEFAULT_LOCAL_SOCKET_FILE			LOCALSTATEDIR"/run/corosync-qnetd.sock"
+#define QNETD_DEFAULT_LOCAL_SOCKET_BACKLOG		10
+#define QNETD_MIN_LOCAL_SOCKET_BACKLOG			1
 
-#define QNETD_DEFAULT_IPC_MAX_CLIENTS		10
-#define QNETD_MIN_IPC_MAX_CLIENTS		0
-#define QNETD_DEFAULT_IPC_MAX_RECEIVE_SIZE	(4*1024)
-#define QNETD_DEFAULT_IPC_MAX_SEND_SIZE		(10*1024*1024)
-#define QNETD_MIN_IPC_RECEIVE_SEND_SIZE		1024
+#define QNETD_DEFAULT_IPC_MAX_CLIENTS			10
+#define QNETD_MIN_IPC_MAX_CLIENTS			0
+#define QNETD_DEFAULT_IPC_MAX_RECEIVE_SIZE		(4*1024)
+#define QNETD_DEFAULT_IPC_MAX_SEND_SIZE			(10*1024*1024)
+#define QNETD_MIN_IPC_RECEIVE_SEND_SIZE			1024
 
-#define QNETD_TOOL_PROGRAM_NAME			"corosync-qnetd-tool"
+#define QNETD_TOOL_PROGRAM_NAME				"corosync-qnetd-tool"
 
-#define QDEVICE_NET_NSS_DB_DIR			COROSYSCONFDIR "/qdevice/net/node/nssdb"
+#define QDEVICE_NET_DEFAULT_NSS_DB_DIR			COROSYSCONFDIR "/qdevice/net/node/nssdb"
 
-#define QDEVICE_NET_INITIAL_MSG_RECEIVE_SIZE	(1 << 15)
-#define QDEVICE_NET_INITIAL_MSG_SEND_SIZE	(1 << 15)
-#define QDEVICE_NET_MIN_MSG_SEND_SIZE		QDEVICE_NET_INITIAL_MSG_SEND_SIZE
-#define QDEVICE_NET_MAX_MSG_RECEIVE_SIZE	(1 << 24)
+#define QDEVICE_NET_DEFAULT_INITIAL_MSG_RECEIVE_SIZE	(1 << 15)
+#define QDEVICE_NET_DEFAULT_INITIAL_MSG_SEND_SIZE	(1 << 15)
+#define QDEVICE_NET_DEFAULT_MIN_MSG_SEND_SIZE		QDEVICE_NET_DEFAULT_INITIAL_MSG_SEND_SIZE
+#define QDEVICE_NET_DEFAULT_MAX_MSG_RECEIVE_SIZE	(1 << 24)
+#define QDEVICE_NET_DEFAULT_MAX_SEND_BUFFERS		10
+#define QDEVICE_NET_MIN_MAX_SEND_BUFFERS		2
+#define QDEVICE_NET_MIN_MSG_RECEIVE_SEND_SIZE		16
 
-#define QDEVICE_NET_NSS_SERVER_CN		"Qnetd Server"
+#define QDEVICE_NET_DEFAULT_NSS_QNETD_CN		"Qnetd Server"
 
-#define QDEVICE_NET_NSS_CLIENT_CERT_NICKNAME	"Cluster Cert"
+#define QDEVICE_NET_DEFAULT_NSS_CLIENT_CERT_NICKNAME	"Cluster Cert"
 
-#define QDEVICE_NET_MAX_SEND_BUFFERS		10
 
-#define QDEVICE_NET_DEFAULT_ALGORITHM		TLV_DECISION_ALGORITHM_TYPE_TEST
+#define QDEVICE_NET_DEFAULT_ALGORITHM			TLV_DECISION_ALGORITHM_TYPE_TEST
 
-#define QDEVICE_NET_DEFAULT_TLS_SUPPORTED	TLV_TLS_SUPPORTED
+#define QDEVICE_NET_DEFAULT_TLS_SUPPORTED		TLV_TLS_SUPPORTED
 
-#define QDEVICE_NET_DEFAULT_TIE_BREAKER_MODE	TLV_TIE_BREAKER_MODE_LOWEST
+#define QDEVICE_NET_DEFAULT_TIE_BREAKER_MODE		TLV_TIE_BREAKER_MODE_LOWEST
 
-#define QDEVICE_NET_HEARTBEAT_INTERVAL_MIN	QNETD_DEFAULT_HEARTBEAT_INTERVAL_MIN
-#define QDEVICE_NET_HEARTBEAT_INTERVAL_MAX	QNETD_DEFAULT_HEARTBEAT_INTERVAL_MAX
+#define QDEVICE_NET_DEFAULT_HEARTBEAT_INTERVAL_MIN	QNETD_DEFAULT_HEARTBEAT_INTERVAL_MIN
+#define QDEVICE_NET_DEFAULT_HEARTBEAT_INTERVAL_MAX	QNETD_DEFAULT_HEARTBEAT_INTERVAL_MAX
+#define QDEVICE_NET_MIN_HEARTBEAT_INTERVAL		1
 
-#define QDEVICE_NET_MIN_CONNECT_TIMEOUT		(1*1000L)
-#define QDEVICE_NET_MAX_CONNECT_TIMEOUT		(2*60*1000L)
+#define QDEVICE_NET_DEFAULT_MIN_CONNECT_TIMEOUT		(1*1000)
+#define QDEVICE_NET_DEFAULT_MAX_CONNECT_TIMEOUT		(2*60*1000)
+#define QDEVICE_NET_MIN_CONNECT_TIMEOUT			1
+
+#ifdef DEBUG
+#define QDEVICE_NET_DEFAULT_TEST_ALGORITHM_ENABLED	1
+#else
+#define QDEVICE_NET_DEFAULT_TEST_ALGORITHM_ENABLED	0
+#endif
+
+#define QDEVICE_NET_DEFAULT_DELAY_BEFORE_RECONNECT	(1000)
+#define QDEVICE_NET_MIN_DELAY_BEFORE_RECONNECT		1
 
 /*
  * Decision algorithms supported by qnetd

+ 7 - 0
qdevices/qnetd-advanced-settings.c

@@ -204,6 +204,13 @@ qnetd_advanced_settings_set(struct qnetd_advanced_settings *settings,
 			return (-2);
 		}
 
+		settings->ipc_max_send_size = (size_t)tmpll;
+	} else if (strcasecmp(option, "ipc_max_send_size") == 0) {
+		tmpll = strtoll(value, &ep, 10);
+		if (tmpll < QNETD_MIN_IPC_RECEIVE_SEND_SIZE || errno != 0 || *ep != '\0') {
+			return (-2);
+		}
+
 		settings->ipc_max_send_size = (size_t)tmpll;
 	} else {
 		return (-1);

+ 1 - 1
qdevices/qnetd-instance.c

@@ -46,7 +46,7 @@
 int
 qnetd_instance_init(struct qnetd_instance *instance,
     enum tlv_tls_supported tls_supported, int tls_client_cert_required, size_t max_clients,
-    struct qnetd_advanced_settings *advanced_settings)
+    const struct qnetd_advanced_settings *advanced_settings)
 {
 
 	memset(instance, 0, sizeof(*instance));

+ 2 - 2
qdevices/qnetd-instance.h

@@ -71,12 +71,12 @@ struct qnetd_instance {
 	struct timer_list_entry *dpd_timer;		/* Dead peer detection timer */
 	struct unix_socket_ipc local_ipc;
 	PRFileDesc *ipc_socket_poll_fd;
-	struct qnetd_advanced_settings *advanced_settings;
+	const struct qnetd_advanced_settings *advanced_settings;
 };
 
 extern int		qnetd_instance_init(struct qnetd_instance *instance,
     enum tlv_tls_supported tls_supported, int tls_client_cert_required, size_t max_clients,
-    struct qnetd_advanced_settings *advanced_settings);
+    const struct qnetd_advanced_settings *advanced_settings);
 
 extern int		qnetd_instance_destroy(struct qnetd_instance *instance);