* keepalived-1.1.3 released.
* Stephan von Krawczynski, <skraw@ithnet.com> extended ip
address framework to support broadcast address selection.
* Extended the scheduling framework to support plain 'long'
timer. Visited the layer4 framework to support this new
scheduling scheme. Reviewed the checkers and VRRP framework
to support long timer.
* VRRP : Removed the timer micro adjust call. Its use is
obsolete with the new scheduling 'long' timer support.
* Jacob Rief, <Jacob.Rief@tiscover.com> and I added support
log level selection for main daemon. A new command line
argument has been created :
--log-facility -S 0-7 Set syslog facility to
LOG_LOCAL[0-7]. (default=LOG_DAEMON)
* Extended the HTTP checker to support non blocking read
while processing stream. NONBLOCK flags is set before
read operation to catch EAGAIN error.
* VRRP : Diego Rivera, <lrivera@racsa.co.cr> and I fixed a
notify issue while building notify exec string.
* VRRP : Diego Rivera, <lrivera@racsa.co.cr> and I extended
FSM to support BACKUP state notifiers and smtp_alert call
during VRRP initialization.
* Jan Vanhercke, <jan.vanhercke@c-cure.be> and I extended
scheduling timer computation to support micro-sec second
overlap. Extended the whole scheduling framework to support
this scheduling scheme while computing thread timers.
* Fixed scheduling framework to support child thread timers
while computing global scheduling timer.
+2003-09-29 Alexandre Cassen <acassen@linux-vs.org>
+ * keepalived-1.1.3 released.
+ * Stephan von Krawczynski, <skraw@ithnet.com> extended ip
+ address framework to support broadcast address selection.
+ * Extended the scheduling framework to support plain 'long'
+ timer. Visited the layer4 framework to support this new
+ scheduling scheme. Reviewed the checkers and VRRP framework
+ to support long timer.
+ * VRRP : Removed the timer micro adjust call. Its use is
+ obsolete with the new scheduling 'long' timer support.
+ * Jacob Rief, <Jacob.Rief@tiscover.com> and I added support
+ log level selection for main daemon. A new command line
+ argument has been created :
+ --log-facility -S 0-7 Set syslog facility to
+ LOG_LOCAL[0-7]. (default=LOG_DAEMON)
+ * Extended the HTTP checker to support non blocking read
+ while processing stream. NONBLOCK flags is set before
+ read operation to catch EAGAIN error.
+ * VRRP : Diego Rivera, <lrivera@racsa.co.cr> and I fixed a
+ notify issue while building notify exec string.
+ * VRRP : Diego Rivera, <lrivera@racsa.co.cr> and I extended
+ FSM to support BACKUP state notifiers and smtp_alert call
+ during VRRP initialization.
+ * Jan Vanhercke, <jan.vanhercke@c-cure.be> and I extended
+ scheduling timer computation to support micro-sec second
+ overlap. Extended the whole scheduling framework to support
+ this scheduling scheme while computing thread timers.
+ * Fixed scheduling framework to support child thread timers
+ while computing global scheduling timer.
+
2003-09-07 Alexandre Cassen <acassen@linux-vs.org>
* keepalived-1.1.2 released.
* Dominik Vogt, <dominik.vogt@gmx.de> and I extended checker
strong multi-threading framework. All the events process use this I/O
multiplexer.
-Keepalived is free software. See the file COPYING for copying conditions.
+Keepalived is free software, Copyright (C) Alexandre Cassen.
+See the file COPYING for copying conditions.
OPENSSL TOOLKIT LICENCE EXCEPTION
The configuration block looks like :
static_ipaddress { # block identification
- <IP ADDRESS>/<MASK> dev <STRING> scope <SCOPE>
- <IP ADDRESS>/<MASK> dev <STRING> scope <SCOPE>
+ <IP ADDRESS>/<MASK> brd <IP ADDRESS> dev <STRING> scope <SCOPE>
+ <IP ADDRESS>/<MASK> brd <IP ADDRESS> dev <STRING> scope <SCOPE>
...
}
auth_pass <STRING> # Password string
}
virtual_ipaddress { # VRRP IP addres block
- <IP ADDRESS>/<MASK> dev <STRING> scope <SCOPE>
- <IP ADDRESS>/<MASK> dev <STRING> scope <SCOPE>
+ <IP ADDRESS>/<MASK> brd <IP ADDRESS> dev <STRING> scope <SCOPE>
+ <IP ADDRESS>/<MASK> brd <IP ADDRESS> dev <STRING> scope <SCOPE>
...
}
virtual_ipaddress_excluded { # VRRP IP excluded from VRRP
- <IP ADDRESS>/<MASK> dev <STRING> scope <SCOPE> # packets
- <IP ADDRESS>/<MASK> dev <STRING> scope <SCOPE>
+ <IP ADDRESS>/<MASK> brd <IP ADDRESS> dev <STRING> scope <SCOPE> # packets
+ <IP ADDRESS>/<MASK> brd <IP ADDRESS> dev <STRING> scope <SCOPE>
...
}
virtual_routes { # VRRP virtual routes
*/
/* free allocated pieces */
-static void free_all(thread * thread)
+static void
+free_all(thread * thread)
{
SOCK *sock = THREAD_ARG(thread);
/* Simple finalization function */
int
-finalize(thread *thread)
+finalize(thread * thread)
{
SOCK *sock = THREAD_ARG(thread);
unsigned char digest[16];
printf("\n");
printf(HTML_MD5);
print_buffer(16, digest);
-
+
printf(HTML_MD5_FINAL);
}
printf("MD5SUM = ");
}
/* Process incoming stream */
-int http_process_stream(SOCK *sock, int r)
+int
+http_process_stream(SOCK * sock, int r)
{
sock->size += r;
sock->total_size += r;
if (!sock->extracted) {
if (req->verbose)
printf(HTTP_HEADER_HEXA);
- if ((sock->extracted =
- extract_html(sock->buffer, sock->size))) {
+ if ((sock->extracted = extract_html(sock->buffer, sock->size))) {
if (req->verbose) {
- print_buffer(sock->extracted - sock->buffer, sock->buffer);
+ print_buffer(sock->extracted - sock->buffer,
+ sock->buffer);
printf(HTTP_HEADER_ASCII);
- for (r = 0; r < sock->extracted - sock->buffer; r++)
+ for (r = 0; r < sock->extracted - sock->buffer;
+ r++)
printf("%c", sock->buffer[r]);
printf("\n");
printf(HTML_HEADER_HEXA);
if (req->verbose)
print_buffer(r, sock->extracted);
memcpy(sock->buffer, sock->extracted, r);
- MD5_Update(&sock->context, sock->buffer,
- r);
+ MD5_Update(&sock->context, sock->buffer, r);
r = 0;
}
sock->size = r;
} else if (sock->size) {
if (req->verbose)
print_buffer(r, sock->buffer);
- MD5_Update(&sock->context, sock->buffer,
- sock->size);
+ MD5_Update(&sock->context, sock->buffer, sock->size);
sock->size = 0;
}
memset(str_request, 0, GET_BUFFER_LENGTH);
snprintf(str_request, GET_BUFFER_LENGTH, REQUEST_TEMPLATE,
- req->url,
- (req->vhost) ? req->vhost : inet_ntop2(req->addr_ip)
+ req->url, (req->vhost) ? req->vhost : inet_ntop2(req->addr_ip)
, ntohs(req->addr_port));
/* Send the GET request to remote Web server */
- DBG("Sending GET request [%s] on fd:%d\n",
- req->url, sock->fd);
+ DBG("Sending GET request [%s] on fd:%d\n", req->url, sock->fd);
if (req->ssl)
ret =
ssl_send_request(sock->ssl, str_request,
if (!ret) {
fprintf(stderr, "Cannot send get request to [%s:%d].\n",
- inet_ntop2(req->addr_ip)
- , ntohs(req->addr_port));
+ inet_ntop2(req->addr_ip)
+ , ntohs(req->addr_port));
return epilog(thread);
}
/* global defs */
#define GET_BUFFER_LENGTH 2048
#define MAX_BUFFER_LENGTH 4096
-#define HTTP_CNX_TIMEOUT 5
+#define HTTP_CNX_TIMEOUT (5 * TIMER_HZ)
#define PROTO_HTTP 0x01
#define PROTO_SSL 0x02
#define HTML_MD5_FINAL DELIM_BEGIN" HTML MD5 final resulting "DELIM_END
/* Define prototypes */
-extern int epilog(thread *thread);
-extern int finalize(thread *thread);
-extern int http_process_stream(SOCK *sock, int r);
+extern int epilog(thread * thread);
+extern int finalize(thread * thread);
+extern int http_process_stream(SOCK * sock, int r);
extern int http_request_thread(thread * thread);
#endif
inet_ntop2(addr_ip), ntohs(addr_port));
timer_min = timer_sub_now(thread->sands);
-
- if (TIMER_SEC(timer_min) <= 0)
- thread_add_write(thread->master, func,
- THREAD_ARG(thread)
- , thread->u.fd, 0);
- else
- thread_add_write(thread->master, func,
- THREAD_ARG(thread)
- , thread->u.fd, TIMER_SEC(timer_min));
+ thread_add_write(thread->master, func, THREAD_ARG(thread)
+ , thread->u.fd, TIMER_LONG(timer_min));
return connect_in_progress;
}
void
tcp_connection_state(int fd, enum connect_result status, thread * thread,
int (*func) (struct _thread *)
- , int timeout)
+ , long timeout)
{
switch (status) {
case connect_error:
fd, timeout);
break;
- /* Checking non-blocking connect, we wait until socket is writable */
+ /* Checking non-blocking connect, we wait until socket is writable */
case connect_in_progress:
thread_add_write(thread->master, func, THREAD_ARG(thread),
fd, timeout);
SOCK *sock = THREAD_ARG(thread);
int ret = 1;
- sock->status = tcp_socket_state(thread->u.fd, thread, req->addr_ip
- , req->addr_port, tcp_check_thread);
+ sock->status =
+ tcp_socket_state(thread->u.fd, thread, req->addr_ip, req->addr_port,
+ tcp_check_thread);
switch (sock->status) {
case connect_error:
DBG("Error connecting server [%s:%d].\n",
*/
sock->lock = 0;
thread_add_event(thread->master,
- http_request_thread,
- sock, 0);
+ http_request_thread, sock, 0);
} else {
DBG("Connection trouble to: [%s:%d].\n",
inet_ntop2(req->addr_ip),
/* Prototypes defs */
extern enum connect_result
-tcp_connect(int fd, uint32_t, uint16_t);
+ tcp_connect(int fd, uint32_t, uint16_t);
extern enum connect_result
-tcp_socket_state(int, thread *, uint32_t, uint16_t,
- int (*func) (struct _thread *));
+ tcp_socket_state(int, thread *, uint32_t, uint16_t,
+ int (*func) (struct _thread *));
extern void
-tcp_connection_state(int, enum connect_result
- , thread *, int (*func) (struct _thread *)
- , int);
+ tcp_connection_state(int, enum connect_result
+ , thread *, int (*func) (struct _thread *)
+ , long);
extern int
-tcp_connect_thread(thread *);
+ tcp_connect_thread(thread *);
#endif
sig.sa_flags = 0;
#ifdef SA_RESTART
sig.sa_flags |= SA_RESTART;
-#endif /* SA_RESTART */
+#endif /* SA_RESTART */
ret = sigaction(signo, &sig, &osig);
if (ret < 0)
return (SIG_ERR);
- else
+ else
return (osig.sa_handler);
}
signal_set(SIGKILL, sigend);
}
-
/* Usage function */
static void
usage(const char *prog)
/* Signal handling initialization */
signal_init();
-
+
/* Create the master thread */
master = thread_make_master();
/* Finalize output informations */
if (req->verbose)
printf("Global response time for [%s] =%lu\n",
- req->url, req->response_time-req->ref_time);
+ req->url, req->response_time - req->ref_time);
/* exit cleanly */
SSL_CTX_free(req->ctx);
} REQ;
/* Global variables */
-REQ *req; /* Cmd line arguments */
+REQ *req; /* Cmd line arguments */
unsigned int debug;
/* Data buffer length description */
extern SOCK *sock;
/* Close the descriptor */
-static void close_sock(SOCK *sock)
+static void
+close_sock(SOCK * sock)
{
if (sock->ssl) {
SSL_shutdown(sock->ssl);
}
/* Destroy the socket handler */
-void free_sock(SOCK *sock)
+void
+free_sock(SOCK * sock)
{
DBG("Freeing fd:%d\n", sock->fd);
}
/* Init socket handler */
-void init_sock(void)
+void
+init_sock(void)
{
- sock = (SOCK *)MALLOC(sizeof(SOCK));
- memset(sock, 0, sizeof(SOCK));
- thread_add_event(master, tcp_connect_thread,
- sock, 0);
+ sock = (SOCK *) MALLOC(sizeof (SOCK));
+ memset(sock, 0, sizeof (SOCK));
+ thread_add_event(master, tcp_connect_thread, sock, 0);
}
} SOCK;
/* Prototypes */
-extern void free_sock(SOCK *sock);
+extern void free_sock(SOCK * sock);
extern void init_sock(void);
#endif
SSL_set_bio(sock->ssl, sock->bio, sock->bio);
ret = SSL_connect(sock->ssl);
- DBG(" SSL_connect return code = %d on fd:%d\n",
- ret, thread->u.fd);
+ DBG(" SSL_connect return code = %d on fd:%d\n", ret, thread->u.fd);
ssl_printerr(SSL_get_error(sock->ssl, ret));
return (ret > 0) ? 1 : 0;
* and sometime not...
*/
-read_stream:
+ read_stream:
/* read the SSL stream */
memset(sock->buffer, 0, MAX_BUFFER_LENGTH);
Name: keepalived
Summary: HA monitor built upon LVS, VRRP and services poller
Packager: Christophe Varoqui, <christophe.varoqui@free.fr>
-Version: 1.1.1
+Version: 1.1.3
Release: 1
Source: http://www.keepalived.org/software/%{name}-%{version}.tar.gz
Copyright: GPL
*
* Part: Checkers registration.
*
- * Version: $Id: check_api.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_api.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: CI-LINUX checker. Integration to Compaq Cluster Infrastructure.
*
- * Version: $Id: check_ci.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_ci.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Aneesh Kumar K.V, <aneesh.kumar@digital.com>
*
* Part: Healthcheckrs child process handling.
*
- * Version: $Id: check_daemon.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_daemon.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
, strerror(errno));
return -1;
} else if (pid) {
- int poll_delay = (wdog_delay_check) ? wdog_delay_check : WATCHDOG_DELAY;
+ long poll_delay = (wdog_delay_check) ? wdog_delay_check : WATCHDOG_DELAY;
checkers_child = pid;
syslog(LOG_INFO, "Starting Healthcheck child process, pid=%d"
, pid);
*
* Part: Healthcheckers dynamic data structure definition.
*
- * Version: $Id: check_data.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_data.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: WEB CHECK. Common HTTP/SSL checker primitives.
*
- * Version: $Id: check_http.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_http.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Jan Holmberg, <jan@artech.net>
if (http_get_chk->bindto)
syslog(LOG_INFO, " Bind to = %s",
inet_ntop2(http_get_chk->bindto));
- syslog(LOG_INFO, " Connection timeout = %d",
- http_get_chk->connection_to);
+ syslog(LOG_INFO, " Connection timeout = %lu",
+ http_get_chk->connection_to/TIMER_HZ);
syslog(LOG_INFO, " Nb get retry = %d", http_get_chk->nb_get_retry);
- syslog(LOG_INFO, " Delay before retry = %d",
- http_get_chk->delay_before_retry);
+ syslog(LOG_INFO, " Delay before retry = %lu",
+ http_get_chk->delay_before_retry/TIMER_HZ);
dump_list(http_get_chk->url);
}
static http_get_checker *
connect_to_handler(vector strvec)
{
http_get_checker *http_get_chk = CHECKER_GET();
- http_get_chk->connection_to = CHECKER_VALUE_INT(strvec);
+ http_get_chk->connection_to = CHECKER_VALUE_INT(strvec) * TIMER_HZ;
}
void
delay_before_retry_handler(vector strvec)
{
http_get_checker *http_get_chk = CHECKER_GET();
- http_get_chk->delay_before_retry = CHECKER_VALUE_INT(strvec);
+ http_get_chk->delay_before_retry = CHECKER_VALUE_INT(strvec) * TIMER_HZ;
}
void
uint16_t addr_port = get_service_port(checker);
unsigned char digest[16];
int r = 0;
+ int val;
/* Handle read timeout */
if (thread->type == THREAD_READ_TIMEOUT)
return timeout_epilog(thread, "=> HTTP CHECK failed on service"
" : recevice data <=\n\n", "HTTP read");
+ /* Set descriptor non blocking */
+ val = fcntl(thread->u.fd, F_GETFL, 0);
+ fcntl(thread->u.fd, F_SETFL, val | O_NONBLOCK);
+
/* read the HTTP stream */
r = read(thread->u.fd, req->buffer + req->len,
MAX_BUFFER_LENGTH - req->len);
+ /* restore descriptor flags */
+ fcntl(thread->u.fd, F_SETFL, val);
+
+ /* Test if data are ready */
+ if (r == -1 && errno == EAGAIN) {
+ syslog(LOG_INFO, "Read error with server [%s:%d]: %s",
+ inet_ntop2(CHECKER_RIP(checker))
+ , ntohs(addr_port)
+ , strerror(errno));
+ thread_add_read(thread->master, http_read_thread, checker,
+ thread->u.fd, http_get_check->connection_to);
+ return 0;
+ }
+
if (r == -1 || r == 0) { /* -1:error , 0:EOF */
/* All the HTTP stream has been parsed */
* Part: MISC CHECK. Perform a system call to run an extra
* system prog or script.
*
- * Version: $Id: check_misc.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_misc.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Eric Jarman, <ehj38230@cmsu2.cmsu.edu>
syslog(LOG_INFO, " Keepalive method = MISC_CHECK");
syslog(LOG_INFO, " script = %s", misc_chk->path);
- syslog(LOG_INFO, " timeout = %d", misc_chk->timeout);
+ syslog(LOG_INFO, " timeout = %lu", misc_chk->timeout/TIMER_HZ);
}
void
misc_timeout_handler(vector strvec)
{
misc_checker *misc_chk = CHECKER_GET();
- misc_chk->timeout = CHECKER_VALUE_INT(strvec);
+ misc_chk->timeout = CHECKER_VALUE_INT(strvec) * TIMER_HZ;
}
void
* data structure representation the conf file representing
* the loadbalanced server pool.
*
- * Version: $Id: check_parser.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_parser.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* url, compute a MD5 over this result and match it to the
* expected value.
*
- * Version: $Id: check_ssl.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_ssl.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Jan Holmberg, <jan@artech.net>
*
* Part: TCP checker.
*
- * Version: $Id: check_tcp.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_tcp.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
ntohs(tcp_chk->connection_port));
if (tcp_chk->bindto)
syslog(LOG_INFO, " Bind to = %s", inet_ntop2(tcp_chk->bindto));
- syslog(LOG_INFO, " Connection timeout = %d", tcp_chk->connection_to);
+ syslog(LOG_INFO, " Connection timeout = %d", tcp_chk->connection_to/TIMER_HZ);
}
void
connect_timeout_handler(vector strvec)
{
tcp_checker *tcp_chk = CHECKER_GET();
- tcp_chk->connection_to = CHECKER_VALUE_INT(strvec);
+ tcp_chk->connection_to = CHECKER_VALUE_INT(strvec) * TIMER_HZ;
}
void
* library to add/remove server MASQ rules to the kernel
* firewall framework.
*
- * Version: $Id: ipfwwrapper.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: ipfwwrapper.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* Part: IPVS Kernel wrapper. Use setsockopt call to add/remove
* server to/from the loadbalanced server pool.
*
- * Version: $Id: ipvswrapper.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: ipvswrapper.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Manipulation functions for IPVS & IPFW wrappers.
*
- * Version: $id: ipwrapper.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $id: ipwrapper.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Main program structure.
*
- * Version: $Id: main.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: main.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
sig.sa_flags = 0;
#ifdef SA_RESTART
sig.sa_flags |= SA_RESTART;
-#endif /* SA_RESTART */
+#endif /* SA_RESTART */
ret = sigaction(signo, &sig, &osig);
*
* Part: Dynamic data structure definition.
*
- * Version: $Id: global_data.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: global_data.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
/* Default settings */
static void
-set_default_lvs_id(conf_data* conf_data)
+set_default_lvs_id(conf_data * conf_data)
{
char *new_id = NULL;
int len = 0;
new_id = get_local_name();
- if (!new_id || !new_id[0]) return;
+ if (!new_id || !new_id[0])
+ return;
len = strlen(new_id);
conf_data->lvs_id = MALLOC(len + 1);
- if (!conf_data->lvs_id) return;
+ if (!conf_data->lvs_id)
+ return;
memcpy(conf_data->lvs_id, new_id, len);
}
static void
-set_default_email_from(conf_data* conf_data)
+set_default_email_from(conf_data * conf_data)
{
struct passwd *pwd = NULL;
- char* hostname = NULL;
+ char *hostname = NULL;
int len = 0;
hostname = get_local_name();
- if (!hostname || !hostname[0]) return;
+ if (!hostname || !hostname[0])
+ return;
pwd = getpwuid(getuid());
- if (!pwd) return;
+ if (!pwd)
+ return;
len = strlen(hostname) + strlen(pwd->pw_name) + 2;
conf_data->email_from = MALLOC(len);
- if (!conf_data->email_from) return;
-
+ if (!conf_data->email_from)
+ return;
+
snprintf(conf_data->email_from, len, "%s@%s", pwd->pw_name, hostname);
}
static void
-set_default_smtp_server(conf_data* conf_data)
+set_default_smtp_server(conf_data * conf_data)
{
conf_data->smtp_server = htonl(DEFAULT_SMTP_SERVER);
}
static void
-set_default_smtp_connection_timeout(conf_data* conf_data)
+set_default_smtp_connection_timeout(conf_data * conf_data)
{
conf_data->smtp_connection_to = DEFAULT_SMTP_CONNECTION_TIMEOUT;
}
static void
-set_default_values(conf_data* conf_data)
+set_default_values(conf_data * conf_data)
{
/* No global data so don't default */
- if (!conf_data) return;
+ if (!conf_data)
+ return;
set_default_lvs_id(conf_data);
set_default_smtp_server(conf_data);
set_default_smtp_connection_timeout(conf_data);
}
void
-free_global_data(conf_data *data)
+free_global_data(conf_data * data)
{
free_list(data->email);
FREE_PTR(data->lvs_id);
}
void
-dump_global_data(conf_data *data)
+dump_global_data(conf_data * data)
{
if (!data)
return;
if (data->lvs_id ||
- data->smtp_server ||
- data->smtp_connection_to || data->email_from) {
+ data->smtp_server || data->smtp_connection_to || data->email_from) {
syslog(LOG_INFO, "------< Global definitions >------");
}
if (data->lvs_id)
syslog(LOG_INFO, " Smtp server = %s",
inet_ntop2(data->smtp_server));
if (data->smtp_connection_to)
- syslog(LOG_INFO, " Smtp server connection timeout = %d",
- data->smtp_connection_to);
+ syslog(LOG_INFO, " Smtp server connection timeout = %lu",
+ data->smtp_connection_to / TIMER_HZ);
if (data->email_from) {
syslog(LOG_INFO, " Email notification from = %s",
data->email_from);
* data structure representation the conf file representing
* the loadbalanced server pool.
*
- * Version: $Id: global_parser.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: global_parser.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
static void
smtpto_handler(vector strvec)
{
- data->smtp_connection_to = atoi(VECTOR_SLOT(strvec, 1));
+ data->smtp_connection_to = atoi(VECTOR_SLOT(strvec, 1)) * TIMER_HZ;
}
static void
smtpip_handler(vector strvec)
* Part: Layer4 checkers handling. Register worker threads &
* upper layer checkers.
*
- * Version: $Id: layer4.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: layer4.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
if (bind_ip) {
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = bind_ip;
- if (bind(fd, (struct sockaddr *) &sin, sizeof(sin)) != 0)
+ if (bind(fd, (struct sockaddr *) &sin, sizeof (sin)) != 0)
return connect_error;
}
inet_ntop2(addr_ip), ntohs(addr_port));
timer_min = timer_sub_now(thread->sands);
-
- if (TIMER_SEC(timer_min) <= 0)
- thread_add_write(thread->master, func,
- THREAD_ARG(thread)
- , thread->u.fd, 0);
- else
- thread_add_write(thread->master, func,
- THREAD_ARG(thread)
- , thread->u.fd, TIMER_SEC(timer_min));
+ thread_add_write(thread->master, func, THREAD_ARG(thread)
+ , thread->u.fd, TIMER_LONG(timer_min));
return connect_in_progress;
} else if (status != 0) {
close(thread->u.fd);
void
tcp_connection_state(int fd, enum connect_result status, thread * thread,
int (*func) (struct _thread *)
- , int timeout)
+ , long timeout)
{
checker *checker;
*
* Part: Main program structure.
*
- * Version: $Id: main.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: main.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
#include "main.h"
#include "watchdog.h"
+/* Log faility table */
+struct {
+ int facility;
+} LOG_FACILITY[LOG_FACILITY_MAX + 1] = {
+ {LOG_LOCAL0}, {LOG_LOCAL1}, {LOG_LOCAL2}, {LOG_LOCAL3},
+ {LOG_LOCAL4}, {LOG_LOCAL5}, {LOG_LOCAL6}, {LOG_LOCAL7}
+};
+
/* Daemon stop sequence */
static void
stop_keepalived(void)
" %s --dump-conf -d Dump the configuration data.\n"
" %s --log-console -l Log message to local console.\n"
" %s --log-detail -D Detailed log messages.\n"
+ " %s --log-facility -S 0-7 Set syslog facility to LOG_LOCAL[0-7]. (default=LOG_DAEMON)\n"
" %s --help -h Display this short inlined help screen.\n"
" %s --version -v Display the version number\n",
- prog, prog, prog, prog, prog, prog, prog, prog, prog, prog, prog);
+ prog, prog, prog, prog, prog, prog, prog, prog, prog, prog,
+ prog, prog);
}
/* Command line parser */
{"help", 'h', POPT_ARG_NONE, NULL, 'h'},
{"log-console", 'l', POPT_ARG_NONE, NULL, 'l'},
{"log-detail", 'D', POPT_ARG_NONE, NULL, 'D'},
+ {"log-facility", 'S', POPT_ARG_STRING, &optarg, 'S'},
{"dont-release-vrrp", 'V', POPT_ARG_NONE, NULL, 'V'},
{"dont-release-ipvs", 'I', POPT_ARG_NONE, NULL, 'I'},
{"dont-fork", 'n', POPT_ARG_NONE, NULL, 'n'},
case 'D':
debug |= 32;
break;
+ case 'S':
+ log_facility = LOG_FACILITY[atoi(optarg)].facility;
+ break;
case 'f':
conf_file = optarg;
break;
case 'R':
- wdog_delay_vrrp = atoi(optarg);
+ wdog_delay_vrrp = atoi(optarg) * TIMER_HZ;
break;
case 'H':
- wdog_delay_check = atoi(optarg);
+ wdog_delay_check = atoi(optarg) * TIMER_HZ;
break;
}
case 'D':
debug |= 32;
break;
+ case 'S':
+ log_facility = LOG_FACILITY[atoi(optarg)].facility;
+ break;
case 'f':
conf_file = optarg;
break;
case 'R':
- wdog_delay_vrrp = atoi(optarg);
+ wdog_delay_vrrp = atoi(optarg) * TIMER_HZ;
break;
case 'H':
- wdog_delay_check = atoi(optarg);
+ wdog_delay_check = atoi(optarg) * TIMER_HZ;
break;
}
}
*/
parse_cmdline(argc, argv);
- openlog(PROG, LOG_PID | (debug & 1) ? LOG_CONS : 0, LOG_DAEMON);
+ openlog(PROG, LOG_PID | (debug & 1) ? LOG_CONS : 0, log_facility);
syslog(LOG_INFO, "Starting " VERSION_STRING);
/* Check if keepalived is already running */
*
* Part: pidfile utility.
*
- * Version: $Id: pidfile.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: pidfile.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
FILE *pidfile = fopen(pid_file, "w");
if (!pidfile) {
- syslog(LOG_INFO, "pidfile_write : Can not open %s pidfile"
- , pid_file);
+ syslog(LOG_INFO, "pidfile_write : Can not open %s pidfile",
+ pid_file);
return 0;
}
fprintf(pidfile, "%d\n", pid);
* using the smtp protocol according to the RFC 821. A non blocking
* timeouted connection is used to handle smtp protocol.
*
- * Version: $Id: smtp.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: smtp.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
smtp_arg = THREAD_ARG(thread);
if (thread->type == THREAD_READ_TIMEOUT) {
- syslog(LOG_INFO, "Timeout reading data to remote SMTP server [%s:%d].",
+ syslog(LOG_INFO,
+ "Timeout reading data to remote SMTP server [%s:%d].",
inet_ntop2(data->smtp_server), SMTP_PORT);
SMTP_FSM_READ(QUIT, thread, 0);
return -1;
if (rcv_buffer_size == -1) {
if (errno == EAGAIN)
goto end;
- syslog(LOG_INFO, "Error reading data from remote SMTP server [%s:%d].",
+ syslog(LOG_INFO,
+ "Error reading data from remote SMTP server [%s:%d].",
inet_ntop2(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) {
- syslog(LOG_INFO, "Received buffer from remote SMTP server [%s:%d]"
- " overflow our get read buffer length."
- , inet_ntop2(data->smtp_server), SMTP_PORT);
+ syslog(LOG_INFO,
+ "Received buffer from remote SMTP server [%s:%d]"
+ " overflow our get read buffer length.",
+ inet_ntop2(data->smtp_server), SMTP_PORT);
SMTP_FSM_READ(QUIT, thread, 0);
return 0;
} else {
buffer[smtp_arg->buflen] = 0; /* NULL terminate */
}
-end:
+ end:
/* parse the buffer, finding the last line of the response for the code */
reply = buffer;
smtp_arg->buflen -= (reply - buffer);
buffer[smtp_arg->buflen] = 0;
- thread_add_read(thread->master, smtp_read_thread, smtp_arg,
- thread->u.fd, data->smtp_connection_to);
+ thread_add_read(thread->master, smtp_read_thread,
+ smtp_arg, thread->u.fd,
+ data->smtp_connection_to);
return 0;
}
thread_add_write(thread->master, smtp_send_thread, smtp_arg,
smtp_arg->fd, data->smtp_connection_to);
} else {
- syslog(LOG_INFO, "Can not read data from remote SMTP server [%s:%d].",
- inet_ntop2(data->smtp_server), SMTP_PORT);
+ syslog(LOG_INFO,
+ "Can not read data from remote SMTP server [%s:%d].",
+ inet_ntop2(data->smtp_server), SMTP_PORT);
SMTP_FSM_READ(QUIT, thread, 0);
}
smtp_send_thread(thread * thread)
{
smtp_thread_arg *smtp_arg = THREAD_ARG(thread);
-
+
if (thread->type == THREAD_WRITE_TIMEOUT) {
- syslog(LOG_INFO, "Timeout sending data to remote SMTP server [%s:%d].",
+ syslog(LOG_INFO,
+ "Timeout sending data to remote SMTP server [%s:%d].",
inet_ntop2(data->smtp_server), SMTP_PORT);
SMTP_FSM_READ(QUIT, thread, 0);
return 0;
thread_add_read(thread->master, smtp_read_thread, smtp_arg,
thread->u.fd, data->smtp_connection_to);
} else {
- syslog(LOG_INFO, "Can not send data to remote SMTP server [%s:%d].",
- inet_ntop2(data->smtp_server), SMTP_PORT);
+ syslog(LOG_INFO,
+ "Can not send data to remote SMTP server [%s:%d].",
+ inet_ntop2(data->smtp_server), SMTP_PORT);
SMTP_FSM_READ(QUIT, thread, 0);
}
return 0;
}
-
static int
connection_code(thread * thread, int status)
{
smtp_arg->stage++;
} else {
syslog(LOG_INFO, "Error connecting SMTP server[%s:%d]."
- " SMTP status code = %d"
- , inet_ntop2(data->smtp_server), SMTP_PORT, status);
+ " SMTP status code = %d", inet_ntop2(data->smtp_server),
+ SMTP_PORT, status);
smtp_arg->stage = ERROR;
}
smtp_thread_arg *smtp_arg = THREAD_ARG(thread);
char *buffer;
- buffer = (char *)MALLOC(SMTP_BUFFER_MAX);
- snprintf(buffer, SMTP_BUFFER_MAX, SMTP_HELO_CMD,
- get_local_name());
+ buffer = (char *) MALLOC(SMTP_BUFFER_MAX);
+ snprintf(buffer, SMTP_BUFFER_MAX, SMTP_HELO_CMD, get_local_name());
if (send(thread->u.fd, buffer, strlen(buffer), 0) == -1)
smtp_arg->stage = ERROR;
FREE(buffer);
if (status == 250) {
smtp_arg->stage++;
} else {
- syslog(LOG_INFO, "Error processing HELO cmd on SMTP server [%s:%d]."
- " SMTP status code = %d"
- , inet_ntop2(data->smtp_server), SMTP_PORT, status);
+ syslog(LOG_INFO,
+ "Error processing HELO cmd on SMTP server [%s:%d]."
+ " SMTP status code = %d", inet_ntop2(data->smtp_server),
+ SMTP_PORT, status);
smtp_arg->stage = ERROR;
}
smtp_thread_arg *smtp_arg = THREAD_ARG(thread);
char *buffer;
- buffer = (char *)MALLOC(SMTP_BUFFER_MAX);
- snprintf(buffer, SMTP_BUFFER_MAX, SMTP_MAIL_CMD,
- data->email_from);
+ buffer = (char *) MALLOC(SMTP_BUFFER_MAX);
+ snprintf(buffer, SMTP_BUFFER_MAX, SMTP_MAIL_CMD, data->email_from);
if (send(thread->u.fd, buffer, strlen(buffer), 0) == -1)
smtp_arg->stage = ERROR;
FREE(buffer);
if (status == 250) {
smtp_arg->stage++;
} else {
- syslog(LOG_INFO, "Error processing MAIL cmd on SMTP server [%s:%d]."
- " SMTP status code = %d"
- , inet_ntop2(data->smtp_server), SMTP_PORT, status);
+ syslog(LOG_INFO,
+ "Error processing MAIL cmd on SMTP server [%s:%d]."
+ " SMTP status code = %d", inet_ntop2(data->smtp_server),
+ SMTP_PORT, status);
smtp_arg->stage = ERROR;
}
char *buffer;
char *fetched_email;
- buffer = (char *)MALLOC(SMTP_BUFFER_MAX);
+ buffer = (char *) MALLOC(SMTP_BUFFER_MAX);
/* We send RCPT TO command multiple time to add all our email receivers.
* --rfc821.3.1
*/
if (!fetched_email)
smtp_arg->stage++;
} else {
- syslog(LOG_INFO, "Error processing RCPT cmd on SMTP server [%s:%d]."
- " SMTP status code = %d"
- , inet_ntop2(data->smtp_server), SMTP_PORT, status);
+ syslog(LOG_INFO,
+ "Error processing RCPT cmd on SMTP server [%s:%d]."
+ " SMTP status code = %d", inet_ntop2(data->smtp_server),
+ SMTP_PORT, status);
smtp_arg->stage = ERROR;
}
if (status == 354) {
smtp_arg->stage++;
} else {
- syslog(LOG_INFO, "Error processing DATA cmd on SMTP server [%s:%d]."
- " SMTP status code = %d"
- , inet_ntop2(data->smtp_server), SMTP_PORT, status);
+ syslog(LOG_INFO,
+ "Error processing DATA cmd on SMTP server [%s:%d]."
+ " SMTP status code = %d", inet_ntop2(data->smtp_server),
+ SMTP_PORT, status);
smtp_arg->stage = ERROR;
}
smtp_thread_arg *smtp_arg = THREAD_ARG(thread);
char *buffer;
- buffer = (char *)MALLOC(SMTP_BUFFER_MAX);
+ buffer = (char *) MALLOC(SMTP_BUFFER_MAX);
snprintf(buffer, SMTP_BUFFER_MAX, SMTP_HEADERS_CMD,
data->email_from, smtp_arg->subject);
smtp_arg->stage = ERROR;
memset(buffer, 0, SMTP_BUFFER_MAX);
- snprintf(buffer, SMTP_BUFFER_MAX, SMTP_BODY_CMD,
- smtp_arg->body);
+ snprintf(buffer, SMTP_BUFFER_MAX, SMTP_BODY_CMD, smtp_arg->body);
/* send the the body field */
if (send(thread->u.fd, buffer, strlen(buffer), 0) == -1)
syslog(LOG_INFO, "SMTP alert successfully sent.");
smtp_arg->stage++;
} else {
- syslog(LOG_INFO, "Error processing DOT cmd on SMTP server [%s:%d]."
- " SMTP status code = %d"
- , inet_ntop2(data->smtp_server), SMTP_PORT, status);
+ syslog(LOG_INFO,
+ "Error processing DOT cmd on SMTP server [%s:%d]."
+ " SMTP status code = %d", inet_ntop2(data->smtp_server),
+ SMTP_PORT, status);
smtp_arg->stage = ERROR;
}
/* connect remote SMTP server */
static void
-smtp_connect(smtp_thread_arg *smtp_arg)
+smtp_connect(smtp_thread_arg * smtp_arg)
{
enum connect_result status;
if ((smtp_arg->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))
- == -1) {
+ == -1) {
DBG("SMTP connect fail to create socket.");
free_smtp_all(smtp_arg);
return;
}
- status = tcp_connect(smtp_arg->fd, data->smtp_server,
- htons(SMTP_PORT));
+ status = tcp_connect(smtp_arg->fd, data->smtp_server, htons(SMTP_PORT));
/* Handle connection status code */
- thread_add_event(master, SMTP_FSM[status].send, smtp_arg,
- smtp_arg->fd);
+ thread_add_event(master, SMTP_FSM[status].send, smtp_arg, smtp_arg->fd);
}
/* Main entry point */
void
smtp_alert(thread_master * master, real_server * rs, vrrp_rt * vrrp,
- vrrp_sgroup *vgroup, const char *subject, const char *body)
+ vrrp_sgroup * vgroup, const char *subject, const char *body)
{
smtp_thread_arg *smtp_arg;
/* Only send mail if email specified */
- if (!LIST_ISEMPTY(data->email) &&
- data->smtp_server != 0) {
+ if (!LIST_ISEMPTY(data->email) && data->smtp_server != 0) {
/* allocate & initialize smtp argument data structure */
smtp_arg = (smtp_thread_arg *) MALLOC(sizeof (smtp_thread_arg));
smtp_arg->subject = (char *) MALLOC(MAX_HEADERS_LENGTH);
*
* Part: Checkers arguments structures definitions.
*
- * Version: $Id: check_api.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_api.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: check_ci.c include file.
*
- * Version: $Id: check_ci.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_ci.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Aneesh Kumar K.V, <aneesh.kumar@digital.com>
*
* Part: check_daemon.c include file.
*
- * Version: $Id: check_daemon.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_daemon.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Healthcheckers dynamic data structure definition.
*
- * Version: $Id: check_data.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_data.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: check_http.c include file.
*
- * Version: $Id: check_http.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_http.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Jan Holmberg, <jan@artech.net>
int proto;
uint16_t connection_port;
uint32_t bindto;
- int connection_to;
+ long connection_to;
int nb_get_retry;
- int delay_before_retry;
+ long delay_before_retry;
list url;
http_arg *arg;
} http_get_checker;
extern int epilog(thread * thread, int metod, int t, int c);
extern int timeout_epilog(thread * thread, char *smtp_msg, char *debug_msg);
extern url *fetch_next_url(http_get_checker * http_get_check);
-extern int http_process_response(REQ *req, int r);
+extern int http_process_response(REQ * req, int r);
extern int http_handle_response(thread * thread, unsigned char digest[16]
, int empty_buffer);
#endif
*
* Part: check_misc.c include file.
*
- * Version: $Id: check_misc.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_misc.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
* Eric Jarman, <ehj38230@cmsu2.cmsu.edu>
/* Checker argument structure */
typedef struct _misc_checker {
char *path;
- int timeout;
+ long timeout;
} misc_checker;
/* Prototypes defs */
*
* Part: check_parser.c include file.
*
- * Version: $Id: check_parser.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_parser.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: check_http.c include file.
*
- * Version: $Id: check_http.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_http.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Jan Holmberg, <jan@artech.net>
*
* Part: check_tcp.c include file.
*
- * Version: $Id: check_tcp.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: check_tcp.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Daemon process handling.
*
- * Version: $Id: daemon.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: daemon.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Dynamic data structure definition.
*
- * Version: $Id: global_data.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: global_data.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
/* local includes */
#include "list.h"
+#include "timer.h"
/* constants */
#define DEFAULT_SMTP_SERVER 0x7f000001
-#define DEFAULT_SMTP_CONNECTION_TIMEOUT 30
+#define DEFAULT_SMTP_CONNECTION_TIMEOUT (30 * TIMER_HZ)
/* email link list */
typedef struct _email {
char *lvs_id;
char *email_from;
uint32_t smtp_server;
- int smtp_connection_to;
+ long smtp_connection_to;
list email;
} conf_data;
*
* Part: vrrp_parser.c include file.
*
- * Version: $Id: global_parser.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: global_parser.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: ipfwwrapper.c include file.
*
- * Version: $Id: ipfwwrapper.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: ipfwwrapper.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: ipvswrapper.c include file.
*
- * Version: $Id: ipvswrapper.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: ipvswrapper.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
/* prototypes */
extern virtual_server_group *ipvs_get_group_by_name(char *gname, list l);
-extern int ipvs_group_remove_entry(virtual_server *vs,
- virtual_server_group_entry *vsge);
-extern int ipvs_cmd(int cmd, list vs_group, virtual_server * vserver, real_server * rserver);
+extern int ipvs_group_remove_entry(virtual_server * vs,
+ virtual_server_group_entry * vsge);
+extern int ipvs_cmd(int cmd, list vs_group, virtual_server * vserver,
+ real_server * rserver);
extern int ipvs_syncd_cmd(int cmd, char *ifname, int state);
extern void ipvs_syncd_master(char *ifname);
extern void ipvs_syncd_backup(char *ifname);
*
* Part: ipwrapper.c include file.
*
- * Version: $Id: ipwrapper.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: ipwrapper.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
/* prototypes */
extern void perform_svr_state(int alive, virtual_server * vs, real_server * rs);
-extern int svr_checker_up(checker_id_t cid, real_server *rs);
-extern void update_svr_checker_state(int alive, checker_id_t cid
- , virtual_server *vs
- , real_server *rs);
+extern int svr_checker_up(checker_id_t cid, real_server * rs);
+extern void update_svr_checker_state(int alive, checker_id_t cid,
+ virtual_server * vs, real_server * rs);
extern int init_services(void);
extern int clear_services(void);
extern int clear_diff_services(void);
*
* Part: layer4.c include file.
*
- * Version: $Id: layer4.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: layer4.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
/* Prototypes defs */
extern enum connect_result
-tcp_bind_connect(int, uint32_t, uint16_t, uint32_t);
+ tcp_bind_connect(int, uint32_t, uint16_t, uint32_t);
extern enum connect_result
-tcp_connect(int, uint32_t, uint16_t);
+ tcp_connect(int, uint32_t, uint16_t);
extern enum connect_result
-tcp_socket_state(int, thread *, uint32_t, uint16_t,
- int (*func) (struct _thread *));
+ tcp_socket_state(int, thread *, uint32_t, uint16_t,
+ int (*func) (struct _thread *));
extern void
-tcp_connection_state(int, enum connect_result
- , thread *, int (*func) (struct _thread *)
- , int);
+ tcp_connection_state(int, enum connect_result
+ , thread *, int (*func) (struct _thread *)
+ , long);
#endif
*
* Part: Main program include file.
*
- * Version: $Id: main.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: main.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
#include "global_data.h"
/* global var */
-thread_master *master = NULL; /* Scheduling master thread */
-char *conf_file = NULL; /* Configuration file */
-int reload = 0; /* Global reloading flag */
-unsigned int debug; /* Debugging flags */
-pid_t vrrp_child = -1; /* VRRP child process ID */
-pid_t checkers_child = -1; /* Healthcheckers child process ID */
-int wdog_delay_vrrp = 0; /* VRRP child polling delay */
-int wdog_delay_check = 0; /* Healthchecker child polling delay */
-conf_data *data; /* Global configuration data */
+thread_master *master = NULL; /* Scheduling master thread */
+char *conf_file = NULL; /* Configuration file */
+int log_facility = LOG_DAEMON; /* Optional logging facilities */
+int reload = 0; /* Global reloading flag */
+unsigned int debug; /* Debugging flags */
+pid_t vrrp_child = -1; /* VRRP child process ID */
+pid_t checkers_child = -1; /* Healthcheckers child process ID */
+long wdog_delay_vrrp = 0; /* VRRP child polling delay */
+long wdog_delay_check = 0; /* Healthchecker child polling delay */
+conf_data *data; /* Global configuration data */
/* Build version */
+#define LOG_FACILITY_MAX 7
#define PROG "Keepalived"
-#define VERSION_CODE 0x010102
-#define DATE_CODE 0x080903
+#define VERSION_CODE 0x010103
+#define DATE_CODE 0x1D0903
#define KEEPALIVED_VERSION(version) \
(version >> 16) & 0xFF, \
*
* Part: pidfile.c include file.
*
- * Version: $Id: pidfile.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: pidfile.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: smtp.c include file.
*
- * Version: $Id: smtp.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: smtp.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
/* Prototypes defs */
extern void smtp_alert(thread_master *,
- real_server *, vrrp_rt *, vrrp_sgroup *,
+ real_server *, vrrp_rt *, vrrp_sgroup *,
const char *, const char *);
#endif
*
* Part: vrrp.c program include file.
*
- * Version: $Id: vrrp.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
/* protocol constants */
#define INADDR_VRRP_GROUP 0xe0000012 /* multicast addr - rfc2338.5.2.2 */
-#define VRRP_IP_TTL 255 /* in and out pkt ttl -- rfc2338.5.2.3 */
-#define IPPROTO_VRRP 112 /* IP protocol number -- rfc2338.5.2.4 */
-#define VRRP_VERSION 2 /* current version -- rfc2338.5.3.1 */
-#define VRRP_PKT_ADVERT 1 /* packet type -- rfc2338.5.3.2 */
-#define VRRP_PRIO_OWNER 255 /* priority of the ip owner -- rfc2338.5.3.4 */
-#define VRRP_PRIO_DFL 100 /* default priority -- rfc2338.5.3.4 */
-#define VRRP_PRIO_STOP 0 /* priority to stop -- rfc2338.5.3.4 */
-#define VRRP_AUTH_NONE 0 /* no authentification -- rfc2338.5.3.6 */
-#define VRRP_AUTH_PASS 1 /* password authentification -- rfc2338.5.3.6 */
-#define VRRP_AUTH_AH 2 /* AH(IPSec) authentification - rfc2338.5.3.6 */
-#define VRRP_ADVER_DFL 1 /* advert. interval (in sec) -- rfc2338.5.3.7 */
-#define VRRP_PREEMPT_DFL 1 /* rfc2338.6.1.2.Preempt_Mode */
-#define VRRP_GARP_DELAY 5 /* Default delay to launch gratuitous arp */
+#define VRRP_IP_TTL 255 /* in and out pkt ttl -- rfc2338.5.2.3 */
+#define IPPROTO_VRRP 112 /* IP protocol number -- rfc2338.5.2.4 */
+#define VRRP_VERSION 2 /* current version -- rfc2338.5.3.1 */
+#define VRRP_PKT_ADVERT 1 /* packet type -- rfc2338.5.3.2 */
+#define VRRP_PRIO_OWNER 255 /* priority of the ip owner -- rfc2338.5.3.4 */
+#define VRRP_PRIO_DFL 100 /* default priority -- rfc2338.5.3.4 */
+#define VRRP_PRIO_STOP 0 /* priority to stop -- rfc2338.5.3.4 */
+#define VRRP_AUTH_NONE 0 /* no authentification -- rfc2338.5.3.6 */
+#define VRRP_AUTH_PASS 1 /* password authentification -- rfc2338.5.3.6 */
+#define VRRP_AUTH_AH 2 /* AH(IPSec) authentification - rfc2338.5.3.6 */
+#define VRRP_ADVER_DFL 1 /* advert. interval (in sec) -- rfc2338.5.3.7 */
+#define VRRP_PREEMPT_DFL 1 /* rfc2338.6.1.2.Preempt_Mode */
+#define VRRP_GARP_DELAY (5 * TIMER_HZ) /* Default delay to launch gratuitous arp */
/*
* parameters per vrrp sync group. A vrrp_sync_group is a set
*
* Part: vrrp_arp.c include file.
*
- * Version: $Id: vrrp_arp.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_arp.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
/* types definition */
typedef struct _m_arphdr {
- unsigned short int ar_hrd; /* Format of hardware address. */
- unsigned short int ar_pro; /* Format of protocol address. */
- unsigned char ar_hln; /* Length of hardware address. */
- unsigned char ar_pln; /* Length of protocol address. */
- unsigned short int ar_op; /* ARP opcode (command). */
+ unsigned short int ar_hrd; /* Format of hardware address. */
+ unsigned short int ar_pro; /* Format of protocol address. */
+ unsigned char ar_hln; /* Length of hardware address. */
+ unsigned char ar_pln; /* Length of protocol address. */
+ unsigned short int ar_op; /* ARP opcode (command). */
/* Ethernet looks like this : This bit is variable sized however... */
unsigned char __ar_sha[ETH_ALEN]; /* Sender hardware address. */
- unsigned char __ar_sip[4]; /* Sender IP address. */
+ unsigned char __ar_sip[4]; /* Sender IP address. */
unsigned char __ar_tha[ETH_ALEN]; /* Target hardware address. */
- unsigned char __ar_tip[4]; /* Target IP address. */
+ unsigned char __ar_tip[4]; /* Target IP address. */
} m_arphdr;
/* Global var */
/* prototypes */
extern void gratuitous_arp_init(void);
extern void gratuitous_arp_close(void);
-extern int send_gratuitous_arp(ip_address *ipaddress);
+extern int send_gratuitous_arp(ip_address * ipaddress);
#endif
*
* Part: vrrp_daemon.c include file.
*
- * Version: $Id: vrrp_daemon.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_daemon.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Dynamic data structure definition.
*
- * Version: $Id: vrrp_data.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_data.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_if.c include file.
*
- * Version: $Id: vrrp_if.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_if.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
#define IF_HWADDR_MAX 20 /* Max MAC address length size */
#define ARPHRD_ETHER 1
#define ARPHRD_LOOPBACK 772
-#define POLLING_DELAY 1
+#define POLLING_DELAY TIMER_HZ
/* Interface Linkbeat code selection */
#define LB_IOCTL 0x1
/* Interface structure definition */
typedef struct _interface {
char ifname[IF_NAMESIZ + 1]; /* Interface name */
- unsigned int ifindex; /* Interface index */
- uint32_t address; /* Interface main primary IP address */
- unsigned long flags; /* flags */
- unsigned int mtu; /* MTU for this interface */
- unsigned short hw_type; /* Type of hardware address */
+ unsigned int ifindex; /* Interface index */
+ uint32_t address; /* Interface main primary IP address */
+ unsigned long flags; /* flags */
+ unsigned int mtu; /* MTU for this interface */
+ unsigned short hw_type; /* Type of hardware address */
u_char hw_addr[IF_HWADDR_MAX]; /* MAC address */
- int hw_addr_len; /* MAC addresss length */
- int lb_type; /* Interface regs selection */
- int linkbeat; /* LinkBeat from MII BMSR req */
+ int hw_addr_len; /* MAC addresss length */
+ int lb_type; /* Interface regs selection */
+ int linkbeat; /* LinkBeat from MII BMSR req */
} interface;
/* Global interface queue */
extern void init_interface_queue(void);
extern void free_interface_queue(void);
extern void dump_if(void *data);
-extern int if_join_vrrp_group(int sd, interface *ifp, int proto);
-extern void if_leave_vrrp_group(int sd, interface *ifp);
-extern int if_setsockopt_bindtodevice(int sd, interface *ifp);
+extern int if_join_vrrp_group(int sd, interface * ifp, int proto);
+extern void if_leave_vrrp_group(int sd, interface * ifp);
+extern int if_setsockopt_bindtodevice(int sd, interface * ifp);
extern int if_setsockopt_hdrincl(int sd);
extern int if_setsockopt_mcast_loop(int sd);
*
* Part: vrrp_index.c include file.
*
- * Version: $Id: vrrp_index.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_index.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_ipaddress.c include file.
*
- * Version: $Id: vrrp_ipaddress.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_ipaddress.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
/* types definition */
typedef struct {
uint32_t addr; /* the ip address */
+ uint32_t broadcast; /* the broadcast address */
uint8_t mask; /* the ip address CIDR netmask */
int ifindex; /* Interface index owning IP address */
interface *ifp; /* Interface owning IP address */
(X)->scope == (Y)->scope)
/* prototypes */
-extern int netlink_address_ipv4(ip_address *ipaddr, int cmd);
+extern int netlink_address_ipv4(ip_address * ipaddr, int cmd);
extern void netlink_iplist_ipv4(list ip_list, int cmd);
extern void free_ipaddress(void *data);
extern void dump_ipaddress(void *data);
-extern void alloc_ipaddress(list ip_list, vector strvec, interface *ifp);
+extern void alloc_ipaddress(list ip_list, vector strvec, interface * ifp);
extern void clear_diff_address(list l, list n);
extern void clear_diff_saddresses(void);
*
* Part: vrrp_iproute.c include file.
*
- * Version: $Id: vrrp_iproute.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_iproute.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_ipsecah.c include file.
*
- * Version: $Id: vrrp_ipsecah.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_ipsecah.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_netlink.c include file.
*
- * Version: $Id: vrrp_netlink.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_netlink.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
+/* local includes */
+#include "timer.h"
+
/* types definitions */
struct nl_handle {
int fd;
};
/* Define types */
-#define NETLINK_TIMER 30
+#define NETLINK_TIMER (30 * TIMER_HZ)
/* Our global netlink handler */
struct nl_handle nl_kernel; /* Kernel reflection channel */
*
* Part: vrrp_notify.c include file.
*
- * Version: $Id: vrrp_notify.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_notify.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_parser.c include file.
*
- * Version: $Id: vrrp_parser.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_parser.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_scheduler.c include file.
*
- * Version: $Id: vrrp_scheduler.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_scheduler.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vrrp_sync.c include file.
*
- * Version: $Id: vrrp_sync.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_sync.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
/* extern prototypes */
extern void vrrp_init_instance_sands(vrrp_rt *);
+extern void vrrp_sync_smtp_notifier(vrrp_sgroup *);
extern void vrrp_sync_set_group(vrrp_sgroup *);
extern int vrrp_sync_group_up(vrrp_sgroup *);
extern int vrrp_sync_leave_fault(vrrp_rt *);
*
* Part: vrrp_track.c include file.
*
- * Version: $Id: vrrp_track.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_track.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* master fails, a backup server takes over.
* The original implementation has been made by jerome etienne.
*
- * Version: $Id: vrrp.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: ARP primitives.
*
- * Version: $Id: vrrp_arp.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_arp.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: VRRP child process handling.
*
- * Version: $Id: vrrp_daemon.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_daemon.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
, strerror(errno));
return -1;
} else if (pid) {
- int poll_delay = (wdog_delay_vrrp) ? wdog_delay_vrrp : WATCHDOG_DELAY;
+ long poll_delay = (wdog_delay_vrrp) ? wdog_delay_vrrp : WATCHDOG_DELAY;
vrrp_child = pid;
syslog(LOG_INFO, "Starting VRRP child process, pid=%d"
, pid);
*
* Part: Dynamic data structure definition.
*
- * Version: $Id: vrrp_data.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_data.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
syslog(LOG_INFO, " Runing LVS sync daemon on interface = %s",
vrrp->lvs_syncd_if);
if (vrrp->garp_delay)
- syslog(LOG_INFO, " Gratuitous ARP delay = %d", vrrp->garp_delay);
+ syslog(LOG_INFO, " Gratuitous ARP delay = %d",
+ vrrp->garp_delay/TIMER_HZ);
syslog(LOG_INFO, " Virtual Router ID = %d", vrrp->vrid);
syslog(LOG_INFO, " Priority = %d", vrrp->priority);
syslog(LOG_INFO, " Advert interval = %dsec",
/* Allocate new VRRP group structure */
new = (vrrp_sgroup *) MALLOC(sizeof (vrrp_sgroup));
new->gname = (char *) MALLOC(size + 1);
- new->state = VRRP_STATE_BACK;
+ new->state = VRRP_STATE_INIT;
memcpy(new->gname, gname, size);
list_add(vrrp_data->vrrp_sync_group, new);
*
* Part: Interfaces manipulation.
*
- * Version: $Id: vrrp_if.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_if.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: VRRP instance index table.
*
- * Version: $Id: vrrp_index.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_index.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: NETLINK IPv4 address manipulation.
*
- * Version: $Id: vrrp_ipaddress.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_ipaddress.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
req.ifa.ifa_scope = ipaddr->scope;
req.ifa.ifa_prefixlen = ipaddr->mask;
addattr_l(&req.n, sizeof (req), IFA_LOCAL, &ipaddr->addr, sizeof (ipaddr->addr));
+ if (ipaddr->broadcast)
+ addattr_l(&req.n, sizeof (req), IFA_BROADCAST,
+ &ipaddr->broadcast, sizeof (ipaddr->broadcast));
if (netlink_talk(&nl_cmd, &req.n) < 0)
status = -1;
dump_ipaddress(void *data)
{
ip_address *ip_addr = data;
- syslog(LOG_INFO, " %s/%d dev %s scope %s"
+ syslog(LOG_INFO, " %s/%d brd %s dev %s scope %s"
, inet_ntop2(ip_addr->addr)
, ip_addr->mask
+ , inet_ntop2(ip_addr->broadcast)
, IF_NAME(if_get_by_ifindex(ip_addr->ifindex))
, netlink_scope_n2a(ip_addr->scope));
}
new->ifindex = IF_INDEX(new->ifp);
} else if (!strcmp(str, "scope")) {
new->scope = netlink_scope_a2n(VECTOR_SLOT(strvec, ++i));
+ } else if (!strcmp(str, "broadcast") || !strcmp(str, "brd")) {
+ inet_ston(VECTOR_SLOT(strvec, ++i), &new->broadcast);
} else {
if (inet_ston(VECTOR_SLOT(strvec, i), &ipaddr)) {
inet_ston(VECTOR_SLOT(strvec, i), &new->addr);
*
* Part: NETLINK IPv4 routes manipulation.
*
- * Version: $Id: vrrp_iproute.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_iproute.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* authentication data encryption using HMAC MD5 according to
* RFCs 2085 & 2104.
*
- * Version: $Id: vrrp_ipsecah.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_ipsecah.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: NETLINK kernel command channel.
*
- * Version: $Id: vrrp_netlink.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_netlink.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: VRRP state transition notification scripts handling.
*
- * Version: $Id: vrrp_notify.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_notify.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
static int
notify_script_exec(char* script, char *type, int state_num, char* name)
{
+ char *state = "{UNKNOWN}";
+ char *command_line = NULL;
+ int size = 0;
+
/*
* Determine the length of the buffer that we'll need to generate the command
* to run:
*
* strlen(script) + strlen(type) + strlen(state) + strlen(name) + 8
*/
-
- char *state = "{UNKNOWN}";
switch (state_num) {
case VRRP_STATE_MAST : state = "MASTER" ; break;
case VRRP_STATE_BACK : state = "BACKUP" ; break;
case VRRP_STATE_FAULT : state = "FAULT" ; break;
}
- int size = (strlen(script) + strlen(type) + strlen(state) + strlen(name) + 8);
- char *command_line = MALLOC(size);
+ size = strlen(script) + strlen(type) + strlen(state) + strlen(name) + 8;
+ command_line = MALLOC(size);
if (!command_line)
return 0;
/* Launch the script */
+ snprintf(command_line, size, "\"%s\" %s \"%s\" %s",script, type, name, state);
notify_exec(command_line);
FREE(command_line);
return 1;
* data structure representation the conf file representing
* the loadbalanced server pool.
*
- * Version: $Id: vrrp_parser.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_parser.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
vrrp_garp_delay_handler(vector strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
- vrrp->garp_delay = atoi(VECTOR_SLOT(strvec, 1));
+ vrrp->garp_delay = atoi(VECTOR_SLOT(strvec, 1)) * TIMER_HZ;
}
static void
vrrp_auth_type_handler(vector strvec)
*
* Part: Sheduling framework for vrrp code.
*
- * Version: $Id: vrrp_scheduler.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_scheduler.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
vrrp_init_state(list l)
{
vrrp_rt *vrrp;
+ vrrp_sgroup *vgroup;
element e;
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
#endif
syslog(LOG_INFO, "VRRP_Instance(%s) Entering BACKUP STATE",
vrrp->iname);
+
+ /* Set BACKUP state */
vrrp->state = VRRP_STATE_BACK;
+ vrrp_smtp_notifier(vrrp);
+ notify_instance_exec(vrrp, VRRP_STATE_BACK);
+
+ /* Init group if needed */
+ if ((vgroup = vrrp->sync)) {
+ if (GROUP_STATE(vgroup) != VRRP_STATE_BACK) {
+ vgroup->state = VRRP_STATE_BACK;
+ vrrp_sync_smtp_notifier(vgroup);
+ notify_group_exec(vgroup, VRRP_STATE_BACK);
+ }
+ }
}
}
}
/* register next dispatcher thread */
vrrp_timer = vrrp_timer_fd(fd);
- TIMER_MICRO_ADJUST(vrrp_timer);
if (fd == -1)
thread_add_timer(thread->master, vrrp_read_dispatcher_thread,
(int *)THREAD_TIMER, vrrp_timer);
*
* Part: VRRP synchronization framework.
*
- * Version: $Id: vrrp_sync.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_sync.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
{
TIMEVAL timer = timer_now();
- /*
- * We only make timer auto-recalibration while being in
- * master state. Other state are transtions so recalibration
- * is not needed. Here we estimate the VRRP advert time
- * handling and substract it to new computed timer.
- * We just take care to the usec sub timer and not sec one
- * to not conflict scheduling decision.
- */
- if (vrrp->state == VRRP_STATE_MAST) {
- long usec;
- usec = timer.tv_usec - vrrp->sands.tv_usec;
- vrrp->sands.tv_sec = timer.tv_sec + vrrp->adver_int / TIMER_HZ;
- vrrp->sands.tv_usec = timer.tv_usec;
- if (usec > 0)
- vrrp->sands.tv_usec -= usec;
- return;
- }
-
- if (vrrp->state == VRRP_STATE_GOTO_MASTER ||
+ if (vrrp->state == VRRP_STATE_MAST ||
+ vrrp->state == VRRP_STATE_GOTO_MASTER ||
vrrp->state == VRRP_STATE_GOTO_FAULT) {
vrrp->sands.tv_sec = timer.tv_sec + vrrp->adver_int / TIMER_HZ;
vrrp->sands.tv_usec = timer.tv_usec;
return;
}
- if (vrrp->state == VRRP_STATE_BACK || vrrp->state == VRRP_STATE_FAULT) {
- vrrp->sands.tv_sec = timer.tv_sec + vrrp->ms_down_timer / TIMER_HZ;
- vrrp->sands.tv_usec = timer.tv_usec + vrrp->ms_down_timer % TIMER_HZ;
- }
+ if (vrrp->state == VRRP_STATE_BACK || vrrp->state == VRRP_STATE_FAULT)
+ vrrp->sands = timer_add_long(timer, vrrp->ms_down_timer);
}
/* Instance name lookup */
}
/* SMTP alert group notifier */
-static void
+void
vrrp_sync_smtp_notifier(vrrp_sgroup *vgroup)
{
if (vgroup->smtp_alert) {
return;
syslog(LOG_INFO, "VRRP_Group(%s) Transition to MASTER state",
- GROUP_NAME(vrrp->sync));
+ GROUP_NAME(vgroup));
/* Perform sync index */
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
list l = vgroup->index;
element e;
+ if (GROUP_STATE(vgroup) == VRRP_STATE_BACK)
+ return;
+
syslog(LOG_INFO, "VRRP_Group(%s) Syncing instances to BACKUP state",
GROUP_NAME(vgroup));
/* Perform sync index */
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
isync = ELEMENT_DATA(e);
- if (isync != vrrp) {
+ if (isync != vrrp && isync->state != VRRP_STATE_BACK) {
isync->wantstate = VRRP_STATE_BACK;
vrrp_state_leave_master(isync);
vrrp_init_instance_sands(isync);
list l = vgroup->index;
element e;
- if (GROUP_STATE(vrrp->sync) == VRRP_STATE_MAST)
+ if (GROUP_STATE(vgroup) == VRRP_STATE_MAST)
return;
syslog(LOG_INFO, "VRRP_Group(%s) Syncing instances to MASTER state",
- GROUP_NAME(vrrp->sync));
+ GROUP_NAME(vgroup));
/* Perform sync index */
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
isync = ELEMENT_DATA(e);
/* Send the higher priority advert on all synced instances */
- if (isync != vrrp) {
+ if (isync != vrrp && isync->state != VRRP_STATE_MAST) {
isync->wantstate = VRRP_STATE_MAST;
vrrp_state_goto_master(isync);
vrrp_init_instance_sands(isync);
list l = vgroup->index;
element e;
- if (GROUP_STATE(vrrp->sync) == VRRP_STATE_FAULT)
+ if (GROUP_STATE(vgroup) == VRRP_STATE_FAULT)
return;
syslog(LOG_INFO, "VRRP_Group(%s) Syncing instances to FAULT state",
- GROUP_NAME(vrrp->sync));
+ GROUP_NAME(vgroup));
/* Perform sync index */
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
* => by default ms_down_timer is set to 3secs.
* => Takeover will be less than 3secs !
*/
- if (isync != vrrp) {
+ if (isync != vrrp && isync->state != VRRP_STATE_FAULT) {
if (isync->state == VRRP_STATE_MAST)
isync->wantstate = VRRP_STATE_GOTO_FAULT;
if (isync->state == VRRP_STATE_BACK)
*
* Part: Interface tracking framework.
*
- * Version: $Id: vrrp_track.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vrrp_track.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: HTML stream parser utility functions.
*
- * Version: $Id: html.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: html.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: parser.c include file.
*
- * Version: $Id: html.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: html.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: List structure manipulation.
*
- * Version: $Id: list.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: list.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: list.c include file.
*
- * Version: $Id: list.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: list.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* Part: Memory management framework. This framework is used to
* find any memory leak.
*
- * Version: $Id: memory.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: memory.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Jan Holmberg, <jan@artech.net>
*
* Part: memory.c include file.
*
- * Version: $Id: memory.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: memory.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Authors: Alexandre Cassen, <acassen@linux-vs.org>
* Jan Holmberg, <jan@artech.net>
*
* Part: Forked system call to launch an extra script.
*
- * Version: $Id: notify.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: notify.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: notify.c include file.
*
- * Version: $Id: notify.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: notify.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* data structure representation the conf file representing
* the loadbalanced server pool.
*
- * Version: $Id: parser.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: parser.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: cfreader.c include file.
*
- * Version: $Id: parser.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: parser.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
* the thread management routine (thread.c) present in the
* very nice zebra project (http://www.zebra.org).
*
- * Version: $Id: scheduler.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: scheduler.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
, void *arg, int fd, long timer)
{
thread *thread;
- TIMEVAL time_now;
assert(m != NULL);
thread->u.fd = fd;
/* Compute read timeout value */
- time_now = timer_now();
- if (timer >= TIMER_MAX_SEC) {
- time_now.tv_sec += timer / TIMER_HZ;
- time_now.tv_usec += timer % TIMER_HZ;
- } else
- time_now.tv_sec += timer;
-
- thread->sands = time_now;
+ thread->sands = timer_add_long(timer_now(), timer);
/* Sort the thread. */
thread_list_add_timeval(&m->read, thread);
, void *arg, int fd, long timer)
{
thread *thread;
- TIMEVAL time_now;
assert(m != NULL);
thread->u.fd = fd;
/* Compute write timeout value */
- time_now = timer_now();
- if (timer >= TIMER_MAX_SEC) {
- time_now.tv_sec += timer / TIMER_HZ;
- time_now.tv_usec += timer % TIMER_HZ;
- } else
- time_now.tv_sec += timer;
-
- thread->sands = time_now;
+ thread->sands = timer_add_long(timer_now(), timer);
/* Sort the thread. */
thread_list_add_timeval(&m->write, thread);
, void *arg, long timer)
{
thread *thread;
- TIMEVAL time_now;
assert(m != NULL);
thread->arg = arg;
/* Do we need jitter here? */
- time_now = timer_now();
- if (timer >= TIMER_MAX_SEC) {
- time_now.tv_sec += timer / TIMER_HZ;
- time_now.tv_usec += timer % TIMER_HZ;
- } else
- time_now.tv_sec += timer;
-
- thread->sands = time_now;
+ thread->sands = timer_add_long(timer_now(), timer);
/* Sort by timeval. */
thread_list_add_timeval(&m->timer, thread);
, void * arg, pid_t pid, long timer)
{
thread *thread;
- TIMEVAL time_now;
assert(m != NULL);
thread->u.c.status = 0;
/* Compute write timeout value */
- time_now = timer_now();
- if (timer >= TIMER_MAX_SEC) {
- time_now.tv_sec += timer / TIMER_HZ;
- time_now.tv_usec += timer % TIMER_HZ;
- } else
- time_now.tv_sec += timer;
-
- thread->sands = time_now;
+ thread->sands = timer_add_long(timer_now(), timer);
/* Sort by timeval. */
thread_list_add_timeval(&m->child, thread);
timer_min = m->read.head->sands;
}
+ if (m->child.head) {
+ if (!TIMER_ISNULL(timer_min)) {
+ if (timer_cmp(m->child.head->sands, timer_min) <= 0)
+ timer_min = m->child.head->sands;
+ } else
+ timer_min = m->child.head->sands;
+ }
+
if (!TIMER_ISNULL(timer_min)) {
timer_min = timer_sub(timer_min, time_now);
if (timer_min.tv_sec < 0) {
*
* Part: scheduler.c include file.
*
- * Version: $Id: scheduler.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: scheduler.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
/* MICRO SEC def */
-#define BOOTSTRAP_DELAY 1
+#define BOOTSTRAP_DELAY TIMER_HZ
/* Macros. */
#define THREAD_ARG(X) ((X)->arg)
*
* Part: Timer manipulations.
*
- * Version: $Id: timer.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: timer.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
return ret;
}
+/* timer add */
+TIMEVAL
+timer_add_long(TIMEVAL a, long b)
+{
+ TIMEVAL ret;
+
+ TIMER_RESET(ret);
+ ret.tv_usec = a.tv_usec + b % TIMER_HZ;
+ ret.tv_sec = a.tv_sec + b / TIMER_HZ;
+
+ if (ret.tv_usec >= TIMER_HZ) {
+ ret.tv_sec++;
+ ret.tv_usec -= TIMER_HZ;
+ }
+
+ return ret;
+}
+
/* current time */
TIMEVAL
timer_now(void)
*
* Part: timer.c include file.
*
- * Version: $Id: timer.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: timer.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
#define TIMER_HZ 1000000
#define TIMER_MAX_SEC 1000
#define TIMER_SEC(T) ((T).tv_sec)
+#define TIMER_LONG(T) ((T).tv_sec * TIMER_HZ + (T).tv_usec)
#define TIMER_ISNULL(T) ((T).tv_sec == 0 && (T).tv_usec == 0)
#define TIMER_RESET(T) (memset(&(T), 0, sizeof(struct timeval)))
-#define TIMER_MICRO_ADJUST(T) ((T) = ((T) < TIMER_MAX_SEC)?TIMER_MAX_SEC:(T))
/* prototypes */
extern TIMEVAL timer_now(void);
extern TIMEVAL timer_dup(TIMEVAL b);
extern int timer_cmp(TIMEVAL a, TIMEVAL b);
extern TIMEVAL timer_sub(TIMEVAL a, TIMEVAL b);
+extern TIMEVAL timer_add_long(TIMEVAL a, long b);
extern TIMEVAL timer_sub_now(TIMEVAL a);
extern void timer_dump(TIMEVAL a);
extern unsigned long timer_tol(TIMEVAL a);
*
* Part: General program utils.
*
- * Version: $Id: utils.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: utils.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: utils.h include file.
*
- * Version: $Id: utils.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: utils.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Vector structure manipulation.
*
- * Version: $Id: vector.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vector.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: vector.c include file.
*
- * Version: $Id: vector.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: vector.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: Software watchdog framework.
*
- * Version: $Id: watchdog.c,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: watchdog.c,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
*
* Part: watchdog.c include file.
*
- * Version: $Id: watchdog.h,v 1.1.2 2003/09/08 01:18:41 acassen Exp $
+ * Version: $Id: watchdog.h,v 1.1.3 2003/09/29 02:37:13 acassen Exp $
*
* Author: Alexandre Cassen, <acassen@linux-vs.org>
*
/* watchdog definition */
#define WATCHDOG_TIMER 30
-#define WATCHDOG_DELAY 5
+#define WATCHDOG_DELAY (5 * TIMER_HZ)
#define WATCHDOG_STRING "hello"
#define WDOG_READ_BUFSIZ 32