[prev in list] [next in list] [prev in thread] [next in thread] 

List:       keepalived-devel
Subject:    [Keepalived-devel] Checking configuration
From:       Vincent Bernat <bernat () luffy ! cx>
Date:       2009-06-04 16:02:59
Message-ID: 787ff1c730a8238e99fb11d70a1fdc3d () chopper ! luffy ! cx
[Download RAW message or body]

Hi!

Keepalived parser seems to be a long time issue. For example, if
"sorry_server" keyword is used without specifying the port, healthchecker
processus will segfault. One solution would be to have a more robust
parser. Another solution would be to have an external configuration
checker. Here is a simple patch changing the way the "-d" option works.
Instead of dumping the configuration and then running keepalived, it will
dump the configuration and not run keepalived.

This is not a very elegant patch but it works.


[Attachment #3 (text/plain)]

"-d" switch dumps configuration on stderr without really starting keepalived.

diff -Naur keepalived-1.1.15/keepalived/check/check_daemon.c \
                keepalived-1.1.15.new/keepalived/check/check_daemon.c
--- keepalived-1.1.15/keepalived/check/check_daemon.c	2007-09-14 17:19:14.000000000 \
                +0200
+++ keepalived-1.1.15.new/keepalived/check/check_daemon.c	2008-12-24 \
15:59:44.000000000 +0100 @@ -79,7 +79,9 @@
 start_check(void)
 {
 	/* Initialize sub-system */
-	ipvs_start();
+	if (!(debug & 4)) {
+		ipvs_start();
+	}
 	init_checkers_queue();
 #ifdef _WITH_VRRP_
 	init_interface_queue();
@@ -91,33 +93,35 @@
 	check_data = alloc_check_data();
 	init_data(conf_file, check_init_keywords);
 	if (!check_data) {
-		stop_check();
+		if (!(debug & 4)) stop_check();
 		return;
 	}
 
 	/* Post initializations */
 	syslog(LOG_INFO, "Configuration is using : %lu Bytes", mem_allocated);
 
-	/* SSL load static data & initialize common ctx context */
-	if (!init_ssl_ctx()) {
-		stop_check();
-		return;
-	}
-
-	/* Processing differential configuration parsing */
-	if (reload)
-		clear_diff_services();
-
-	/* Initialize IPVS topology */
-	if (!init_services()) {
-		stop_check();
-		return;
-	}
+	if (!(debug & 4)) {
 
+		/* SSL load static data & initialize common ctx context */
+		if (!init_ssl_ctx()) {
+			stop_check();
+			return;
+		}
+		
+		/* Processing differential configuration parsing */
+		if (reload)
+			clear_diff_services();
+		
+		/* Initialize IPVS topology */
+		if (!init_services()) {
+			stop_check();
+			return;
+		}
+	} else {
 	/* Dump configuration */
-	if (debug & 4) {
 		dump_global_data(data);
 		dump_check_data(check_data);
+		return;
 	}
 
 	/* Register checkers thread */
@@ -215,6 +219,12 @@
 {
 	pid_t pid;
 
+	if (debug & 4) {
+		// thread_destroy_master(master);
+		master = thread_make_master();
+		start_check();
+		return;
+	}
 	/* Dont start if pid is already running */
 	if (checkers_running()) {
 		syslog(LOG_INFO, "Healthcheck child process already running");
diff -Naur keepalived-1.1.15/keepalived/core/main.c \
                keepalived-1.1.15.new/keepalived/core/main.c
--- keepalived-1.1.15/keepalived/core/main.c	2007-09-14 17:20:28.000000000 +0200
+++ keepalived-1.1.15.new/keepalived/core/main.c	2008-12-24 16:00:45.000000000 +0100
@@ -287,46 +287,51 @@
 	 */
 	parse_cmdline(argc, argv);
 
-	openlog(PROG, LOG_PID | (debug & 1) ? LOG_CONS : 0, log_facility);
+	openlog(PROG, ((debug & 4) ? 0 : LOG_PID) | ((debug & 1) ? LOG_CONS : 0) | ((debug \
& 4) ? LOG_PERROR : 0), log_facility);  syslog(LOG_INFO, "Starting " VERSION_STRING);
 
 	/* Check if keepalived is already running */
-	if (keepalived_running(daemon_mode)) {
-		syslog(LOG_INFO, "daemon is already running");
-		goto end;
-	}
+	if (!(debug & 4))
+		if (keepalived_running(daemon_mode)) {
+			syslog(LOG_INFO, "daemon is already running");
+			goto end;
+		}
 
 	/* daemonize process */
-	if (!(debug & 2))
+	if (!(debug & 2) && !(debug & 4))
 		xdaemon(0, 0, 0);
 
 	/* write the pidfile */
-	if (daemon_mode == 3 || !daemon_mode) {
-		if (!pidfile_write(KEEPALIVED_PID_FILE, getpid()))
-			goto end;
-	} else {
-		if (!pidfile_write((daemon_mode & 1) ? KEEPALIVED_VRRP_PID_FILE :
-				    KEEPALIVED_CHECKERS_PID_FILE, getpid()))
-			goto end;
-	}
+	if (!(debug & 4)) {
+		if (daemon_mode == 3 || !daemon_mode) {
+			if (!pidfile_write(KEEPALIVED_PID_FILE, getpid()))
+				goto end;
+		} else {
+			if (!pidfile_write((daemon_mode & 1) ? KEEPALIVED_VRRP_PID_FILE :
+					   KEEPALIVED_CHECKERS_PID_FILE, getpid()))
+				goto end;
+		}
 
 #ifndef _DEBUG_
-	/* Signal handling initialization  */
-	signal_init();
+		/* Signal handling initialization  */
+		signal_init();
 #endif
 
-	/* Create the master thread */
-	master = thread_make_master();
+		/* Create the master thread */
+		master = thread_make_master();
+	}
 
 	/* Init daemon */
 	start_keepalived();
 
 #ifndef _DEBUG_
-	/* Launch the scheduling I/O multiplexer */
-	launch_scheduler();
-
-	/* Finish daemon process */
-	stop_keepalived();
+	if (!(debug & 4)) {
+		/* Launch the scheduling I/O multiplexer */
+		launch_scheduler();
+		
+		/* Finish daemon process */
+		stop_keepalived();
+	}
 #endif
 
 	/*
diff -Naur keepalived-1.1.15/keepalived/vrrp/vrrp_daemon.c \
                keepalived-1.1.15.new/keepalived/vrrp/vrrp_daemon.c
--- keepalived-1.1.15/keepalived/vrrp/vrrp_daemon.c	2007-09-14 17:20:57.000000000 \
                +0200
+++ keepalived-1.1.15.new/keepalived/vrrp/vrrp_daemon.c	2008-12-24 16:09:20.000000000 \
+0100 @@ -89,49 +89,55 @@
 static void
 start_vrrp(void)
 {
-	/* Initialize sub-system */
 	init_interface_queue();
 	kernel_netlink_init();
-	gratuitous_arp_init();
+	if (!(debug & 4)) {
+                /* Initialize sub-system */
+                gratuitous_arp_init();
 
 #ifdef _WITH_LVS_
-	/* Initialize ipvs related */
-	ipvs_start();
+                /* Initialize ipvs related */
+                ipvs_start();
 #endif
+        }
+
 	/* Parse configuration file */
 	data = alloc_global_data();
 	vrrp_data = alloc_vrrp_data();
 	alloc_vrrp_buffer();
 	init_data(conf_file, vrrp_init_keywords);
 	if (!vrrp_data) {
-		stop_vrrp();
+		if (!(debug & 4)) stop_vrrp();
 		return;
 	}
 
-	if (reload) {
-		clear_diff_saddresses();
-		clear_diff_sroutes();
-		clear_diff_vrrp();
-		clear_diff_script();
-	}
-
-	/* Complete VRRP initialization */
-	if (!vrrp_complete_init()) {
-		stop_vrrp();
-		return;
-	}
+        if (!(debug & 4)) {
+                if (reload) {
+                        clear_diff_saddresses();
+                        clear_diff_sroutes();
+                        clear_diff_vrrp();
+                        clear_diff_script();
+                }
+
+                /* Complete VRRP initialization */
+                if (!vrrp_complete_init()) {
+                        stop_vrrp();
+                        return;
+                }
+        }
 
 	/* Post initializations */
 	syslog(LOG_INFO, "Configuration is using : %lu Bytes", mem_allocated);
 
-	/* Set static entries */
-	netlink_iplist_ipv4(vrrp_data->static_addresses, IPADDRESS_ADD);
-	netlink_rtlist_ipv4(vrrp_data->static_routes, IPROUTE_ADD);
-
+        if (!(debug & 4)) {
+                /* Set static entries */
+                netlink_iplist_ipv4(vrrp_data->static_addresses, IPADDRESS_ADD);
+                netlink_rtlist_ipv4(vrrp_data->static_routes, IPROUTE_ADD);
+        } else {
 	/* Dump configuration */
-	if (debug & 4) {
 		dump_global_data(data);
 		dump_vrrp_data(vrrp_data);
+                return;
 	}
 
 	/* Init & start the VRRP packet dispatcher */
@@ -233,6 +239,13 @@
 	pid_t pid;
 #endif
 
+        if (debug & 4) {
+                // thread_destroy_master(master);
+                master = thread_make_master();
+                start_vrrp();
+                return;
+        }
+
 	/* Dont start if pid is already running */
 	if (vrrp_running()) {
 		syslog(LOG_INFO, "VRRP child process already running");



------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises 
looking to deploy the next generation of Solaris that includes the latest 
innovations from Sun and the OpenSource community. Download a copy and 
enjoy capabilities such as Networking, Storage and Virtualization. 
Go to: http://p.sf.net/sfu/opensolaris-get

_______________________________________________
Keepalived-devel mailing list
Keepalived-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/keepalived-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic