Blob Blame History Raw
From 70bd35fc06e68a010d780dfa39bd68d4bd2f7da7 Mon Sep 17 00:00:00 2001
From: Jan Friesse <jfriesse@redhat.com>
Date: Mon, 24 Nov 2014 10:32:03 +0100
Subject: [PATCH] config: Process broadcast option consistently

Broadcast option is global but in config set in interface section. When
more interfaces are defined, only broadcast from last section was used.

Solution is to use broadcast whenever at least one interface use
broadcast.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
---
 exec/totemconfig.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/exec/totemconfig.c b/exec/totemconfig.c
index 3bcf49d..9cb9b07 100644
--- a/exec/totemconfig.c
+++ b/exec/totemconfig.c
@@ -812,6 +812,12 @@ extern int totem_config_read (
 		free(str);
 	}
 
+	/*
+	 * Broadcast option is global but set in interface section,
+	 * so reset before processing interfaces.
+	 */
+	totem_config->broadcast_use = 0;
+
 	iter = icmap_iter_init("totem.interface.");
 	while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
 		res = sscanf(iter_key, "totem.interface.%[^.].%s", ringnumber_key, tmp_key);
@@ -866,14 +872,10 @@ extern int totem_config_read (
 					&totem_config->interfaces[ringnumber].mcast_addr);
 		}
 
-		totem_config->broadcast_use = 0;
 		snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.broadcast", ringnumber);
 		if (icmap_get_string(tmp_key, &str) == CS_OK) {
 			if (strcmp (str, "yes") == 0) {
 				totem_config->broadcast_use = 1;
-				totemip_parse (
-					&totem_config->interfaces[ringnumber].mcast_addr,
-					"255.255.255.255", totem_config->ip_version);
 			}
 			free(str);
 		}
@@ -927,6 +929,16 @@ extern int totem_config_read (
 	icmap_iter_finalize(iter);
 
 	/*
+	 * Use broadcast is global, so if set, make sure to fill mcast addr correctly
+	 */
+	if (totem_config->broadcast_use) {
+		for (ringnumber = 0; ringnumber < totem_config->interface_count; ringnumber++) {
+			totemip_parse (&totem_config->interfaces[ringnumber].mcast_addr,
+				"255.255.255.255", 0);
+		}
+	}
+
+	/*
 	 * Store automatically generated items back to icmap
 	 */
 	for (i = 0; i < totem_config->interface_count; i++) {
-- 
1.7.1