keepalived-1.0.0 v1.0.0
authorAlexandre Cassen <acassen@freebox.fr>
Sun, 12 Jan 2003 23:09:39 +0000 (00:09 +0100)
committerAlexandre Cassen <acassen@freebox.fr>
Mon, 28 Sep 2009 08:58:57 +0000 (10:58 +0200)
* keepalived-1.0.0 released.
* After fixed all bugs users reported during 2 months, I am glad to
  announce the first STABLE production ready Keepalived release.
* Rename keepalived.init to keepalived RedHat startup script. Fixed
  some issues to be RedHat release generic. Thanks go to
  Jeroen Simonetti <jeroens@q-go.com> & Jason Gilbert <jason@doozer.com>
* Jason Gilbert, <jason@doozer.com> cleaned keepalived.spec.
* Added support to "ha_suspend" for healthcheckers. This option, if set,
  inform Keepalived to active/suspend checkers according to netlink
  IP address information reflection. If one IP is removed and this is
  a virtual_server VIP then the healthcheckers corresponding will be
  desactivated. (and reciprocity).
* Added support to "notify_up" & "notify_down" for realserver config.
  These options specify a script to be run according to healthchecker
  activity. If healthchecking fails then "notify_down" script is
  launched (and reciprocity for healthcheck succeed). This can be
  usefull for global monitoring system, to send alert to Unicenter TNG
  or HPOV.
* Set default realserver weight to 1. So, realserver will be active
  if no weight is specified into the configuration file.
* Review the layer4.c/tcp_socket_state to return connection in progress
  only if SOL_SOCKET/SO_ERROR return EINPROGRESS. Thanks go to
  Mark Weaver, <mark@npsl.co.uk>
* Reviewed the global SIGCHLD handler to not suspend execution of the
  calling process if status is not immediately available for one of the
  child processes. This remove zombies by reaping.
* Extended the parser.c/set_value() code to accept encapsulated quoted
  string.
* Review SMTP DBG() message to LOG_INFO message for more verbose
  error handling.
* Review the check_tcp.c/check_http.c logging messages to be more
  detailed.
* Review the check_tcp.c/check_http.c retry facility to fixes some
  stalled issues.
* VRRP : Added support to sync_group smtp notification in addition to
  the per instances approach.
* VRRP : Fixed some IPSEC-AH seq_num synchronizations issues. Force
  seq_num sync if vrrp instance is linked to a group.
* VRRP : In BACKUP state, force a new MASTER election is received adv.
  has a lower priority as locale instance.
* VRRP : vrrp.c/vrrp_state_master_rx(), sync IPSEC-AH seq_num counter
  (decrement) if receiving higher prio advert in MASTER state.
* VRRP : Reviewed the TSM to be fully filled. Extended speed-up
  synchronization handling MASTER sync if group is not already synced.
* VRRP : Leaving fault state, force MASTER transition is received adv
  priority is lower than locale.
* VRRP : Extended the parser to not be borred with sync_group
  declaration position in the conf file. vrrp_sync_group can be
  declared before or after vrrp_instance. Done by adding a reverse
  instance lookup during parsing.
* VRRP : sync_master_election cleanup.
* Some cosmetics patches.
* Created the keepalived/samples/keepalived.conf.SYNOPSIS to describe
  all keywords available.

77 files changed:
ChangeLog
TODO
VERSION
keepalived.spec
keepalived/Makefile.in
keepalived/core/Makefile.in
keepalived/core/daemon.c
keepalived/core/data.c
keepalived/core/layer4.c
keepalived/core/main.c
keepalived/core/parser.c
keepalived/core/pidfile.c
keepalived/core/smtp.c
keepalived/etc/init.d/keepalived.init
keepalived/healthcheck/Makefile.in
keepalived/healthcheck/check_api.c
keepalived/healthcheck/check_ci.c
keepalived/healthcheck/check_http.c
keepalived/healthcheck/check_misc.c
keepalived/healthcheck/check_ssl.c
keepalived/healthcheck/check_tcp.c
keepalived/healthcheck/ipfwwrapper.c
keepalived/healthcheck/ipvswrapper.c
keepalived/healthcheck/ipwrapper.c
keepalived/include/check_api.h
keepalived/include/check_ci.h
keepalived/include/check_http.h
keepalived/include/check_misc.h
keepalived/include/check_ssl.h
keepalived/include/check_tcp.h
keepalived/include/daemon.h
keepalived/include/data.h
keepalived/include/ipfwwrapper.h
keepalived/include/ipvswrapper.h
keepalived/include/ipwrapper.h
keepalived/include/layer4.h
keepalived/include/main.h
keepalived/include/parser.h
keepalived/include/pidfile.h
keepalived/include/smtp.h
keepalived/include/vrrp.h
keepalived/include/vrrp_arp.h
keepalived/include/vrrp_if.h
keepalived/include/vrrp_ipaddress.h
keepalived/include/vrrp_ipsecah.h
keepalived/include/vrrp_netlink.h
keepalived/include/vrrp_notify.h
keepalived/include/vrrp_scheduler.h
keepalived/include/vrrp_sync.h
keepalived/samples/keepalived.conf.SYNOPSIS [new file with mode: 0644]
keepalived/vrrp/Makefile.in
keepalived/vrrp/vrrp.c
keepalived/vrrp/vrrp_arp.c
keepalived/vrrp/vrrp_if.c
keepalived/vrrp/vrrp_ipaddress.c
keepalived/vrrp/vrrp_ipsecah.c
keepalived/vrrp/vrrp_netlink.c
keepalived/vrrp/vrrp_notify.c
keepalived/vrrp/vrrp_scheduler.c
keepalived/vrrp/vrrp_sync.c
lib/Makefile.in
lib/html.c
lib/html.h
lib/list.c
lib/list.h
lib/memory.c
lib/memory.h
lib/notify.c [new file with mode: 0644]
lib/notify.h [new file with mode: 0644]
lib/scheduler.c
lib/scheduler.h
lib/timer.c
lib/timer.h
lib/utils.c
lib/utils.h
lib/vector.c
lib/vector.h

index 0e45b68..03fcf5a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,59 @@
+2003-01-06  Alexandre Cassen  <acassen@linux-vs.org>
+       * keepalived-1.0.0 released.
+       * After fixed all bugs users reported during 2 months, I am glad to
+         announce the first STABLE production ready Keepalived release.
+       * Rename keepalived.init to keepalived RedHat startup script. Fixed
+         some issues to be RedHat release generic. Thanks go to
+         Jeroen Simonetti <jeroens@q-go.com> & Jason Gilbert <jason@doozer.com>
+       * Jason Gilbert, <jason@doozer.com> cleaned keepalived.spec.
+       * Added support to "ha_suspend" for healthcheckers. This option, if set,
+         inform Keepalived to active/suspend checkers according to netlink
+         IP address information reflection. If one IP is removed and this is
+         a virtual_server VIP then the healthcheckers corresponding will be
+         desactivated. (and reciprocity).
+       * Added support to "notify_up" & "notify_down" for realserver config.
+         These options specify a script to be run according to healthchecker
+         activity. If healthchecking fails then "notify_down" script is
+         launched (and reciprocity for healthcheck succeed). This can be
+         usefull for global monitoring system, to send alert to Unicenter TNG
+         or HPOV.
+       * Set default realserver weight to 1. So, realserver will be active
+         if no weight is specified into the configuration file.
+       * Review the layer4.c/tcp_socket_state to return connection in progress
+         only if SOL_SOCKET/SO_ERROR return EINPROGRESS. Thanks go to
+         Mark Weaver, <mark@npsl.co.uk>
+       * Reviewed the global SIGCHLD handler to not suspend execution of the
+         calling process if status is not immediately available for one of the
+         child processes. This remove zombies by reaping.
+       * Extended the parser.c/set_value() code to accept encapsulated quoted
+         string.
+       * Review SMTP DBG() message to LOG_INFO message for more verbose
+         error handling.
+       * Review the check_tcp.c/check_http.c logging messages to be more
+         detailed.
+       * Review the check_tcp.c/check_http.c retry facility to fixes some
+         stalled issues.
+       * VRRP : Added support to sync_group smtp notification in addition to
+         the per instances approach.
+       * VRRP : Fixed some IPSEC-AH seq_num synchronizations issues. Force
+         seq_num sync if vrrp instance is linked to a group.
+       * VRRP : In BACKUP state, force a new MASTER election is received adv.
+         has a lower priority as locale instance.
+       * VRRP : vrrp.c/vrrp_state_master_rx(), sync IPSEC-AH seq_num counter
+         (decrement) if receiving higher prio advert in MASTER state.
+       * VRRP : Reviewed the TSM to be fully filled. Extended speed-up
+         synchronization handling MASTER sync if group is not already synced.
+       * VRRP : Leaving fault state, force MASTER transition is received adv
+         priority is lower than locale.
+       * VRRP : Extended the parser to not be borred with sync_group
+         declaration position in the conf file. vrrp_sync_group can be
+         declared before or after vrrp_instance. Done by adding a reverse
+         instance lookup during parsing.
+       * VRRP : sync_master_election cleanup.
+       * Some cosmetics patches.
+       * Created the keepalived/samples/keepalived.conf.SYNOPSIS to describe
+         all keywords available.
+
 2002-11-20  Alexandre Cassen  <acassen@linux-vs.org>
        * keepalived-0.7.6 released.
        * Created a common library for code modularization. This lib will
diff --git a/TODO b/TODO
index 66e7dd1..df9936f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,15 +1,12 @@
 * Insert LDAP, FTP, SSH, IMAP, POP, RADIUS checkers.
 * Add minimum configuration verification (realserver must have
   a checker defined, ...)
-* VRRP : finish IPSEC-AH integration for seqnum synchronization when
-  using vrrp_sync_group in fallback mode.
 * documentation:
        - hackers guide
        - code documentation
 * code cleanup:
        - name space cleanup
        - function returnval check
-       - beautifull the genhash code
        - check_ssl.c audit the password_cb() call back func
          for buffer overflow.
        - check smtp.c to release allocated buffer when terminate
diff --git a/VERSION b/VERSION
index c006218..3eefcb9 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.7.6
+1.0.0
index 8348cf2..a265c84 100644 (file)
@@ -1,33 +1,52 @@
-Summary: Generic HA monitor build upon VRRP and services poller, strongly recommanded for LVS HA.
 Name: keepalived
+Summary: HA monitor built upon LVS, VRRP and services poller
 Packager: Christophe Varoqui, <christophe.varoqui@free.fr>
-Version: 0.7.6
+Version: 1.0.0
 Release: 1
-Source: http://www.keepalived.org/software/keepalived-0.7.6.tar.gz
+Source: http://www.keepalived.org/software/%{name}-%{version}.tar.gz
 Copyright: GPL
-Group: Utilities/File
+Group: Applications/System
 BuildRoot: /tmp/%{name}-%{version}.build
-BuildArchitectures: i386
+
+%define _exec_prefix /
 
 %description
 The main goal of the keepalived project is to add a strong & robust keepalive facility to the Linux Virtual Server project. This project is written in C with multilayer TCP/IP stack checks. Keepalived implements a framework based on three family checks : Layer3, Layer4 & Layer5. This framework gives the daemon the ability of checking a LVS server pool states. When one of the server of the LVS server pool is down, keepalived informs the linux kernel via a setsockopt call to remove this server entrie from the LVS topology. In addition keepalived implements a VRRPv2 stack to handle director failover. So in short keepalived is a userspace daemon for LVS cluster nodes healthchecks and LVS directors failover.
 
 %prep
 rm -rf %{buildroot}
-%setup -n keepalived-0.7.6
+%setup -q
 
 %build
 ./configure --prefix=%{buildroot} --exec-prefix=%{buildroot} --sysconfdir=%{buildroot}/etc
 make
 
 %install
-make install
+rm -rf %{buildroot}
+%makeinstall
+
+%clean
+rm -rf %{buildroot}
+
+%post
+/sbin/chkconfig --add keepalived
+
+%preun
+/sbin/chkconfig --del keepalived
 
 %files
 %defattr(-,root,root)
-/bin/genhash
-/sbin/keepalived
-/etc/init.d/keepalived.init
-%config /etc/keepalived/keepalived.conf
-%config /etc/keepalived/samples/*
+%{_bindir}/genhash
+%{_sbindir}/keepalived
+%{_sysconfdir}/init.d/keepalived
+%dir %{_sysconfdir}/keepalived/
+%doc keepalived/samples
 %doc AUTHOR CONTRIBUTORS TODO COPYING README INSTALL VERSION ChangeLog
+
+%changelog
+* Fri Dec 20 2002 Jason Gilbert <jason@doozer.com> 0.7.6-dzr1
+- Move the samples to be %doc instead of %config
+- Install the init script as 'keepalived' instead of 'keepalived.init'
+- Use the rpm %configure macro
+- No initial config file supplied in /etc/keepalived since it's hard to say what
+  a default config should be
index eb0a998..c8164d7 100644 (file)
@@ -81,7 +81,7 @@ install:
        install -d $(sbindir)
        install -m 700 $(BIN)/$(EXEC) $(sbindir)/
        install -d $(sysconfdir)/init.d
-       install -m 755 $(init_script) $(sysconfdir)/init.d/
+       install -m 755 $(init_script) $(sysconfdir)/init.d/keepalived
        install -d $(sysconfdir)/keepalived/samples
        install -m 644 $(conf_file) $(sysconfdir)/keepalived/
        install -m 644 samples/* $(sysconfdir)/keepalived/samples/
index c0c12e6..f1a95e2 100644 (file)
@@ -32,7 +32,7 @@ pidfile.o: pidfile.c ../include/pidfile.h
 data.o: data.c ../include/data.h ../../lib/memory.h ../../lib/utils.h \
   ../include/check_api.h ../include/vrrp.h ../include/vrrp_sync.h
 parser.o: parser.c ../include/parser.h ../../lib/memory.h ../include/vrrp.h \
-  ../include/vrrp_if.h ../include/check_api.h
+  ../include/vrrp_if.h ../include/vrrp_sync.h ../include/check_api.h
 layer4.o: layer4.c ../include/layer4.h ../include/check_api.h ../../lib/utils.h
 smtp.o: smtp.c ../include/smtp.h ../../lib/memory.h ../../lib/list.h \
   ../../lib/utils.h
index f2027b3..f3f4330 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        Main program structure.
  *
- * Version:     $Id: main.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: main.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -73,35 +73,3 @@ xdaemon(int nochdir, int noclose, int exitflag)
        umask(0);
        return 0;
 }
-
-/* Close all FDs >= a specified value */
-void
-closeall(int fd)
-{
-       int fdlimit = sysconf(_SC_OPEN_MAX);
-       while (fd < fdlimit)
-               close(fd++);
-}
-
-/* perform a system call */
-int
-system_call(char *cmdline)
-{
-       int retval;
-
-       retval = system(cmdline);
-
-       if (retval == 127) {
-               /* couldn't exec command */
-               syslog(LOG_ALERT, "Couldn't exec command: %s", cmdline);
-       } else if (retval == -1) {
-               /* other error */
-               syslog(LOG_ALERT, "Error exec-ing command: %s", cmdline);
-       } else {
-               /* everything is good */
-               DBG("Successfully exec command: %s retval is %d",
-                   cmdline, retval);
-       }
-
-       return retval;
-}
index 18e8955..bb6d76c 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        Dynamic data structure definition.
  *
- * Version:     $Id: data.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: data.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -126,6 +126,8 @@ dump_vgroup(void *data)
        if (vgroup->script_fault)
                syslog(LOG_INFO, "   Fault state transition script = %s",
                       vgroup->script_fault);
+       if (vgroup->smtp_alert)
+               syslog(LOG_INFO, "   Using smtp notification");
 }
 
 static void
@@ -316,6 +318,8 @@ dump_vs(void *data)
                       inet_ntop2(vs->granularity_persistence));
        syslog(LOG_INFO, "   protocol = %s",
               (vs->service_type == IPPROTO_TCP) ? "TCP" : "UDP");
+       if (vs->ha_suspend)
+               syslog(LOG_INFO, "   Using HA suspend");
 
        switch (vs->loadbalancing_kind) {
 #ifdef _WITH_LVS_
@@ -393,6 +397,8 @@ static void
 free_rs(void *data)
 {
        real_server *rs = data;
+       FREE_PTR(rs->notify_up);
+       FREE_PTR(rs->notify_down);
        FREE(rs);
 }
 static void
@@ -405,6 +411,12 @@ dump_rs(void *data)
               , rs->weight);
        if (rs->inhibit)
                syslog(LOG_INFO, "     -> Inhibit service on failure");
+       if (rs->notify_up)
+               syslog(LOG_INFO, "     -> Notify script UP = %s",
+                      rs->notify_up);
+       if (rs->notify_down)
+               syslog(LOG_INFO, "     -> Notify script DOWN = %s",
+                      rs->notify_down);
 }
 
 void
@@ -417,6 +429,7 @@ alloc_rs(char *ip, char *port)
 
        inet_ston(ip, &new->addr_ip);
        new->addr_port = htons(atoi(port));
+       new->weight = 1;
 
        if (LIST_ISEMPTY(vs->rs))
                vs->rs = alloc_list(free_rs, dump_rs);
index fa65574..cab0dae 100644 (file)
@@ -6,7 +6,7 @@
  * Part:        Layer4 checkers handling. Register worker threads &
  *              upper layer checkers.
  *
- * Version:     $Id: layer4.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: layer4.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -106,7 +106,7 @@ tcp_socket_state(int fd, thread * thread, uint32_t addr_ip, uint16_t addr_port,
         * and other error code until connection is established.
         * Recompute the write timeout (or pending connection).
         */
-       if (status != 0) {
+       if (status == EINPROGRESS) {
                DBG("TCP connection to [%s:%d] still IN_PROGRESS.",
                    inet_ntop2(addr_ip), ntohs(addr_port));
 
@@ -121,6 +121,9 @@ tcp_socket_state(int fd, thread * thread, uint32_t addr_ip, uint16_t addr_port,
                                         THREAD_ARG(thread)
                                         , thread->u.fd, TIMER_SEC(timer_min));
                return connect_in_progress;
+       } else if (status != 0) {
+               close(thread->u.fd);
+               return connect_error;
        }
 
        return connect_success;
index 5fe5d78..270e2bf 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        Main program structure.
  *
- * Version:     $Id: main.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: main.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -170,12 +170,15 @@ sigend(int sig)
        thread_add_terminate_event(master);
 }
 
-/* SIGCHLD handler */
+/*
+ * SIGCHLD handler. Reap any zombie child.
+ * WNOHANG prevent against parent process get
+ * stuck waiting child termination.
+ */
 void
 sigchld(int sig)
 {
-       int child;
-       wait(&child);
+       waitpid(-1, NULL, WNOHANG);
 }
 
 /* Signal wrapper */
index 3721cba..073e870 100644 (file)
@@ -7,7 +7,7 @@
  *              data structure representation the conf file representing
  *              the loadbalanced server pool.
  *  
- * Version:     $Id: parser.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: parser.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  * 
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              
@@ -26,6 +26,7 @@
 #include "memory.h"
 #include "vrrp.h"
 #include "vrrp_if.h"
+#include "vrrp_sync.h"
 #include "check_api.h"
 
 /* global defs */
@@ -236,6 +237,7 @@ set_value(vector strvec)
        int i = 0;
        int len = 0;
        char *alloc = NULL;
+       char *tmp;
 
        if (*str == '"') {
                for (i = 2; i < VECTOR_SIZE(strvec); i++) {
@@ -248,9 +250,12 @@ set_value(vector strvec)
                        else {
                                alloc =
                                    REALLOC(alloc, sizeof (char *) * (len + 1));
-                               strncat(alloc, " ", 1);
+                               tmp = VECTOR_SLOT(strvec, i-1);
+                               if (*str != '"' && *tmp != '"')
+                                       strncat(alloc, " ", 1);
                        }
-                       if (*str != '"')
+
+                       if (i != VECTOR_SIZE(strvec)-1)
                                strncat(alloc, str, strlen(str));
                }
        } else {
@@ -335,6 +340,7 @@ vrrp_group_handler(vector strvec)
 {
        vrrp_sgroup *vgroup = LIST_TAIL_DATA(conf_data->vrrp_sync_group);
        vgroup->iname = read_value_block();
+       vrrp_sync_set_group(vgroup);
 }
 static void
 vrrp_gnotify_backup_handler(vector strvec)
@@ -358,6 +364,12 @@ vrrp_gnotify_fault_handler(vector strvec)
        vgroup->notify_exec = 1;
 }
 static void
+vrrp_gsmtp_handler(vector strvec)
+{
+       vrrp_sgroup *vgroup = LIST_TAIL_DATA(conf_data->vrrp_sync_group);
+       vgroup->smtp_alert = 1;
+}
+static void
 vrrp_handler(vector strvec)
 {
        alloc_vrrp(VECTOR_SLOT(strvec, 1));
@@ -519,7 +531,7 @@ vrrp_vip_handler(vector strvec)
        vector vips = read_value_block();
        vrrp_rt *vrrp = LIST_TAIL_DATA(conf_data->vrrp);
        int i;
-       int nbvip = 0;
+       int nbvip = VECTOR_SIZE(vips);
 
        if (VECTOR_SIZE(vips) > VRRP_MAX_VIP) {
                syslog(LOG_INFO,
@@ -529,8 +541,7 @@ vrrp_vip_handler(vector strvec)
                syslog(LOG_INFO,
                       "  => Declare another VRRP instance to handle all the VIPs");
                nbvip = VRRP_MAX_VIP;
-       } else
-               nbvip = VECTOR_SIZE(vips);
+       }
 
        for (i = 0; i < nbvip; i++)
                alloc_vrrp_vip(VECTOR_SLOT(vips, i));
@@ -641,6 +652,12 @@ proto_handler(vector strvec)
        vs->service_type = (!strcmp(str, "TCP")) ? IPPROTO_TCP : IPPROTO_UDP;
 }
 static void
+hasuspend_handler(vector strvec)
+{
+       virtual_server *vs = LIST_TAIL_DATA(conf_data->vs);
+       vs->ha_suspend = 1;
+}
+static void
 virtualhost_handler(vector strvec)
 {
        virtual_server *vs = LIST_TAIL_DATA(conf_data->vs);
@@ -674,6 +691,20 @@ inhibit_handler(vector strvec)
        real_server *rs = LIST_TAIL_DATA(vs->rs);
        rs->inhibit = 1;
 }
+static void
+notify_up_handler(vector strvec)
+{
+       virtual_server *vs = LIST_TAIL_DATA(conf_data->vs);
+       real_server *rs = LIST_TAIL_DATA(vs->rs);
+       rs->notify_up = set_value(strvec);
+}
+static void
+notify_down_handler(vector strvec)
+{
+       virtual_server *vs = LIST_TAIL_DATA(conf_data->vs);
+       real_server *rs = LIST_TAIL_DATA(vs->rs);
+       rs->notify_down = set_value(strvec);
+}
 
 /* Real Servers Groups for VS handlers */
 static void
@@ -758,6 +789,7 @@ init_keywords(void)
        install_keyword("notify_backup", &vrrp_gnotify_backup_handler);
        install_keyword("notify_master", &vrrp_gnotify_master_handler);
        install_keyword("notify_fault", &vrrp_gnotify_fault_handler);
+       install_keyword("smtp_alert", &vrrp_gsmtp_handler);
        install_keyword_root("vrrp_instance", &vrrp_handler);
        install_keyword("state", &vrrp_state_handler);
        install_keyword("interface", &vrrp_int_handler);
@@ -799,6 +831,7 @@ init_keywords(void)
        install_keyword("persistence_timeout", &pto_handler);
        install_keyword("persistence_granularity", &pgr_handler);
        install_keyword("protocol", &proto_handler);
+       install_keyword("ha_suspend", &hasuspend_handler);
        install_keyword("virtualhost", &virtualhost_handler);
 
        /* Real server mapping */
@@ -807,6 +840,8 @@ init_keywords(void)
        install_sublevel();
        install_keyword("weight", &weight_handler);
        install_keyword("inhibit_on_failure", &inhibit_handler);
+       install_keyword("notify_up", &notify_up_handler);
+       install_keyword("notify_down", &notify_down_handler);
 
        /* Checkers mapping */
        install_checkers_keyword();
index 31a879d..a2a800d 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        pidfile utility.
  *
- * Version:     $Id: pidfile.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: pidfile.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 8f8ec49..4c517a2 100644 (file)
@@ -7,7 +7,7 @@
  *              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 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: smtp.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -92,8 +92,8 @@ connection_error(thread * thread)
 {
        smtp_thread_arg *smtp_arg = THREAD_ARG(thread);
 
-       DBG("SMTP connection ERROR to [%s:%d].",
-           inet_ntop2(conf_data->smtp_server), SMTP_PORT);
+       syslog(LOG_INFO, "SMTP connection ERROR to [%s:%d].",
+              inet_ntop2(conf_data->smtp_server), SMTP_PORT);
        free_smtp_all(smtp_arg);
        return 0;
 }
@@ -102,8 +102,8 @@ connection_timeout(thread * thread)
 {
        smtp_thread_arg *smtp_arg = THREAD_ARG(thread);
 
-       DBG("Timeout connecting SMTP server [%s:%d].",
-           inet_ntop2(conf_data->smtp_server), SMTP_PORT);
+       syslog(LOG_INFO, "Timeout connecting SMTP server [%s:%d].",
+              inet_ntop2(conf_data->smtp_server), SMTP_PORT);
        free_smtp_all(smtp_arg);
        return 0;
 }
@@ -133,8 +133,8 @@ connection_success(thread * thread)
 {
        smtp_thread_arg *smtp_arg = THREAD_ARG(thread);
 
-       DBG("Remote SMTP server [%s:%d] connected.",
-           inet_ntop2(conf_data->smtp_server), SMTP_PORT);
+       syslog(LOG_INFO, "Remote SMTP server [%s:%d] connected.",
+              inet_ntop2(conf_data->smtp_server), SMTP_PORT);
 
        smtp_arg->stage = connect_success;
        thread_add_read(thread->master, smtp_read_thread, smtp_arg,
@@ -155,8 +155,8 @@ smtp_read_thread(thread * thread)
        smtp_arg = THREAD_ARG(thread);
 
        if (thread->type == THREAD_READ_TIMEOUT) {
-               DBG("Timeout reading data to remote SMTP server [%s:%d].",
-                   inet_ntop2(conf_data->smtp_server), SMTP_PORT);
+               syslog(LOG_INFO, "Timeout reading data to remote SMTP server [%s:%d].",
+                      inet_ntop2(conf_data->smtp_server), SMTP_PORT);
                SMTP_FSM_READ(QUIT, thread, 0);
                return -1;
        }
@@ -169,17 +169,17 @@ smtp_read_thread(thread * thread)
        if (rcv_buffer_size == -1) {
                if (errno == EAGAIN)
                        goto end;
-               DBG("Error reading data from remote SMTP server [%s:%d].",
-                   inet_ntop2(conf_data->smtp_server), SMTP_PORT);
+               syslog(LOG_INFO, "Error reading data from remote SMTP server [%s:%d].",
+                      inet_ntop2(conf_data->smtp_server), SMTP_PORT);
                SMTP_FSM_READ(QUIT, thread, 0);
                return 0;
        }
 
        /* received data overflow buffer size ? */
        if (smtp_arg->buflen >= SMTP_BUFFER_MAX) {
-               DBG("Received buffer from remote SMTP server [%s:%d]"
-                   " overflow our get read buffer length.",
-                   inet_ntop2(conf_data->smtp_server), SMTP_PORT);
+               syslog(LOG_INFO, "Received buffer from remote SMTP server [%s:%d]"
+                      " overflow our get read buffer length."
+                      , inet_ntop2(conf_data->smtp_server), SMTP_PORT);
                SMTP_FSM_READ(QUIT, thread, 0);
                return 0;
        } else {
@@ -237,8 +237,8 @@ end:
                thread_add_write(thread->master, smtp_send_thread, smtp_arg,
                                 smtp_arg->fd, conf_data->smtp_connection_to);
        } else {
-               DBG("Can not read data from remote SMTP server [%s:%d].",
-                   inet_ntop2(conf_data->smtp_server), SMTP_PORT);
+               syslog(LOG_INFO, "Can not read data from remote SMTP server [%s:%d].",
+                      inet_ntop2(conf_data->smtp_server), SMTP_PORT);
                SMTP_FSM_READ(QUIT, thread, 0);
        }
 
@@ -251,8 +251,8 @@ smtp_send_thread(thread * thread)
        smtp_thread_arg *smtp_arg = THREAD_ARG(thread);
        
        if (thread->type == THREAD_WRITE_TIMEOUT) {
-               DBG("Timeout sending data to remote SMTP server [%s:%d].",
-                   inet_ntop2(conf_data->smtp_server), SMTP_PORT);
+               syslog(LOG_INFO, "Timeout sending data to remote SMTP server [%s:%d].",
+                      inet_ntop2(conf_data->smtp_server), SMTP_PORT);
                SMTP_FSM_READ(QUIT, thread, 0);
                return 0;
        }
@@ -270,8 +270,8 @@ smtp_send_thread(thread * thread)
                thread_add_read(thread->master, smtp_read_thread, smtp_arg,
                                thread->u.fd, conf_data->smtp_connection_to);
        } else {
-               DBG("Can not send data to remote SMTP server [%s:%d].",
-                   inet_ntop2(conf_data->smtp_server), SMTP_PORT);
+               syslog(LOG_INFO, "Can not send data to remote SMTP server [%s:%d].",
+                      inet_ntop2(conf_data->smtp_server), SMTP_PORT);
                SMTP_FSM_READ(QUIT, thread, 0);
        }
 
@@ -287,7 +287,9 @@ connection_code(thread * thread, int status)
        if (status == 220) {
                smtp_arg->stage++;
        } else {
-               DBG("Error connecting smtp server");
+               syslog(LOG_INFO, "Error connecting SMTP server[%s:%d]."
+                      " SMTP status code = %d"
+                      , inet_ntop2(conf_data->smtp_server), SMTP_PORT, status);
                smtp_arg->stage = ERROR;
        }
 
@@ -318,7 +320,9 @@ helo_code(thread * thread, int status)
        if (status == 250) {
                smtp_arg->stage++;
        } else {
-               DBG("Error processing HELO cmd");
+               syslog(LOG_INFO, "Error processing HELO cmd on SMTP server [%s:%d]."
+                      " SMTP status code = %d"
+                      , inet_ntop2(conf_data->smtp_server), SMTP_PORT, status);
                smtp_arg->stage = ERROR;
        }
 
@@ -349,7 +353,9 @@ mail_code(thread * thread, int status)
        if (status == 250) {
                smtp_arg->stage++;
        } else {
-               DBG("Error processing MAIL cmd");
+               syslog(LOG_INFO, "Error processing MAIL cmd on SMTP server [%s:%d]."
+                      " SMTP status code = %d"
+                      , inet_ntop2(conf_data->smtp_server), SMTP_PORT, status);
                smtp_arg->stage = ERROR;
        }
 
@@ -391,7 +397,9 @@ rcpt_code(thread * thread, int status)
                if (!fetched_email)
                        smtp_arg->stage++;
        } else {
-               DBG("Error processing RCPT cmd");
+               syslog(LOG_INFO, "Error processing RCPT cmd on SMTP server [%s:%d]."
+                      " SMTP status code = %d"
+                      , inet_ntop2(conf_data->smtp_server), SMTP_PORT, status);
                smtp_arg->stage = ERROR;
        }
 
@@ -417,7 +425,9 @@ data_code(thread * thread, int status)
        if (status == 354) {
                smtp_arg->stage++;
        } else {
-               DBG("Error processing DATA cmd");
+               syslog(LOG_INFO, "Error processing DATA cmd on SMTP server [%s:%d]."
+                      " SMTP status code = %d"
+                      , inet_ntop2(conf_data->smtp_server), SMTP_PORT, status);
                smtp_arg->stage = ERROR;
        }
 
@@ -468,7 +478,9 @@ body_code(thread * thread, int status)
                syslog(LOG_INFO, "SMTP alert successfully sent.");
                smtp_arg->stage++;
        } else {
-               DBG("Error processing DOT cmd");
+               syslog(LOG_INFO, "Error processing DOT cmd on SMTP server [%s:%d]."
+                      " SMTP status code = %d"
+                      , inet_ntop2(conf_data->smtp_server), SMTP_PORT, status);
                smtp_arg->stage = ERROR;
        }
 
@@ -523,7 +535,7 @@ smtp_connect(smtp_thread_arg *smtp_arg)
 /* Main entry point */
 void
 smtp_alert(thread_master * master, real_server * rs, vrrp_rt * vrrp,
-          const char *subject, const char *body)
+          vrrp_sgroup *vgroup, const char *subject, const char *body)
 {
        smtp_thread_arg *smtp_arg;
 
@@ -547,6 +559,10 @@ smtp_alert(thread_master * master, real_server * rs, vrrp_rt * vrrp,
                        snprintf(smtp_arg->subject, MAX_HEADERS_LENGTH,
                                 "[%s] VRRP Instance %s - %s",
                                 conf_data->lvs_id, vrrp->iname, subject);
+               else if (vgroup)
+                       snprintf(smtp_arg->subject, MAX_HEADERS_LENGTH,
+                                "[%s] VRRP Group %s - %s",
+                                conf_data->lvs_id, vgroup->gname, subject);
                else if (conf_data->lvs_id)
                        snprintf(smtp_arg->subject, MAX_HEADERS_LENGTH,
                                 "[%s] %s", conf_data->lvs_id, subject);
index f0d1407..bb1f48e 100755 (executable)
@@ -5,7 +5,7 @@
 # processname: keepalived
 # pidfile: /var/run/keepalived.pid
 # config: /etc/keepalived/keepalived.conf
-# chkconfig: 2345 92 08
+# chkconfig: 35 21 79
 # description: Start and stop Keepalived
 
 # Global definitions
@@ -16,12 +16,14 @@ case "$1" in
   start)
        echo -n "Starting Keepalived for LVS: "
        keepalived
+       touch /var/lock/subsys/keepalived
        echo
        ;;
   stop)
        echo -n "Shutting down Keepalived for LVS: "
        PID=`cat $PID_FILE`
        kill $PID
+       rm -rf /var/lock/subsys/keepalived
        echo
        ;;
   restart)
index a782daf..e952dde 100644 (file)
@@ -52,7 +52,8 @@ check_ssl.o: check_ssl.c ../include/check_ssl.h ../include/check_api.h \
   ../../lib/utils.h
 check_misc.o: check_misc.c ../include/check_misc.h ../include/check_api.h \
   ../../lib/memory.h ../include/ipwrapper.h ../include/smtp.h \
-  ../../lib/utils.h ../include/parser.h ../include/daemon.h
-ipwrapper.o: ipwrapper.c ../include/ipwrapper.h ../../lib/utils.h
+  ../../lib/utils.h ../../lib/notify.h ../include/parser.h ../include/daemon.h
+ipwrapper.o: ipwrapper.c ../include/ipwrapper.h ../../lib/utils.h \
+  ../../lib/notify.h
 ipvswrapper.o: ipvswrapper.c ../include/ipvswrapper.h ../../lib/utils.h \
   ../../lib/memory.h
index 815f2ad..9d9932c 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        Checkers registration.
  *
- * Version:     $Id: check_api.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: check_api.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -111,6 +111,11 @@ register_checkers_thread(void)
 
        for (e = LIST_HEAD(checkers_queue); e; ELEMENT_NEXT(e)) {
                checker = ELEMENT_DATA(e);
+               syslog(LOG_INFO,
+                      "Activating healtchecker for service [%s:%d]",
+                      inet_ntop2(CHECKER_RIP(checker)),
+                      ntohs(CHECKER_RPORT(checker)));
+               CHECKER_ENABLE(checker);
                thread_add_timer(master, checker->launch, checker,
                                 BOOTSTRAP_DELAY);
        }
@@ -131,7 +136,7 @@ update_checker_activity(uint32_t address, int enable)
        if (!LIST_ISEMPTY(checkers_queue))
                for (e = LIST_HEAD(checkers_queue); e; ELEMENT_NEXT(e)) {
                        checker = ELEMENT_DATA(e);
-                       if (CHECKER_VIP(checker) == address) {
+                       if (CHECKER_VIP(checker) == address && CHECKER_HA_SUSPEND(checker)) {
                                if (!CHECKER_ENABLED(checker) && enable)
                                        syslog(LOG_INFO,
                                               "Activating healtchecker for service [%s:%d]",
index d50bb25..3d628b2 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        CI-LINUX checker. Integration to Compaq Cluster Infrastructure.
  *
- * Version:     $Id: check_ci.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: check_ci.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Aneesh Kumar K.V, <aneesh.kumar@digital.com>
@@ -175,14 +175,14 @@ ci_check_thread(thread * thread)
        switch (status) {
        case UP:
                if (!ISALIVE(checker->rs)) {
-                       smtp_alert(thread->master, checker->rs, NULL, "UP",
+                       smtp_alert(thread->master, checker->rs, NULL, NULL, "UP",
                                   "=> CI-Linux  CHECK succeed on service <=\n\n");
                        perform_svr_state(UP, checker->vs, checker->rs);
                }
                break;
        case DOWN:
                if (ISALIVE(checker->rs)) {
-                       smtp_alert(thread->master, checker->rs, NULL, "DOWN",
+                       smtp_alert(thread->master, checker->rs, NULL, NULL, "DOWN",
                                   "=> CI-Linux CHECK failed on service <=\n\n");
                        perform_svr_state(DOWN, checker->vs, checker->rs);
                }
index 7d74ae2..e042aaa 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        WEB CHECK. Common HTTP/SSL checker primitives.
  *
- * Version:     $Id: check_http.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: check_http.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Jan Holmberg, <jan@artech.net>
@@ -95,6 +95,7 @@ alloc_http_get(char *proto)
        http_get_chk->proto =
            (!strcmp(proto, "HTTP_GET")) ? PROTO_HTTP : PROTO_SSL;
        http_get_chk->url = alloc_list(free_url, dump_url);
+       http_get_chk->nb_get_retry = 1;
 
        return http_get_chk;
 }
@@ -278,6 +279,7 @@ epilog(thread * thread, int method, int t, int c)
        http_get_checker *http_get_check = CHECKER_ARG(checker);
        http_arg *http_arg = HTTP_ARG(http_get_check);
        REQ *req = HTTP_REQ(http_arg);
+       uint16_t addr_port = get_service_port(checker);
        int delay = 0;
 
        if (method) {
@@ -285,6 +287,29 @@ epilog(thread * thread, int method, int t, int c)
                http_arg->retry_it += c ? c : -http_arg->retry_it;
        }
 
+       /*
+        * The get retry implementation mean that we retry performing
+        * a GET on the same url until the remote web server return 
+        * html buffer. This is sometime needed with some applications
+        * servers.
+        */
+       if (http_arg->retry_it > http_get_check->nb_get_retry-1) {
+               if (ISALIVE(checker->rs)) {
+                       syslog(LOG_INFO, "Check on service [%s:%d] failed after %d retry."
+                              , inet_ntop2(CHECKER_RIP(checker))
+                              , ntohs(addr_port), http_arg->retry_it);
+                       smtp_alert(thread->master, checker->rs, NULL, NULL,
+                                  "DOWN",
+                                  "=> CHECK failed on service"
+                                  " : MD5 digest mismatch <=\n\n");
+                       perform_svr_state(DOWN, checker->vs, checker->rs);
+               }
+
+               /* Reset it counters */
+               http_arg->url_it = 0;
+               http_arg->retry_it = 0;
+       }
+
        /* register next timer thread */
        switch (method) {
        case 1:
@@ -292,11 +317,13 @@ epilog(thread * thread, int method, int t, int c)
                        delay = checker->vs->delay_loop;
                else
                        delay =
-                           checker->vs->delay_loop -
                            http_get_check->delay_before_retry;
                break;
        case 2:
-               delay = http_get_check->delay_before_retry;
+               if (http_arg->url_it == 0 && http_arg->retry_it == 0)
+                       delay = checker->vs->delay_loop;
+               else
+                       delay = http_get_check->delay_before_retry;
                break;
        }
 
@@ -320,40 +347,21 @@ int
 timeout_epilog(thread * thread, char *smtp_msg, char *debug_msg)
 {
        checker *checker = THREAD_ARG(thread);
-       http_get_checker *http_get_check = CHECKER_ARG(checker);
-       http_arg *http_arg = HTTP_ARG(http_get_check);
-#ifdef _DEBUG_
        uint16_t addr_port = get_service_port(checker);
-#endif
 
-       /*
-        * The get retry implementation mean that we retry performing
-        * a GET on the same url until the remote web server return 
-        * html buffer. This is sometime needed with some applications
-        * servers.
-        */
-       if (++http_arg->retry_it <= http_get_check->nb_get_retry) {
-               DBG("Retry %s server [%s:%d] after %d retry.",
-                   debug_msg, inet_ntop2(CHECKER_RIP(checker)),
-                   ntohs(addr_port), http_arg->retry_it - 1);
-               return epilog(thread, 2, 0, 1);
+       syslog(LOG_INFO, "Timeout %s server [%s:%d].",
+              debug_msg
+              , inet_ntop2(CHECKER_RIP(checker))
+              , ntohs(addr_port));
 
-       } else {
-               if (checker->rs)
-                       DBG("Timeout %s server [%s:%d].",
-                           debug_msg, inet_ntop2(CHECKER_RIP(checker)),
-                           ntohs(addr_port));
-               /* check if server is currently alive */
-               if (ISALIVE(checker->rs)) {
-                       smtp_alert(thread->master, checker->rs, NULL, "DOWN",
-                                  smtp_msg);
-                       perform_svr_state(DOWN, checker->vs, checker->rs);
-               }
-
-               return epilog(thread, 1, 0, 0);
+       /* check if server is currently alive */
+       if (ISALIVE(checker->rs)) {
+               smtp_alert(thread->master, checker->rs, NULL, NULL,
+                          "DOWN", smtp_msg);
+               perform_svr_state(DOWN, checker->vs, checker->rs);
        }
 
-       return 0;
+       return epilog(thread, 1, 0, 0);
 }
 
 /* return the url pointer of the current url iterator  */
@@ -391,18 +399,37 @@ http_handle_response(thread * thread, unsigned char digest[16]
                        /* check if server is currently alive */
                        if (ISALIVE(checker->rs)) {
                                syslog(LOG_INFO,
-                                      "HTTP status code error to [%s:%d] url[%s]"
+                                      "HTTP status code error to [%s:%d] url(%s)"
                                       ", status_code [%d].",
                                       inet_ntop2(CHECKER_RIP(checker)),
                                       ntohs(addr_port), fetched_url->path,
                                       req->status_code);
-                               smtp_alert(thread->master, checker->rs, NULL,
+                               smtp_alert(thread->master, checker->rs, NULL, NULL,
                                           "DOWN",
                                           "=> CHECK failed on service"
                                           " : HTTP status code mismatch <=\n\n");
                                perform_svr_state(DOWN, checker->vs, checker->rs);
+                       } else {
+                               DBG("HTTP Status_code to [%s:%d] url(%d) = [%d].",
+                                   inet_ntop2(CHECKER_RIP(checker))
+                                   , ntohs(addr_port)
+                                   , http_arg->url_it + 1
+                                   , req->status_code);
+                               /*
+                                * We set retry iterator to max value to not retry
+                                * when service is already know as die.
+                                */
+                               http_arg->retry_it = http_get_check->nb_get_retry;
                        }
-                       return epilog(thread, 1, 0, 0);
+                       return epilog(thread, 2, 0, 1);
+               } else {
+                       if (!ISALIVE(checker->rs))
+                               syslog(LOG_INFO,
+                                      "HTTP status code success to [%s:%d] url(%d).",
+                                      inet_ntop2(CHECKER_RIP(checker))
+                                      , ntohs(addr_port)
+                                      , http_arg->url_it + 1);
+                       return epilog(thread, 1, 1, 0) + 1;
                }
        }
 
@@ -413,10 +440,6 @@ http_handle_response(thread * thread, unsigned char digest[16]
                for (di = 0; di < 16; di++)
                        sprintf(digest_tmp + 2 * di, "%02x", digest[di]);
 
-               DBG("MD5SUM to [%s:%d] url(%d) = [%s].",
-                   inet_ntop2(CHECKER_RIP(checker)), ntohs(addr_port),
-                   http_arg->url_it + 1, digest_tmp);
-
                r = strcmp(fetched_url->digest, digest_tmp);
 
                if (r) {
@@ -428,18 +451,26 @@ http_handle_response(thread * thread, unsigned char digest[16]
                                       inet_ntop2(CHECKER_RIP(checker)),
                                       ntohs(addr_port), fetched_url->path,
                                       digest_tmp);
-                               smtp_alert(thread->master, checker->rs, NULL,
-                                          "DOWN",
-                                          "=> CHECK failed on service"
-                                          " : MD5 digest mismatch <=\n\n");
-                               perform_svr_state(DOWN, checker->vs, checker->rs);
+                       } else {
+                               DBG("MD5SUM to [%s:%d] url(%d) = [%s].",
+                                   inet_ntop2(CHECKER_RIP(checker))
+                                   , ntohs(addr_port)
+                                   , http_arg->url_it + 1
+                                   , digest_tmp);
+                               /*
+                                * We set retry iterator to max value to not retry
+                                * when service is already know as die.
+                                */
+                               http_arg->retry_it = http_get_check->nb_get_retry;
                        }
                        FREE(digest_tmp);
-                       return epilog(thread, 1, 0, 0);
+                       return epilog(thread, 2, 0, 1);
                } else {
-                       DBG("MD5 digest success to [%s:%d] url(%d).",
-                           inet_ntop2(CHECKER_RIP(checker)), ntohs(addr_port),
-                           http_arg->url_it + 1);
+                       if (!ISALIVE(checker->rs))
+                               syslog(LOG_INFO, "MD5 digest success to [%s:%d] url(%d).",
+                                      inet_ntop2(CHECKER_RIP(checker))
+                                      , ntohs(addr_port)
+                                      , http_arg->url_it + 1);
                        FREE(digest_tmp);
                        return epilog(thread, 1, 1, 0) + 1;
                }
@@ -490,9 +521,7 @@ http_read_thread(thread * thread)
        http_get_checker *http_get_check = CHECKER_ARG(checker);
        http_arg *http_arg = HTTP_ARG(http_get_check);
        REQ *req = HTTP_REQ(http_arg);
-#ifdef _DEBUG_
        uint16_t addr_port = get_service_port(checker);
-#endif
        unsigned char digest[16];
        int r = 0;
 
@@ -512,11 +541,12 @@ http_read_thread(thread * thread)
 
                if (r == -1) {
                        /* We have encourred a real read error */
-                       DBG("Read error with server [%s:%d]: %s",
-                           inet_ntop2(CHECKER_RIP(checker)), ntohs(addr_port),
-                           strerror(errno));
                        if (ISALIVE(checker->rs)) {
-                               smtp_alert(thread->master, checker->rs, NULL,
+                               syslog(LOG_INFO, "Read error with server [%s:%d]: %s",
+                                      inet_ntop2(CHECKER_RIP(checker))
+                                      , ntohs(addr_port)
+                                      , strerror(errno));
+                               smtp_alert(thread->master, checker->rs, NULL, NULL,
                                           "DOWN",
                                           "=> HTTP CHECK failed on service"
                                           " : cannot receive data <=\n\n");
@@ -608,8 +638,9 @@ http_request_thread(thread * thread)
                 (vhost) ? vhost : inet_ntop2(CHECKER_RIP(checker))
                 , ntohs(addr_port));
        DBG("Processing url(%d) of [%s:%d].",
-           http_arg->url_it + 1, inet_ntop2(CHECKER_RIP(checker)),
-           ntohs(addr_port));
+           http_arg->url_it + 1
+           , inet_ntop2(CHECKER_RIP(checker))
+           , ntohs(addr_port));
 
        /* Send the GET request to remote Web server */
        if (http_get_check->proto == PROTO_SSL)
@@ -630,7 +661,8 @@ http_request_thread(thread * thread)
 
                /* check if server is currently alive */
                if (ISALIVE(checker->rs)) {
-                       smtp_alert(thread->master, checker->rs, NULL, "DOWN",
+                       smtp_alert(thread->master, checker->rs, NULL, NULL,
+                                  "DOWN",
                                   "=> CHECK failed on service"
                                   " : cannot send data <=\n\n");
                        perform_svr_state(DOWN, checker->vs, checker->rs);
@@ -662,11 +694,13 @@ http_check_thread(thread * thread)
                                  , addr_port, http_check_thread);
        switch (status) {
        case connect_error:
-               DBG("Error connecting server [%s:%d].",
-                   inet_ntop2(CHECKER_RIP(checker)), ntohs(addr_port));
                /* check if server is currently alive */
                if (ISALIVE(checker->rs)) {
-                       smtp_alert(thread->master, checker->rs, NULL, "DOWN",
+                       syslog(LOG_INFO, "Error connecting server [%s:%d].",
+                              inet_ntop2(CHECKER_RIP(checker))
+                              , ntohs(addr_port));
+                       smtp_alert(thread->master, checker->rs, NULL, NULL,
+                                  "DOWN",
                                   "=> CHECK failed on service"
                                   " : connection error <=\n\n");
                        perform_svr_state(DOWN, checker->vs, checker->rs);
@@ -699,9 +733,9 @@ http_check_thread(thread * thread)
                                                 thread->u.fd,
                                                 http_get_check->connection_to);
                        } else {
-                               DBG("Connection trouble to: [%s:%d].",
-                                   inet_ntop2(CHECKER_RIP(checker)),
-                                   ntohs(addr_port));
+                               syslog(LOG_INFO, "Connection trouble to: [%s:%d].",
+                                      inet_ntop2(CHECKER_RIP(checker))
+                                      , ntohs(addr_port));
 #ifdef _DEBUG_
                                if (http_get_check->proto == PROTO_SSL)
                                        ssl_printerr(SSL_get_error
@@ -746,12 +780,12 @@ http_connect_thread(thread * thread)
                 * check if server is currently alive.
                 */
                if (!ISALIVE(checker->rs)) {
-                       smtp_alert(thread->master, checker->rs, NULL, "UP",
+                       syslog(LOG_INFO, "Remote Web server [%s:%d] succeed on service.",
+                              inet_ntop2(CHECKER_RIP(checker))
+                              , ntohs(addr_port));
+                       smtp_alert(thread->master, checker->rs, NULL, NULL, "UP",
                                   "=> CHECK succeed on service <=\n\n");
                        perform_svr_state(UP, checker->vs, checker->rs);
-                       DBG("Remote Web server [%s:%d] succeed on service.",
-                           inet_ntop2(CHECKER_RIP(checker)),
-                           ntohs(addr_port));
                }
                http_arg->req = NULL;
                return epilog(thread, 1, 0, 0) + 1;
index 64d46c0..d147aa4 100644 (file)
@@ -6,7 +6,7 @@
  * Part:        MISC CHECK. Perform a system call to run an extra
  *              system prog or script.
  *
- * Version:     $Id: check_misc.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: check_misc.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Eric Jarman, <ehj38230@cmsu2.cmsu.edu>
@@ -29,7 +29,7 @@
 #include "smtp.h"
 #include "utils.h"
 #include "parser.h"
-#include "daemon.h"
+#include "notify.h"
 
 int misc_check_thread(thread *);
 
@@ -115,10 +115,11 @@ misc_check_thread(thread * thread)
                return -1;
        }
 
-       /* In case of this is parent process. */
+       /* In case of this is parent process */
        if (pid)
-               return (0);
+               return 0;
 
+       /* Child part */
        closeall(0);
 
        open("/dev/null", O_RDWR);
@@ -131,14 +132,14 @@ misc_check_thread(thread * thread)
                if (status == 0) {
                        /* everything is good */
                        if (!ISALIVE(checker->rs)) {
-                               smtp_alert(thread->master, checker->rs, NULL,
+                               smtp_alert(thread->master, checker->rs, NULL, NULL,
                                           "UP",
                                           "=> MISC CHECK succeed on service <=\n\n");
                                perform_svr_state(UP, checker->vs, checker->rs);
                        }
                } else {
                        if (ISALIVE(checker->rs)) {
-                               smtp_alert(thread->master, checker->rs, NULL,
+                               smtp_alert(thread->master, checker->rs, NULL, NULL,
                                           "DOWN",
                                           "=> MISC CHECK failed on service <=\n\n");
                                perform_svr_state(DOWN, checker->vs, checker->rs);
index 4ac8fcb..767f32e 100644 (file)
@@ -7,7 +7,7 @@
  *              url, compute a MD5 over this result and match it to the
  *              expected value.
  *
- * Version:     $Id: check_ssl.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: check_ssl.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Jan Holmberg, <jan@artech.net>
@@ -158,29 +158,29 @@ ssl_printerr(int err)
 
        switch (err) {
        case SSL_ERROR_ZERO_RETURN:
-               DBG("  SSL error: (zero return)");
+               syslog(LOG_INFO, "  SSL error: (zero return)");
                break;
        case SSL_ERROR_WANT_READ:
-               DBG("  SSL error: (read error)");
+               syslog(LOG_INFO, "  SSL error: (read error)");
                break;
        case SSL_ERROR_WANT_WRITE:
-               DBG("  SSL error: (write error)");
+               syslog(LOG_INFO, "  SSL error: (write error)");
                break;
        case SSL_ERROR_WANT_CONNECT:
-               DBG("  SSL error: (connect error)");
+               syslog(LOG_INFO, "  SSL error: (connect error)");
                break;
        case SSL_ERROR_WANT_X509_LOOKUP:
-               DBG("  SSL error: (X509 lookup error)");
+               syslog(LOG_INFO, "  SSL error: (X509 lookup error)");
                break;
        case SSL_ERROR_SYSCALL:
-               DBG("  SSL error: (syscall error)");
+               syslog(LOG_INFO, "  SSL error: (syscall error)");
                break;
        case SSL_ERROR_SSL:{
                        ssl_strerr = (char *) MALLOC(500);
 
                        extended_error = ERR_get_error();
                        ERR_error_string(extended_error, ssl_strerr);
-                       DBG("  SSL error: (%s)", ssl_strerr);
+                       syslog(LOG_INFO, "  SSL error: (%s)", ssl_strerr);
                        FREE(ssl_strerr);
                        break;
                }
@@ -256,7 +256,7 @@ ssl_read_thread(thread * thread)
                if (r && !req->extracted) {
                        /* check if server is currently alive */
                        if (ISALIVE(checker->rs)) {
-                               smtp_alert(thread->master, checker->rs, NULL,
+                               smtp_alert(thread->master, checker->rs, NULL, NULL,
                                           "DOWN",
                                           "=> SSL CHECK failed on service"
                                           " : cannot receive data <=\n\n");
index 50bd7d0..3427b01 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        TCP checker.
  *
- * Version:     $Id: check_tcp.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: check_tcp.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -108,22 +108,26 @@ tcp_check_thread(thread * thread)
         * Otherwise we have a real connection error or connection timeout.
         */
        if (status == connect_success) {
-               DBG("TCP connection to [%s:%d] success.",
-                   inet_ntop2(CHECKER_RIP(checker)), ntohs(addr_port));
                close(thread->u.fd);
 
                if (!ISALIVE(checker->rs)) {
-                       smtp_alert(thread->master, checker->rs, NULL, "UP",
+                       syslog(LOG_INFO, "TCP connection to [%s:%d] success.",
+                              inet_ntop2(CHECKER_RIP(checker))
+                              , ntohs(addr_port));
+                       smtp_alert(thread->master, checker->rs, NULL, NULL,
+                                  "UP",
                                   "=> TCP CHECK succeed on service <=\n\n");
                        perform_svr_state(UP, checker->vs, checker->rs);
                }
 
        } else {
-               DBG("TCP connection to [%s:%d] failed !!!",
-                   inet_ntop2(CHECKER_RIP(checker)), ntohs(addr_port));
 
                if (ISALIVE(checker->rs)) {
-                       smtp_alert(thread->master, checker->rs, NULL, "DOWN",
+                       syslog(LOG_INFO, "TCP connection to [%s:%d] failed !!!",
+                              inet_ntop2(CHECKER_RIP(checker))
+                              , ntohs(addr_port));
+                       smtp_alert(thread->master, checker->rs, NULL, NULL,
+                                  "DOWN",
                                   "=> TCP CHECK failed on service <=\n\n");
                        perform_svr_state(DOWN, checker->vs, checker->rs);
                }
index 7ac1ad7..99efaa0 100644 (file)
@@ -7,7 +7,7 @@
  *              library to add/remove server MASQ rules to the kernel 
  *              firewall framework.
  *
- * Version:     $Id: ipfwwrapper.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: ipfwwrapper.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 3ebc93f..57ce53a 100644 (file)
@@ -6,7 +6,7 @@
  * Part:        IPVS Kernel wrapper. Use setsockopt call to add/remove
  *              server to/from the loadbalanced server pool.
  *  
- * Version:     $Id: ipvswrapper.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: ipvswrapper.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  * 
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              
index 4e00718..f558da7 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        Manipulation functions for IPVS & IPFW wrappers.
  *
- * Version:     $id: ipwrapper.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $id: ipwrapper.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -22,6 +22,7 @@
 
 #include "ipwrapper.h"
 #include "utils.h"
+#include "notify.h"
 
 /* extern global vars */
 extern data *conf_data;
@@ -240,6 +241,16 @@ perform_svr_state(int alive, virtual_server * vs, real_server * rs)
                       , inet_ntoa2(SVR_IP(vs), vsip)
                       , ntohs(SVR_PORT(vs)));
                ipvs_cmd(LVS_CMD_ADD_DEST, vs, rs);
+               if (rs->notify_up) {
+                       syslog(LOG_INFO, "Executing [%s] for service [%s:%d]"
+                              " in VS [%s:%d]"
+                              , rs->notify_up
+                              , inet_ntoa2(SVR_IP(rs), rsip)
+                              , ntohs(SVR_PORT(rs))
+                              , inet_ntoa2(SVR_IP(vs), vsip)
+                              , ntohs(SVR_PORT(vs)));
+                       notify_exec(rs->notify_up);
+               }
 #ifdef _KRNL_2_2_
                if (vs->nat_mask == HOST_NETMASK)
                        ipfw_cmd(IP_FW_CMD_ADD, vs, rs);
@@ -257,6 +268,16 @@ perform_svr_state(int alive, virtual_server * vs, real_server * rs)
 
                /* server is down, it is removed from the LVS realserver pool */
                ipvs_cmd(LVS_CMD_DEL_DEST, vs, rs);
+               if (rs->notify_down) {
+                       syslog(LOG_INFO, "Executing [%s] for service [%s:%d]"
+                              " in VS [%s:%d]"
+                              , rs->notify_down
+                              , inet_ntoa2(SVR_IP(rs), rsip)
+                              , ntohs(SVR_PORT(rs))
+                              , inet_ntoa2(SVR_IP(vs), vsip)
+                              , ntohs(SVR_PORT(vs)));
+                       notify_exec(rs->notify_down);
+               }
 
 #ifdef _KRNL_2_2_
                if (vs->nat_mask == HOST_NETMASK)
index 5e0dfdf..08188af 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        Checkers arguments structures definitions.
  *
- * Version:     $Id: check_api.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: check_api.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -55,6 +55,7 @@ list checkers_queue;
 #define CHECKER_ENABLED(C) ((C)->enabled)
 #define CHECKER_ENABLE(C)  ((C)->enabled = 1)
 #define CHECKER_DISABLE(C) ((C)->enabled = 0)
+#define CHECKER_HA_SUSPEND(C) ((C)->vs->ha_suspend)
 
 /* Prototypes definition */
 extern void init_checkers_queue(void);
index 1ed4ecf..8a58a65 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        check_ci.c include file.
  *
- * Version:     $Id: check_ci.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: check_ci.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Aneesh Kumar K.V, <aneesh.kumar@digital.com>
index 5c585ad..00efcc3 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        check_http.c include file.
  *
- * Version:     $Id: check_http.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: check_http.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Jan Holmberg, <jan@artech.net>
index 3144522..dfda75d 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        check_misc.c include file.
  *
- * Version:     $Id: check_misc.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: check_misc.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              Eric Jarman, <ehj38230@cmsu2.cmsu.edu>
index 2e13b63..224f01a 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        check_http.c include file.
  *
- * Version:     $Id: check_http.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: check_http.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Jan Holmberg, <jan@artech.net>
index 659649f..1a595ca 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        check_tcp.c include file.
  *
- * Version:     $Id: check_tcp.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: check_tcp.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index b033bb0..32bf462 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        Daemon process handling.
  *
- * Version:     $Id: daemon.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: daemon.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -35,7 +35,5 @@
 
 /* prototype */
 extern pid_t xdaemon(int, int, int);
-extern void closeall(int fd);
-extern int system_call(char *cmdline);
 
 #endif
index cbc4171..dab87c2 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        Dynamic data structure definition.
  *
- * Version:     $Id: data.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: data.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -73,6 +73,8 @@ typedef struct _real_server {
        int inhibit;            /* Set weight to 0 instead of removing
                                 * the service from IPVS topology.
                                 */
+       char *notify_up;        /* Script to launch when RS is added to LVS */
+       char *notify_down;      /* Script to launch when RS is removed from LVS */
        int alive;
 } real_server;
 
@@ -90,6 +92,7 @@ typedef struct _virtual_server {
        uint16_t addr_port;
        uint16_t service_type;
        int delay_loop;
+       int ha_suspend;
        char sched[SCHED_MAX_LENGTH];
        char timeout_persistence[MAX_TIMEOUT_LENGTH];
        unsigned loadbalancing_kind;
index 28b7b37..a664432 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        ipfwwrapper.c include file.
  *
- * Version:     $Id: ipfwwrapper.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: ipfwwrapper.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index de64ff3..53f9474 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        ipvswrapper.c include file.
  *
- * Version:     $Id: ipvswrapper.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: ipvswrapper.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 7cc31d2..e05030a 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        ipwrapper.c include file.
  *
- * Version:     $Id: ipwrapper.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: ipwrapper.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index de1e783..eca52b4 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        layer4.c include file.
  *
- * Version:     $Id: layer4.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: layer4.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index ba1e7c9..3ae62d3 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        Main program include file.
  *
- * Version:     $Id: main.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: main.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -65,8 +65,8 @@ extern void register_vrrp_thread(void);
 /* Build version */
 #define PROG    "Keepalived"
 
-#define VERSION_CODE 0x000706
-#define DATE_CODE    0x140A02
+#define VERSION_CODE 0x010000
+#define DATE_CODE    0x060103
 
 #define KEEPALIVED_VERSION(version)    \
        (version >> 16) & 0xFF,         \
index 45ee731..7320bcf 100644 (file)
@@ -5,7 +5,7 @@
  * 
  * Part:        cfreader.c include file.
  *  
- * Version:     $Id: parser.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: parser.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 4a69b17..b4fc76e 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        pidfile.c include file.
  *
- * Version:     $Id: pidfile.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: pidfile.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 2598c24..68879b5 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        smtp.c include file.
  *
- * Version:     $Id: smtp.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: smtp.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -88,6 +88,7 @@ typedef struct _smtp_thread_arg {
 #define SMTP_QUIT_CMD    "QUIT\r\n"
 
 /* Prototypes defs */
-extern void smtp_alert(thread_master *, real_server *, vrrp_rt *, const char *,
-                      const char *);
+extern void smtp_alert(thread_master *,
+                      real_server *, vrrp_rt *,  vrrp_sgroup *,
+                      const char *, const char *);
 #endif
index af301db..7516c66 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Part:        vrrp.c program include file.
  *
- * Version:     $Id: vrrp.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -77,6 +77,7 @@ typedef struct _vrrp_sgroup {
        char *script_backup;
        char *script_master;
        char *script_fault;
+       int smtp_alert;
 } vrrp_sgroup;
 
 /* parameters per virtual router -- rfc2338.6.1.2 */
index b922c8e..8f4d03d 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        vrrp_arp.c include file.
  *
- * Version:     $Id: vrrp_arp.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_arp.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index b19fa7e..0ad0605 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        vrrp_if.c include file.
  *
- * Version:     $Id: vrrp_if.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_if.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -75,6 +75,7 @@ list if_queue;
 #define IF_NAME(X) ((X)->ifname)
 #define IF_INDEX(X) ((X)->ifindex)
 #define IF_ADDR(X) ((X)->address)
+#define IF_MTU(X) ((X)->mtu)
 #define IF_HWADDR(X) ((X)->hw_addr)
 #define IF_MII_SUPPORTED(X) ((X)->lb_type & LB_MII)
 #define IF_ETHTOOL_SUPPORTED(X) ((X)->lb_type & LB_ETHTOOL)
index 8f87fac..d1691fa 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        vrrp_ipaddress.c include file.
  *
- * Version:     $Id: vrrp_ipaddress.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_ipaddress.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 1631651..efa9a31 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        vrrp_ipsecah.c include file.
  * 
- * Version:     $Id: vrrp_ipsecah.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_ipsecah.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  * 
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              
index 2061738..0942da4 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        vrrp_netlink.c include file.
  *
- * Version:     $Id: vrrp_netlink.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_netlink.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 186b316..543e092 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Part:        vrrp_notify.c include file.
  *
- * Version:     $Id: vrrp_notify.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_notify.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 3278840..6d71c4d 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        vrrp_scheduler.c include file.
  * 
- * Version:     $Id: vrrp_scheduler.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_scheduler.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  * 
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              
index ab3560d..c71167f 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        vrrp_sync.c include file.
  * 
- * Version:     $Id: vrrp_sync.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_sync.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  * 
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              
 #define GROUP_NAME(G)  ((G)->gname)
 
 /* extern prototypes */
-extern void vrrp_init_instance_sands(vrrp_rt * vrrp);
-extern vrrp_sgroup *vrrp_get_sync_group(char *iname);
-extern int vrrp_sync_group_up(vrrp_sgroup * vgroup);
-extern int vrrp_sync_leave_fault(vrrp_rt * vrrp);
+extern void vrrp_init_instance_sands(vrrp_rt *);
+extern vrrp_sgroup *vrrp_get_sync_group(char *);
+extern void vrrp_sync_set_group(vrrp_sgroup *);
+extern int vrrp_sync_group_up(vrrp_sgroup *);
+extern int vrrp_sync_leave_fault(vrrp_rt *);
 extern void vrrp_sync_backup(vrrp_rt *);
 extern void vrrp_sync_master(vrrp_rt *);
 extern void vrrp_sync_master_election(vrrp_rt *);
diff --git a/keepalived/samples/keepalived.conf.SYNOPSIS b/keepalived/samples/keepalived.conf.SYNOPSIS
new file mode 100644 (file)
index 0000000..5be6428
--- /dev/null
@@ -0,0 +1,153 @@
+This file describe all the Keepalived available keywords. The keepalived.conf
+file is compounded by three configurations parts :
+
+       * Globals configurations
+       * VRRP configuration
+       * LVS configuration
+
+0. Comment string
+
+There is 2 valid comment valid string : # or ! If you want to add comment
+in you configuration file use this char.
+
+1. Globals configurations
+
+The configuration block looks like :
+
+global_defs {                          # Block identification
+   notification_email {                        # Email to send alertes to
+     <EMAIL ADDRESS>                   # Standard email address
+     <EMAIL ADDRESS>
+     ...
+   }
+   notification_email_from <EMAIL ADDRESS> # Email From dealing with SMTP proto
+   smtp_server <IP ADDRESS>               # SMTP server IP address
+   smtp_connect_timeout <INTEGER>         # Number of seconds timeout connect
+                                          #  remote SMTP server
+   lvs_id <STRING>                        # String identifying router
+}
+
+
+2. VRRP configuration
+
+This block is divided in 2 sub-block :
+
+       * VRRP synchronization group
+       * VRRP instance
+
+       2.1. VRRP synchronization group
+
+       The configuration block looks like :
+
+vrrp_sync_group <STRING> {     # VRRP sync group declaration
+  group {                      # group of instance to sync together
+    <STRING>                   #   a
+    <STRING>                   #       set
+    ...                                #             of VRRP_Instance string
+  }
+  notify_master <STRING>|<QUOTED-STRING> # Script to run during MASTER transit
+  notify_backup <STRING>|<QUOTED-STRING> # Script to run during BACKUP transit
+  notify_fault <STRING>|<QUOTED-STRING>  # Script to run during FAULT transit
+  smtp_alert            # Send email notif during state transit
+}
+
+       2.2. VRRP instance
+
+       The configuration block looks like :
+
+vrrp_instance <STRING> {               # VRRP instance declaration
+    state MASTER|BACKUP                        # Start-up default state
+    interface <STRING>                 # Binding interface
+    mcast_src_ip <IP ADDRESS>          # src_ip to use into the VRRP packets
+    lvs_sync_daemon_interface <STRING> # Binding interface for lvs syncd
+    garp_master_delay <INTEGER>                # delay for gratuitous ARP after MASTER
+                                       #  state transition
+    virtual_router_id <INTEGER-0..255> # VRRP VRID
+    priority <INTEGER-0..255>          # VRRP PRIO
+    advert_int <INTEGER>               # VRRP Advert interval (use default)
+    authentication {                   # Authentication block
+        auth_type PASS|AH              # Simple Passwd or IPSEC AH
+        auth_pass <STRING>             # Password string
+    }
+    virtual_ipaddress {                        # VRRP IP addres block
+        <IP ADDRESS>
+        <IP ADDRESS>
+        ...
+    }
+    virtual_ipaddress_excluded {       # VRRP IP to excluded from VRRP
+        <IP ADDRESS>                   # packets
+        <IP ADDRESS>
+        ...
+    }
+    preempt                            # VRRP preempt mode (default set)
+    debug                              # Debug level
+    notify_master <STRING>|<QUOTED-STRING> # Same as vrrp_sync_group
+    notify_backup <STRING>|<QUOTED-STRING> # Same as vrrp_sync_group
+    notify_fault <STRING>|<QUOTED-STRING>  # Same as vrrp_sync_group
+    smtp_alert                            # Same as vrrp_sync_group
+}
+
+
+3. LVS configuration
+
+The configuration block looks like :
+
+
+virtual_server <IP ADDRESS> <PORT> {   # VS declaration
+    delay_loop <INTEGER>               # delay timer for service polling
+    lb_algo rr|wrr|lc|wlc|lblc|sh|dh   # LVS scheduler used
+    lb_kind NAT|DR|TUN                 # LVS method used
+    persistence_timeout <INTEGER>      # LVS persistence timeout
+    persistence_granularity <NETMASK>  # LVS granularity mask
+    protocol TCP                       # Only TCP is implemented
+    ha_suspend                         # If VS IP address is not set, suspend
+                                       #  healthcheckers activity
+    virtualhost <STRING>               # VirtualHost string to use for
+                                       #  HTTP_GET or SSL_GET
+
+    sorry_server <IP ADDRESS> <PORT>   # RS to add to LVS topology when all
+                                       #   realserver are down
+
+    real_server <IP ADDRESS> <PORT> {  # RS declaration
+        weight <INTEGER>               # weight to use (default: 1)
+        inhibit_on_failure             # Set weight to 0 on healtchecker
+                                       #  failure
+        notify_up <STRING>|<QUOTED-STRING> # Script to launch when
+                                          #  healthchecker consider service
+                                          #  as up.
+        notify_down <STRING>|<QUOTED-STRING> # Script to launch when 
+                                            #  healthchecker consider service
+                                            #  as down.
+       
+        HTTP_GET|SSL_GET {             # HTTP and SSL healthcheckers
+            url {                      # A set of url to test
+              path <STRING>            # Path
+              digest <STRING>          # Digest computed with genhash
+              status_code <INTEGER>    # status code returned into the HTTP
+            }                           #   header.
+            url {
+              path <STRING>
+              digest <STRING>
+              status_code <INTEGER>
+            }
+            ...
+            connect_port <PORT>                # TCP port to connect
+            connect_timeout <INTEGER>  # Timeout connection
+            nb_get_retry <INTEGER>     # number of get retry
+            delay_before_retry <INTEGER> # delay before retry
+        }
+    }
+
+    real_server <IP ADDRESS> <PORT> {  # Idem
+        weight <INTEGER>               # Idem
+        inhibit_on_failure             # Idem
+        notify_up <STRING>|<QUOTED-STRING> # Idem
+        notify_down <STRING>|<QUOTED-STRING> # Idem
+
+        TCP_CHECK {                    # TCP healthchecker
+            connect_port <PORT>                # TCP port to connect
+            connect_timeout <INTEGER>  # Timeout connection
+        }
+    }
+}
+
index de53940..b44f344 100644 (file)
@@ -29,7 +29,8 @@ distclean: clean
 vrrp.o: vrrp.c ../include/vrrp.h ../include/vrrp_scheduler.h \
   ../include/vrrp_notify.h ../include/ipvswrapper.h ../../lib/memory.h \
   ../../lib/list.h ../include/data.h ../include/vrrp_arp.h
-vrrp_notify.o: vrrp_notify.c ../include/vrrp_notify.h ../../lib/memory.h
+vrrp_notify.o: vrrp_notify.c ../include/vrrp_notify.h ../../lib/memory.h \
+  ../../lib/notify.h
 vrrp_scheduler.o: vrrp_scheduler.c ../include/vrrp_scheduler.h \
   ../include/vrrp_ipsecah.h ../include/vrrp_if.h ../include/vrrp.h \
   ../include/vrrp_sync.h ../include/vrrp_notify.h ../include/ipvswrapper.h \
index b07d12a..4c8e41a 100644 (file)
@@ -8,7 +8,7 @@
  *              master fails, a backup server takes over.
  *              The original implementation has been made by jerome etienne.
  *
- * Version:     $Id: vrrp.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -170,13 +170,13 @@ vrrp_in_chk_ipsecah(vrrp_rt * vrrp, char *buffer)
         * sender counter.
         */
        vrrp->ipsecah_counter->seq_number++;
-       if (ah->seq_number >= vrrp->ipsecah_counter->seq_number) {
+       if (ah->seq_number >= vrrp->ipsecah_counter->seq_number || vrrp->sync) {
                vrrp->ipsecah_counter->seq_number = ah->seq_number;
        } else {
                syslog(LOG_INFO,
                       "VRRP_Instance(%s) IPSEC-AH : sequence number %d"
-                      " already proceeded. Packet dropped", vrrp->iname
-                      , ah->seq_number);
+                      " already proceeded. Packet dropped. Local(%d)", vrrp->iname
+                      , ah->seq_number, vrrp->ipsecah_counter->seq_number);
                return 1;
        }
 
@@ -762,7 +762,11 @@ vrrp_state_backup(vrrp_rt * vrrp, char *buf, int buflen)
                vrrp->ms_down_timer =
                    3 * vrrp->adver_int + VRRP_TIMER_SKEW(vrrp);
        } else if (hd->priority < vrrp->priority) {
+               syslog(LOG_INFO,
+                      "VRRP_Instance(%s) forcing a new MASTER election",
+                      vrrp->iname);
                vrrp->wantstate = VRRP_STATE_GOTO_MASTER;
+               vrrp_send_adv(vrrp, vrrp->priority);
        }
 }
 
@@ -829,7 +833,8 @@ vrrp_state_master_rx(vrrp_rt * vrrp, char *buf, int buflen)
                if (iph->protocol == IPPROTO_IPSEC_AH) {
                        ah = (ipsec_ah *) (buf + sizeof(struct iphdr));
                        syslog(LOG_INFO, "VRRP_Instance(%s) IPSEC-AH : Syncing seq_num"
-                              " with received = %d", vrrp->iname, ah->seq_number);
+                              " - Increment seq"
+                              , vrrp->iname);
                        vrrp->ipsecah_counter->seq_number = ah->seq_number + 1;
                        vrrp->ipsecah_counter->cycle = 0;
                }
@@ -845,6 +850,14 @@ vrrp_state_master_rx(vrrp_rt * vrrp, char *buf, int buflen)
                syslog(LOG_INFO,
                       "VRRP_Instance(%s) Received higher prio advert",
                       vrrp->iname);
+               if (iph->protocol == IPPROTO_IPSEC_AH) {
+                       ah = (ipsec_ah *) (buf + sizeof(struct iphdr));
+                       syslog(LOG_INFO, "VRRP_Instance(%s) IPSEC-AH : Syncing seq_num"
+                              " - Decrement seq"
+                              , vrrp->iname);
+                       vrrp->ipsecah_counter->seq_number = ah->seq_number - 1;
+                       vrrp->ipsecah_counter->cycle = 0;
+               }
                vrrp->ms_down_timer =
                    3 * vrrp->adver_int + VRRP_TIMER_SKEW(vrrp);
                vrrp->wantstate = VRRP_STATE_BACK;
index f0b35fb..88cbdb0 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        ARP primitives.
  *
- * Version:     $Id: vrrp_arp.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_arp.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index bfbee33..fb8b4a6 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        Interfaces manipulation.
  *
- * Version:     $Id: vrrp_if.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_if.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 60c0735..e4506b2 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        NETLINK IPv4 address manipulation.
  *
- * Version:     $Id: vrrp_ipaddress.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_ipaddress.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index f717474..fa7f2db 100644 (file)
@@ -7,7 +7,7 @@
  *              authentication data encryption using HMAC MD5 according to
  *              RFCs 2085 & 2104.
  *
- * Version:     $Id: vrrp_ipsecah.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_ipsecah.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index ca4a522..e65c5ca 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        NETLINK kernel command channel.
  *
- * Version:     $Id: vrrp_netlink.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_netlink.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 20f53db..921c82c 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        VRRP state transition notification scripts handling.
  *
- * Version:     $Id: vrrp_notify.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_notify.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -26,7 +26,7 @@
 /* local include */
 #include "vrrp_notify.h"
 #include "memory.h"
-#include "daemon.h"
+#include "notify.h"
 
 static char *
 get_iscript(vrrp_rt * vrrp, int state)
@@ -75,35 +75,6 @@ notify_script_name(char *cmdline)
        return script;
 }
 
-/* Execute extern script/program */
-static int
-notify_exec(char *cmd)
-{
-       pid_t pid;
-
-       pid = fork();
-
-       /* In case of fork is error. */
-       if (pid < 0) {
-               syslog(LOG_INFO, "Failed fork process");
-               return -1;
-       }
-
-       /* In case of this is parent process. */
-       if (pid)
-               return (0);
-
-       closeall(0);
-
-       open("/dev/null", O_RDWR);
-       dup(0);
-       dup(0);
-
-       system_call(cmd);
-
-       exit(0);
-}
-
 static int
 script_open(char *script)
 {
index 29bf940..12795bb 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        Sheduling framework for vrrp code.
  *
- * Version:     $Id: vrrp_scheduler.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_scheduler.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -125,7 +125,7 @@ struct {
 {
   { {NULL}, {NULL},                      {NULL},             {NULL}            },
   { {NULL}, {vrrp_sync_master_election}, {vrrp_sync_master}, {vrrp_sync_fault} },
-  { {NULL}, {vrrp_sync_backup},          {NULL},             {vrrp_sync_fault} },
+  { {NULL}, {vrrp_sync_backup},          {vrrp_sync_master}, {vrrp_sync_fault} },
   { {NULL}, {vrrp_sync_backup},          {vrrp_sync_master}, {vrrp_sync_fault} }
 };
 
@@ -136,11 +136,11 @@ vrrp_smtp_notifier(vrrp_rt * vrrp)
 {
        if (vrrp->smtp_alert) {
                if (vrrp->state == VRRP_STATE_MAST)
-                       smtp_alert(master, NULL, vrrp,
+                       smtp_alert(master, NULL, vrrp, NULL,
                                   "Entering MASTER state",
                                   "=> VRRP Instance is now owning VRRP VIPs <=\n\n");
                if (vrrp->state == VRRP_STATE_BACK)
-                       smtp_alert(master, NULL, vrrp,
+                       smtp_alert(master, NULL, vrrp, NULL,
                                   "Entering BACKUP state",
                                   "=> VRRP Instance is nolonger owning VRRP VIPs <=\n\n");
        }
@@ -312,11 +312,11 @@ free_sock(void *data)
 void
 dump_sock(void *data)
 {
-#ifdef _DEBUG_
        sock *sock = data;
-       DBG("sockpool -> ifindex(%d), proto(%d), fd(%d)",
-           sock->ifindex, sock->proto, sock->fd);
-#endif
+       syslog(LOG_INFO, "VRRP sockpool: [ifindex(%d), proto(%d), fd(%d)]",
+              sock->ifindex
+              , sock->proto
+              , sock->fd);
 }
 
 void
@@ -503,6 +503,19 @@ vrrp_leave_master(vrrp_rt * vrrp, char *vrrp_buffer, int len)
 }
 
 static void
+vrrp_ah_sync(vrrp_rt *vrrp)
+{
+       /*
+        * Transition to BACKUP state for AH
+        * seq number synchronization.
+        */
+       syslog(LOG_INFO, "VRRP_Instance(%s) in FAULT state jump to AH sync",
+              vrrp->iname);
+       vrrp->wantstate = VRRP_STATE_BACK;
+       vrrp_state_leave_master(vrrp);
+}
+
+static void
 vrrp_leave_fault(vrrp_rt * vrrp, char *vrrp_buffer, int len)
 {
        if (vrrp_state_fault_rx(vrrp, vrrp_buffer, len)) {
@@ -625,14 +638,9 @@ vrrp_fault(vrrp_rt * vrrp)
        vrrp_sgroup *vgroup = vrrp->sync;
 
        if (vgroup) {
-               if (vrrp_sync_group_up(vgroup)) {
-                       if (vgroup->state == VRRP_STATE_FAULT) {
-                               syslog(LOG_INFO,
-                                      "VRRP_Group(%s) Leaving FAULT state",
-                                      GROUP_NAME(vgroup));
-                               notify_group_exec(vgroup, vrrp->init_state);
+               if (vrrp_sync_leave_fault(vrrp)) {
+                       if (vgroup->state == VRRP_STATE_FAULT)
                                vgroup->state = vrrp->init_state;
-                       }
                } else
                        return;
        } else if (IF_ISUP(vrrp->ifp))
@@ -653,15 +661,7 @@ vrrp_fault(vrrp_rt * vrrp)
         * instance.
         */
        if (vrrp->auth_type == VRRP_AUTH_AH) {
-               /*
-                * Transition to BACKUP state for AH
-                * seq number synchronization.
-                */
-               syslog(LOG_INFO,
-                      "VRRP_Instance(%s) in FAULT state jump to AH sync",
-                      vrrp->iname);
-               vrrp->wantstate = VRRP_STATE_BACK;
-               vrrp_state_leave_master(vrrp);
+               vrrp_ah_sync(vrrp);
        } else {
                /* Otherwise, we transit to init state */
                if (vrrp->init_state == VRRP_STATE_BACK)
index 2cc004c..323d1ac 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        VRRP synchronization framework.
  *
- * Version:     $Id: vrrp_sync.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vrrp_sync.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
 #include "vrrp_if.h"
 #include "vrrp_notify.h"
 #include "data.h"
+#include "smtp.h"
 
 /* extern global vars */
+extern thread_master *master;
 extern data *conf_data;
 
 /* Compute the new instance sands */
@@ -86,6 +88,22 @@ vrrp_get_instance(char *iname)
        return NULL;
 }
 
+/* Set instances group pointer */
+void
+vrrp_sync_set_group(vrrp_sgroup *vgroup)
+{
+       vrrp_rt *vrrp;
+       char *str;
+       int i;
+
+       for (i = 0; i < VECTOR_SIZE(vgroup->iname); i++) {
+               str = VECTOR_SLOT(vgroup->iname, i);
+               vrrp = vrrp_get_instance(str);
+               if (vrrp)
+                       vrrp->sync = vgroup;
+       }
+}
+
 /* All interface are UP in the same group */
 int
 vrrp_sync_group_up(vrrp_sgroup * vgroup)
@@ -110,6 +128,22 @@ vrrp_sync_group_up(vrrp_sgroup * vgroup)
        return 0;
 }
 
+/* SMTP alert group notifier */
+static void
+vrrp_sync_smtp_notifier(vrrp_sgroup *vgroup)
+{
+       if (vgroup->smtp_alert) {
+               if (GROUP_STATE(vgroup) == VRRP_STATE_MAST)
+                       smtp_alert(master, NULL, NULL, vgroup,
+                                  "Entering MASTER state",
+                                  "=> All VRRP group instances are now in MASTER state <=\n\n");
+               if (GROUP_STATE(vgroup) == VRRP_STATE_BACK)
+                       smtp_alert(master, NULL, NULL, vgroup,
+                                  "Entering BACKUP state",
+                                  "=> All VRRP group instances are now in BACKUP state <=\n\n");
+       }
+}
+
 /* Leaving fault state */
 int
 vrrp_sync_leave_fault(vrrp_rt * vrrp)
@@ -119,8 +153,6 @@ vrrp_sync_leave_fault(vrrp_rt * vrrp)
        if (vrrp_sync_group_up(vgroup)) {
                syslog(LOG_INFO, "VRRP_Group(%s) Leaving FAULT state",
                       GROUP_NAME(vgroup));
-               vgroup->state = VRRP_STATE_MAST;
-               notify_group_exec(vgroup, VRRP_STATE_MAST);
                return 1;
        }
        return 0;
@@ -136,7 +168,7 @@ vrrp_sync_master_election(vrrp_rt * vrrp)
 
        if (vrrp->wantstate != VRRP_STATE_GOTO_MASTER)
                return;
-       if (GROUP_STATE(vrrp->sync) == VRRP_STATE_FAULT)
+       if (GROUP_STATE(vgroup) == VRRP_STATE_FAULT)
                return;
 
        syslog(LOG_INFO, "VRRP_Group(%s) Transition to MASTER state",
@@ -145,17 +177,15 @@ vrrp_sync_master_election(vrrp_rt * vrrp)
        for (i = 0; i < VECTOR_SIZE(vgroup->iname); i++) {
                str = VECTOR_SLOT(vgroup->iname, i);
                isync = vrrp_get_instance(str);
-               if (isync != vrrp)
+               if (isync != vrrp) {
+                       /* Force a new protocol master election */
                        isync->wantstate = VRRP_STATE_GOTO_MASTER;
-
-               /* Force a new protocol master election */
-               syslog(LOG_INFO,
-                      "VRRP_Instance(%s) forcing a new MASTER election",
-                      isync->iname);
-               vrrp_send_adv(isync, isync->priority);
+                       syslog(LOG_INFO,
+                              "VRRP_Instance(%s) forcing a new MASTER election",
+                              isync->iname);
+                       vrrp_send_adv(isync, isync->priority);
+               }
        }
-       vgroup->state = VRRP_STATE_MAST;
-       notify_group_exec(vgroup, VRRP_STATE_MAST);
 }
 
 void
@@ -167,7 +197,7 @@ vrrp_sync_backup(vrrp_rt * vrrp)
        vrrp_sgroup *vgroup = vrrp->sync;
 
        syslog(LOG_INFO, "VRRP_Group(%s) Syncing instances to BACKUP state",
-              GROUP_NAME(vrrp->sync));
+              GROUP_NAME(vgroup));
 
        for (i = 0; i < VECTOR_SIZE(vgroup->iname); i++) {
                str = VECTOR_SLOT(vgroup->iname, i);
@@ -179,6 +209,7 @@ vrrp_sync_backup(vrrp_rt * vrrp)
                }
        }
        vgroup->state = VRRP_STATE_BACK;
+       vrrp_sync_smtp_notifier(vgroup);
        notify_group_exec(vgroup, VRRP_STATE_BACK);
 }
 
@@ -190,6 +221,9 @@ vrrp_sync_master(vrrp_rt * vrrp)
        vrrp_rt *isync;
        vrrp_sgroup *vgroup = vrrp->sync;
 
+       if (GROUP_STATE(vrrp->sync) == VRRP_STATE_MAST)
+               return;
+
        syslog(LOG_INFO, "VRRP_Group(%s) Syncing instances to MASTER state",
               GROUP_NAME(vrrp->sync));
 
@@ -205,6 +239,7 @@ vrrp_sync_master(vrrp_rt * vrrp)
                }
        }
        vgroup->state = VRRP_STATE_MAST;
+       vrrp_sync_smtp_notifier(vgroup);
        notify_group_exec(vgroup, VRRP_STATE_MAST);
 }
 
index 4df501a..1d0e61a 100644 (file)
@@ -11,7 +11,8 @@ CFLAGS         = @CFLAGS@ $(INCLUDES) \
 DEFS    = @DFLAGS@
 COMPILE         = $(CC) $(CFLAGS) $(DEFS)
 
-OBJS =         memory.o utils.o timer.o scheduler.o vector.o list.o html.o
+OBJS =         memory.o utils.o notify.o timer.o scheduler.o \
+       vector.o list.o html.o
 HEADERS = $(OBJS:.o=.h)
 
 .c.o:
@@ -25,9 +26,9 @@ clean:
 distclean: clean
        rm -f Makefile
 
-
 memory.o: memory.c memory.h
 utils.o: utils.c utils.h
+notify.o: notify.c notify.h
 timer.o: timer.c timer.h
 scheduler.o: scheduler.c scheduler.h memory.h utils.h
 vector.o: vector.c vector.h memory.h
index 3cbd322..1797796 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        HTML stream parser utility functions.
  *
- * Version:     $Id: html.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: html.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *
index 01a880b..580769e 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        parser.c include file.
  *
- * Version:     $Id: html.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: html.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *
index 9c52964..a0bf82c 100644 (file)
@@ -5,7 +5,7 @@
  * 
  * Part:        List structure manipulation.
  *  
- * Version:     $Id: list.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: list.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  * 
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              
index 1d2ce45..252a856 100644 (file)
@@ -5,7 +5,7 @@
  * 
  * Part:        list.c include file.
  *  
- * Version:     $Id: list.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: list.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 0f2e77e..515fbea 100644 (file)
@@ -6,7 +6,7 @@
  * Part:        Memory management framework. This framework is used to
  *              find any memory leak.
  *
- * Version:     $Id: memory.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: memory.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Jan Holmberg, <jan@artech.net>
index 8ed8fa2..92af2fd 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        memory.c include file.
  *
- * Version:     $Id: memory.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: memory.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Jan Holmberg, <jan@artech.net>
diff --git a/lib/notify.c b/lib/notify.c
new file mode 100644 (file)
index 0000000..d315b46
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * 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:        Forked system call to launch an extra script.
+ *
+ * Version:     $Id: notify.c,v 1.0.0 2003/01/06 19:40: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.
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <syslog.h>
+#include <fcntl.h>
+#include "notify.h"
+
+/* perform a system call */
+int
+system_call(char *cmdline)
+{
+       int retval;
+
+       retval = system(cmdline);
+
+       if (retval == 127) {
+               /* couldn't exec command */
+               syslog(LOG_ALERT, "Couldn't exec command: %s", cmdline);
+       } else if (retval == -1) {
+               /* other error */
+               syslog(LOG_ALERT, "Error exec-ing command: %s", cmdline);
+       }
+
+       return retval;
+}
+
+/* Close all FDs >= a specified value */
+void
+closeall(int fd)
+{
+       int fdlimit = sysconf(_SC_OPEN_MAX);
+       while (fd < fdlimit)
+               close(fd++);
+}
+
+/* Execute external script/program */
+int
+notify_exec(char *cmd)
+{
+       pid_t pid;
+
+       pid = fork();
+
+       /* In case of fork is error. */
+       if (pid < 0) {
+               syslog(LOG_INFO, "Failed fork process");
+               return -1;
+       }
+
+       /* In case of this is parent process */
+       if (pid)
+               return 0;
+
+       closeall(0);
+
+       open("/dev/null", O_RDWR);
+       dup(0);
+       dup(0);
+
+       system_call(cmd);
+
+       exit(0);
+}
diff --git a/lib/notify.h b/lib/notify.h
new file mode 100644 (file)
index 0000000..1c920cf
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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:        notify.c include file.
+ *
+ * Version:     $Id: notify.h,v 1.0.0 2003/01/06 19:40: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.
+ */
+
+#ifndef _NOTIFY_H
+#define _NOTIFY_H
+
+/* system includes */
+extern int system_call(char *cmdline);
+extern void closeall(int fd);
+extern int notify_exec(char *cmd);
+
+#endif
index c97e59a..d49b1ee 100644 (file)
@@ -7,7 +7,7 @@
  *              the thread management routine (thread.c) present in the 
  *              very nice zebra project (http://www.zebra.org).
  *
- * Version:     $Id: scheduler.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: scheduler.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 80989cf..338d763 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        scheduler.c include file.
  *
- * Version:     $Id: scheduler.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: scheduler.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index bb51393..7fd5714 100644 (file)
@@ -5,7 +5,7 @@
  * 
  * Part:        Timer manipulations.
  *  
- * Version:     $Id: timer.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: timer.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  * 
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              
index 0cffce7..8a40449 100644 (file)
@@ -5,7 +5,7 @@
  * 
  * Part:        timer.c include file.
  *  
- * Version:     $Id: timer.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: timer.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index d794b78..1a86684 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        General program utils.
  *
- * Version:     $Id: utils.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: utils.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 2e0346d..7b4fde4 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        utils.h include file.
  *
- * Version:     $Id: utils.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: utils.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 5bd67ed..2dc0261 100644 (file)
@@ -5,7 +5,7 @@
  * 
  * Part:        Vector structure manipulation.
  *  
- * Version:     $Id: vector.c,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vector.c,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  * 
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              
index 02bccc8..0f2ee56 100644 (file)
@@ -5,7 +5,7 @@
  * 
  * Part:        vector.c include file.
  *  
- * Version:     $Id: vector.h,v 0.7.6 2002/11/20 21:34:18 acassen Exp $
+ * Version:     $Id: vector.h,v 1.0.0 2003/01/06 19:40:11 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *