From 7a273b8714da400d292d6c9762acedcde1997e52 Mon Sep 17 00:00:00 2001 From: David Windsor Date: May 14 2019 17:16:45 +0000 Subject: dlm_controld: bind to all interfaces for failover Support for automatic failover in the face of network interruptions is being added to the DLM kernel component. [1] This patch aids in that effort by adding a mechanism whereby userspace can convey to the kernel its intention to use all network addresses for automatic failover. DLM's current default behavior is to bind to only a single interface. When --bind_all is set, dlm_controld will write to a configfs node that alerts the kernel of its intention to use all local network addresses for automatic failover. When selecting the next address to bind to, DLM will iterate through its list of local network addresses in a round-robin fashion. Support for other address selection heuritics may be added in the future. It is important to understand that, per the DLM spec, while DLM can use a set of addresses for automatic failover, only one address is considered the active address between two DLM nodes at a time. This patch does not violate that constraint. [1] https://www.redhat.com/archives/cluster-devel/2019-January/msg00009.html Signed-off-by: David Windsor --- diff --git a/dlm_controld/action.c b/dlm_controld/action.c index 84637f1..ecd0d02 100644 --- a/dlm_controld/action.c +++ b/dlm_controld/action.c @@ -662,6 +662,25 @@ int add_configfs_node(int nodeid, char *addr, int addrlen, int local) return -1; } close(fd); + + if (opt(bind_all_ind)) { + memset(path, 0, PATH_MAX); + snprintf(path, PATH_MAX, "%s/%d/bind_all", COMMS_DIR, nodeid); + + fd = open(path, O_WRONLY); + if (fd < 0) { + log_error("%s: open failed: %d", path, errno); + return -1; + } + + rv = do_write(fd, (void *)"1", strlen("1")); + if (rv < 0) { + log_error("%s: write failed: %d", path, errno); + close(fd); + return -1; + } + close(fd); + } out: return 0; } diff --git a/dlm_controld/dlm.conf.5 b/dlm_controld/dlm.conf.5 index 616b60d..0949217 100644 --- a/dlm_controld/dlm.conf.5 +++ b/dlm_controld/dlm.conf.5 @@ -38,6 +38,8 @@ log_debug .br protocol .br +bind_all +.br debug_logfile .br enable_plock diff --git a/dlm_controld/dlm_daemon.h b/dlm_controld/dlm_daemon.h index 1182c97..3221e19 100644 --- a/dlm_controld/dlm_daemon.h +++ b/dlm_controld/dlm_daemon.h @@ -95,6 +95,7 @@ enum { timewarn_ind, protocol_ind, debug_logfile_ind, + bind_all_ind, enable_fscontrol_ind, enable_plock_ind, plock_debug_ind, diff --git a/dlm_controld/main.c b/dlm_controld/main.c index 1b60ccd..8be6a4b 100644 --- a/dlm_controld/main.c +++ b/dlm_controld/main.c @@ -1727,6 +1727,11 @@ static void set_opt_defaults(void) -1, "detect", "dlm kernel lowcomms protocol: tcp, sctp, detect"); + set_opt_default(bind_all_ind, + "bind_all", '\0', req_arg_int, + 0, NULL, + ""); /* do not advertise */ + set_opt_default(debug_logfile_ind, "debug_logfile", 'L', no_arg, 0, NULL,