Kaynağa Gözat

config: Fix crash in reload if new interfaces are added

This is a bug I seem to have introduced in
429209f4aa3c55504a49833e0004489f241e7819 where we compare links
for changes. if a new node was added on an existing link then it
was compared against a non-existant one in the previous configuration.
We now only compare nodes that are in both interfaces.

As I needed min() for this function, I moved it from individual
.c files into util.h so we only have one copy.

And the error message was fixed.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Christine Caulfield 7 yıl önce
ebeveyn
işleme
9f2d5a3a3f
4 değiştirilmiş dosya ile 4 ekleme ve 6 silme
  1. 2 2
      exec/totemconfig.c
  2. 1 2
      exec/totempg.c
  3. 0 2
      exec/util.c
  4. 1 0
      exec/util.h

+ 2 - 2
exec/totemconfig.c

@@ -1137,7 +1137,7 @@ static void check_things_have_not_changed(struct totem_config *totem_config)
 				log_printf(LOGSYS_LEVEL_ERROR, "New config has different knet transport for link %d. Internal value was NOT changed.\n", i);
 				log_printf(LOGSYS_LEVEL_ERROR, "New config has different knet transport for link %d. Internal value was NOT changed.\n", i);
 				changed = 1;
 				changed = 1;
 			}
 			}
-			for (j=0; j<totem_config->interfaces[i].member_count; j++) {
+			for (j=0; j < min(totem_config->interfaces[i].member_count, totem_config->orig_interfaces[i].member_count); j++) {
 				if (memcmp(&totem_config->interfaces[i].member_list[j],
 				if (memcmp(&totem_config->interfaces[i].member_list[j],
 					   &totem_config->orig_interfaces[i].member_list[j],
 					   &totem_config->orig_interfaces[i].member_list[j],
 					   sizeof(struct totem_ip_address))) {
 					   sizeof(struct totem_ip_address))) {
@@ -1152,7 +1152,7 @@ static void check_things_have_not_changed(struct totem_config *totem_config)
 	}
 	}
 
 
 	if (changed) {
 	if (changed) {
-		log_printf(LOGSYS_LEVEL_ERROR, "To reconfigure and interface it must be deleted and recreated. A working interface needs to be available to corosync at all times");
+		log_printf(LOGSYS_LEVEL_ERROR, "To reconfigure an interface it must be deleted and recreated. A working interface needs to be available to corosync at all times");
 	}
 	}
 }
 }
 
 

+ 1 - 2
exec/totempg.c

@@ -108,10 +108,9 @@
 #define LOGSYS_UTILS_ONLY 1
 #define LOGSYS_UTILS_ONLY 1
 #include <corosync/logsys.h>
 #include <corosync/logsys.h>
 
 
+#include "util.h"
 #include "totemsrp.h"
 #include "totemsrp.h"
 
 
-#define min(a,b) ((a) < (b)) ? a : b
-
 struct totempg_mcast_header {
 struct totempg_mcast_header {
 	short version;
 	short version;
 	short type;
 	short type;

+ 0 - 2
exec/util.c

@@ -136,8 +136,6 @@ void _corosync_exit_error (
 	exit (err);
 	exit (err);
 }
 }
 
 
-#define min(a,b) ((a) < (b) ? (a) : (b))
-
 char *getcs_name_t (cs_name_t *name)
 char *getcs_name_t (cs_name_t *name)
 {
 {
 	static char ret_name[CS_MAX_NAME_LENGTH];
 	static char ret_name[CS_MAX_NAME_LENGTH];

+ 1 - 0
exec/util.h

@@ -63,6 +63,7 @@ enum e_corosync_done {
 	COROSYNC_DONE_PLOAD = 99
 	COROSYNC_DONE_PLOAD = 99
 };
 };
 
 
+#define min(a,b) ((a) < (b) ? (a) : (b))
 
 
 /**
 /**
  * Compare two names.  returns non-zero on match.
  * Compare two names.  returns non-zero on match.