keepalived-0.5.7 v0.5.7
authorAlexandre Cassen <acassen@freebox.fr>
Thu, 2 May 2002 20:25:23 +0000 (22:25 +0200)
committerAlexandre Cassen <acassen@freebox.fr>
Mon, 28 Sep 2009 08:58:55 +0000 (10:58 +0200)
* keepalived-0.5.7 released.
* Review autoconf/automake scripts to be more generic on system and code
  selection. Added primitives (configure) :
    --disable-lvs-syncd : Do not use IPVS sync daemon
    --disable-lvs       : Do not use IPVS framework
    --disable-vrrp      : Do not use VRRP framework
    --enable-debug      : Compile with debugging flags
* Fixed a SSL stream handling bug.
  Thanks to Andres Salomon, <dilinger@voxel.net> for pointing the issue.
* Added a global memory counter to track global memory used.
* Fixed configuration parser. read_line. Remove static allocated
  temporary read buffer. Only handle stream if line has been spitted into
  vector.
* Limit maximum number of VIPs per VRRP Instance to 20. (for fragmentation,
  overhead, and others reasons).
* Added IPVS wrapper support to persistence granularity.
  Thanks to Mike Zimmerman, <tarmon@spamcop.net> for the suggestion.
* Review smtp notifier to handle VRRP MASTER state transition alert.
  Thanks to Paul, <xerox@foonet.net> for the suggestion.
* Review the UserGuide.pdf to fixe some english issues :)
  Thanks to Jacques Thomas, <jacktom@noos.fr> for reviewing.

60 files changed:
ChangeLog
Makefile.in
VERSION
check_api.c
check_api.h
check_http.c
check_http.h
check_misc.c
check_misc.h
check_ssl.c
check_ssl.h
check_tcp.c
check_tcp.h
configure
configure.in
daemon.c
daemon.h
data.c
data.h
ipfwwrapper.c
ipfwwrapper.h
ipvswrapper.c
ipvswrapper.h
ipwrapper.c
ipwrapper.h
layer4.c
layer4.h
list.c
list.h
main.c
main.h
memory.c
memory.h
parser.c
parser.h
pidfile.c
pidfile.h
samples/keepalived.conf.vrrp
scheduler.c
scheduler.h
smtp.c
smtp.h
timer.c
timer.h
utils.c
utils.h
vector.c
vector.h
vrrp.c
vrrp.h
vrrp_if.c
vrrp_if.h
vrrp_ipaddress.c
vrrp_ipaddress.h
vrrp_ipsecah.c
vrrp_ipsecah.h
vrrp_netlink.c
vrrp_netlink.h
vrrp_scheduler.c
vrrp_scheduler.h

index ae6784a..ba3e474 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2002-05-02  Alexandre Cassen  <acassen@linux-vs.org>
+       * keepalived-0.5.7 released.
+       * Review autoconf/automake scripts to be more generic on system and code
+         selection. Added primitives (configure) :
+           --disable-lvs-syncd : Do not use IPVS sync daemon
+           --disable-lvs       : Do not use IPVS framework
+           --disable-vrrp      : Do not use VRRP framework
+           --enable-debug      : Compile with debugging flags
+       * Fixed a SSL stream handling bug.
+         Thanks to Andres Salomon, <dilinger@voxel.net> for pointing the issue.
+       * Added a global memory counter to track global memory used.
+       * Fixed configuration parser. read_line. Remove static allocated
+         temporary read buffer. Only handle stream if line has been spitted into
+         vector.
+       * Limit maximum number of VIPs per VRRP Instance to 20. (for fragmentation,
+         overhead, and others reasons).
+       * Added IPVS wrapper support to persistence granularity.
+         Thanks to Mike Zimmerman, <tarmon@spamcop.net> for the suggestion.
+       * Review smtp notifier to handle VRRP MASTER state transition alert.
+         Thanks to Paul, <xerox@foonet.net> for the suggestion.
+       * Review the UserGuide.pdf to fixe some english issues :)
+         Thanks to Jacques Thomas, <jacktom@noos.fr> for reviewing.
+
 2002-04-13  Alexandre Cassen  <acassen@linux-vs.org>
        * keepalived-0.5.6 released.
        * VRRP : Review in "GOTO_MASTER_STATE" the IP address handling.
index 325ad9f..abbf812 100644 (file)
@@ -5,25 +5,32 @@
 # Copyright (C) 2001, 2002 Alexandre Cassen, <acassen@linux-vs.org>
 
 EXEC = keepalived
-KERNEL := _KRNL_2_$(shell uname -r | cut -d'.' -f2)_
+KERNEL    := _KRNL_2_$(shell uname -r | cut -d'.' -f2)_
+IPVS_FLAG := @IPVS_SUPPORT@
+VRRP_FLAG := @VRRP_SUPPORT@
 
-prefix = @prefix@
+prefix      = @prefix@
 exec_prefix = @exec_prefix@
-sbindir = @sbindir@
+sbindir     = @sbindir@
 
-init_dir            = /etc/rc.d/init.d
+init_dir            = @SYSTEM_SCRIPT_DIR@
 init_script         = keepalived.init
 src_init_script     = etc/rc.d/init.d/$(init_script)
 src_conf_file       = etc/keepalived/keepalived.conf
 keepalived_conf_dir = /etc/keepalived
 
 CC = @CC@
-CFLAGS = @CFLAGS@ -Wall -Wunused -Wstrict-prototypes -D_DEBUG_ -D$(KERNEL)
+CFLAGS = @CFLAGS@ \
+       -Wall -Wunused -Wstrict-prototypes \
+       -D$(KERNEL) -D$(VRRP_FLAG) @DFLAGS@
 LDFLAGS = @LIBS@ @LDFLAGS@ @LIBFW@
-OBJS = @LIBOBJS@ \
+IPVSFLAGS = -D$(IPVS_FLAG) -D@IPVS_SYNCD@
+
+CORE_OBJS = @LIBOBJS@ \
        main.o \
        memory.o \
        daemon.o \
+       pidfile.o \
        utils.o \
        timer.o \
        scheduler.o \
@@ -32,26 +39,34 @@ OBJS = @LIBOBJS@ \
        data.o \
        parser.o \
        layer4.o \
+       smtp.o
+
+ifeq ($(IPVS_FLAG),_WITH_LVS_)
+IPVS_OBJS = \
        check_api.o \
        check_tcp.o \
        check_http.o \
        check_ssl.o \
        check_misc.o \
        ipwrapper.o \
-       ipvswrapper.o \
-       pidfile.o \
-       smtp.o \
+       ipvswrapper.o
+endif
+        
+ifeq ($(VRRP_FLAG),_WITH_VRRP_)
+VRRP_OBJS = \
        vrrp.o \
        vrrp_scheduler.o \
        vrrp_netlink.o \
        vrrp_if.o \
        vrrp_ipaddress.o \
        vrrp_ipsecah.o
+endif
 
-INCLUDE= -I/usr/src/linux/include
+INCLUDE = -I/usr/src/linux/include
+OBJS    = $(CORE_OBJS) $(IPVS_OBJS) $(VRRP_OBJS)
 
 .c.o:
-       $(CC) -o $@ $(CFLAGS) $(INCLUDE) -c $*.c
+       $(CC) -o $@ $(CFLAGS) $(IPVSFLAGS) $(INCLUDE) -c $*.c
 
 all:    $(EXEC)
        strip $(EXEC)
diff --git a/VERSION b/VERSION
index b49b253..d3532a1 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.5.6
+0.5.7
index 6196bbd..8018d91 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        Checkers registration.
  *
- * Version:     $Id: check_api.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: check_api.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -61,8 +61,8 @@ void queue_checker(void (*free) (void *), void (*dump) (void *)
                                         , void *data)
 {
   virtual_server *vs = LIST_TAIL_DATA(conf_data->vs);
-  real_server *rs = LIST_TAIL_DATA(vs->rs);
-  checker *chk = (checker *)MALLOC(sizeof(checker));
+  real_server *rs    = LIST_TAIL_DATA(vs->rs);
+  checker *chk       = (checker *)MALLOC(sizeof(checker));
 
   chk->free   = free;
   chk->dump   = dump;
index 01fc62a..b1bc74f 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        Checkers arguments structures definitions.
  *
- * Version:     $Id: check_api.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: check_api.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 2a35a75..eed5221 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        WEB CHECK. Common HTTP/SSL checker primitives.
  *
- * Version:     $Id: check_http.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: check_http.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Jan Holmberg, <jan@artech.net>
@@ -74,8 +74,8 @@ void http_get_handler(vector strvec)
   http_get_checker *http_get_chk;
   char *str = VECTOR_SLOT(strvec, 0);
 
-  http_get_chk = (http_get_checker *)MALLOC(sizeof(http_get_checker));
-  http_get_chk->arg = (http_arg *)MALLOC(sizeof(http_arg));
+  http_get_chk        = (http_get_checker *)MALLOC(sizeof(http_get_checker));
+  http_get_chk->arg   = (http_arg *)MALLOC(sizeof(http_arg));
   http_get_chk->proto = (!strcmp(str, "HTTP_GET"))?PROTO_HTTP:PROTO_SSL;
   http_get_chk->url   = alloc_list(free_url, dump_url);
 
@@ -207,15 +207,9 @@ int epilog(thread *thread, int metod, int t, int c)
         delay = checker->vs->delay_loop;
       else
         delay = checker->vs->delay_loop - http_get_check->delay_before_retry;
-      thread_add_timer(thread->master, http_connect_thread
-                                     , checker
-                                     , delay);
       break; 
     case 2:
       delay = http_get_check->delay_before_retry;
-      thread_add_timer(thread->master, http_connect_thread
-                                     , checker
-                                     , delay);
       break;
   }
 
@@ -229,6 +223,10 @@ int epilog(thread *thread, int metod, int t, int c)
     close(thread->u.fd);
   }
 
+  /* Register next checker thread */
+  thread_add_timer(thread->master, http_connect_thread
+                                 , checker
+                                 , delay);
   return 0;
 }
 
@@ -267,6 +265,7 @@ int timeout_epilog(thread *thread, char *smtp_msg, char *debug_msg)
     /* 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);
@@ -306,7 +305,9 @@ int http_handle_response(thread *thread, unsigned char digest[16]
 {
   checker *checker                 = THREAD_ARG(thread);
   http_get_checker *http_get_check = CHECKER_ARG(checker);
+#ifdef _DEBUG_
   http_arg *http_arg               = HTTP_ARG(http_get_check);
+#endif
   int r, di = 0;
   unsigned char *digest_tmp;
   url *fetched_url;
@@ -347,6 +348,7 @@ int http_handle_response(thread *thread, unsigned char digest[16]
       /* check if server is currently alive */
       if (ISALIVE(checker->rs)) {
         smtp_alert(thread->master, checker->rs
+                                 , NULL
                                  , "DOWN"
                                  , "=> CHECK failed on service"
                                    " : MD5 digest mismatch <=\n\n");
@@ -360,7 +362,7 @@ int http_handle_response(thread *thread, unsigned char digest[16]
                       , ntohs(CHECKER_RPORT(checker))
                       , http_arg->url_it + 1);
 #endif
-      return epilog(thread,2,1,0)+1;
+      return epilog(thread,1,1,0)+1;
     }
   }
   return epilog(thread,0,0,0)+1;
@@ -393,8 +395,15 @@ int http_read_thread(thread *thread)
 
     if (r == -1) {
       /* We have encourred a real read error */
+#ifdef _DEBUG_
+      syslog(LOG_DEBUG, "Read error with server [%s:%d]: %s"
+                      , ip_ntoa(CHECKER_RIP(checker))
+                      , ntohs(CHECKER_RPORT(checker))
+                      , strerror(errno));
+#endif
       if (ISALIVE(checker->rs)) {
         smtp_alert(thread->master, checker->rs
+                                 , NULL
                                  , "DOWN"
                                  , "=> HTTP CHECK failed on service"
                                    " : cannot receive data <=\n\n");
@@ -471,9 +480,10 @@ int http_response_thread(thread *thread)
 
   /* Register asynchronous http/ssl read thread */
   if (http_get_check->proto == PROTO_SSL)
-    thread_add_event(thread->master, ssl_read_thread
-                                   , checker
-                                   , 0);
+    thread_add_read(thread->master, ssl_read_thread
+                                  , checker
+                                  , thread->u.fd
+                                  , http_get_check->connection_to);
   else
     thread_add_read(thread->master, http_read_thread
                                   , checker
@@ -533,6 +543,7 @@ int http_request_thread(thread *thread)
     /* check if server is currently alive */
     if (ISALIVE(checker->rs)) {
       smtp_alert(thread->master, checker->rs
+                               , NULL
                                , "DOWN"
                                , "=> CHECK failed on service"
                                  " : cannot send data <=\n\n");
@@ -554,8 +565,10 @@ int http_check_thread(thread *thread)
 {
   checker *checker                 = THREAD_ARG(thread);
   http_get_checker *http_get_check = CHECKER_ARG(checker);
+#ifdef _DEBUG_
   http_arg *http_arg               = HTTP_ARG(http_get_check);
   REQ *req                         = HTTP_REQ(http_arg);
+#endif
   int ret = 1;
   int status;
 
@@ -573,6 +586,7 @@ int http_check_thread(thread *thread)
       /* check if server is currently alive */
       if (ISALIVE(checker->rs)) {
         smtp_alert(thread->master, checker->rs
+                                 , NULL
                                  , "DOWN"
                                  , "=> CHECK failed on service"
                                    " : connection error <=\n\n");
@@ -641,6 +655,7 @@ int http_connect_thread(thread *thread)
      */
     if (!ISALIVE(checker->rs)) {
       smtp_alert(thread->master, checker->rs
+                               , NULL
                                , "UP"
                                , "=> CHECK succeed on service <=\n\n");
       perform_svr_state(UP, checker->vs, checker->rs);
index 61cbb46..ca00d4e 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        check_http.c include file.
  *
- * Version:     $Id: check_http.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: check_http.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Jan Holmberg, <jan@artech.net>
index 146c73f..7a83924 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.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: check_misc.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Eric Jarman, <ehj38230@cmsu2.cmsu.edu>
@@ -119,6 +119,7 @@ int misc_check_thread(thread *thread)
       /* everything is good */
       if (!checker->rs->alive) {
         smtp_alert(thread->master, checker->rs
+                                 , NULL
                                  , "UP"
                                  , "=> MISC CHECK succeed on service <=\n\n");
         perform_svr_state(UP, checker->vs, checker->rs);
@@ -126,6 +127,7 @@ int misc_check_thread(thread *thread)
     } else {
       if (checker->rs->alive) {
         smtp_alert(thread->master, checker->rs
+                                 , NULL
                                  , "DOWN"
                                  , "=> MISC CHECK failed on service <=\n\n");
         perform_svr_state(DOWN, checker->vs, checker->rs);
index fca618e..030247e 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        check_misc.c include file.
  *
- * Version:     $Id: check_misc.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: check_misc.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              Eric Jarman, <ehj38230@cmsu2.cmsu.edu>
index 84e1248..958169e 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.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: check_ssl.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Jan Holmberg, <jan@artech.net>
@@ -241,6 +241,7 @@ int ssl_read_thread(thread *thread)
       /* check if server is currently alive */
       if (ISALIVE(checker->rs)) {
         smtp_alert(thread->master, checker->rs
+                                 , NULL
                                  , "DOWN"
                                  , "=> SSL CHECK failed on service"
                                    " : cannot receive data <=\n\n");
index 62a199e..05faeca 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        check_http.c include file.
  *
- * Version:     $Id: check_http.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: check_http.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Jan Holmberg, <jan@artech.net>
index 956bf86..2c51d5f 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        TCP checker.
  *
- * Version:     $Id: check_tcp.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: check_tcp.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -95,6 +95,7 @@ int tcp_check_thread(thread *thread)
 
     if (!ISALIVE(checker->rs)) {
       smtp_alert(thread->master, checker->rs
+                               , NULL
                                , "UP"
                                , "=> TCP CHECK succeed on service <=\n\n");
       perform_svr_state(UP, checker->vs, checker->rs);
@@ -109,6 +110,7 @@ int tcp_check_thread(thread *thread)
 
     if (ISALIVE(checker->rs)) {
       smtp_alert(thread->master, checker->rs
+                               , NULL
                                , "DOWN"
                                , "=> TCP CHECK failed on service <=\n\n");
       perform_svr_state(DOWN, checker->vs, checker->rs);
index 02eebac..4fe43d8 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        check_tcp.c include file.
  *
- * Version:     $Id: check_tcp.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: check_tcp.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 50f6ad9..9d36221 100755 (executable)
--- a/configure
+++ b/configure
 ac_help=
 ac_default_prefix=/usr/local
 # Any additions from configure.in:
+ac_help="$ac_help
+  --disable-lvs-syncd     do not use LVS synchronization daemon"
+ac_help="$ac_help
+  --disable-lvs           do not use the LVS framework"
+ac_help="$ac_help
+  --disable-vrrp          do not use the VRRP framework"
+ac_help="$ac_help
+  --enable-debug          compile with debugging flags"
 
 # Initialize some variables set by options.
 # The variables have the same names as the options, with
@@ -525,7 +533,7 @@ fi
 # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:529: checking for $ac_word" >&5
+echo "configure:537: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -555,7 +563,7 @@ if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:559: checking for $ac_word" >&5
+echo "configure:567: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -606,7 +614,7 @@ fi
       # Extract the first word of "cl", so it can be a program name with args.
 set dummy cl; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:610: checking for $ac_word" >&5
+echo "configure:618: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -638,7 +646,7 @@ fi
 fi
 
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
-echo "configure:642: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+echo "configure:650: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
 
 ac_ext=c
 # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@@ -649,12 +657,12 @@ cross_compiling=$ac_cv_prog_cc_cross
 
 cat > conftest.$ac_ext << EOF
 
-#line 653 "configure"
+#line 661 "configure"
 #include "confdefs.h"
 
 main(){return(0);}
 EOF
-if { (eval echo configure:658: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:666: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   ac_cv_prog_cc_works=yes
   # If we can't run a trivial program, we are probably using a cross compiler.
   if (./conftest; exit) 2>/dev/null; then
@@ -680,12 +688,12 @@ if test $ac_cv_prog_cc_works = no; then
   { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
 fi
 echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
-echo "configure:684: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "configure:692: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
 cross_compiling=$ac_cv_prog_cc_cross
 
 echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
-echo "configure:689: checking whether we are using GNU C" >&5
+echo "configure:697: checking whether we are using GNU C" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -694,7 +702,7 @@ else
   yes;
 #endif
 EOF
-if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:698: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:706: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
   ac_cv_prog_gcc=yes
 else
   ac_cv_prog_gcc=no
@@ -713,7 +721,7 @@ ac_test_CFLAGS="${CFLAGS+set}"
 ac_save_CFLAGS="$CFLAGS"
 CFLAGS=
 echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
-echo "configure:717: checking whether ${CC-cc} accepts -g" >&5
+echo "configure:725: checking whether ${CC-cc} accepts -g" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -775,7 +783,7 @@ ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
-echo "configure:779: checking for a BSD compatible install" >&5
+echo "configure:787: checking for a BSD compatible install" >&5
 if test -z "$INSTALL"; then
 if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -828,7 +836,15 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
 
 
+if test -d /etc/init.d; then
+  SYSTEM_SCRIPT_DIR="/etc/init.d"
+elif test -d /etc/rc.d/init.d; then
+  SYSTEM_SCRIPT_DIR="/etc/rc.d/init.d"
+fi
+
+
 KERNEL_VERSION=`uname -r`
+KERNEL_CODE=`echo $KERNEL_VERSION | cut -d'.' -f2`
 
 IPVS_MODULE="/lib/modules/`uname -r`/kernel/net/ipv4/ipvs/ip_vs.o"
 if test -f $IPVS_MODULE; then
@@ -837,18 +853,95 @@ fi
 
 if test -f /proc/net/ip_vs; then
   IPVS_VERSION=`cat /proc/net/ip_vs | head -1 | awk '{ print $5}'`
+  IPVS_SUPPORT="_WITH_LVS_"
 elif test -f /proc/net/ip_masq/vs; then
   IPVS_VERSION=`cat /proc/net/ip_masq/vs | head -1 | awk '{ print $5}'`
+  IPVS_SUPPORT="_WITH_LVS_"
 else
-  echo
-  echo "!!!WARN!!! Your kernel need to be patched with LVS code !!!WARN!!!"
-  echo
-  exit 1
+  IPVS_VERSION="0.0.0"
+  IPVS_SUPPORT="_WITHOUT_LVS_"
 fi
 VERSION=`cat VERSION`
 
+IPVS_MAJOR=`echo $IPVS_VERSION | cut -d'.' -f1`
+IPVS_MINOR=`echo $IPVS_VERSION | cut -d'.' -f2`
+IPVS_PATCH=`echo $IPVS_VERSION | cut -d'.' -f3`
+
+# Check whether --enable-lvs-syncd or --disable-lvs-syncd was given.
+if test "${enable_lvs_syncd+set}" = set; then
+  enableval="$enable_lvs_syncd"
+  :
+fi
+
+# Check whether --enable-lvs or --disable-lvs was given.
+if test "${enable_lvs+set}" = set; then
+  enableval="$enable_lvs"
+  :
+fi
+
+# Check whether --enable-vrrp or --disable-vrrp was given.
+if test "${enable_vrrp+set}" = set; then
+  enableval="$enable_vrrp"
+  :
+fi
+
+# Check whether --enable-debug or --disable-debug was given.
+if test "${enable_debug+set}" = set; then
+  enableval="$enable_debug"
+  :
+fi
+
+
+if test "${enable_lvs}" = "no"; then
+  if test "${enable_vrrp}" = "no"; then
+    echo
+    echo "  !!!WARN!!! Keepalived MUST be compiled at least with LVS or VRRP framework !!!WARN!!!"
+    echo
+    exit 1
+  fi
+fi
+
+VRRP_SUPPORT="_WITH_VRRP_"
+if test "${enable_lvs}" = "no"; then
+  IPVS_SUPPORT="_WITHOUT_LVS_"
+fi
+if test "${enable_vrrp}" = "no"; then
+  VRRP_SUPPORT="_WITHOUT_VRRP_"
+fi
+if test "${enable_debug}" = "yes"; then
+  DFLAGS="-D_DEBUG_"
+  
+fi
+
+
+
+
+
+IPVS_SYNCD="_WITHOUT_IPVS_SYNCD_"
+if test ${IPVS_MAJOR} -eq 0; then
+  if test ${IPVS_MINOR} -eq 9; then
+    if test ${IPVS_PATCH} -ge 2; then
+      if test "${KERNEL_CODE}" = "4"; then
+        IPVS_SYNCD="_HAVE_IPVS_SYNCD_"
+      fi
+    fi
+  fi
+fi
+if test ${IPVS_MAJOR} -ge 1; then
+  if test "${KERNEL_CODE}" = "4"; then
+    IPVS_SYNCD="_HAVE_IPVS_SYNCD_"
+  fi
+fi
+if test "${IPVS_SUPPORT}" = "_WITHOUT_LVS_"; then
+  IPVS_SYNCD="_WITHOUT_IPVS_SYNCD_"
+fi
+if test "${enable_lvs_syncd}" = "no"; then
+  IPVS_SYNCD="_WITHOUT_IPVS_SYNCD_"
+fi
+
+
 echo $ac_n "checking for MD5_Init in -lcrypto""... $ac_c" 1>&6
-echo "configure:852: checking for MD5_Init in -lcrypto" >&5
+echo "configure:945: checking for MD5_Init in -lcrypto" >&5
 ac_lib_var=`echo crypto'_'MD5_Init | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -856,7 +949,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lcrypto  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 860 "configure"
+#line 953 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -867,7 +960,7 @@ int main() {
 MD5_Init()
 ; return 0; }
 EOF
-if { (eval echo configure:871: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:964: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -896,7 +989,7 @@ else
 fi
 
 echo $ac_n "checking for SSL_CTX_new in -lssl""... $ac_c" 1>&6
-echo "configure:900: checking for SSL_CTX_new in -lssl" >&5
+echo "configure:993: checking for SSL_CTX_new in -lssl" >&5
 ac_lib_var=`echo ssl'_'SSL_CTX_new | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -904,7 +997,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lssl  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 908 "configure"
+#line 1001 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -915,7 +1008,7 @@ int main() {
 SSL_CTX_new()
 ; return 0; }
 EOF
-if { (eval echo configure:919: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1012: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -944,7 +1037,7 @@ else
 fi
 
 echo $ac_n "checking for poptGetContext in -lpopt""... $ac_c" 1>&6
-echo "configure:948: checking for poptGetContext in -lpopt" >&5
+echo "configure:1041: checking for poptGetContext in -lpopt" >&5
 ac_lib_var=`echo popt'_'poptGetContext | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -952,7 +1045,7 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lpopt  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 956 "configure"
+#line 1049 "configure"
 #include "confdefs.h"
 /* Override any gcc2 internal prototype to avoid an error.  */
 /* We use char because int might match the return type of a gcc2
@@ -963,7 +1056,7 @@ int main() {
 poptGetContext()
 ; return 0; }
 EOF
-if { (eval echo configure:967: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1060: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
@@ -992,14 +1085,13 @@ else
 fi
 
 
-KERNEL_CODE=`echo $KERNEL_VERSION | cut -d'.' -f2`
 if test "${KERNEL_CODE}" = "2"; then
   LIBFW="libipfwc/libipfwc.a"
   LIBOBJS="$LIBOBJS ipfwwrapper.o"
     fi
 
 echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:1003: checking how to run the C preprocessor" >&5
+echo "configure:1095: checking how to run the C preprocessor" >&5
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -1014,13 +1106,13 @@ else
   # On the NeXT, cc -E runs the code through the compiler's parser,
   # not just through cpp.
   cat > conftest.$ac_ext <<EOF
-#line 1018 "configure"
+#line 1110 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1024: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1116: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -1031,13 +1123,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -E -traditional-cpp"
   cat > conftest.$ac_ext <<EOF
-#line 1035 "configure"
+#line 1127 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1041: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1133: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -1048,13 +1140,13 @@ else
   rm -rf conftest*
   CPP="${CC-cc} -nologo -E"
   cat > conftest.$ac_ext <<EOF
-#line 1052 "configure"
+#line 1144 "configure"
 #include "confdefs.h"
 #include <assert.h>
 Syntax Error
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1058: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1150: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   :
@@ -1079,12 +1171,12 @@ fi
 echo "$ac_t""$CPP" 1>&6
 
 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:1083: checking for ANSI C header files" >&5
+echo "configure:1175: checking for ANSI C header files" >&5
 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1088 "configure"
+#line 1180 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 #include <stdarg.h>
@@ -1092,7 +1184,7 @@ else
 #include <float.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1096: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1188: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1109,7 +1201,7 @@ rm -f conftest*
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1113 "configure"
+#line 1205 "configure"
 #include "confdefs.h"
 #include <string.h>
 EOF
@@ -1127,7 +1219,7 @@ fi
 if test $ac_cv_header_stdc = yes; then
   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
 cat > conftest.$ac_ext <<EOF
-#line 1131 "configure"
+#line 1223 "configure"
 #include "confdefs.h"
 #include <stdlib.h>
 EOF
@@ -1148,7 +1240,7 @@ if test "$cross_compiling" = yes; then
   :
 else
   cat > conftest.$ac_ext <<EOF
-#line 1152 "configure"
+#line 1244 "configure"
 #include "confdefs.h"
 #include <ctype.h>
 #define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1159,7 +1251,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
 exit (0); }
 
 EOF
-if { (eval echo configure:1163: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1255: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
 then
   :
 else
@@ -1183,12 +1275,12 @@ EOF
 fi
 
 echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6
-echo "configure:1187: checking for sys/wait.h that is POSIX.1 compatible" >&5
+echo "configure:1279: checking for sys/wait.h that is POSIX.1 compatible" >&5
 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1192 "configure"
+#line 1284 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -1204,7 +1296,7 @@ wait (&s);
 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;
 ; return 0; }
 EOF
-if { (eval echo configure:1208: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1300: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_sys_wait_h=yes
 else
@@ -1228,17 +1320,17 @@ for ac_hdr in openssl/ssl.h openssl/md5.h openssl/err.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1232: checking for $ac_hdr" >&5
+echo "configure:1324: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1237 "configure"
+#line 1329 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1242: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1334: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1271,17 +1363,17 @@ for ac_hdr in fcntl.h sys/ioctl.h sys/time.h syslog.h unistd.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1275: checking for $ac_hdr" >&5
+echo "configure:1367: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1280 "configure"
+#line 1372 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1285: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1377: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -1309,12 +1401,12 @@ done
 
 
 echo $ac_n "checking for working const""... $ac_c" 1>&6
-echo "configure:1313: checking for working const" >&5
+echo "configure:1405: checking for working const" >&5
 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1318 "configure"
+#line 1410 "configure"
 #include "confdefs.h"
 
 int main() {
@@ -1363,7 +1455,7 @@ ccp = (char const *const *) p;
 
 ; return 0; }
 EOF
-if { (eval echo configure:1367: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1459: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_c_const=yes
 else
@@ -1384,12 +1476,12 @@ EOF
 fi
 
 echo $ac_n "checking for pid_t""... $ac_c" 1>&6
-echo "configure:1388: checking for pid_t" >&5
+echo "configure:1480: checking for pid_t" >&5
 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1393 "configure"
+#line 1485 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #if STDC_HEADERS
@@ -1417,12 +1509,12 @@ EOF
 fi
 
 echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
-echo "configure:1421: checking whether time.h and sys/time.h may both be included" >&5
+echo "configure:1513: checking whether time.h and sys/time.h may both be included" >&5
 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1426 "configure"
+#line 1518 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -1431,7 +1523,7 @@ int main() {
 struct tm *tp;
 ; return 0; }
 EOF
-if { (eval echo configure:1435: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1527: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_header_time=yes
 else
@@ -1454,13 +1546,13 @@ fi
 
 if test $ac_cv_prog_gcc = yes; then
     echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
-echo "configure:1458: checking whether ${CC-cc} needs -traditional" >&5
+echo "configure:1550: checking whether ${CC-cc} needs -traditional" >&5
 if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
     ac_pattern="Autoconf.*'x'"
   cat > conftest.$ac_ext <<EOF
-#line 1464 "configure"
+#line 1556 "configure"
 #include "confdefs.h"
 #include <sgtty.h>
 Autoconf TIOCGETP
@@ -1478,7 +1570,7 @@ rm -f conftest*
 
   if test $ac_cv_prog_gcc_traditional = no; then
     cat > conftest.$ac_ext <<EOF
-#line 1482 "configure"
+#line 1574 "configure"
 #include "confdefs.h"
 #include <termio.h>
 Autoconf TCGETA
@@ -1500,12 +1592,12 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6
 fi
 
 echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
-echo "configure:1504: checking return type of signal handlers" >&5
+echo "configure:1596: checking return type of signal handlers" >&5
 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1509 "configure"
+#line 1601 "configure"
 #include "confdefs.h"
 #include <sys/types.h>
 #include <signal.h>
@@ -1522,7 +1614,7 @@ int main() {
 int i;
 ; return 0; }
 EOF
-if { (eval echo configure:1526: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+if { (eval echo configure:1618: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
   rm -rf conftest*
   ac_cv_type_signal=void
 else
@@ -1543,12 +1635,12 @@ EOF
 for ac_func in gettimeofday select socket strerror strtol uname
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1547: checking for $ac_func" >&5
+echo "configure:1639: checking for $ac_func" >&5
 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 1552 "configure"
+#line 1644 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -1571,7 +1663,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:1575: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:1667: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -1745,6 +1837,11 @@ s%@CC@%$CC%g
 s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
 s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
 s%@INSTALL_DATA@%$INSTALL_DATA%g
+s%@SYSTEM_SCRIPT_DIR@%$SYSTEM_SCRIPT_DIR%g
+s%@DFLAGS@%$DFLAGS%g
+s%@IPVS_SUPPORT@%$IPVS_SUPPORT%g
+s%@VRRP_SUPPORT@%$VRRP_SUPPORT%g
+s%@IPVS_SYNCD@%$IPVS_SYNCD%g
 s%@LIBFW@%$LIBFW%g
 s%@LIBOBJS@%$LIBOBJS%g
 s%@CPP@%$CPP%g
@@ -1865,13 +1962,45 @@ cat <<EOF;
 
 Keepalived configuration
 ------------------------
-Keepalived version   : ${VERSION}
-Linux Kernel release : ${KERNEL_VERSION}
-IPVS version code    : ${IPVS_VERSION}
-Compiler             : ${CC}
-Compiler flags       : ${CFLAGS}
-Extra Lib            : $LIBS
-Lib objects          : $LIBOBJS
-Firewall Lib         : $LIBFW
-
+Keepalived version       : ${VERSION}
+Compiler                 : ${CC}
+Compiler flags           : ${CFLAGS}
+Compiler flags           : ${CFLAGS}
+Linux Kernel release     : ${KERNEL_VERSION}
+Startup scripts location : ${SYSTEM_SCRIPT_DIR}
 EOF
+
+if test -n "$LIBS"; then
+  echo "Extra Lib                : $LIBS"
+fi
+if test -n "$LIBOBJS"; then
+  echo "Lib objects              : $LIBOBJS"
+fi
+if test -n "$LIBFW"; then
+  echo "Firewall Lib             : $LIBFW"
+fi
+
+if test "${IPVS_SUPPORT}" = "_WITH_LVS_"; then
+  echo "Use IPVS Framework       : Yes"
+  echo "IPVS version code        : ${IPVS_VERSION}"
+  if test "${IPVS_SYNCD}" = "_HAVE_IPVS_SYNCD_"; then
+    echo "IPVS sync daemon support : Yes"
+  elif test "${IPVS_SYNCD}" = "_WITHOUT_IPVS_SYNCD_"; then
+    echo "IPVS sync daemon support : No"
+  fi
+else
+  echo "Use IPVS Framework       : No"
+  echo "IPVS sync daemon support : No"
+fi
+
+if test "${VRRP_SUPPORT}" = "_WITH_VRRP_"; then
+  echo "Use VRRP Framework       : Yes"
+else
+  echo "Use VRRP Framework       : No"
+fi
+if test "${DFLAGS}" = "-D_DEBUG_"; then
+  echo "Use Debug flags          : Yes"
+else
+  echo "Use Debug flags          : No"
+fi
+echo
index d1cb12d..baa59f7 100644 (file)
@@ -13,8 +13,17 @@ dnl ----[ Checks for programs ]----
 AC_PROG_CC
 AC_PROG_INSTALL
 
+dnl ----[ Checks for system init script dir ]----
+if test -d /etc/init.d; then
+  SYSTEM_SCRIPT_DIR="/etc/init.d"
+elif test -d /etc/rc.d/init.d; then
+  SYSTEM_SCRIPT_DIR="/etc/rc.d/init.d"
+fi
+AC_SUBST(SYSTEM_SCRIPT_DIR)
+
 dnl ----[ Checks for kernel support ]----
 KERNEL_VERSION=`uname -r`
+KERNEL_CODE=`echo $KERNEL_VERSION | cut -d'.' -f2`
 
 IPVS_MODULE="/lib/modules/`uname -r`/kernel/net/ipv4/ipvs/ip_vs.o"
 if test -f $IPVS_MODULE; then
@@ -23,23 +32,87 @@ fi
 
 if test -f /proc/net/ip_vs; then
   IPVS_VERSION=`cat /proc/net/ip_vs | head -1 | awk '{ print $5}'`
+  IPVS_SUPPORT="_WITH_LVS_"
 elif test -f /proc/net/ip_masq/vs; then
   IPVS_VERSION=`cat /proc/net/ip_masq/vs | head -1 | awk '{ print $5}'`
+  IPVS_SUPPORT="_WITH_LVS_"
 else
-  echo
-  echo "!!!WARN!!! Your kernel need to be patched with LVS code !!!WARN!!!"
-  echo
-  exit 1
+  IPVS_VERSION="0.0.0"
+  IPVS_SUPPORT="_WITHOUT_LVS_"
 fi
 VERSION=`cat VERSION`
 
+dnl ----[ Split IPVS NVERSION code  ]----
+IPVS_MAJOR=`echo $IPVS_VERSION | cut -d'.' -f1`
+IPVS_MINOR=`echo $IPVS_VERSION | cut -d'.' -f2`
+IPVS_PATCH=`echo $IPVS_VERSION | cut -d'.' -f3`
+
+dnl ----[ Keepalived specific configure options ]----
+AC_ARG_ENABLE(lvs-syncd,
+  [  --disable-lvs-syncd     do not use LVS synchronization daemon])
+AC_ARG_ENABLE(lvs,
+  [  --disable-lvs           do not use the LVS framework])
+AC_ARG_ENABLE(vrrp,
+  [  --disable-vrrp          do not use the VRRP framework])
+AC_ARG_ENABLE(debug,
+  [  --enable-debug          compile with debugging flags])
+
+if test "${enable_lvs}" = "no"; then
+  if test "${enable_vrrp}" = "no"; then
+    echo
+    echo "  !!!WARN!!! Keepalived MUST be compiled at least with LVS or VRRP framework !!!WARN!!!"
+    echo
+    exit 1
+  fi
+fi
+
+VRRP_SUPPORT="_WITH_VRRP_"
+if test "${enable_lvs}" = "no"; then
+  IPVS_SUPPORT="_WITHOUT_LVS_"
+fi
+if test "${enable_vrrp}" = "no"; then
+  VRRP_SUPPORT="_WITHOUT_VRRP_"
+fi
+if test "${enable_debug}" = "yes"; then
+  DFLAGS="-D_DEBUG_"
+  AC_SUBST(DFLAGS)
+fi
+
+AC_SUBST(IPVS_SUPPORT)
+AC_SUBST(VRRP_SUPPORT)
+
+dnl ----[ LVS syncd support probe ]---
+dnl Sync daemon is supported since LVS 0.9.2 for kernel 2.4
+
+IPVS_SYNCD="_WITHOUT_IPVS_SYNCD_"
+if test ${IPVS_MAJOR} -eq 0; then
+  if test ${IPVS_MINOR} -eq 9; then
+    if test ${IPVS_PATCH} -ge 2; then
+      if test "${KERNEL_CODE}" = "4"; then
+        IPVS_SYNCD="_HAVE_IPVS_SYNCD_"
+      fi
+    fi
+  fi
+fi
+if test ${IPVS_MAJOR} -ge 1; then
+  if test "${KERNEL_CODE}" = "4"; then
+    IPVS_SYNCD="_HAVE_IPVS_SYNCD_"
+  fi
+fi
+if test "${IPVS_SUPPORT}" = "_WITHOUT_LVS_"; then
+  IPVS_SYNCD="_WITHOUT_IPVS_SYNCD_"
+fi
+if test "${enable_lvs_syncd}" = "no"; then
+  IPVS_SYNCD="_WITHOUT_IPVS_SYNCD_"
+fi
+AC_SUBST(IPVS_SYNCD)
+
 dnl ----[ Checks for libraries ]----
 AC_CHECK_LIB(crypto, MD5_Init,,AC_MSG_ERROR([OpenSSL libraries are required]))
 AC_CHECK_LIB(ssl, SSL_CTX_new,,AC_MSG_ERROR([OpenSSL libraries are required]))
 AC_CHECK_LIB(popt, poptGetContext,,AC_MSG_ERROR([Popt libraries is required]))
 
 dnl ----[ Create object list ]----
-KERNEL_CODE=`echo $KERNEL_VERSION | cut -d'.' -f2`
 if test "${KERNEL_CODE}" = "2"; then
   LIBFW="libipfwc/libipfwc.a"
   LIBOBJS="$LIBOBJS ipfwwrapper.o"
@@ -72,13 +145,47 @@ cat <<EOF;
 
 Keepalived configuration
 ------------------------
-Keepalived version   : ${VERSION}
-Linux Kernel release : ${KERNEL_VERSION}
-IPVS version code    : ${IPVS_VERSION}
-Compiler             : ${CC}
-Compiler flags       : ${CFLAGS}
-Extra Lib            : $LIBS
-Lib objects          : $LIBOBJS
-Firewall Lib         : $LIBFW
-
+Keepalived version       : ${VERSION}
+Compiler                 : ${CC}
+Compiler flags           : ${CFLAGS}
+Compiler flags           : ${CFLAGS}
+Linux Kernel release     : ${KERNEL_VERSION}
+Startup scripts location : ${SYSTEM_SCRIPT_DIR}
 EOF
+
+dnl ----[ display optional vars  ]----
+if test -n "$LIBS"; then
+  echo "Extra Lib                : $LIBS"
+fi
+if test -n "$LIBOBJS"; then
+  echo "Lib objects              : $LIBOBJS"
+fi
+if test -n "$LIBFW"; then
+  echo "Firewall Lib             : $LIBFW"
+fi
+
+if test "${IPVS_SUPPORT}" = "_WITH_LVS_"; then
+  echo "Use IPVS Framework       : Yes"
+  echo "IPVS version code        : ${IPVS_VERSION}"
+  if test "${IPVS_SYNCD}" = "_HAVE_IPVS_SYNCD_"; then
+    echo "IPVS sync daemon support : Yes"
+  elif test "${IPVS_SYNCD}" = "_WITHOUT_IPVS_SYNCD_"; then
+    echo "IPVS sync daemon support : No"
+  fi
+else
+  echo "Use IPVS Framework       : No"
+  echo "IPVS sync daemon support : No"
+fi
+
+if test "${VRRP_SUPPORT}" = "_WITH_VRRP_"; then
+  echo "Use VRRP Framework       : Yes"
+else
+  echo "Use VRRP Framework       : No"
+fi
+if test "${DFLAGS}" = "-D_DEBUG_"; then
+  echo "Use Debug flags          : Yes"
+else
+  echo "Use Debug flags          : No"
+fi
+dnl ----[ end configure ]---
+echo
index 42ff690..97c3888 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -5,7 +5,7 @@
  *
  * Part:        Main program structure.
  *
- * Version:     $Id: main.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: main.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 732432c..a4441f7 100644 (file)
--- a/daemon.h
+++ b/daemon.h
@@ -5,7 +5,7 @@
  *
  * Part:        Daemon process handling.
  *
- * Version:     $Id: daemon.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: daemon.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
diff --git a/data.c b/data.c
index 52dc27c..5e767c0 100644 (file)
--- a/data.c
+++ b/data.c
@@ -5,7 +5,7 @@
  *
  * Part:        Dynamic data structure definition.
  *
- * Version:     $Id: data.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: data.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -123,6 +123,11 @@ static void dump_vrrp(void *data)
   syslog(LOG_INFO, "   VIP count = %d", vrrp->naddr);
   for (i = 0; i < vrrp->naddr; i++)
     syslog(LOG_INFO, "     VIP%d = %s", i+1, ip_ntoa(vrrp->vaddr[i].addr));
+  if (vrrp->notify_exec)
+    syslog(LOG_INFO, "   Using notification script = %s"
+                   , vrrp->notify_file);
+  if (vrrp->smtp_alert)
+    syslog(LOG_INFO, "   Using smtp notification");
 }
 void alloc_vrrp(char *iname)
 {
@@ -182,8 +187,11 @@ static void dump_vs(void *data)
                  , vs->delay_loop
                  , vs->sched);
   if (atoi(vs->timeout_persistence) > 0)
-    syslog(LOG_INFO, "   persistence = %s"
+    syslog(LOG_INFO, "   persistence timeout = %s"
                    , vs->timeout_persistence);
+  if (vs->granularity_persistence)
+    syslog(LOG_INFO, "   persistence granularity = %s"
+                   , ip_ntoa(vs->granularity_persistence));
   syslog(LOG_INFO, "   protocol = %s"
                  , (vs->service_type == IPPROTO_TCP)?"TCP":"UDP");
 
@@ -299,8 +307,8 @@ void free_data(void)
   free_list(conf_data->vrrp);
   free_list(conf_data->vs);
 
-//  FREE(conf_data->lvs_id);
-//  FREE(conf_data->email_from);
+  FREE_PTR(conf_data->lvs_id);
+  FREE_PTR(conf_data->email_from);
   FREE(conf_data);
 }
 void dump_data(void)
@@ -333,5 +341,7 @@ void dump_data(void)
                    , NVERSION(IP_VS_VERSION_CODE));
     dump_list(conf_data->vs);
   }
+#ifdef _WITH_LVS_
   dump_checkers_queue();
+#endif
 }
diff --git a/data.h b/data.h
index a216f82..721e08a 100644 (file)
--- a/data.h
+++ b/data.h
@@ -5,7 +5,7 @@
  *
  * Part:        Dynamic data structure definition.
  *
- * Version:     $Id: data.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: data.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -79,6 +79,7 @@ typedef struct _virtual_server {
   unsigned             loadbalancing_kind;
   uint32_t             nat_mask;
   char                 timeout_persistence[MAX_TIMEOUT_LENGTH];
+  uint32_t             granularity_persistence;
   real_server          *s_svr;
   list                 rs;
 } virtual_server;
index ed0f2d8..428a403 100644 (file)
@@ -7,7 +7,7 @@
  *              library to add/remove server MASQ rules to the kernel 
  *              firewall framework.
  *
- * Version:     $Id: ipfwwrapper.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: ipfwwrapper.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 6bc30b8..5795989 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        ipfwwrapper.c include file.
  *
- * Version:     $Id: ipfwwrapper.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: ipfwwrapper.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 785390b..6d969ca 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.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: ipvswrapper.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  * 
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              
@@ -45,15 +45,15 @@ int ipvs_cmd(int cmd, virtual_server *vs, real_server *rs)
   strncpy(ctl.m_tname, vs->sched, IP_MASQ_TNAME_MAX);
   ctl.u.vs_user.weight = -1;
   ctl.u.vs_user.masq_flags = vs->loadbalancing_kind;
-  ctl.u.vs_user.netmask = ((u_int32_t) 0xffffffff); /* f:f:f:f for default netmask */
+  ctl.u.vs_user.netmask = ((u_int32_t) 0xffffffff);
   ctl.u.vs_user.protocol = vs->service_type;
 
-  if(!parse_timeout(vs->timeout_persistence, &ctl.u.vs_user.timeout)) {
+  if(!parse_timeout(vs->timeout_persistence, &ctl.u.vs_user.timeout))
     syslog(LOG_INFO, "IPVS WRAPPER : Virtual service [%s:%d] illegal timeout."
                    , ip_ntoa(SVR_IP(vs))
                    , ntohs(SVR_PORT(vs)));
-  }
-  ctl.u.vs_user.vs_flags = (ctl.u.vs_user.timeout!=0)?IP_VS_SVC_F_PERSISTENT:0;
+  if (urule.timeout != 0 || vs->granularity_persistence)
+    ctl.u.vs_user.vs_flags = IP_VS_SVC_F_PERSISTENT;
   
   /* VS specific */
   if (vs->vfwmark) {
@@ -63,6 +63,10 @@ int ipvs_cmd(int cmd, virtual_server *vs, real_server *rs)
     ctl.u.vs_user.vport = SVR_PORT(vs);
   }
 
+  if (ctl.m_cmd == IP_MASQ_CMD_ADD || ctl.m_cmd == IP_MASQ_CMD_DEL)
+    if (vs->granularity_persistence)
+      ctl.u.vs_user.netmask = vs->granularity_persistence;
+
   /* SVR specific */
   if (ctl.m_cmd == IP_MASQ_CMD_ADD_DEST || ctl.m_cmd == IP_MASQ_CMD_DEL_DEST) {
     ctl.u.vs_user.weight = rs->weight;
@@ -102,6 +106,8 @@ int ipvs_cmd(int cmd, virtual_server *vs, real_server *rs)
 
 int ipvs_syncd_cmd(int cmd, char *ifname, int state)
 {
+#ifdef _HAVE_IPVS_SYNCD_
+
   struct ip_vs_rule_user urule;
   int result = 0;
   int sockfd;
@@ -138,6 +144,11 @@ int ipvs_syncd_cmd(int cmd, char *ifname, int state)
 
   close(sockfd);
   return IPVS_SUCCESS;
+
+#else
+  syslog(LOG_INFO, "IPVS WRAPPER : Sync daemon not supported on kernel v2.2");
+  return IPVS_ERROR;
+#endif
 }
 
 int ipvs_cmd(int cmd, virtual_server *vs, real_server *rs)
@@ -151,14 +162,15 @@ int ipvs_cmd(int cmd, virtual_server *vs, real_server *rs)
   strncpy(urule.sched_name, vs->sched, IP_VS_SCHEDNAME_MAXLEN);
   urule.weight = 1;
   urule.conn_flags = vs->loadbalancing_kind;
-  urule.netmask    = ((u_int32_t) 0xffffffff);
+  urule.netmask  = ((u_int32_t) 0xffffffff);
   urule.protocol   = vs->service_type;
   
   if (!parse_timeout(vs->timeout_persistence, &urule.timeout))
     syslog(LOG_INFO, "IPVS WRAPPER : Virtual service [%s:%d] illegal timeout."
                    , ip_ntoa(SVR_IP(vs))
                    , ntohs(SVR_PORT(vs)));
-  urule.vs_flags = (urule.timeout != 0)?IP_VS_SVC_F_PERSISTENT:0;
+  if (urule.timeout != 0 || vs->granularity_persistence)
+    urule.vs_flags = IP_VS_SVC_F_PERSISTENT;
 
   /* VS specific */
   if (vs->vfwmark) {
@@ -167,6 +179,11 @@ int ipvs_cmd(int cmd, virtual_server *vs, real_server *rs)
     urule.vaddr = SVR_IP(vs);
     urule.vport = SVR_PORT(vs);
   }
+
+  if (cmd == IP_VS_SO_SET_ADD || cmd == IP_VS_SO_SET_DEL)
+    if (vs->granularity_persistence)
+      urule.netmask  = vs->granularity_persistence;
+
   /* SVR specific */
   if (cmd == IP_VS_SO_SET_ADDDEST || cmd == IP_VS_SO_SET_DELDEST) {
     urule.weight = rs->weight;
index deb68b9..8c176d4 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        ipvswrapper.c include file.
  *
- * Version:     $Id: ipvswrapper.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: ipvswrapper.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
 #define IPVS_SUCCESS   1
 #define IPVS_CMD_DELAY 3
 
-#ifdef _KRNL_2_2_
-  #define IPVS_STARTDAEMON     1
-  #define IPVS_STOPDAEMON      2
-  #define IPVS_MASTER          3
-  #define IPVS_BACKUP          4
-#else
+#ifdef _HAVE_IPVS_SYNCD_
   #define IPVS_STARTDAEMON     IP_VS_SO_SET_STARTDAEMON
   #define IPVS_STOPDAEMON      IP_VS_SO_SET_STOPDAEMON
   #define IPVS_MASTER          IP_VS_STATE_MASTER
   #define IPVS_BACKUP          IP_VS_STATE_BACKUP
+#else
+  #define IPVS_STARTDAEMON     1
+  #define IPVS_STOPDAEMON      2
+  #define IPVS_MASTER          3
+  #define IPVS_BACKUP          4
 #endif
 
 extern thread_master *master;
index 2dbae89..8db83ff 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        Manipulation functions for IPVS & IPFW wrappers.
  *
- * Version:     $id: ipwrapper.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $id: ipwrapper.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index cbf7e73..1774034 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        ipwrapper.c include file.
  *
- * Version:     $Id: ipwrapper.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: ipwrapper.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 49ea8d9..5542de2 100644 (file)
--- a/layer4.c
+++ b/layer4.c
@@ -6,7 +6,7 @@
  * Part:        Layer4 checkers handling. Register worker threads &
  *              upper layer checkers.
  *
- * Version:     $Id: layer4.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: layer4.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 3dab641..f49e26d 100644 (file)
--- a/layer4.h
+++ b/layer4.h
@@ -5,7 +5,7 @@
  *
  * Part:        layer4.c include file.
  *
- * Version:     $Id: layer4.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: layer4.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
diff --git a/list.c b/list.c
index 6af2a3b..0124e52 100644 (file)
--- a/list.c
+++ b/list.c
@@ -5,7 +5,7 @@
  * 
  * Part:        List structure manipulation.
  *  
- * Version:     $Id: list.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: list.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  * 
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              
diff --git a/list.h b/list.h
index 78a97d4..c035d2c 100644 (file)
--- a/list.h
+++ b/list.h
@@ -5,7 +5,7 @@
  * 
  * Part:        list.c include file.
  *  
- * Version:     $Id: list.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: list.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
diff --git a/main.c b/main.c
index d398db1..3ec75ec 100644 (file)
--- a/main.c
+++ b/main.c
@@ -5,7 +5,7 @@
  *
  * Part:        Main program structure.
  *
- * Version:     $Id: main.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: main.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
  */
 
 #include "main.h"
-#include "daemon.h"
-#include "memory.h"
-#include "parser.h"
-#include "vrrp_if.h"
 
 /* SIGHUP handler */
 void sighup(int sig)
@@ -218,20 +214,18 @@ int main(int argc, char **argv)
   /* Signal handling initialization  */
   signal_init();
 
-  /* Create the master thread */
-  master = thread_make_master();
-
   /* Init interface queue */
   init_interface_queue();
 
   /* Parse the configuration file */
+#ifdef _WITH_LVS_
   init_checkers_queue();
+#endif
   init_keywords();
   init_data(conf_file);
   if (!conf_data) {
     syslog(LOG_INFO, "Stopping "VERSION_STRING);
     closelog();
-    thread_destroy_master(master);
 #ifdef _DEBUG_
     keepalived_free_final();
 #endif
@@ -239,27 +233,37 @@ int main(int argc, char **argv)
   }
 
   /* SSL load static data & initialize common ctx context */
+#ifdef _WITH_LVS_
   if (!init_ssl_ctx()) {
     closelog();
-    thread_destroy_master(master);
 #ifdef _DEBUG_
     keepalived_free_final();
 #endif
     exit(0);
   }
+#endif
 
   if (debug & 4) 
     dump_data();
 
+#ifdef _WITH_LVS_
   if (!init_services()) {
     syslog(LOG_INFO, "Stopping "VERSION_STRING);
     closelog();
     free_data();
     exit(0);
   }
+#endif
+
+  /* Create the master thread */
+  master = thread_make_master();
 
   /* register workers threads */
+  kernel_netlink_init();
+  if_mii_poller_init();
+#ifdef _WITH_LVS_
   register_checkers_thread();
+#endif
   vrrp_complete_init();
   register_vrrp_thread();
 
@@ -280,9 +284,11 @@ int main(int argc, char **argv)
   syslog(LOG_INFO, "Stopping "VERSION_STRING);
 
   /* Just cleanup memory & exit */
-  free_checkers_queue();
   thread_destroy_master(master);
+#ifdef _WITH_LVS_
+  free_checkers_queue();
   clear_services();
+#endif
   shutdown_vrrp_instances();
   free_interface_queue();
   free_data();
diff --git a/main.h b/main.h
index ba0c1f5..4ca375a 100644 (file)
--- a/main.h
+++ b/main.h
@@ -5,7 +5,7 @@
  *
  * Part:        Main program include file.
  *
- * Version:     $Id: main.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: main.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
 #include <popt.h>
 
 /* local includes */
+#include "daemon.h"
+#include "memory.h"
+#include "parser.h"
 #include "utils.h"
 #include "pidfile.h"
 #include "data.h"
 #include "scheduler.h"
 #include "ipwrapper.h"
-#include "smtp.h"
-#include "vrrp.h"
 #include "check_api.h"
+#include "vrrp.h"
+#include "vrrp_if.h"
 #include "vrrp_netlink.h"
 
 /* global var */
 thread_master *master;
 unsigned int debug;
+unsigned long mem_allocated = 0;
 data *conf_data;
 
 /* extern prototypes */
-extern void clear_ssl(SSL_DATA *ssl);
-extern int init_ssl_ctx(void);
+#ifdef _WITH_LVS_
+  extern void clear_ssl(SSL_DATA *ssl);
+  extern int init_ssl_ctx(void);
+#endif
 extern void register_vrrp_thread(void);
 
 /* Build version */
 #define PROG    "Keepalived"
 
-#define VERSION_CODE 0x000506
-#define DATE_CODE    0x0d0402
+#define VERSION_CODE 0x000507
+#define DATE_CODE    0x160402
 
 #define KEEPALIVED_VERSION(version)    \
        (version >> 16) & 0xFF,         \
index f587bf0..64148fd 100644 (file)
--- a/memory.c
+++ b/memory.c
@@ -6,7 +6,7 @@
  * Part:        Memory management framework. This framework is used to
  *              find any memory leak.
  *
- * Version:     $Id: memory.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: memory.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Jan Holmberg, <jan@artech.net>
 
 #include "memory.h"
 
-
 void *xalloc(unsigned long size)
 {
   void *mem;
-
-  if ((mem = malloc(size)))
+  if ((mem = malloc(size))) {
     memset(mem, 0, size);
+    mem_allocated += size;
+  }
   return mem;
 }
+void xfree(void *p)
+{
+  mem_allocated -= sizeof(p);
+  free(p);
+}
 
 /* KeepAlived memory management. in debug mode,
  * help finding eventual memory leak.
index 7f209a5..a3abf57 100644 (file)
--- a/memory.h
+++ b/memory.h
@@ -5,7 +5,7 @@
  *
  * Part:        memory.c include file.
  *
- * Version:     $Id: memory.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: memory.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Authors:     Alexandre Cassen, <acassen@linux-vs.org>
  *              Jan Holmberg, <jan@artech.net>
@@ -32,6 +32,9 @@
 
 /* extern types */
 extern unsigned int debug;
+extern unsigned long mem_allocated;
+extern void *xalloc(unsigned long size);
+extern void xfree(void *p);
 
 /* Local defines */
 #ifdef _DEBUG_
@@ -52,7 +55,7 @@ extern void keepalived_free_final(void);
 #else
 
 #define MALLOC(n)    (xalloc(n))
-#define FREE(p)      (free(p))
+#define FREE(p)      (xfree(p))
 #define REALLOC(p,n) (realloc((p),(n)))
 
 #endif
index 8aa0840..26ac9e6 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -7,7 +7,7 @@
  *              data structure representation the conf file representing
  *              the loadbalanced server pool.
  *  
- * Version:     $Id: parser.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: parser.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  * 
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              
@@ -25,6 +25,7 @@
 #include "parser.h"
 #include "memory.h"
 #include "vrrp.h"
+#include "vrrp_if.h"
 #include "check_api.h"
 
 /* global defs */
@@ -32,6 +33,7 @@ static vector keywords;
 static int sublevel = 0;
 static FILE *stream;
 extern data *conf_data;
+extern unsigned long mem_allocated;
 
 static void keyword_alloc(vector keywords, char *string, void (*handler)(vector))
 {
@@ -96,8 +98,8 @@ static void dump_keywords(vector keydump, int level)
 
 static void free_keywords(vector keywords)
 {
-  int i;
   struct keyword *keyword;
+  int i;
 
   for (i = 0; i < VECTOR_SIZE(keywords); i++) {
     keyword = VECTOR_SLOT(keywords, i);
@@ -154,8 +156,7 @@ static vector alloc_strvec(char *string)
   cp = string;
 
   /* Skip white spaces */
-  while ((isspace((int) *cp) || *cp == '\r' || *cp == '\n') &&
-         *cp != '\0')
+  while (isspace((int) *cp) && *cp != '\0')
     cp++;
 
   /* Return if there is only white spaces */
@@ -171,8 +172,7 @@ static vector alloc_strvec(char *string)
 
   while (1) {
     start = cp;
-    while (!(isspace((int) *cp) || *cp == '\r' || *cp == '\n') &&
-           *cp != '\0')
+    while (!isspace((int) *cp) && *cp != '\0')
       cp++;
     strlen = cp - start;
     token = MALLOC(strlen + 1);
@@ -183,47 +183,62 @@ static vector alloc_strvec(char *string)
     vector_alloc_slot(strvec);
     vector_set_slot(strvec, token);
 
-    while ((isspace((int) *cp) || *cp == '\n' || *cp == '\r') &&
-           *cp != '\0')
+    while (isspace((int) *cp) && *cp != '\0')
       cp++;
     if (*cp == '\0' || *cp == '!' || *cp == '#')
       return strvec;
   }
 }
 
-static char *read_line(char *buf, int size)
+static int read_line(char *buf, int size)
 {
-  return(fgets(buf, size, stream));
+  int ch;
+  int count = 0;
+
+  while ((ch = fgetc(stream)) != EOF && (int) ch != '\n'
+                                     && (int) ch != '\r') {
+    if (count < size)
+      buf[count] = (int) ch;
+    else
+      break;
+    count++;
+  }
+  return (ch == EOF)?0:1;
 }
 
 vector read_value_block(void)
 {
-  char buf[BUFSIZ];
+  char *buf;
   int i;
   char *str = NULL;
   char *dup;
   vector vec = NULL;
   vector elements = vector_alloc();
 
-  while (read_line(buf, BUFSIZ)) {
+  buf = (char *)MALLOC(MAXBUF);
+  while (read_line(buf, MAXBUF)) {
     vec = alloc_strvec(buf);
-    str = VECTOR_SLOT(vec, 0);
-    if (!strcmp(str, EOB)) {
+    if (vec) {
+      str = VECTOR_SLOT(vec, 0);
+      if (!strcmp(str, EOB)) {
+        free_strvec(vec);
+        break;
+      }
+
+      if (VECTOR_SIZE(vec))
+        for (i = 0; i < VECTOR_SIZE(vec); i++) {
+          str = VECTOR_SLOT(vec, i);
+          dup = (char *)MALLOC(strlen(str)+1);
+          memcpy(dup, str, strlen(str));
+          vector_alloc_slot(elements);
+          vector_set_slot(elements, dup);
+        }
       free_strvec(vec);
-      break;
     }
-
-    if (VECTOR_SIZE(vec))
-      for (i = 0; i < VECTOR_SIZE(vec); i++) {
-        str = VECTOR_SLOT(vec, i);
-        dup = (char *)MALLOC(strlen(str)+1);
-        memcpy(dup, str, strlen(str));
-        vector_alloc_slot(elements);
-        vector_set_slot(elements, dup);
-      }
-    free_strvec(vec);
+    memset(buf, 0, MAXBUF);
   }
-
+  
+  FREE(buf);
   return elements;
 }
 
@@ -382,6 +397,11 @@ static void vrrp_notify_handler(vector strvec)
   memcpy(vrrp->notify_file, str, size);
   vrrp->notify_exec = 1;
 }
+static void vrrp_smtp_handler(vector strvec)
+{
+  vrrp_rt *vrrp = LIST_TAIL_DATA(conf_data->vrrp);
+  vrrp->smtp_alert = 1;
+}
 static void vrrp_lvs_syncd_handler(vector strvec)
 {
   vrrp_rt *vrrp = LIST_TAIL_DATA(conf_data->vrrp);
@@ -407,11 +427,23 @@ static void vrrp_auth_pass_handler(vector strvec)
 }
 static void vrrp_vip_handler(vector strvec)
 {
-  vector vips = read_value_block();
-  int i;
+  vector vips   = read_value_block();
+  vrrp_rt *vrrp = LIST_TAIL_DATA(conf_data->vrrp);
   char *str;
-
-  for (i = 0; i < VECTOR_SIZE(vips); i++) {
+  int i;
+  int nbvip = 0;
+
+  if (VECTOR_SIZE(vips) > VRRP_MAX_VIP) {
+    syslog(LOG_INFO, "VRRP_Instance(%s) use %d VIPs, trunc to the first %d VIPs."
+                   , vrrp->iname
+                   , VECTOR_SIZE(vips)
+                   , VRRP_MAX_VIP);
+    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++) {
     str = VECTOR_SLOT(vips, i);
     alloc_vrrp_vip(str);
   }
@@ -477,7 +509,11 @@ static void pto_handler(vector strvec)
   int size = sizeof(vs->timeout_persistence);
   
   memcpy(vs->timeout_persistence, str, size);
-  
+}
+static void pgr_handler(vector strvec)
+{
+  virtual_server *vs = LIST_TAIL_DATA(conf_data->vs);
+  vs->granularity_persistence = inet_addr(VECTOR_SLOT(strvec, 1));
 }
 static void proto_handler(vector strvec)
 {
@@ -510,13 +546,17 @@ static void process_stream(vector keywords)
   int i;
   struct keyword *keyword;
   char *str;
-  char buf[BUFSIZ];
+  char *buf;
   vector strvec;
 
-  if (!read_line(buf, BUFSIZ))
+  buf = MALLOC(MAXBUF);
+  if (!read_line(buf, MAXBUF)) {
+    FREE(buf);
     return;
+  }
 
   strvec = alloc_strvec(buf);
+  FREE(buf);
 
   if (!strvec) {
     process_stream(keywords);
@@ -578,6 +618,7 @@ void init_keywords(void)
   install_keyword("preempt",                   &vrrp_preempt_handler);
   install_keyword("debug",                     &vrrp_debug_handler);
   install_keyword("notify",                    &vrrp_notify_handler);
+  install_keyword("smtp_alert",                        &vrrp_smtp_handler);
   install_keyword("lvs_sync_daemon_interface", &vrrp_lvs_syncd_handler);
   install_keyword("authentication",            NULL);
   install_sublevel();
@@ -592,6 +633,7 @@ void init_keywords(void)
   install_keyword("lb_kind",                   &lbkind_handler);
   install_keyword("nat_mask",                  &natmask_handler);
   install_keyword("persistence_timeout",       &pto_handler);
+  install_keyword("persistence_granularity",   &pgr_handler);
   install_keyword("protocol",                  &proto_handler);
 
   /* Real server mapping */
@@ -601,7 +643,10 @@ void init_keywords(void)
   install_keyword("weight",                    &weight_handler);
 
   /* Checkers mapping */
+#ifdef _WITH_LVS_
   install_checkers_keyword();
+#endif
+  install_sublevel_end();
 }
 
 void init_data(char *conf_file)
@@ -620,12 +665,13 @@ void init_data(char *conf_file)
   process_stream(keywords);
 
 /* Dump configuration *
-
   vector_dump(keywords);
   dump_keywords(keywords, 0);
-  free_keywords(keywords);
 */
 
   fclose(stream);
   free_keywords(keywords);
+
+  syslog(LOG_INFO, "Configuration is using : %lu Bytes"
+                 , mem_allocated);
 }
index ca14160..f9b966b 100644 (file)
--- a/parser.h
+++ b/parser.h
@@ -5,7 +5,7 @@
  * 
  * Part:        cfreader.c include file.
  *  
- * Version:     $Id: parser.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: parser.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -37,6 +37,7 @@
 /* Global definitions */
 #define CONF "/etc/keepalived/keepalived.conf"
 #define EOB  "}"
+#define MAXBUF 1024
 
 /* ketword definition */
 struct keyword {
index 51108d5..db03209 100644 (file)
--- a/pidfile.c
+++ b/pidfile.c
@@ -5,7 +5,7 @@
  *
  * Part:        pidfile utility.
  *
- * Version:     $Id: pidfile.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: pidfile.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index bad0258..b226d71 100644 (file)
--- a/pidfile.h
+++ b/pidfile.h
@@ -5,7 +5,7 @@
  *
  * Part:        pidfile.c include file.
  *
- * Version:     $Id: pidfile.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: pidfile.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 09fb8dc..496d6b6 100644 (file)
@@ -14,6 +14,7 @@ global_defs {
 vrrp_instance VI_1 {
     state MASTER
     interface eth0
+    smtp_alert
     virtual_router_id 51
     priority 100
     advert_int 1
@@ -30,6 +31,7 @@ vrrp_instance VI_1 {
 
 vrrp_instance VI_2 {
     interface eth0
+    smtp_alert
     virtual_router_id 50
     priority 50
     advert_int 1
@@ -43,6 +45,7 @@ vrrp_instance VI_2 {
 vrrp_instance VI_3 {
     state MASTER
     interface eth1
+    smtp_alert
     virtual_router_id 52
     priority 100
     advert_int 1
@@ -59,6 +62,7 @@ vrrp_instance VI_3 {
 
 vrrp_instance VI_4 {
     interface eth1
+    smtp_alert
     virtual_router_id 53
     priority 50
     advert_int 1
index dc3b5c1..42c4ed6 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.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: scheduler.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -487,7 +487,7 @@ retry:  /* When thread can't fetch try to find next thread again. */
   if (ret < 0) {
     if (errno != EINTR) {
       /* Real error. */
-#ifdef DEBUG
+#ifdef _DEBUG_
       syslog(LOG_DEBUG, "select error: %s", strerror (errno));
 #endif
       assert (0);
index f2d7f64..5c9c609 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        scheduler.c include file.
  *
- * Version:     $Id: scheduler.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: scheduler.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
diff --git a/smtp.c b/smtp.c
index b82e33f..d83319c 100644 (file)
--- a/smtp.c
+++ b/smtp.c
@@ -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.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: smtp.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -378,6 +378,12 @@ static int smtp_connect_thread(thread *thread)
 
   smtp_arg = THREAD_ARG(thread);
 
+  /* Return if no smtp server is defined */
+  if (conf_data->smtp_server == 0) {
+    free_smtp_all(smtp_arg);
+    return 0;
+  }
+
   if ( (fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1 ) {
 #ifdef _DEBUG_
     syslog(LOG_DEBUG, "SMTP connect fail to create socket.");
@@ -438,6 +444,7 @@ static int smtp_connect_thread(thread *thread)
 
 void smtp_alert(thread_master *master
                 , real_server *rs
+                , vrrp_rt *vrrp
                 , const char *subject
                 , const char *body)
 {
@@ -454,15 +461,25 @@ void smtp_alert(thread_master *master
 
     /* format subject if rserver is specified */
     if (rs)
-      snprintf(smtp_arg->subject, MAX_HEADERS_LENGTH, "[%s] %s:%d - %s"
-               , conf_data->lvs_id
-               , ip_ntoa(SVR_IP(rs))
-               , ntohs(SVR_PORT(rs))
-               , subject);
-    else
+      snprintf(smtp_arg->subject, MAX_HEADERS_LENGTH
+                                , "[%s] Realserver %s:%d - %s"
+                                , conf_data->lvs_id
+                                , ip_ntoa(SVR_IP(rs))
+                                , ntohs(SVR_PORT(rs))
+                                , subject);
+    else if (vrrp)
+      snprintf(smtp_arg->subject, MAX_HEADERS_LENGTH
+                                , "[%s] VRRP Instance %s - %s"
+                                , conf_data->lvs_id
+                                , vrrp->iname
+                                , subject);
+    else if (conf_data->lvs_id)
       snprintf(smtp_arg->subject, MAX_HEADERS_LENGTH, "[%s] %s"
                                 , conf_data->lvs_id
                                 , subject);
+    else
+      snprintf(smtp_arg->subject, MAX_HEADERS_LENGTH, "%s"
+                                , subject);
 
     strncpy(smtp_arg->body, body, MAX_BODY_LENGTH);
 
diff --git a/smtp.h b/smtp.h
index 2af76a0..3717776 100644 (file)
--- a/smtp.h
+++ b/smtp.h
@@ -5,7 +5,7 @@
  *
  * Part:        smtp.c include file.
  *
- * Version:     $Id: smtp.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: smtp.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -32,6 +32,7 @@
 #include "data.h"
 #include "scheduler.h"
 #include "layer4.h"
+#include "vrrp.h"
 
 /* global defs */
 #define SMTP_PORT          25
@@ -82,6 +83,7 @@ typedef struct _smtp_thread_arg {
 /* Prototypes defs */
 extern void smtp_alert(thread_master *
                        , real_server *
+                       , vrrp_rt *
                        , const char *
                        , const char *);
 #endif
diff --git a/timer.c b/timer.c
index c724d73..720fb97 100644 (file)
--- a/timer.c
+++ b/timer.c
@@ -5,7 +5,7 @@
  * 
  * Part:        Timer manipulations.
  *  
- * Version:     $Id: timer.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: timer.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  * 
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              
diff --git a/timer.h b/timer.h
index 8d4e0c9..936b224 100644 (file)
--- a/timer.h
+++ b/timer.h
@@ -5,7 +5,7 @@
  * 
  * Part:        timer.c include file.
  *  
- * Version:     $Id: timer.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: timer.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
diff --git a/utils.c b/utils.c
index 1a43332..0c6a2d9 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -5,7 +5,7 @@
  *
  * Part:        General program utils.
  *
- * Version:     $Id: utils.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: utils.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
diff --git a/utils.h b/utils.h
index 494873d..6f186a4 100644 (file)
--- a/utils.h
+++ b/utils.h
@@ -5,7 +5,7 @@
  *
  * Part:        utils.h include file.
  *
- * Version:     $Id: utils.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: utils.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 1864dea..3a3b89f 100644 (file)
--- a/vector.c
+++ b/vector.c
@@ -5,7 +5,7 @@
  * 
  * Part:        Vector structure manipulation.
  *  
- * Version:     $Id: vector.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: vector.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  * 
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              
index ce4e600..6c22fb4 100644 (file)
--- a/vector.h
+++ b/vector.h
@@ -5,7 +5,7 @@
  * 
  * Part:        vector.c include file.
  *  
- * Version:     $Id: vector.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: vector.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
diff --git a/vrrp.c b/vrrp.c
index a5f7991..b4e8cea 100644 (file)
--- a/vrrp.c
+++ b/vrrp.c
@@ -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.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: vrrp.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -762,11 +762,13 @@ void vrrp_state_goto_master(vrrp_rt *vrrp)
                      , vrrp->notify_exec);
   }
 
+#ifdef _HAVE_IPVS_SYNCD_
   /* Check if sync daemon handling is needed */
   if (vrrp->lvs_syncd_if)
     thread_add_timer(master, ipvs_syncd_master_thread
                            , vrrp->lvs_syncd_if
                            , IPVS_CMD_DELAY);
+#endif
 
   if (vrrp->wantstate == VRRP_STATE_MAST) {
     vrrp->state = VRRP_STATE_MAST;
@@ -804,11 +806,13 @@ void vrrp_state_leave_master(vrrp_rt *vrrp)
                      , vrrp->notify_exec);
   }
 
+#ifdef _HAVE_IPVS_SYNCD_
   /* Check if sync daemon handling is needed */
   if (vrrp->lvs_syncd_if)
     thread_add_timer(master, ipvs_syncd_backup_thread
                            , vrrp->lvs_syncd_if
                            , IPVS_CMD_DELAY);
+#endif
 
   /* set the new vrrp state */
   switch (vrrp->wantstate) {
@@ -1126,9 +1130,11 @@ void shutdown_vrrp_instances(void)
         vrrp->state == VRRP_STATE_DUMMY_MAST)
       vrrp_restore_interface(vrrp, 1);
 
+#ifdef _HAVE_IPVS_SYNCD_
     /* Stop stalled syncd */
     if (vrrp->lvs_syncd_if)
       ipvs_syncd_cmd(IPVS_STOPDAEMON, NULL, 0);
+#endif
   }
 }
 
diff --git a/vrrp.h b/vrrp.h
index 2a3d54f..0b0bef6 100644 (file)
--- a/vrrp.h
+++ b/vrrp.h
@@ -6,7 +6,7 @@
  *
  * Part:        vrrp.c program include file.
  *
- * Version:     $Id: vrrp.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: vrrp.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              Based on the Jerome Etienne, <jetienne@arobas.net> code.
@@ -102,6 +102,9 @@ typedef struct _vrrp_rt {
        int     fd;             /* the socket descriptor */
 
        int     debug;          /* Debug level 0-4 */
+
+       /* State transition notification */
+       int     smtp_alert;
        int     notify_exec;
        char    notify_file[FILENAME_MAX];
 
@@ -145,17 +148,17 @@ typedef struct _vrrp_rt {
 #define VRRP_PACKET_DROP     2
 #define VRRP_PACKET_NULL     3
 #define VRRP_PACKET_OTHER    4      /* Muliple VRRP on LAN, Identify "other" VRRP */
-#define VRRP_PACKET_TEMP_LEN 256
 
-#define VRRP_AUTH_LEN  8
+/* VRRP Packet fixed lenght */
+#define VRRP_MAX_VIP           20
+#define VRRP_PACKET_TEMP_LEN   512
+#define VRRP_AUTH_LEN          8
 
 #define VRRP_IS_BAD_VID(id)            ((id)<1 || (id)>255)    /* rfc2338.6.1.vrid */
 #define VRRP_IS_BAD_PRIORITY(p)                ((p)<1 || (p)>255)      /* rfc2338.6.1.prio */
 #define VRRP_IS_BAD_ADVERT_INT(d)      ((d)<1)
-
 #define VRRP_IS_BAD_DEBUG_INT(d)       ((d)<0 || (d)>4)
 
-
 #define VRRP_TIMER_SKEW(srv)   ((256-(srv)->priority)*TIMER_HZ/256) 
 
 #define VRRP_MIN(a, b) ((a) < (b)?(a):(b))
index 1d74b06..c3e73d5 100644 (file)
--- a/vrrp_if.c
+++ b/vrrp_if.c
@@ -5,7 +5,7 @@
  *
  * Part:        Interfaces manipulation.
  *
- * Version:     $Id: vrrp_if.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: vrrp_if.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -290,9 +290,10 @@ void init_interface_queue(void)
   init_if_queue();
   netlink_interface_lookup();
   init_if_mii();
-  kernel_netlink_init();
 //  dump_list(if_queue);
-
+}
+void if_mii_poller_init(void)
+{
   /* Register NIC Heartbeat monitoring thread */
   thread_add_timer(master, if_monitor_thread
                          , NULL
index 9cd07e5..65435b7 100644 (file)
--- a/vrrp_if.h
+++ b/vrrp_if.h
@@ -5,7 +5,7 @@
  *
  * Part:        vrrp_if.c include file.
  *
- * Version:     $Id: vrrp_if.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: vrrp_if.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
@@ -82,6 +82,7 @@ extern interface *if_get_by_ifindex(const int ifindex);
 extern interface *if_get_by_ifname(const char *ifname);
 extern int if_mii_linkbeat(const interface *ifp);
 extern int if_mii_probe(const char *ifname);
+extern void if_mii_poller_init(void);
 extern void if_add_queue(interface *ifp);
 extern int if_monitor_thread(thread *thread);
 extern void init_interface_queue(void);
index 4bc65f5..18c6f34 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        NETLINK IPv4 address manipulation.
  *
- * Version:     $Id: vrrp_ipaddress.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: vrrp_ipaddress.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index cc979a6..4586f23 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        vrrp_ipaddress.c include file.
  *
- * Version:     $Id: vrrp_ipaddress.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: vrrp_ipaddress.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 9ba6d54..7c0a18e 100644 (file)
@@ -7,7 +7,7 @@
  *              authentication data encryption using HMAC MD5 according to
  *              RFCs 2085 & 2104.
  *
- * Version:     $Id: vrrp_ipsecah.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: vrrp_ipsecah.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index df835cd..6c8204b 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        vrrp_ipsecah.c include file.
  * 
- * Version:     $Id: vrrp_ipsecah.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: vrrp_ipsecah.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  * 
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *              
index b31c85f..b1eb8cf 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        NETLINK kernel command channel.
  *
- * Version:     $Id: vrrp_netlink.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: vrrp_netlink.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index 5665bee..9e83336 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        vrrp_netlink.c include file.
  *
- * Version:     $Id: vrrp_netlink.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: vrrp_netlink.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
index d34e3b7..0ad699c 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        Sheduling framework for vrrp code.
  *
- * Version:     $Id: vrrp_scheduler.c,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: vrrp_scheduler.c,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  *
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *
 #include "memory.h"
 #include "list.h"
 #include "data.h"
+#include "smtp.h"
 
 extern thread_master *master;
 extern data *conf_data;
 
+/* SMTP alert notifier */
+static void vrrp_smtp_notifier(vrrp_rt *vrrp)
+{
+  if (vrrp->smtp_alert)
+    smtp_alert(master, NULL, vrrp
+                     , "Transition to MASTER state"
+                     , "=> VRRP Instance is now owning VRRP VIPs <=\n\n");
+}
+
 /*
  * Initialize state handling
  * --rfc2338.6.4.1
@@ -51,10 +61,12 @@ static void vrrp_init_state(list l)
     } else {
       vrrp->ms_down_timer = 3 * vrrp->adver_int
                               + VRRP_TIMER_SKEW(vrrp);
+#ifdef _HAVE_IPVS_SYNCD_
       /* Check if sync daemon handling is needed */
       if (vrrp->lvs_syncd_if)
         ipvs_syncd_cmd(IPVS_STARTDAEMON, vrrp->lvs_syncd_if
                                        , IPVS_BACKUP);
+#endif
       vrrp->state = VRRP_STATE_BACK;
     }
   }
@@ -393,6 +405,7 @@ static void vrrp_handle_become_master(vrrp_rt *vrrp
   /* Then jump to master state */
   vrrp->wantstate = VRRP_STATE_MAST;
   vrrp_state_goto_master(vrrp);
+  vrrp_smtp_notifier(vrrp);
 }
 
 static void vrrp_handle_leave_master(vrrp_rt *vrrp
@@ -514,6 +527,7 @@ static void vrrp_handle_goto_master(vrrp_rt *vrrp)
 
     /* handle master state transition */
     vrrp_state_goto_master(vrrp);
+    vrrp_smtp_notifier(vrrp);
   }
 }
 
@@ -577,8 +591,10 @@ static void vrrp_handle_fault(vrrp_rt *vrrp)
       /* Otherwise, we transit to init state */
       if (vrrp->init_state == VRRP_STATE_BACK)
         vrrp->state = VRRP_STATE_BACK;
-      else
+      else {
         vrrp_handle_goto_master(vrrp);
+        vrrp_smtp_notifier(vrrp);
+      }
     }
   }
 }
index dd6a4e1..204af22 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Part:        vrrp_scheduler.c include file.
  * 
- * Version:     $Id: vrrp_scheduler.h,v 0.5.6 2002/04/13 06:21:33 acassen Exp $
+ * Version:     $Id: vrrp_scheduler.h,v 0.5.7 2002/05/02 22:18:07 acassen Exp $
  * 
  * Author:      Alexandre Cassen, <acassen@linux-vs.org>
  *