aboutsummaryrefslogtreecommitdiffstats
path: root/src/charon/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/charon/plugins')
-rw-r--r--src/charon/plugins/ha/ha_plugin.c28
-rw-r--r--src/charon/plugins/ha/ha_segments.c26
-rw-r--r--src/charon/plugins/ha/ha_segments.h8
3 files changed, 35 insertions, 27 deletions
diff --git a/src/charon/plugins/ha/ha_plugin.c b/src/charon/plugins/ha/ha_plugin.c
index fb780cab2..661db8af8 100644
--- a/src/charon/plugins/ha/ha_plugin.c
+++ b/src/charon/plugins/ha/ha_plugin.c
@@ -105,7 +105,7 @@ plugin_t *plugin_create()
private_ha_plugin_t *this;
char *local, *remote, *secret;
u_int count;
- bool fifo;
+ bool fifo, monitor, resync;
local = lib->settings->get_str(lib->settings,
"charon.plugins.ha.local", NULL);
@@ -114,7 +114,11 @@ plugin_t *plugin_create()
secret = lib->settings->get_str(lib->settings,
"charon.plugins.ha.secret", NULL);
fifo = lib->settings->get_bool(lib->settings,
- "charon.plugins.ha.fifo_interface", FALSE);
+ "charon.plugins.ha.fifo_interface", TRUE);
+ monitor = lib->settings->get_bool(lib->settings,
+ "charon.plugins.ha.monitor", TRUE);
+ resync = lib->settings->get_bool(lib->settings,
+ "charon.plugins.ha.resync", TRUE);
count = min(SEGMENTS_MAX, lib->settings->get_int(lib->settings,
"charon.plugins.ha.segment_count", 1));
if (!local || !remote)
@@ -129,26 +133,20 @@ plugin_t *plugin_create()
this->tunnel = NULL;
this->ctl = NULL;
+ if (secret)
+ {
+ this->tunnel = ha_tunnel_create(local, remote, secret);
+ }
this->socket = ha_socket_create(local, remote);
if (!this->socket)
{
+ DESTROY_IF(this->tunnel);
free(this);
return NULL;
}
this->kernel = ha_kernel_create(count);
- if (!this->kernel)
- {
- this->socket->destroy(this->socket);
- free(this);
- return NULL;
- }
-
- if (secret)
- {
- this->tunnel = ha_tunnel_create(local, remote, secret);
- }
- this->segments = ha_segments_create(this->socket, this->kernel,
- this->tunnel, local, remote, count);
+ this->segments = ha_segments_create(this->socket, this->kernel, this->tunnel,
+ count, strcmp(local, remote) > 0, monitor, resync);
if (fifo)
{
this->ctl = ha_ctl_create(this->segments);
diff --git a/src/charon/plugins/ha/ha_segments.c b/src/charon/plugins/ha/ha_segments.c
index c82bd0723..3575d05b8 100644
--- a/src/charon/plugins/ha/ha_segments.c
+++ b/src/charon/plugins/ha/ha_segments.c
@@ -77,9 +77,9 @@ struct private_ha_segments_t {
segment_mask_t active;
/**
- * Are we the master node handling segment assignement?
+ * Node number
*/
- bool master;
+ u_int node;
};
/**
@@ -388,7 +388,7 @@ static void handle_status(private_ha_segments_t *this, segment_mask_t mask)
{
if (missing & SEGMENTS_BIT(i))
{
- if (this->master != i % 2)
+ if (this->node == i % 2)
{
DBG1(DBG_CFG, "HA segment %d was not handled, taking", i);
enable_disable(this, i, TRUE, TRUE);
@@ -458,7 +458,8 @@ static void destroy(private_ha_segments_t *this)
* See header
*/
ha_segments_t *ha_segments_create(ha_socket_t *socket, ha_kernel_t *kernel,
- ha_tunnel_t *tunnel, char *local, char *remote, u_int count)
+ ha_tunnel_t *tunnel, u_int count, u_int node,
+ bool monitor, bool sync)
{
private_ha_segments_t *this = malloc_thing(private_ha_segments_t);
@@ -476,20 +477,25 @@ ha_segments_t *ha_segments_create(ha_socket_t *socket, ha_kernel_t *kernel,
this->mutex = mutex_create(MUTEX_TYPE_DEFAULT);
this->condvar = condvar_create(CONDVAR_TYPE_DEFAULT);
this->count = count;
- this->master = strcmp(local, remote) > 0;
+ this->node = node;
this->job = NULL;
/* initially all segments are deactivated */
this->active = 0;
- send_status(this);
-
- start_watchdog(this);
+ if (monitor)
+ {
+ send_status(this);
+ start_watchdog(this);
+ }
- /* request a resync as soon as we are up */
- charon->processor->queue_job(charon->processor, (job_t*)
+ if (sync)
+ {
+ /* request a resync as soon as we are up */
+ charon->processor->queue_job(charon->processor, (job_t*)
callback_job_create((callback_job_cb_t)request_resync,
this, NULL, NULL));
+ }
return &this->public;
}
diff --git a/src/charon/plugins/ha/ha_segments.h b/src/charon/plugins/ha/ha_segments.h
index 6e5a0dbc8..6d1cd5441 100644
--- a/src/charon/plugins/ha/ha_segments.h
+++ b/src/charon/plugins/ha/ha_segments.h
@@ -97,11 +97,15 @@ struct ha_segments_t {
*
* @param socket socket to communicate segment (de-)activation
* @param kernel interface to control segments at kernel level
+ * @param tunnel HA tunnel
* @param count number of segments the cluster uses
- * @param active bit mask of initially active segments
+ * @param node node, currently 1 or 0
+ * @param monitor should we use monitoring functionality
+ * @param resync request a complete resync on startup
* @return segment object
*/
ha_segments_t *ha_segments_create(ha_socket_t *socket, ha_kernel_t *kernel,
- ha_tunnel_t *tunnel, char *local, char *remote, u_int count);
+ ha_tunnel_t *tunnel, u_int count, u_int node,
+ bool monitor, bool resync);
#endif /* HA_SEGMENTS_ @}*/