* keepalived-1.1.9 released.
* VRRP : Chris Caputo, <ccaputo@alt.net> updated keepalived manpage
for nopreempt and preempt_delay.
* VRRP : Fixed an issue while releasing vrrp socket pool... Just
release pool one time !
* VRRP : Fixed netlink framework to properly save netlink socket flags
while setting blocking flags.
* VRRP : Fixed a regression introduced with previous release while
hashing vrrp fd bucket into fd hash index.
* Patrick Boutilier, <boutilpj@ednet.ns.ca> fixed an issue in the
extract_html function. Read the full html header.
* Chris Caputo, <ccaputo@alt.net> and I fixed compilation issue
while using --enable-debug configuration option.
* Extended both VRRP and Healthchecker framework to support
debugging flags.
* Removed the watchdog framework. Since scheduling framework
support child, we register a child thread for both process
VRRP & Healthcheck. When child die or stop prematuraly this
launch scheduling callback previously registered. Watchdog
is now handled by signaling.
(credit goes to Kevin Lindsay, <kevinl@netnation.com> for nice
idea).
* Some cosmetics cleanup.
+2005-02-07 Alexandre Cassen <acassen@linux-vs.org>
+ * keepalived-1.1.9 released.
+ * VRRP : Chris Caputo, <ccaputo@alt.net> updated keepalived manpage
+ for nopreempt and preempt_delay.
+ * VRRP : Fixed an issue while releasing vrrp socket pool... Just
+ release pool one time !
+ * VRRP : Fixed netlink framework to properly save netlink socket flags
+ while setting blocking flags.
+ * VRRP : Fixed a regression introduced with previous release while
+ hashing vrrp fd bucket into fd hash index.
+ * Patrick Boutilier, <boutilpj@ednet.ns.ca> fixed an issue in the
+ extract_html function. Read the full html header.
+ * Chris Caputo, <ccaputo@alt.net> and I fixed compilation issue
+ while using --enable-debug configuration option.
+ * Extended both VRRP and Healthchecker framework to support
+ debugging flags.
+ * Removed the watchdog framework. Since scheduling framework
+ support child, we register a child thread for both process
+ VRRP & Healthcheck. When child die or stop prematuraly this
+ launch scheduling callback previously registered. Watchdog
+ is now handled by signaling.
+ (credit goes to Kevin Lindsay, <kevinl@netnation.com> for nice
+ idea).
+ * Some cosmetics cleanup.
+
2005-01-25 Alexandre Cassen <acassen@linux-vs.org>
* keepalived-1.1.8 released.
* VRRP : Chris Caputo, <ccaputo@alt.net> added "dont_track_primary"
+keepalived (1.1.9) unstable; urgency=low
+
+ * Cf ChangeLog
+
+ -- Alexandre Cassen <acassen@linux-vs.org> Tue, 07 Feb 2005 03:17:15 +0200
+
keepalived (1.1.8) unstable; urgency=low
* Cf ChangeLog
192.168.111.0/24 dev eth2\r
192.168.112.0/24 via 192.168.100.254\r
}\r
- \r
- #VRRP will normally preempt a backup when the\r
- #original master comes back on line.\r
- #nopreempt allows the backup to maintain the\r
- #master role.\r
+\r
+ # VRRP will normally preempt a lower priority\r
+ # machine when a higher priority machine comes\r
+ # online. "nopreempt" allows the lower priority\r
+ # machine to maintain the master role, even when\r
+ # a higher priority machine comes back online.\r
+ # NOTE: For this to work, the initial state of this\r
+ # entry must be BACKUP.\r
nopreempt\r
\r
+ # Seconds after startup until preemption\r
+ # (if not disabled by "nopreempt").\r
+ # Range: 0 (default) to 1,000\r
+ # NOTE: For this to work, the initial state of this\r
+ # entry must be BACKUP.\r
+ preempt_delay 300 # waits 5 minutes\r
+\r
# Debug level, not implemented yet.\r
debug\r
\r
%setup -q
%build
+export CFLAGS=-D__KERNGLUE__
./configure --prefix=%{buildroot} --exec-prefix=%{buildroot} --sysconfdir=%{buildroot}/etc
make
for i in $(SUBDIRS); do \
$(MAKE) -C $$i || exit 1; done && \
echo "Building $(BIN)/$(EXEC)" && \
- $(CC) -o $(BIN)/$(EXEC) `find $(SUBDIRS) ../lib -name '*.[oa]'` $(LDFLAGS)
+ $(CC) -o $(BIN)/$(EXEC) `find $(SUBDIRS) ../lib -name '*.[oa]'` $(LDFLAGS) -ggdb
@echo ""
@echo "Make complete"
../include/check_parser.h ../include/check_data.h ../include/check_api.h \
../include/global_data.h ../include/ipwrapper.h ../include/ipwrapper.h \
../include/pidfile.h ../include/daemon.h ../../lib/list.h ../../lib/memory.h \
- ../../lib/parser.h ../../lib/watchdog.h ../include/vrrp_netlink.h \
+ ../../lib/parser.h ../include/vrrp_netlink.h \
../include/vrrp_if.h
check_data.o: check_data.c ../include/check_data.h \
../include/check_api.h ../../lib/memory.h ../../lib/utils.h
*
* Part: Checkers registration.
*
- * Version: $Id: check_api.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_api.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Healthcheckrs child process handling.
*
- * Version: $Id: check_daemon.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_daemon.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
#include "main.h"
#include "memory.h"
#include "parser.h"
-#include "watchdog.h"
#include "vrrp_netlink.h"
#include "vrrp_if.h"
-/* Global vars */
-static int check_wdog_sd = -1;
-
-/* Healthchecker watchdog data */
-static wdog_data check_wdog_data = {
- "Healthcheck Child",
- WDOG_CHECK,
- -1,
- -1,
- start_check_child
-};
-
/* Daemon stop sequence */
static void
stop_check(void)
keepalived_free_final("Healthcheck child process");
#endif
- /* free watchdog sd */
- wdog_close(check_wdog_sd, WDOG_CHECK);
-
/*
* Reached when terminate signal catched.
* finally return to parent process.
dump_check_data(check_data);
}
- /* Register healthcheckers software watchdog */
- check_wdog_sd = wdog_init(WDOG_CHECK);
-
/* Register checkers thread */
register_checkers_thread();
}
free_ssl();
ipvs_stop();
- /* free watchdog sd */
- wdog_close(check_wdog_sd, WDOG_CHECK);
-
/* Save previous conf data */
old_check_data = check_data;
check_data = NULL;
void
sighup_check(int sig)
{
- syslog(LOG_INFO, "Reloading Healthchecker child process on signal");
+ syslog(LOG_INFO, "Reloading Healthchecker child processi(%d) on signal",
+ checkers_child);
thread_add_event(master, reload_check_thread, NULL, 0);
}
signal_noignore_sigchld();
}
+/* CHECK Child respawning thread */
+int
+check_respawn_thread(thread * thread)
+{
+ pid_t pid;
+
+ /* Fetch thread args */
+ pid = THREAD_CHILD_PID(thread);
+
+ /* Restart respawning thread */
+ if (thread->type == THREAD_CHILD_TIMEOUT) {
+ thread_add_child(master, check_respawn_thread, NULL,
+ pid, RESPAWN_TIMER);
+ return 0;
+ }
+
+ /* We catch a SIGCHLD, handle it */
+ syslog(LOG_INFO, "Healthcheck child process(%d) died: Respawning", pid);
+ start_check_child();
+ return 0;
+}
+
/* Register CHECK thread */
int
start_check_child(void)
return -1;
}
+#ifndef _DEBUG_
/* Initialize child process */
pid = fork();
, strerror(errno));
return -1;
} else if (pid) {
- long poll_delay = (wdog_delay_check) ? wdog_delay_check : WATCHDOG_DELAY;
checkers_child = pid;
syslog(LOG_INFO, "Starting Healthcheck child process, pid=%d"
, pid);
- /* Connect child watchdog */
- check_wdog_data.wdog_pid = pid;
- thread_add_timer(master, wdog_boot_thread, &check_wdog_data,
- poll_delay);
+
+ /* Start respawning thread */
+ thread_add_child(master, check_respawn_thread, NULL,
+ pid, RESPAWN_TIMER);
return 0;
}
thread_destroy_master(master);
master = thread_make_master();
- /* Signal handling initialization */
- check_signal_init();
-
/* change to / dir */
chdir("/");
/* Set mask */
umask(0);
+#endif
+
+ /* Signal handling initialization */
+ check_signal_init();
/* Start Healthcheck daemon */
start_check();
*
* Part: Healthcheckers dynamic data structure definition.
*
- * Version: $Id: check_data.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_data.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: WEB CHECK. Common HTTP/SSL checker primitives.
*
- * Version: $Id: check_http.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_http.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Jan Holmberg, <jan@artech.net>
* Part: MISC CHECK. Perform a system call to run an extra
* system prog or script.
*
- * Version: $Id: check_misc.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_misc.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Eric Jarman, <ehj38230@cmsu2.cmsu.edu>
* data structure representation the conf file representing
* the loadbalanced server pool.
*
- * Version: $Id: check_parser.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_parser.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
char *str = VECTOR_SLOT(strvec, 1);
int size = sizeof (vs->sched);
+ int str_len = strlen(str);
+
+ if (size > str_len)
+ size = str_len;
memcpy(vs->sched, str, size);
}
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
char *str = VECTOR_SLOT(strvec, 1);
int size = sizeof (vs->timeout_persistence);
+ int str_len = strlen(str);
+
+ if (size > str_len)
+ size = str_len;
memcpy(vs->timeout_persistence, str, size);
}
*
* Part: SMTP CHECK. Check an SMTP-server.
*
- * Version: $Id: check_smtp.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_smtp.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Jeremy Rumpf, <jrumpf@heavyload.net>
* url, compute a MD5 over this result and match it to the
* expected value.
*
- * Version: $Id: check_ssl.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_ssl.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Jan Holmberg, <jan@artech.net>
*
* Part: TCP checker.
*
- * Version: $Id: check_tcp.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_tcp.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* library to add/remove server MASQ rules to the kernel
* firewall framework.
*
- * Version: $Id: ipfwwrapper.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: ipfwwrapper.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* Part: IPVS Kernel wrapper. Use setsockopt call to add/remove
* server to/from the loadbalanced server pool.
*
- * Version: $Id: ipvswrapper.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: ipvswrapper.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Manipulation functions for IPVS & IPFW wrappers.
*
- * Version: $id: ipwrapper.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: ipwrapper.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
rm -f Makefile
-main.o: main.c ../include/main.h ../../lib/watchdog.h ../include/config.h
+main.o: main.c ../include/main.h ../include/config.h
daemon.o: daemon.c ../include/daemon.h ../../lib/utils.h
pidfile.o: pidfile.c ../include/pidfile.h
layer4.o: layer4.c ../include/layer4.h ../include/check_api.h ../../lib/utils.h
*
* Part: Main program structure.
*
- * Version: $Id: main.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: main.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Dynamic data structure definition.
*
- * Version: $Id: global_data.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: global_data.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* data structure representation the conf file representing
* the loadbalanced server pool.
*
- * Version: $Id: global_parser.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: global_parser.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* Part: Layer4 checkers handling. Register worker threads &
* upper layer checkers.
*
- * Version: $Id: layer4.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: layer4.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Main program structure.
*
- * Version: $Id: main.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: main.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*/
#include "main.h"
-#include "watchdog.h"
#include "config.h"
/* global var */
int log_facility = LOG_DAEMON; /* Optional logging facilities */
pid_t vrrp_child = -1; /* VRRP child process ID */
pid_t checkers_child = -1; /* Healthcheckers child process ID */
-long wdog_delay_vrrp = 0; /* VRRP child polling delay */
-long wdog_delay_check = 0; /* Healthchecker child polling delay */
int daemon_mode = 0; /* VRRP/CHECK subsystem selection */
int linkwatch = 0; /* Use linkwatch kernel netlink reflection */
" %s --dont-fork -n Dont fork the daemon process.\n"
" %s --use-file -f Use the specified configuration file.\n"
" Default is /etc/keepalived/keepalived.conf.\n"
- " %s --wdog-vrrp -R Define VRRP watchdog polling delay. (default=5s)\n"
- " %s --wdog-check -H Define checkers watchdog polling delay. (default=5s)\n"
" %s --dump-conf -d Dump the configuration data.\n"
" %s --log-console -l Log message to local console.\n"
" %s --log-detail -D Detailed log messages.\n"
" %s --log-facility -S 0-7 Set syslog facility to LOG_LOCAL[0-7]. (default=LOG_DAEMON)\n"
" %s --help -h Display this short inlined help screen.\n"
" %s --version -v Display the version number\n",
- prog, prog, prog, prog, prog, prog, prog, prog, prog, prog,
+ prog, prog, prog, prog, prog, prog, prog, prog,
prog, prog, prog, prog);
}
{"dont-fork", 'n', POPT_ARG_NONE, NULL, 'n'},
{"dump-conf", 'd', POPT_ARG_NONE, NULL, 'd'},
{"use-file", 'f', POPT_ARG_STRING, &optarg, 'f'},
- {"wdog-vrrp", 'R', POPT_ARG_STRING, &optarg, 'R'},
- {"wdog-check", 'H', POPT_ARG_STRING, &optarg, 'H'},
{"vrrp", 'P', POPT_ARG_NONE, NULL, 'P'},
{"check", 'C', POPT_ARG_NONE, NULL, 'C'},
{NULL, 0, 0, NULL, 0}
case 'f':
conf_file = optarg;
break;
- case 'R':
- wdog_delay_vrrp = atoi(optarg) * TIMER_HZ;
- break;
- case 'H':
- wdog_delay_check = atoi(optarg) * TIMER_HZ;
- break;
case 'P':
daemon_mode |= 1;
break;
case 'f':
conf_file = optarg;
break;
- case 'R':
- wdog_delay_vrrp = atoi(optarg) * TIMER_HZ;
- break;
- case 'H':
- wdog_delay_check = atoi(optarg) * TIMER_HZ;
- break;
case 'P':
daemon_mode |= 1;
break;
goto end;
}
+#ifndef _DEBUG_
/* Signal handling initialization */
signal_init();
+#endif
/* 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();
+#endif
/*
* Reached when terminate signal catched.
*
* Part: pidfile utility.
*
- * Version: $Id: pidfile.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: pidfile.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* using the smtp protocol according to the RFC 821. A non blocking
* timeouted connection is used to handle smtp protocol.
*
- * Version: $Id: smtp.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: smtp.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Checkers arguments structures definitions.
*
- * Version: $Id: check_api.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_api.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: check_daemon.c include file.
*
- * Version: $Id: check_daemon.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_daemon.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Healthcheckers dynamic data structure definition.
*
- * Version: $Id: check_data.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_data.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: check_http.c include file.
*
- * Version: $Id: check_http.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_http.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Jan Holmberg, <jan@artech.net>
*
* Part: check_misc.c include file.
*
- * Version: $Id: check_misc.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_misc.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
* Eric Jarman, <ehj38230@cmsu2.cmsu.edu>
*
* Part: check_parser.c include file.
*
- * Version: $Id: check_parser.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_parser.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: check_smtp.c include file.
*
- * Version: $Id: check_smtp.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_smtp.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
* Jeremy Rumpf, <jrumpf@heavyload.net>
*
* Part: check_http.c include file.
*
- * Version: $Id: check_http.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_http.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Jan Holmberg, <jan@artech.net>
*
* Part: check_tcp.c include file.
*
- * Version: $Id: check_tcp.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: check_tcp.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Configuration include file.
*
- * Version: $Id: config.h.in,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: config.h.in,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Jacob Rief, <jacob.rief@tiscover.com>
*
*
* Part: Daemon process handling.
*
- * Version: $Id: daemon.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: daemon.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Dynamic data structure definition.
*
- * Version: $Id: global_data.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: global_data.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_parser.c include file.
*
- * Version: $Id: global_parser.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: global_parser.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: ipfwwrapper.c include file.
*
- * Version: $Id: ipfwwrapper.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: ipfwwrapper.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: ipvswrapper.c include file.
*
- * Version: $Id: ipvswrapper.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: ipvswrapper.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: ipwrapper.c include file.
*
- * Version: $Id: ipwrapper.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: ipwrapper.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: layer4.c include file.
*
- * Version: $Id: layer4.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: layer4.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Main program include file.
*
- * Version: $Id: main.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: main.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
extern int log_facility; /* Optional logging facilities */
extern pid_t vrrp_child; /* VRRP child process ID */
extern pid_t checkers_child; /* Healthcheckers child process ID */
-extern long wdog_delay_vrrp; /* VRRP child polling delay */
-extern long wdog_delay_check; /* Healthchecker child polling delay */
extern int daemon_mode; /* VRRP/CHECK subsystem selection */
extern int linkwatch; /* Use linkwatch kernel netlink reflection */
*
* Part: pidfile.c include file.
*
- * Version: $Id: pidfile.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: pidfile.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: smtp.c include file.
*
- * Version: $Id: smtp.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: smtp.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp.c program include file.
*
- * Version: $Id: vrrp.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_arp.c include file.
*
- * Version: $Id: vrrp_arp.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_arp.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_daemon.c include file.
*
- * Version: $Id: vrrp_daemon.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_daemon.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Dynamic data structure definition.
*
- * Version: $Id: vrrp_data.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_data.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
#include "list.h"
#include "vector.h"
+/*
+ * Our instance dispatcher use a socket pool.
+ * That way we handle VRRP protocol type per
+ * physical interface.
+ */
+typedef struct {
+ int ifindex;
+ int proto;
+ int fd_in;
+ int fd_out;
+} sock;
+
/* Configuration data root */
typedef struct _vrrp_conf_data {
list static_addresses;
*
* Part: vrrp_if.c include file.
*
- * Version: $Id: vrrp_if.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_if.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
if_linkbeat(X))
#endif
-/* Global vars exported */
-extern list if_queue;
-
/* prototypes */
extern interface *if_get_by_ifindex(const int ifindex);
extern interface *if_get_by_ifname(const char *ifname);
*
* Part: vrrp_index.c include file.
*
- * Version: $Id: vrrp_index.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_index.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_ipaddress.c include file.
*
- * Version: $Id: vrrp_ipaddress.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_ipaddress.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_iproute.c include file.
*
- * Version: $Id: vrrp_iproute.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_iproute.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_ipsecah.c include file.
*
- * Version: $Id: vrrp_ipsecah.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_ipsecah.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_netlink.c include file.
*
- * Version: $Id: vrrp_netlink.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_netlink.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_notify.c include file.
*
- * Version: $Id: vrrp_notify.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_notify.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_parser.c include file.
*
- * Version: $Id: vrrp_parser.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_parser.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_scheduler.c include file.
*
- * Version: $Id: vrrp_scheduler.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_scheduler.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
#include "scheduler.h"
#include "vrrp_data.h"
-/*
- * Our instance dispatcher use a socket pool.
- * That way we handle VRRP protocol type per
- * physical interface.
- */
-typedef struct {
- int ifindex;
- int proto;
- int fd_in;
- int fd_out;
-} sock;
-
/* VRRP FSM Macro */
#define VRRP_FSM_READ_TO(V) \
do { \
*
* Part: vrrp_sync.c include file.
*
- * Version: $Id: vrrp_sync.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_sync.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_track.c include file.
*
- * Version: $Id: vrrp_track.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_track.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
static void* ipvs_func = NULL;
struct ip_vs_getinfo ipvs_info;
-
int ipvs_init(void)
{
socklen_t len;
(char *)dm, sizeof(*dm));
}
-
struct ip_vs_get_services *ipvs_get_services(void)
{
struct ip_vs_get_services *get;
/* stop a connection synchronizaiton daemon (master/backup) */
extern int ipvs_stop_daemon(ipvs_daemon_t *dm);
-
/* get all the ipvs services */
extern struct ip_vs_get_services *ipvs_get_services(void);
../include/vrrp_if.h ../include/vrrp_arp.h ../include/vrrp_netlink.h ../include/vrrp_iproute.h \
../include/vrrp_iproute.h ../include/vrrp_parser.h ../include/vrrp_data.h \
../include/vrrp.h ../include/global_data.h ../include/pidfile.h ../include/daemon.h \
- ../include/ipvswrapper.h ../../lib/list.h ../../lib/memory.h ../../lib/parser.h ../../lib/watchdog.h
+ ../include/ipvswrapper.h ../../lib/list.h ../../lib/memory.h ../../lib/parser.h
vrrp_data.o: vrrp_data.c ../include/vrrp_data.h \
../include/vrrp_sync.h ../include/vrrp_index.h ../include/vrrp.h ../../lib/memory.h \
../../lib/utils.h
* master fails, a backup server takes over.
* The original implementation has been made by jerome etienne.
*
- * Version: $Id: vrrp.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
vrrp_restore_interface(vrrp, 1);
#ifdef _HAVE_IPVS_SYNCD_
- /* Stop stalled syncd */
+ /*
+ * Stop stalled syncd. IPVS syncd state is the
+ * same as VRRP instance one. We need here to
+ * stop stalled syncd thread according to last
+ * VRRP instance state.
+ */
if (vrrp->lvs_syncd_if)
- ipvs_syncd_cmd(IPVS_STOPDAEMON, NULL, 0);
+ ipvs_syncd_cmd(IPVS_STOPDAEMON, NULL,
+ (vrrp->state == VRRP_STATE_MAST) ? IPVS_MASTER:
+ IPVS_BACKUP);
#endif
}
}
*
* Part: ARP primitives.
*
- * Version: $Id: vrrp_arp.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_arp.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: VRRP child process handling.
*
- * Version: $Id: vrrp_daemon.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_daemon.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
#include "main.h"
#include "memory.h"
#include "parser.h"
-#include "watchdog.h"
-
-/* Global vars */
-static int vrrp_wdog_sd = -1;
-
-/* VRRP watchdog data */
-static wdog_data vrrp_wdog_data = {
- "VRRP Child",
- WDOG_VRRP,
- -1,
- -1,
- start_vrrp_child
-};
/* Daemon stop sequence */
static void
/* Clean data */
free_global_data(data);
- vrrp_dispatcher_release(vrrp_data);
free_vrrp_data(vrrp_data);
free_vrrp_buffer();
keepalived_free_final("VRRP Child process");
#endif
- /* free watchdog sd */
- wdog_close(vrrp_wdog_sd, WDOG_VRRP);
-
/*
* Reached when terminate signal catched.
* finally return to parent process.
dump_vrrp_data(vrrp_data);
}
- /* Register vrrp software watchdog */
- vrrp_wdog_sd = wdog_init(WDOG_VRRP);
-
/* Init & start the VRRP packet dispatcher */
thread_add_event(master, vrrp_dispatcher_init, NULL,
VRRP_DISPATCHER);
free_vrrp_buffer();
gratuitous_arp_close();
- /* free watchdog sd */
- wdog_close(vrrp_wdog_sd, WDOG_VRRP);
-
/* Save previous conf data */
old_vrrp_data = vrrp_data;
vrrp_data = NULL;
start_vrrp();
/* free backup data */
- vrrp_dispatcher_release(old_vrrp_data);
free_vrrp_data(old_vrrp_data);
UNSET_RELOAD;
void
sighup_vrrp(int sig)
{
- syslog(LOG_INFO, "Reloading VRRP child process on signal");
+ syslog(LOG_INFO, "Reloading VRRP child process(%d) on signal",
+ vrrp_child);
thread_add_event(master, reload_vrrp_thread, NULL, 0);
}
signal_noignore_sigchld();
}
+/* VRRP Child respawning thread */
+int
+vrrp_respawn_thread(thread * thread)
+{
+ pid_t pid;
+
+ /* Fetch thread args */
+ pid = THREAD_CHILD_PID(thread);
+
+ /* Restart respawning thread */
+ if (thread->type == THREAD_CHILD_TIMEOUT) {
+ thread_add_child(master, vrrp_respawn_thread, NULL,
+ pid, RESPAWN_TIMER);
+ return 0;
+ }
+
+ /* We catch a SIGCHLD, handle it */
+ syslog(LOG_INFO, "VRRP child process(%d) died: Respawning", pid);
+ start_vrrp_child();
+ return 0;
+}
+
/* Register VRRP thread */
int
start_vrrp_child(void)
{
+#ifndef _DEBUG_
pid_t pid;
+#endif
/* Dont start if pid is already running */
if (vrrp_running()) {
return -1;
}
+#ifndef _DEBUG_
/* Initialize child process */
pid = fork();
, strerror(errno));
return -1;
} else if (pid) {
- long poll_delay = (wdog_delay_vrrp) ? wdog_delay_vrrp : WATCHDOG_DELAY;
vrrp_child = pid;
syslog(LOG_INFO, "Starting VRRP child process, pid=%d"
, pid);
- /* Connect child watchdog */
- vrrp_wdog_data.wdog_pid = pid;
- thread_add_timer(master, wdog_boot_thread, &vrrp_wdog_data,
- poll_delay);
+
+ /* Start respawning thread */
+ thread_add_child(master, vrrp_respawn_thread, NULL,
+ pid, RESPAWN_TIMER);
return 0;
}
thread_destroy_master(master);
master = thread_make_master();
- /* Signal handling initialization */
- vrrp_signal_init();
-
/* change to / dir */
chdir("/");
/* Set mask */
umask(0);
+#endif
+
+ /* Signal handling initialization */
+ vrrp_signal_init();
/* Start VRRP daemon */
start_vrrp();
*
* Part: Dynamic data structure definition.
*
- * Version: $Id: vrrp_data.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_data.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
syslog(LOG_INFO, " Using smtp notification");
}
+/* Socket pool functions */
+void
+free_sock(void *data)
+{
+ sock *sock = data;
+ interface *ifp = if_get_by_ifindex(sock->ifindex);
+ if_leave_vrrp_group(sock->fd_in, ifp);
+ close(sock->fd_out);
+ FREE(data);
+}
+
+void
+dump_sock(void *data)
+{
+ sock *sock = data;
+ syslog(LOG_INFO, "VRRP sockpool: [ifindex(%d), proto(%d), fd(%d,%d)]",
+ sock->ifindex
+ , sock->proto
+ , sock->fd_in
+ , sock->fd_out);
+}
+
static void
free_vrrp(void *data)
{
new->vrrp_index = alloc_mlist(NULL, NULL, 255);
new->vrrp_index_fd = alloc_mlist(NULL, NULL, 1024+1);
new->vrrp_sync_group = alloc_list(free_vgroup, dump_vgroup);
+ new->vrrp_socket_pool = alloc_list(free_sock, dump_sock);
return new;
}
*
* Part: Interfaces manipulation.
*
- * Version: $Id: vrrp_if.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_if.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
#include "utils.h"
/* Global vars */
-list if_queue;
+static list if_queue;
static struct ifreq ifr;
/* Helper functions */
interface *ifp;
element e;
+ if (LIST_ISEMPTY(if_queue))
+ return NULL;
+
for (e = LIST_HEAD(if_queue); e; ELEMENT_NEXT(e)) {
ifp = ELEMENT_DATA(e);
if (ifp->ifindex == ifindex)
interface *ifp;
element e;
+ if (LIST_ISEMPTY(if_queue))
+ return NULL;
+
for (e = LIST_HEAD(if_queue); e; ELEMENT_NEXT(e)) {
ifp = ELEMENT_DATA(e);
if (!strcmp(ifp->ifname, ifname))
int ret = 0;
/* If fd is -1 then we add a membership trouble */
- if (sd < 0)
+ if (sd < 0 || !ifp)
return;
/* Leaving the VRRP multicast group */
*
* Part: VRRP instance index table.
*
- * Version: $Id: vrrp_index.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_index.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
{
vrrp_rt *vrrp_ptr;
element e;
- element next;
list l = &vrrp_data->vrrp_index_fd[old_fd%1024 + 1];
- for (e = LIST_HEAD(l); e; e = next) {
- next = e->next;
+ for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
vrrp_ptr = ELEMENT_DATA(e);
- if (vrrp_ptr->fd_in == old_fd) {
+ if (IF_INDEX(vrrp_ptr->ifp) == IF_INDEX(vrrp->ifp)) {
vrrp_ptr->fd_in = vrrp->fd_in;
vrrp_ptr->fd_out = vrrp->fd_out;
-
- /* Re-hash fd */
- alloc_vrrp_fd_bucket(vrrp_ptr);
-
- /* Release element */
- if (e->prev)
- e->prev->next = e->next;
- else
- l->head = e->next;
-
- if (e->next)
- e->next->prev = e->prev;
- else
- l->tail = e->prev;
- l->count--;
- FREE(e);
}
}
-
- if (LIST_ISEMPTY(l)) {
- l->head = NULL;
- l->tail = NULL;
- }
}
*
* Part: NETLINK IPv4 address manipulation.
*
- * Version: $Id: vrrp_ipaddress.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_ipaddress.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: NETLINK IPv4 routes manipulation.
*
- * Version: $Id: vrrp_iproute.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_iproute.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* authentication data encryption using HMAC MD5 according to
* RFCs 2085 & 2104.
*
- * Version: $Id: vrrp_ipsecah.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_ipsecah.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: NETLINK kernel command channel.
*
- * Version: $Id: vrrp_netlink.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_netlink.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
int
netlink_set_block(struct nl_handle *nl, int *flags)
{
- int ret;
-
- ret = fcntl(nl->fd, F_GETFL, 0);
- if (ret < 0) {
+ if ((*flags = fcntl(nl->fd, F_GETFL, 0)) < 0) {
syslog(LOG_INFO, "Netlink: Cannot F_GETFL socket : (%s)",
strerror(errno));
return -1;
}
*flags &= ~O_NONBLOCK;
- ret = fcntl(nl->fd, F_SETFL, *flags);
- if (ret < 0) {
+ if (fcntl(nl->fd, F_SETFL, *flags) < 0) {
syslog(LOG_INFO, "Netlink: Cannot F_SETFL socket : (%s)",
strerror(errno));
return -1;
int
netlink_set_nonblock(struct nl_handle *nl, int *flags)
{
- int ret;
-
*flags |= O_NONBLOCK;
- ret = fcntl(nl->fd, F_SETFL, *flags);
- if (ret < 0) {
+ if (fcntl(nl->fd, F_SETFL, *flags) < 0) {
syslog(LOG_INFO, "Netlink: Cannot F_SETFL socket : (%s)",
strerror(errno));
return -1;
*
* Part: VRRP state transition notification scripts handling.
*
- * Version: $Id: vrrp_notify.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_notify.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* data structure representation the conf file representing
* the loadbalanced server pool.
*
- * Version: $Id: vrrp_parser.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_parser.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Sheduling framework for vrrp code.
*
- * Version: $Id: vrrp_scheduler.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_scheduler.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
return 0;
}
-/* sockpool list primitives */
-void
-free_sock(void *data)
-{
- sock *sock = data;
- interface *ifp = if_get_by_ifindex(sock->ifindex);
- if_leave_vrrp_group(sock->fd_in, ifp);
- close(sock->fd_out);
- FREE(data);
-}
-
-void
-dump_sock(void *data)
-{
- sock *sock = data;
- syslog(LOG_INFO, "VRRP sockpool: [ifindex(%d), proto(%d), fd(%d,%d)]",
- sock->ifindex
- , sock->proto
- , sock->fd_in
- , sock->fd_out);
-}
-
void
alloc_sock(list l, int ifindex, int proto)
{
int
vrrp_dispatcher_init(thread * thread)
{
- /* allocate the sockpool */
- vrrp_data->vrrp_socket_pool = alloc_list(free_sock, dump_sock);
-
/* create the VRRP socket pool list */
vrrp_create_sockpool(vrrp_data->vrrp_socket_pool);
*
* Part: VRRP synchronization framework.
*
- * Version: $Id: vrrp_sync.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_sync.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Interface tracking framework.
*
- * Version: $Id: vrrp_track.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vrrp_track.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
COMPILE = $(CC) $(CFLAGS) $(DEFS)
OBJS = memory.o utils.o notify.o timer.o scheduler.o \
- vector.o list.o html.o parser.o watchdog.o
+ vector.o list.o html.o parser.o
HEADERS = $(OBJS:.o=.h)
.c.o:
distclean: clean
rm -f Makefile
-memory.o: memory.c memory.h
+memory.o: memory.c memory.h utils.h
utils.o: utils.c utils.h
notify.o: notify.c notify.h
timer.o: timer.c timer.h
list.o: list.c list.h memory.h
html.o: html.c html.h memory.h
parser.o: parser.c parser.h memory.h
-watchdog.o: watchdog.c watchdog.h scheduler.h memory.h parser.h
*
* Part: HTML stream parser utility functions.
*
- * Version: $Id: html.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: html.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
*
char *end = buffer + size_buffer;
char *cur;
- for (cur = buffer; cur + 4 < end; cur++)
+ for (cur = buffer; cur + 3 < end; cur++)
if (*cur == '\r' && *(cur+1) == '\n'
&& *(cur+2) == '\r' && *(cur+3) == '\n')
return cur + 4;
*
* Part: parser.c include file.
*
- * Version: $Id: html.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: html.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: List structure manipulation.
*
- * Version: $Id: list.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: list.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: list.c include file.
*
- * Version: $Id: list.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: list.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* Part: Memory management framework. This framework is used to
* find any memory leak.
*
- * Version: $Id: memory.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: memory.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Jan Holmberg, <jan@artech.net>
*/
#include "memory.h"
+#include "utils.h"
/* Global var */
unsigned long mem_allocated; /* Total memory used in Bytes */
*/
#ifdef _DEBUG_
-extern void dump_buffer(char *, int);
typedef struct {
int type;
static int number_alloc_list = 0;
static int n = 0; /* Alloc list pointer */
static int f = 0; /* Free list pointer */
-static int s = 0; /* Indent counter */
char *
keepalived_malloc(unsigned long size, char *file, char *function, int line)
*
* Part: memory.c include file.
*
- * Version: $Id: memory.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: memory.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Jan Holmberg, <jan@artech.net>
#define MAX_ALLOC_LIST 2048
#define MALLOC(n) ( keepalived_malloc((n), \
- (__FILE__), (__FUNCTION__), (__LINE__)) )
+ (__FILE__), (char *)(__FUNCTION__), (__LINE__)) )
#define FREE(b) ( keepalived_free((b), \
- (__FILE__), (__FUNCTION__), (__LINE__)) )
+ (__FILE__), (char *)(__FUNCTION__), (__LINE__)) )
#define REALLOC(b,n) ( keepalived_realloc((b), (n), \
- (__FILE__), (__FUNCTION__), (__LINE__)) )
+ (__FILE__), (char *)(__FUNCTION__), (__LINE__)) )
/* Memory debug prototypes defs */
extern char *keepalived_malloc(unsigned long, char *, char *, int);
*
* Part: Forked system call to launch an extra script.
*
- * Version: $Id: notify.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: notify.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: notify.c include file.
*
- * Version: $Id: notify.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: notify.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* data structure representation the conf file representing
* the loadbalanced server pool.
*
- * Version: $Id: parser.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: parser.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
/* global vars */
vector keywords;
FILE *stream;
+int reload = 0;
/* local vars */
static int sublevel = 0;
keywords = vector_alloc();
(*init_keywords) ();
-/* Dump configuration */
+/* Dump configuration *
vector_dump(keywords);
dump_keywords(keywords, 0);
+*/
/* Stream handling */
process_stream(keywords);
*
* Part: cfreader.c include file.
*
- * Version: $Id: parser.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: parser.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
/* global vars exported */
extern vector keywords;
extern FILE *stream;
+extern int reload;
/* Prototypes */
extern void keyword_alloc(vector keywords, char *string, void (*handler) (vector));
* the thread management routine (thread.c) present in the
* very nice zebra project (http://www.zebra.org).
*
- * Version: $Id: scheduler.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: scheduler.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: scheduler.c include file.
*
- * Version: $Id: scheduler.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: scheduler.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
#define THREAD_CHILD_TIMEOUT 9
#define THREAD_TERMINATE 10
-
/* MICRO SEC def */
#define BOOTSTRAP_DELAY TIMER_HZ
+#define RESPAWN_TIMER 60*TIMER_HZ
/* Macros. */
#define THREAD_ARG(X) ((X)->arg)
*
* Part: Timer manipulations.
*
- * Version: $Id: timer.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: timer.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: timer.c include file.
*
- * Version: $Id: timer.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: timer.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: General program utils.
*
- * Version: $Id: utils.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: utils.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: utils.h include file.
*
- * Version: $Id: utils.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: utils.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Vector structure manipulation.
*
- * Version: $Id: vector.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vector.c,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vector.c include file.
*
- * Version: $Id: vector.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
+ * Version: $Id: vector.h,v 1.1.9 2005/02/07 03:18:31 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
+++ /dev/null
-/*
- * Soft: Keepalived is a failover program for the LVS project
- * <www.linuxvirtualserver.org>. It monitor & manipulate
- * a loadbalanced server pool using multi-layer checks.
- *
- * Part: Software watchdog framework.
- *
- * Version: $Id: watchdog.c,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
- *
- * Author: Alexandre Cassen, <acassen@linux-vs.org>
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Copyright (C) 2001-2005 Alexandre Cassen, <acassen@linux-vs.org>
- */
-
-#include <unistd.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <syslog.h>
-#include <errno.h>
-#include <signal.h>
-#include "watchdog.h"
-#include "memory.h"
-#include "parser.h"
-
-/* global vars */
-int reload = 0;
-
-/* Watchdog connection reader */
-static int
-wdog_read(thread *thread)
-{
- int sd;
- int nbytes;
- char *path;
- unsigned char *buf;
-
- sd = THREAD_FD(thread);
- path = THREAD_ARG(thread);
-
- /* Wait until read event */
- if (thread->type == THREAD_READ_TIMEOUT) {
- thread_add_read(master, wdog_read, path, sd,
- WATCHDOG_TIMER);
- return 0;
- }
-
- /* Process incoming data */
- buf = (char *) MALLOC(WDOG_READ_BUFSIZ);
- nbytes = read(sd, buf, WDOG_READ_BUFSIZ);
- if (nbytes <= 0) {
- syslog(LOG_INFO, "Watchdog: Error reading to %s wdog socket",
- path);
- FREE(buf);
- return -1;
- }
-
- /* Register next thread */
- thread_add_read(master, wdog_read, path, sd,
- WATCHDOG_TIMER);
- FREE(buf);
- return 0;
-}
-
-/* Watchdog connection acceptor */
-static int
-wdog_accept(thread *thread)
-{
- struct sockaddr_un sock;
- int sd, accept_sd;
- int len;
- char *path;
-
- sd = THREAD_FD(thread);
- path = THREAD_ARG(thread);
-
- /* Wait until accept event */
- if (thread->type == THREAD_READ_TIMEOUT) {
- thread_add_read(master, wdog_accept, path, sd,
- WATCHDOG_TIMER);
- return 0;
- }
-
- /* Set unix domain socket */
- memset(&sock, 0, sizeof(struct sockaddr_un));
- len = sizeof(struct sockaddr_un);
-
- /* Accept incoming connection */
- accept_sd = accept(sd, (struct sockaddr *) &sock, &len);
- if (accept_sd < 0) {
- syslog(LOG_INFO, "Watchdog: Error accepting on %s wdog socket: %s",
- path, strerror(errno));
- return -1;
- }
-
- /* Register read thread */
- thread_add_read(master, wdog_read, path, accept_sd,
- WATCHDOG_TIMER);
- return 0;
-}
-
-/* Watchdog initialization */
-int
-wdog_init(char *path)
-{
- struct sockaddr_un sock;
- int sd, len, err;
- mode_t old_mask;
-
- /* Free stalled socket */
- unlink(path);
-
- /* Mask */
- old_mask = umask(0077);
-
- /* Simple welcome msg */
- syslog(LOG_INFO, "Watchdog: Starting listener on %s wdog socket"
- , path);
-
- /* Create unix domain socket */
- sd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (sd < 0) {
- syslog(LOG_INFO, "Watchdog: Error creating %s wdog socket",
- path);
- return -1;
- }
-
- /* Create listening socket */
- memset(&sock, 0, sizeof(struct sockaddr_un));
- sock.sun_family = AF_UNIX;
- strncpy(sock.sun_path, path, strlen(path));
- len = sizeof(sock.sun_family) + strlen(path);
- err = bind(sd, (struct sockaddr *) &sock, len);
- if (err < 0) {
- syslog(LOG_INFO, "Watchdog: Error binding %s wdog socket",
- path);
- close(sd);
- return -1;
- }
-
- /* Only parent process can connect child wdog listener */
- err = listen(sd, 1);
- if (err < 0) {
- syslog(LOG_INFO, "Watchdog: Error listening %s wdog socket",
- path);
- close(sd);
- return -1;
- }
-
- /* Restore old mask */
- umask(old_mask);
-
- /* Register acceptor thread */
- thread_add_read(master, wdog_accept, path, sd,
- WATCHDOG_TIMER);
- return sd;
-}
-
-/* Close watchdog channel */
-void
-wdog_close(int sd, char *path)
-{
- if (sd > 0) {
- close(sd);
- sd = -1;
- }
- if (path)
- unlink(path);
-}
-
-/* Watchdog thread */
-static int
-wdog_thread(thread *thread)
-{
- wdog_data *wdata = THREAD_ARG(thread);
- int ret, status;
-
- /* Refresh if reload */
- if (reload)
- goto reload;
-
- /* Send watchdog string */
- ret = (send(wdata->wdog_sd, WATCHDOG_STRING, strlen(WATCHDOG_STRING),
- MSG_NOSIGNAL) != -1) ? 1 : 0;
-
- /* connection trouble */
- if (!ret) {
- syslog(LOG_INFO, "Watchdog: Error while sending data"
- " to %s. error=(%s)."
- , wdata->wdog_string, strerror(errno));
-
- /* Test if pid is alive */
- if (wdata->wdog_pid > 0) {
- if (kill(wdata->wdog_pid, 0)) {
- /* Process has gone */
- syslog(LOG_INFO, "Watchdog: %s no longer"
- " exist, restarting..."
- , wdata->wdog_string);
- close(wdata->wdog_sd); /* avoid sd leak */
- (*wdata->wdog_start) ();
- return 0;
- } else {
- /* Dead loop detected */
- syslog(LOG_INFO, "Watchdog: %s dead loop"
- " detected, restarting..."
- , wdata->wdog_string);
- close(wdata->wdog_sd); /* avoid sd leak */
- kill(wdata->wdog_pid, SIGTERM);
- wait(&status);
- (*wdata->wdog_start) ();
- return 0;
- }
- }
-
- /* Unexpected error */
- syslog(LOG_INFO, "Watchdog: %s unexpected error,"
- " restarting..."
- , wdata->wdog_string);
- (*wdata->wdog_start) ();
- return 0;
- }
-
- /* Register next timer thread */
- thread_add_timer(master, wdog_thread, wdata, WATCHDOG_DELAY);
- return 0;
-
-reload:
- close(wdata->wdog_sd);
- wdata->wdog_sd = -1;
- thread_add_timer(master, wdog_boot_thread, wdata,
- WATCHDOG_DELAY);
- return 0;
-}
-
-/* Client watchdog channel */
-static int
-wdog_connect(wdog_data *wdata)
-{
- struct sockaddr_un sock;
- int len, err;
-
- /* Create unix domain socket */
- wdata->wdog_sd = socket(AF_UNIX, SOCK_STREAM, 0);
- if (wdata->wdog_sd < 0) {
- syslog(LOG_INFO, "Watchdog: Error creating %s wdog connect socket",
- wdata->wdog_path);
- return -1;
- }
-
- /* create connection socket */
- memset(&sock, 0, sizeof(struct sockaddr_un));
- sock.sun_family = AF_UNIX;
- strncpy(sock.sun_path, wdata->wdog_path, strlen(wdata->wdog_path));
- len = sizeof(sock.sun_family) + strlen(wdata->wdog_path);
- err = connect(wdata->wdog_sd, (struct sockaddr *) &sock, len);
- if (err < 0) {
- syslog(LOG_INFO, "Watchdog: Error connecting %s wdog socket",
- wdata->wdog_path);
- close(wdata->wdog_sd);
- return -1;
- }
-
- /* Register watchdog handler */
- syslog(LOG_INFO, "Watchdog: success connecting %s wdog socket",
- wdata->wdog_path);
-
- /* First connection succes unset reload flag */
- if (reload)
- UNSET_RELOAD;
- thread_add_timer(master, wdog_thread, wdata, WATCHDOG_DELAY);
- return 0;
-}
-
-/* Bootstrap thread */
-int
-wdog_boot_thread(thread *thread)
-{
- wdog_data *wdata = THREAD_ARG(thread);
- int err;
-
- /* connect VRRP child domain socket */
- err = wdog_connect(wdata);
-
- /* Retry child connect until success */
- if (err < 0)
- thread_add_timer(master, wdog_boot_thread,
- wdata, WATCHDOG_DELAY);
- return 0;
-}
+++ /dev/null
-/*
- * Soft: Keepalived is a failover program for the LVS project
- * <www.linuxvirtualserver.org>. It monitor & manipulate
- * a loadbalanced server pool using multi-layer checks.
- *
- * Part: watchdog.c include file.
- *
- * Version: $Id: watchdog.h,v 1.1.8 2005/01/25 23:20:11 acassen Exp $
- *
- * Author: Alexandre Cassen, <acassen@linux-vs.org>
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Copyright (C) 2001-2005 Alexandre Cassen, <acassen@linux-vs.org>
- */
-
-#ifndef _WATCHDOG_H
-#define _WATCHDOG_H
-
-/* local includes */
-#include "scheduler.h"
-
-/* watchdog data */
-typedef struct _wdog_data {
- char *wdog_string; /* motd wdog string */
- char *wdog_path; /* unix domain socket */
- pid_t wdog_pid; /* pid to monitor */
- int wdog_sd; /* wdog socket descriptor */
- int (*wdog_start) (void); /* respawn handler */
-} wdog_data;
-
-/* watchdog definition */
-#define WATCHDOG_TIMER (30 * TIMER_HZ)
-#define WATCHDOG_DELAY (5 * TIMER_HZ)
-#define WATCHDOG_STRING "hello"
-#define WDOG_READ_BUFSIZ 32
-
-/* gloabal vars exported */
-extern int reload;
-
-/* Prototypes */
-extern int wdog_init(char *path);
-extern void wdog_close(int sd, char *path);
-extern int wdog_boot_thread(thread *thread);
-
-#endif