Răsfoiți Sursa

config: Enforce use of 'name' node attribute in multi-link clusters

If the local host does not have a 'name' attribute and the cluster
has more than one link then fail the validation test.

I'm open to the idea of checking all of the nodes in the nodelist
if necessary. It seems overkill as each node will check its own
entry though.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Christine Caulfield 7 ani în urmă
părinte
comite
d1db8c2851
1 a modificat fișierele cu 23 adăugiri și 0 ștergeri
  1. 23 0
      exec/totemconfig.c

+ 23 - 0
exec/totemconfig.c

@@ -305,6 +305,9 @@ static int totem_volatile_config_validate (
 {
 	static char local_error_reason[512];
 	const char *error_reason = local_error_reason;
+	char name_key[ICMAP_KEYNAME_MAXLEN];
+	char *name_str;
+	int i, num_configured;
 
 	if (totem_config->max_network_delay < MINIMUM_TIMEOUT) {
 		snprintf (local_error_reason, sizeof(local_error_reason),
@@ -369,6 +372,26 @@ static int totem_volatile_config_validate (
 		goto parse_error;
 	}
 
+	/* Check that we have nodelist 'name' if there is more than one link */
+	num_configured = 0;
+	for (i = 0; i < INTERFACE_MAX; i++) {
+		if (totem_config->interfaces[i].configured) {
+			num_configured++;
+		}
+	}
+
+	if (num_configured > 1) {
+		for (i=0; i<totem_config->interfaces[0].member_count; i++) {
+			snprintf(name_key, sizeof(name_key), "nodelist.node.%d.name", i);
+
+			if (icmap_get_string(name_key, &name_str) != CS_OK) {
+				snprintf (local_error_reason, sizeof(local_error_reason),
+					  "for a multi-link configuration, all nodes must have a 'name' attribute");
+				goto parse_error;
+			}
+		}
+	}
+
 	return 0;
 
 parse_error: