diff options
Diffstat (limited to 'sbin/hastd/parse.y')
-rw-r--r-- | sbin/hastd/parse.y | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/sbin/hastd/parse.y b/sbin/hastd/parse.y index 04ea7ab..bd0690a 100644 --- a/sbin/hastd/parse.y +++ b/sbin/hastd/parse.y @@ -236,6 +236,7 @@ replication_statement: REPLICATION replication_type case 1: PJDLOG_ASSERT(curres != NULL); curres->hr_replication = $2; + curres->hr_original_replication = $2; break; default: PJDLOG_ABORT("replication at wrong depth level"); @@ -533,8 +534,10 @@ resource_start: STR curres->hr_role = HAST_ROLE_INIT; curres->hr_previous_role = HAST_ROLE_INIT; curres->hr_replication = -1; + curres->hr_original_replication = -1; curres->hr_checksum = -1; curres->hr_compression = -1; + curres->hr_version = 1; curres->hr_timeout = -1; curres->hr_exec[0] = '\0'; curres->hr_provname[0] = '\0'; @@ -724,6 +727,7 @@ static int isitme(const char *name) { char buf[MAXHOSTNAMELEN]; + unsigned long hostid; char *pos; size_t bufsize; @@ -738,7 +742,7 @@ isitme(const char *name) return (1); /* - * Now check if it matches first part of the host name. + * Check if it matches first part of the host name. */ pos = strchr(buf, '.'); if (pos != NULL && (size_t)(pos - buf) == strlen(name) && @@ -747,7 +751,7 @@ isitme(const char *name) } /* - * At the end check if name is equal to our host's UUID. + * Check if it matches host UUID. */ bufsize = sizeof(buf); if (sysctlbyname("kern.hostuuid", buf, &bufsize, NULL, 0) < 0) { @@ -758,6 +762,18 @@ isitme(const char *name) return (1); /* + * Check if it matches hostid. + */ + bufsize = sizeof(hostid); + if (sysctlbyname("kern.hostid", &hostid, &bufsize, NULL, 0) < 0) { + pjdlog_errno(LOG_ERR, "sysctlbyname(kern.hostid) failed"); + return (-1); + } + (void)snprintf(buf, sizeof(buf), "hostid%lu", hostid); + if (strcmp(buf, name) == 0) + return (1); + + /* * Looks like this isn't about us. */ return (0); @@ -769,7 +785,7 @@ family_supported(int family) int sock; sock = socket(family, SOCK_STREAM, 0); - if (sock == -1 && errno == EAFNOSUPPORT) + if (sock == -1 && errno == EPROTONOSUPPORT) return (false); if (sock >= 0) (void)close(sock); @@ -781,6 +797,7 @@ node_names(char **namesp) { static char names[MAXHOSTNAMELEN * 3]; char buf[MAXHOSTNAMELEN]; + unsigned long hostid; char *pos; size_t bufsize; @@ -808,6 +825,16 @@ node_names(char **namesp) return (-1); } (void)strlcat(names, buf, sizeof(names)); + (void)strlcat(names, ", ", sizeof(names)); + + /* Host ID. */ + bufsize = sizeof(hostid); + if (sysctlbyname("kern.hostid", &hostid, &bufsize, NULL, 0) < 0) { + pjdlog_errno(LOG_ERR, "sysctlbyname(kern.hostid) failed"); + return (-1); + } + (void)snprintf(buf, sizeof(buf), "hostid%lu", hostid); + (void)strlcat(names, buf, sizeof(names)); *namesp = names; @@ -833,7 +860,7 @@ yy_config_parse(const char *config, bool exitonerror) lineno = 0; depth0_timeout = HAST_TIMEOUT; - depth0_replication = HAST_REPLICATION_FULLSYNC; + depth0_replication = HAST_REPLICATION_MEMSYNC; depth0_checksum = HAST_CHECKSUM_NONE; depth0_compression = HAST_COMPRESSION_HOLE; strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control)); @@ -943,11 +970,7 @@ yy_config_parse(const char *config, bool exitonerror) * Use global or default setting. */ curres->hr_replication = depth0_replication; - } - if (curres->hr_replication == HAST_REPLICATION_MEMSYNC) { - pjdlog_warning("Replication mode \"%s\" is not implemented, falling back to \"%s\".", - "memsync", "fullsync"); - curres->hr_replication = HAST_REPLICATION_FULLSYNC; + curres->hr_original_replication = depth0_replication; } if (curres->hr_checksum == -1) { /* |