2 CTDB cluster config handling
4 Copyright (C) Martin Schwenke 2018
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "system/network.h"
23 #include "lib/util/debug.h"
25 #include "common/conf.h"
27 #include "cluster_conf.h"
29 #define CLUSTER_TRANSPORT_DEFAULT "tcp"
32 * Ideally this wants to be a void function but it also used directly
33 * as a validation function
35 static bool check_static_string_change(const char *key,
36 const char *old_value,
37 const char *new_value,
38 enum conf_update_mode mode)
40 if (mode == CONF_MODE_RELOAD) {
41 if (strcmp(old_value, new_value) != 0) {
42 D_WARNING("Ignoring update of [%s] -> %s\n",
51 static bool validate_transport(const char *key,
52 const char *old_transport,
53 const char *new_transport,
54 enum conf_update_mode mode)
56 /* Don't allow "ib" for now. It is broken! */
57 if (strcmp(new_transport, CLUSTER_TRANSPORT_DEFAULT) != 0) {
58 D_ERR("Invalid value for [cluster] -> transport = %s\n",
63 /* This sometimes warns but always returns true */
64 return check_static_string_change(key,
70 static bool validate_node_address(const char *key,
71 const char *old_node_address,
72 const char *new_node_address,
73 enum conf_update_mode mode)
76 struct in6_addr addr6;
79 if (new_node_address == NULL) {
83 ret = inet_pton(AF_INET, new_node_address, &addr4);
88 ret = inet_pton(AF_INET6, new_node_address, &addr6);
93 D_ERR("Invalid value for [cluster] -> node address = %s\n",
98 /* This sometimes warns but always returns true */
99 return check_static_string_change(key,
105 void cluster_conf_init(struct conf_context *conf)
107 conf_define_section(conf, CLUSTER_CONF_SECTION, NULL);
109 conf_define_string(conf,
110 CLUSTER_CONF_SECTION,
111 CLUSTER_CONF_TRANSPORT,
112 CLUSTER_TRANSPORT_DEFAULT,
114 conf_define_string(conf,
115 CLUSTER_CONF_SECTION,
116 CLUSTER_CONF_NODE_ADDRESS,
118 validate_node_address);
119 conf_define_string(conf,
120 CLUSTER_CONF_SECTION,
121 CLUSTER_CONF_RECOVERY_LOCK,
123 check_static_string_change);