[-]
[+]
|
Changed |
keepalived.changes
|
|
[-]
[+]
|
Changed |
keepalived.spec
^
|
|
[-]
[+]
|
Deleted |
keepalived-1.2.10.tar.bz2/genhash/hash.h
^
|
@@ -1,68 +0,0 @@
-/*
- * Soft: Perform a GET query to a remote HTTP/HTTPS server.
- * Set a timer to compute global remote server response
- * time.
- *
- * Part: Hash-related declarations (to break circular deps).
- *
- * Version: hash.h 2013/07/22
- *
- * Authors: Jan Pokorny, <jpokorny@redhat.com>
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Copyright 2013 Red Hat, Inc.
- */
-
-#ifndef _HASH_H
-#define _HASH_H
-
-#include <openssl/md5.h>
-#ifdef FEAT_SHA1
-# include <openssl/sha.h>
-#endif
-
-/* available hashes enumeration */
-enum feat_hashes {
- hash_first,
- hash_md5 = hash_first,
-#ifdef FEAT_SHA1
- hash_sha1,
-#endif
- hash_guard,
- hash_default = hash_md5,
-};
-
-typedef union {
- MD5_CTX md5;
-#ifdef FEAT_SHA1
- SHA_CTX sha;
-#endif
- /* this is due to poor C standard/draft wording (wrapped):
- https://groups.google.com/forum/#!msg/comp.lang.c/
- 1kQMGXhgn4I/0VBEYG_ji44J */
- char *dummy;
-} hash_context_t;
-
-typedef void (*hash_init_f)(hash_context_t *);
-typedef void (*hash_update_f)(hash_context_t *, const void *, unsigned long);
-typedef void (*hash_final_f)(unsigned char *, hash_context_t *);
-
-typedef struct {
- hash_init_f init;
- hash_update_f update;
- hash_final_f final;
- unsigned char length; /* length of the digest */
- const char *id; /* command-line handing + help*/
- const char *label; /* final output */
-} hash_t;
-
-#endif
|
[-]
[+]
|
Deleted |
keepalived-1.2.10.tar.bz2/genhash/http.h
^
|
@@ -1,70 +0,0 @@
-/*
- * Soft: Perform a GET query to a remote HTTP/HTTPS server.
- * Set a timer to compute global remote server response
- * time.
- *
- * Part: http.c include file.
- *
- * Version: $Id: http.h,v 1.1.16 2009/02/14 03:25:07 acassen Exp $
- *
- * Authors: Alexandre Cassen, <acassen@linux-vs.org>
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
- */
-
-#ifndef _HTTP_H
-#define _HTTP_H
-
-/* system includes */
-#include <stdio.h>
-#include <openssl/ssl.h>
-
-/* local includes */
-#include "scheduler.h"
-#include "sock.h"
-
-/* global defs */
-#define GET_BUFFER_LENGTH 2048
-#define MAX_BUFFER_LENGTH 4096
-#define HTTP_CNX_TIMEOUT (5 * TIMER_HZ)
-#define PROTO_HTTP 0x01
-#define PROTO_SSL 0x02
-
-/* GET processing command */
-#define REQUEST_TEMPLATE "GET %s HTTP/1.0\r\n" \
- "User-Agent: GenHash (Linux powered)\r\n" \
- "Host: %s%s\r\n\r\n"
-
-#define REQUEST_TEMPLATE_IPV6 "GET %s HTTP/1.0\r\n" \
- "User-Agent: GenHash (Linux powered)\r\n" \
- "Host: [%s]%s\r\n\r\n"
-
-/* Output delimiters */
-#define DELIM_BEGIN "-----------------------["
-#define DELIM_END "]-----------------------\n"
-#define HTTP_HEADER_HEXA DELIM_BEGIN" HTTP Header Buffer "DELIM_END
-#define HTTP_HEADER_ASCII DELIM_BEGIN" HTTP Header Ascii Buffer "DELIM_END
-#define HTML_HEADER_HEXA DELIM_BEGIN" HTML Buffer "DELIM_END
-#define HTML_HASH DELIM_BEGIN" HTML hash resulting "DELIM_END
-#define HTML_HASH_FINAL DELIM_BEGIN" HTML hash final resulting "DELIM_END
-
-/* Globals exported */
-extern const hash_t hashes[];
-
-/* Define prototypes */
-extern int epilog(thread_t *);
-extern int finalize(thread_t *);
-extern int http_process_stream(SOCK *, int);
-extern int http_request_thread(thread_t *);
-
-#endif
|
[-]
[+]
|
Deleted |
keepalived-1.2.10.tar.bz2/genhash/main.h
^
|
@@ -1,90 +0,0 @@
-/*
- * Soft: Perform a GET query to a remote HTTP/HTTPS server.
- * Set a timer to compute global remote server response
- * time.
- *
- * Part: main.c include file.
- *
- * Version: $Id: main.h,v 1.1.16 2009/02/14 03:25:07 acassen Exp $
- *
- * Authors: Alexandre Cassen, <acassen@linux-vs.org>
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
- */
-
-#ifndef _MAIN_H
-#define _MAIN_H
-
-/* global includes */
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
-#include <errno.h>
-#include <getopt.h>
-#include <openssl/ssl.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-
-/* local includes */
-#include "memory.h"
-#include "timer.h"
-#include "http.h"
-#include "ssl.h"
-#include "list.h"
-#include "sock.h"
-
-/* Build version */
-#define PROG "genhash"
-
-#define VERSION_CODE 0x010000
-#define DATE_CODE 0x15070d
-
-#define GETMETER_VERSION(version) \
- (version >> 16) & 0xFF, \
- (version >> 8) & 0xFF, \
- version & 0xFF
-
-#define VERSION_STRING PROG" v%d.%d.%d (%.2d/%.2d, 20%.2d)\n", \
- GETMETER_VERSION(VERSION_CODE), \
- GETMETER_VERSION(DATE_CODE)
-
-/* HTTP/HTTPS request structure */
-typedef struct {
- struct addrinfo *dst;
- char ipaddress[INET6_ADDRSTRLEN];
- uint16_t addr_port;
- char *url;
- char *vhost;
- int verbose;
- int ssl;
- SSL_CTX *ctx;
- SSL_METHOD *meth;
- enum feat_hashes hash;
- unsigned long ref_time;
- unsigned long response_time;
-} REQ;
-
-/* Global variables */
-extern thread_master_t *master;
-extern REQ *req; /* Cmd line arguments */
-
-/* Data buffer length description */
-#define BUFSIZE 1024
-
-/* Command line error handling */
-#define CMD_LINE_ERROR 0
-#define CMD_LINE_SUCCESS 1
-
-#endif
|
[-]
[+]
|
Deleted |
keepalived-1.2.10.tar.bz2/genhash/sock.h
^
|
@@ -1,56 +0,0 @@
-/*
- * Soft: Perform a GET query to a remote HTTP/HTTPS server.
- * Set a timer to compute global remote server response
- * time.
- *
- * Part: sock.c include file.
- *
- * Version: $Id: sock.h,v 1.1.16 2009/02/14 03:25:07 acassen Exp $
- *
- * Authors: Alexandre Cassen, <acassen@linux-vs.org>
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
- */
-
-#ifndef _SOCK_H
-#define _SOCK_H
-
-/* system includes */
-#include <openssl/ssl.h>
-
-/* local includes */
-#include "hash.h"
-
-/* Engine socket pool element structure */
-typedef struct {
- int fd;
- SSL *ssl;
- BIO *bio;
- const hash_t *hash;
- hash_context_t context;
- int status;
- int lock;
- char *buffer;
- char *extracted;
- int size;
- int total_size;
-} SOCK;
-
-/* global vars exported */
-extern SOCK *sock;
-
-/* Prototypes */
-extern void free_sock(SOCK *);
-extern void init_sock(void);
-
-#endif
|
[-]
[+]
|
Deleted |
keepalived-1.2.10.tar.bz2/genhash/ssl.h
^
|
@@ -1,37 +0,0 @@
-/*
- * Soft: Perform a GET query to a remote HTTP/HTTPS server.
- * Set a timer to compute global remote server response
- * time.
- *
- * Part: ssl.c include file.
- *
- * Version: $Id: ssl.h,v 1.1.16 2009/02/14 03:25:07 acassen Exp $
- *
- * Authors: Alexandre Cassen, <acassen@linux-vs.org>
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- *
- * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
- */
-
-#ifndef _SSL_H
-#define _SSL_H
-
-#include <openssl/ssl.h>
-
-/* Prototypes */
-extern void init_ssl(void);
-extern int ssl_connect(thread_t *);
-extern int ssl_printerr(int);
-extern int ssl_send_request(SSL *, char *, int);
-extern int ssl_read_thread(thread_t *);
-
-#endif
|
|
Deleted |
keepalived-1.2.11.tar.bz2
^
|
|
Deleted |
keepalived-1.2.12.tar.bz2
^
|
|
Deleted |
keepalived-1.2.13.tar.bz2
^
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/ChangeLog
^
|
@@ -1,3 +1,366 @@
+2015-03-31 Alexandre Cassen <acassen@linux-vs.org>
+ * keepalived-1.2.16 released.
+ * Properly close netlink channel to avoid fd leak.
+ * Use getaddrinfo instead of gethostbyname to workaround
+ glibc gethostbyname function buffer overflow.
+ * ipvs: log http timeout only when server goes down
+ All other calls to log_message() when a check fails are
+ performed when a server changes its state.
+ The http timeout log message is the only exception.
+ * ipvs: properly fix bug when Q < H.
+ The commit a77c2c7 has not fixed the issue.
+ Log messages became accurate, but unsigned comparison
+ was still in use.
+ * ipvs: HUP processing refactored.
+ copy_srv_states is removed: we can copy states with
+ existing clear_diff_*functions, as long as
+ clear_diff_services is called before the init_services.
+ vs_exist, rs_exist: remove side-effects from these functions.
+ Now they do only search and return pointers.
+ get_rs_list removed: the new rs list is now passed to
+ clear_diff_rs.
+ init_service_vs: quorum_state assignment is not needed
+ here. It is already assigned either by vs constructor, or
+ by alpha handler, or by clear_diff_services.
+ * ipvs: refactoring link vsg structure to vs.
+ this adds a pointer to virtual_server_group_t into
+ the virtual_server_t structure and fills these pointers
+ after config load.
+ This change will allow to access vsg items of a vs easily,
+ without iterating and name compare.
+ * ipvs: refactoring use links to vs->vsg links.
+ ipvs_cmd: removed vs_group list parameter. Link to vsg
+ is obtained via vs->vsg. These functions are also modified
+ in the same way: ipvs_group_cmd, clear_service_rs,
+ clear_service_vs, clear_diff_rs.
+ clear_diff_vsg: new_vs is passed as a param, vsg pointers
+ are retrieved w/o iterating.
+ * ipvs: fix problems with config reload.
+ The commit 7bf6fc contained a bad trying to fix the issue
+ when an alive RS does not appear in a new VSG entry on reload.
+ It has not fixed the original issue and added a new one:
+ vs_groups lose quorum on config reload.
+ This commit fixes the issue properly, and also the case when
+ RS in VSG is in inhibit mode.
+ The reloaded flag is added to the virtual_server_group_entry_t.
+ ipvs_group_sync_entry: add alive destinations to the newly
+ created vsge. It is aware of inhibit-on-failure destinations.
+ sync_service_vsg: calls the former for each created vsg entry
+ vsge_exist: changed just as other *_exist routines.
+ * genhash: add support of fwmark in genhash
+ * genhash: terminate thread if connect_error
+ * Fixed filenames and paths so that make uninstall removes
+ initscript and man pages. Changed perms for keepalived.sysconfig
+ from 755 to 644
+ * Fix a typo in dump_global-data().
+ * vrrp: revert previous buggy preempt extension.
+ * smtp: fix infinite loop when the smtp server unexpectedly
+ closes the connection.
+
+2014-12-21 Alexandre Cassen <acassen@linux-vs.org>
+ * keepalived-1.2.15 released.
+ * vrrp: Use ancillary data on sending path for IPv6
+ mcast_src_ip. Well, previous code used bind() to specify
+ IPv6 src address. Ancillary data is a much more cleaner
+ and efficient way...
+ * ipvs: Fix format of long int in log_message call.
+ * ipvs: fix building with fwmark disabled.
+ * vrrp: Pointer dereference before NULL check.
+ * STR(SMTP_PORT) returns "SMTP_PORT", not "25".
+
+2014-12-16 Alexandre Cassen <acassen@linux-vs.org>
+ * keepalived-1.2.14 released.
+ * The "Date:" mail header is now localtime.
+ * bugfix: fwmark field was formatted as signed int
+ * dump_conn_opts: fwmark was not displayed.
+ * log_message: emit -Wformat= compiler warnings.
+ There could be (and actually are) situations when the format
+ string and the arguments list passed to the log_message() are
+ inconsistent or mistyped. The compiler did not show any warnings
+ because the vsnprintf was called indirectly.
+ * Further unification of IP endpoints logging.
+ This change tries to keep usage of the standard "[%s]:%d" format
+ string to a minimum. Instead, use inet_sockaddrtopair wherever
+ possible.
+ * Add SNMP subsystem option to man page.
+ The keepalived(8) man page did not mention the -x option to
+ enable the SNMP subsystem. This patch adds the -x (and --smmp)
+ options to the keepalived(8) man page, as described in the
+ keepalived help message.
+ * vrrp: fix gratuitous ARP refresh timer handling.
+ Previous code was using an 'int' to store parsed timer value.
+ This value was then expanded to TIMER_HZ which can lead to a
+ wrapping issue if requested timer is longer than local machine
+ 'int' representation. This patch reworked the code to use
+ timeval_t instead and perfrom regular timeval operations.
+ * vrrp: Fix a memory leak while dropping incoming IPSEC-AH
+ authenticated advert. Digest was allocated in previous code
+ without freeing it on HMAC-MD5 missmatch.
+ * vrrp: Extend IPSEC-AH auth to support unicast.
+ If you plane to use IPSEC-AH auth in unicast mode (which THE best
+ idea), then IP header TTL MUST be zeroed since it is mutable field
+ on transit.
+ * vrrp: Update VRRP VMAC doc.
+ Add vmac_xmit_base in configuration example and force rp_filter=0
+ on macvlan interface.
+ * vrrp: make gratuitous ARP repeat count configurable.
+ . garp_master_repeat : Gratuitous ARP count sent on the wire
+ after MASTER state transition.
+ . garp_master_refresh_repeat : Gratuitous ARP count sent on the
+ wire when garp_refresh_timer fir
+ * vrrp: fix preempt and state BACKUP when prio 255.
+ This makes it so that keepalived will respect various settings that
+ should prevent it from assuming the MASTER role for a vrrp_instance
+ unconditionally and immediately, even if the priority of the
+ vrrp_instance in question is set to 255 (VRRP_PRIO_OWNER). These
+ settings include:
+ ---- conf ----
+ state BACKUP
+ preempt_delay <N>
+ nopreempt
+ * vrrp: in backup state notify when vrrp is not up and move to FAULT
+ state.
+ * ipvs: failed RS was flapping on config reload.
+ The RS disabled by health-checker was turned on w/o health-checking
+ by SIGHUP handler in the init_service_rs() subroutine.
+ This did not happen with alpha mode set.
+ * libipvs: allow IPv4 RS in IPv6 VS and vice versa.
+ This change syncronizes local copy of libipvs with the upstream
+ (kernel/ipvsadm/ipvsadm.git) to the date. IPVS in Linux 3.18 will
+ include the feature of mixing of tunneled RS families in single VS.
+ The compatibility with older kernel versions is kept.
+ * libipvs: minor bugfix with retreiving dest af.
+ This change needs to be sent to the ipvsadm upstream, too.
+ This clarifies the previous commit, so there is no need to mention
+ it in the changelog.
+ * vrrp: check if interface is known when using use_vmac.
+ vrrp->ifp is NULL when use_vmac keyword is defined before the
+ interface keyword. This would result in a segfault
+ * vrrp: simplify macvlan creation.
+ Create the macvlan interface in one netlink command rather than
+ three (creation of the macvlan in netlink_link_add_vmac function,
+ set of the mac address in the netlink_link_setlladdr function, set
+ macvlan mode in the netlink_link_setmode function).
+ This simplification:
+ 1. avoids potential issues if the firt netlink command passes butcw
+ not the next ones
+ 2. reduces number of netlink messages (light optimization)
+ * ipvs: bugfix quorum state was flapping when Q < H.
+ When a service had quorum < hysteresis, the lower threshold of RS
+ weights was calculated incorrecly. Unsigned arythmetics was used, so
+ errors like this appeared in log: Keepalived_healthcheckers[2535]:
+ Lost quorum 1-2=18446744073709551615 > 10 for VS
+ The up -> down quorum state transition was happening every time when
+ alive RS set was changed. This bug was in place since
+ keepalived-1.2.9
+ * vrrp: add support to IPv6 mcast src address specification.
+ For some reason (well... which one ?), previous code didnt support
+ specification of multicast source address in IPv6 mode. If you are
+ using 'native_ipv6' and want to specify IPv6 mcast source ip address
+ then you can use 'mcast_src_ip' keyword with IPv6 address.
+ * vrrp: Add support to IPv6 src_address discrimination in master
+ rx state.
+ Previous code didnt support IPv6 address discrimination while in
+ MASTER state receiving same prio advert. This patch extend previous
+ code to support IP address comparison agnostic.
+ * vrrp: IPv6 mcast src_addr handling and VMAC fix.
+ Properly bind socket for v6 use-case when mcasr_src_ip is in use or
+ when VMAC is used. This patch fix VRRP VMAC in native_ipv6 mode,
+ previous code just use the vmac interface link-local IP Address as
+ src_ip leading to a corner case (to keep polite).
+ * vrrp: in IPv6 scope_id is mandatory to bind link-local address.
+ In IPv6 use-case, source IP address is set binding sokect to
+ socaddr_in6. Linux Kernel requires interface to bind link-local
+ address.
+ * vrrp: fix nopreempt mode in master_rx.
+ While receiving lower prio advert, preempt election according to
+ nopreempt keyword. By default preempt is on as requested by RFC.
+ * exit on malloc failure.
+ * genhash: code cleanup.
+
+2014-05-13 Alexandre Cassen <acassen@linux-vs.org>
+ * keepalived-1.2.13 released.
+ * vrrp : Use the standard unsigned int types. This fixes
+ building with musl libc, which does not expose the internal
+ __uint* defines. (Natanael Copa)
+ * check : Fix template issue in IPv6 host header.
+ (Jan Hugo Prins)
+ * ipvs : ipvs_syncd_cmd uses memset() to zero the daemonrule
+ buffer before populating it and sending it up. daemonrule is
+ malloc()ed by ipvs_start(). ipvs_start() can bail early if it
+ can't communicate with ipvs. Neither place which call
+ ipvs_start() check the return value, allowing them to walk
+ straight into a NULL pointer deref. (jsgh)
+ * check : Without inhibit_on_failure on a real_server, when the
+ server is marked down existing TCP connections to it are simply
+ blackholed. Hence inhibit_on_failure: by setting the weight to
+ zero no new connections are sent to that server, but because the
+ server isn't completely removed from the table existing
+ connections are allowed to continue. The same problem exists
+ with sorry_server. When a real_server comes back up the
+ sorry_server is removed from the pool and existing connections
+ are blackholed. Instead of continued service, which may usually
+ be a fast response indicating overload, the client must engage
+ in a lengthy wait for the connection to time out. It would be
+ better in many cases to allow the sorry_server connections to
+ complete naturally. Luckily the code is structured well enough
+ that all is required to get this behaviour is to set the inhibit
+ member of the sorry_server structure, which is mostly just a
+ change to the config file parser. (jsgh)
+ * check : unify logging of RS and VS. This fixes the bug of
+ displaying a FWM service as [x.x.x.x]:0, where x.x.x.x is the
+ first RS of that service. (Alexey Andriyanov)
+ * check : unify connection options among checkers.
+ All the remote checkers (TCP, HTTP/SSL, SMTP) now have the
+ same set of connection options:
+ . connect_ip (new to TCP, HTTP)
+ . connect_port
+ . bindto
+ . bind_port (new)
+ . connect_timeout (new to SMTP)
+ All of them are optional with reasonable defaults. The patch
+ is designed for simplicity in adding a new option. Since the
+ connect_ip could be inequal to the RS address and, worse, the
+ same for all RSes, the endpoint is now logged as [RS]:rport,
+ not the [connect_ip]:connect_port. (Alexey Andriyanov)
+ * check : fwmark connection option. (Alexey Andriyanov)
+ * check : make SO_MARK a compile-time option.
+ (Alexey Andriyanov)
+ * check : documentation for generic connection opts.
+ (Alexey Andriyanov)
+ * check : random delay before doing the first check.
+ every RS check is registered with a random delay between 0
+ and vs->delay_loop seconds. It helps avoiding multiple
+ simultaneous checks to the same RS server. (Alexey Andriyanov)
+ * vrrp : Fix sync of interface status flag when using VMAC
+ interface. There is a chance that the VMAC interface status
+ flags (up/down) could be different from the base interface flags.
+ This patch will only change the VMAC interface status flags when
+ the base interface is changed. (Jonas Johansson)
+ * vrrp : Let only base interface change the VMAC interface status
+ flags. The interface status flags for a VMAC interface shall
+ only be changed by the base interface, never by reading the
+ actual VMAC interface flags. (Jonas Johansson)
+ * vrrp : Fix initial interface status flag value for VMAC
+ interface. In commit a05a503, "vrrp: Fix sync of interface
+ status flag when using VMAC interface", no inital value for the
+ VMAC interface status flag was set. Due to that the VMAC interface
+ flags shall follow the base interface, the base interface status
+ flags value shall be copied to the VMAC interface status flags
+ after the VMAC interface has been created. (Jonas Johansson)
+ * vrrp : Proper restore of VMAC interface properties on SIGHUP.
+ On SIGHUP the VMAC flag and base ifindex for a VMAC interface was
+ lost. (Jonas Johansson)
+ * vrrp : Revert "Honor preempt_delay setting on startup.".
+ This commit resulted in two individual bugs:
+
+ 1) A keepalived instance coming on-line would not transition to
+ MASTER state until the preempt_delay duration had passed, even
+ though there was no already existing VRRP speaker in MASTER
+ state on the link. In other words, it changed the semantics of
+ preempt_delay from a delay that only took place before
+ *preemption* of another VRRP speaker, to a delay that
+ unconditionally took place after Keepalived came online. The
+ keepalived.conf manual page has always documented the former
+ meaning, which is also IMHO the only one that you would
+ intuitively expect.
+
+ 2) The preempt_delay was applied when a Keepalived process was
+ reloading its configuration following the recipt of SIGHUP.
+ If the Keepalived instance was in MASTER state before the
+ reload, it would cease transmitting VRRP hellos for the
+ duration of preempt_delay, but *not* actually remove the
+ virtual addresses from the network interfaces. This in turn
+ resulted in any backup VRRP speakers on the links transition
+ to the MASTER state while preempt_delay was still in effect
+ on the original MASTER that was reloaded, thus creating a
+ service-impacting split-brain scenario where the virtual
+ addresses are present and active on multiple VRRP speakers
+ simultaneously.
+
+ (Tore Anderson)
+ * vrrp : fix ip_address comparison. Extend IP_ISEQ() macro to
+ take care of NULL addresses. This issue end on SEGV while
+ using virtual_route. thanks to Tore Anderson for reporting.
+ * vrrp : fix double close issue (DROP_MEMBERSHIP & netlink
+ channel). This is a old pending 'bug', not arming at all
+ but just frustrating to see again and again this log message :
+
+ "cant do IP_DROP_MEMBERSHIP errno=Bad file descriptor (9)"
+
+ What the hell ! it was due to a double close during reload &
+ stop procedure. VRRP fd are stored in a socket pool and use
+ the I/O MUX to handle VRRP traffic. While reloading or stopping
+ the daemon the I/O MUX was released first and secondly socket
+ pool. The issue spotted here, in thread_destroy_master() all
+ pending thread are canceled and read/write fds related are
+ close(). Well OK a close on a mcast socket perform kernel side
+ the DROP_MEMBERSHIP when needed, but it is much more clean to
+ perform proper operations userspace ! This patch sequencely
+ cancel pending thread, release socket pool and finally
+ destroy master thread. Same 'issue' appear in netlink channel.
+
+2014-02-08 Alexandre Cassen <acassen@linux-vs.org>
+ * keepalived-1.2.12 released.
+ * lib: Fix reallocation issue introduced in last merge.
+
+2014-01-28 Alexandre Cassen <acassen@linux-vs.org>
+ * keepalived-1.2.11 released.
+ * ipvs: make nlerr2syserr libnl dependent. nlerr2syserr()
+ is only used when libnl is present... simply reflect this in
+ libipvs.
+ * Fix libnl/libnl-3 logic in configure script.
+ This patch causes the configure script to prefer libnl-3 over
+ libnl(1). The configure script will first check for libnl-3 and
+ libnl-genl-3. If both are found, use them. If not, check for
+ libnl(1). This is useful when building on systems that have both
+ libnl-3 and libnl(1) installed. It also fixes some redundant
+ libraries in LIBS.
+ * libipvs: libnl-3 include fix.
+ * lib: extend command lib string parser.
+ Extend cmd_make_strvec to support quoted string as a single slot
+ and commented string at the end of parsed string.
+ * lib: cosmetics at command.c.
+ Extend command framework to support logger and remove some dead
+ code. some cosmetics too.
+ * lib: extend vty to support logger.
+ * autoconf: better libnl3 detection.
+ * Fix memory allocation in parser. The set_value function was
+ incorrectly using sizeof (char *) when allocation and reallocating
+ memory.
+ * Fix memory allocation for MD5 digest.
+ The vrrp_in_chk_ipsecah and vrrp_build_ipsecah functions were
+ incorrectly using sizeof (unsigned char *) when allocating memory
+ for the MD5 digest.
+ * Fix memory leak in vty_read_config. If vty_use_backup_config
+ returns NULL, free any memory that has been allocated before
+ returning.
+ * Fix memory leak in check_include. The check_include function
+ should always free the allocated strvec.
+ * Check content length before allocating memory.
+ Since extract_content_length should return 0 if CONTENT_LENGTH is
+ not found in the buffer, this check should be done before
+ allocating memory. This avoids unnecessary malloc/free calls and
+ fixes a potential memory leak.
+ * Free memory if realloc fails in vty_out. If realloc returns NULL,
+ free the original memory before returning.
+ * Remove redundant close from vty_use_backup_config. The sav file
+ descriptor is closed after read, so there is no need to close it
+ again is chmod operation fails.
+ * Remove unnecessary netlink rtattr structures.
+ Both netlink_link_setmode and netlink_link_add_vmac have rtattr
+ structures that are no needed. The addattr_l function will handle
+ adding the rtattr to the message. Also, this patch removes
+ incorrect void pointer arithmetic when setting rta_len.
+ * vrrp: dont try to leave mcast group in unicast mode.
+ * vrrp: Release and refresh properly fd hash index.
+ Rehashing into the same loop as releasing is not really the best
+ idea... Reworked a little previous patch to properly release hash
+ entries related to the same instance and then hash it back on new
+ fd.
+ * vrrp: use configuration mcast group for leave message.
+ * vrrp: dont try to load ip_vs module when not needed.
+
2014-01-02 Alexandre Cassen <acassen@linux-vs.org>
* keepalived-1.2.10 released.
* Jonas Johansson removed unused option character in getopt
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/VERSION
^
|
@@ -1 +1 @@
-1.2.10
+1.2.16
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/configure
^
|
@@ -627,6 +627,7 @@
VERSION_DATE
VERSION
DFLAGS
+SO_MARK_SUPPORT
SHA1_SUPPORT
SNMP_SUPPORT
NETSNMP_CONFIG
@@ -693,6 +694,7 @@
enable_vrrp
with_kernel_dir
with_kernel_version
+enable_fwmark
enable_snmp
enable_sha1
enable_debug
@@ -1317,6 +1319,7 @@
--disable-lvs-syncd do not use LVS synchronization daemon
--disable-lvs do not use the LVS framework
--disable-vrrp do not use the VRRP framework
+ --disable-fwmark compile without SO_MARK support
--enable-snmp compile with SNMP support
--enable-sha1 compile with SHA1 support
--enable-debug compile with debugging flags
@@ -3256,6 +3259,11 @@
kernelversion=""
fi
+# Check whether --enable-fwmark was given.
+if test "${enable_fwmark+set}" = set; then :
+ enableval=$enable_fwmark;
+fi
+
# Check whether --enable-snmp was given.
if test "${enable_snmp+set}" = set; then :
enableval=$enable_snmp;
@@ -3896,50 +3904,8 @@
as_fn_error $? "OpenSSL libraries are required" "$LINENO" 5
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_socket_modify_cb in -lnl" >&5
-$as_echo_n "checking for nl_socket_modify_cb in -lnl... " >&6; }
-if ${ac_cv_lib_nl_nl_socket_modify_cb+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lnl $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char nl_socket_modify_cb ();
-int
-main ()
-{
-return nl_socket_modify_cb ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_nl_nl_socket_modify_cb=yes
-else
- ac_cv_lib_nl_nl_socket_modify_cb=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nl_nl_socket_modify_cb" >&5
-$as_echo "$ac_cv_lib_nl_nl_socket_modify_cb" >&6; }
-if test "x$ac_cv_lib_nl_nl_socket_modify_cb" = xyes; then :
-
- USE_NL="LIBIPVS_USE_NL"
- CFLAGS="$CFLAGS -DFALLBACK_LIBNL1"
- LIBS="$LIBS -lnl"
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_socket_alloc in -lnl-3" >&5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_socket_alloc in -lnl-3" >&5
$as_echo_n "checking for nl_socket_alloc in -lnl-3... " >&6; }
if ${ac_cv_lib_nl_3_nl_socket_alloc+:} false; then :
$as_echo_n "(cached) " >&6
@@ -3977,10 +3943,7 @@
$as_echo "$ac_cv_lib_nl_3_nl_socket_alloc" >&6; }
if test "x$ac_cv_lib_nl_3_nl_socket_alloc" = xyes; then :
- USE_NL="LIBIPVS_USE_NL"
- CFLAGS="$CFLAGS $(pkg-config --libs --cflags libnl-3.0)"
- LIBS="$LIBS -lnl-3"
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for genl_connect in -lnl-genl-3" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for genl_connect in -lnl-genl-3" >&5
$as_echo_n "checking for genl_connect in -lnl-genl-3... " >&6; }
if ${ac_cv_lib_nl_genl_3_genl_connect+:} false; then :
$as_echo_n "(cached) " >&6
@@ -4018,19 +3981,65 @@
$as_echo "$ac_cv_lib_nl_genl_3_genl_connect" >&6; }
if test "x$ac_cv_lib_nl_genl_3_genl_connect" = xyes; then :
- LIBS="$LIBS -lnl-3 -lnl-genl-3"
+ USE_NL="LIBIPVS_USE_NL"
+ CFLAGS="$CFLAGS $(pkg-config --cflags libnl-genl-3.0)"
+ LIBS="$LIBS $(pkg-config --libs libnl-genl-3.0)"
else
- as_fn_error $? "libnl-3 is installed but not libnl-gen-3. Please, install libnl-gen-3." "$LINENO" 5
+ as_fn_error $? "libnl-3 is installed but not libnl-gen-3. Please, install libnl-gen-3." "$LINENO" 5
fi
else
- USE_NL="LIBIPVS_DONTUSE_NL"
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: keepalived will be built without libnl support." >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_socket_modify_cb in -lnl" >&5
+$as_echo_n "checking for nl_socket_modify_cb in -lnl... " >&6; }
+if ${ac_cv_lib_nl_nl_socket_modify_cb+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lnl $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char nl_socket_modify_cb ();
+int
+main ()
+{
+return nl_socket_modify_cb ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_nl_nl_socket_modify_cb=yes
+else
+ ac_cv_lib_nl_nl_socket_modify_cb=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nl_nl_socket_modify_cb" >&5
+$as_echo "$ac_cv_lib_nl_nl_socket_modify_cb" >&6; }
+if test "x$ac_cv_lib_nl_nl_socket_modify_cb" = xyes; then :
+
+ USE_NL="LIBIPVS_USE_NL"
+ CFLAGS="$CFLAGS -DFALLBACK_LIBNL1"
+ LIBS="$LIBS $(pkg-config --libs libnl-1)"
+
+else
+
+ USE_NL="LIBIPVS_DONTUSE_NL"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: keepalived will be built without libnl support." >&5
$as_echo "$as_me: WARNING: keepalived will be built without libnl support." >&2;}
fi
@@ -4446,6 +4455,24 @@
+if test "${enable_fwmark}" = "no"; then
+ SO_MARK_SUPPORT="_WITHOUT_SO_MARK_"
+else
+ ac_fn_c_check_decl "$LINENO" "SO_MARK" "ac_cv_have_decl_SO_MARK" "#include <sys/socket.h>
+
+"
+if test "x$ac_cv_have_decl_SO_MARK" = xyes; then :
+
+else
+ as_fn_error $? "No SO_MARK declaration in headers" "$LINENO" 5
+fi
+
+ SO_MARK_SUPPORT="_WITH_SO_MARK_"
+fi
+
+
+
+
if test "${enable_debug}" = "yes"; then
DFLAGS="-D_DEBUG_"
@@ -5946,6 +5973,12 @@
echo "IPVS sync daemon support : No"
fi
+if test "${SO_MARK_SUPPORT}" = "_WITH_SO_MARK_"; then
+ echo "fwmark socket support : Yes"
+else
+ echo "fwmark socket support : No"
+fi
+
if test "${VRRP_SUPPORT}" = "_WITH_VRRP_"; then
echo "Use VRRP Framework : Yes"
if test "${VRRP_VMAC}" = "_HAVE_VRRP_VMAC_"; then
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/configure.in
^
|
@@ -31,6 +31,8 @@
AC_ARG_WITH(kernel-version,
[ --with-kernel-version=VER forced value for linux kernel version (VER=2.4|2.6)],
[kernelversion="$withval"], [kernelversion=""])
+AC_ARG_ENABLE(fwmark,
+ [ --disable-fwmark compile without SO_MARK support])
AC_ARG_ENABLE(snmp,
[ --enable-snmp compile with SNMP support])
AC_ARG_ENABLE(sha1,
@@ -55,29 +57,30 @@
AC_CHECK_LIB(crypt, crypt,,AC_MSG_ERROR([crypt() function is required]))
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(nl, nl_socket_modify_cb,
+
+AC_CHECK_LIB(nl-3, nl_socket_alloc,
[
- USE_NL="LIBIPVS_USE_NL"
- CFLAGS="$CFLAGS -DFALLBACK_LIBNL1"
- LIBS="$LIBS -lnl"
+ AC_CHECK_LIB(nl-genl-3, genl_connect,
+ [
+ USE_NL="LIBIPVS_USE_NL"
+ CFLAGS="$CFLAGS $(pkg-config --cflags libnl-genl-3.0)"
+ LIBS="$LIBS $(pkg-config --libs libnl-genl-3.0)"
+ ],
+ [
+ AC_MSG_ERROR([libnl-3 is installed but not libnl-gen-3. Please, install libnl-gen-3.])
+ ])
],
- [AC_CHECK_LIB(nl-3, nl_socket_alloc,
- [
- USE_NL="LIBIPVS_USE_NL"
- CFLAGS="$CFLAGS $(pkg-config --libs --cflags libnl-3.0)"
- LIBS="$LIBS -lnl-3"
- AC_CHECK_LIB(nl-genl-3, genl_connect,
- [
- LIBS="$LIBS -lnl-3 -lnl-genl-3"
- ],
- [
- AC_MSG_ERROR([libnl-3 is installed but not libnl-gen-3. Please, install libnl-gen-3.])
- ])
- ],
- [
- USE_NL="LIBIPVS_DONTUSE_NL"
- AC_MSG_WARN([keepalived will be built without libnl support.])
- ])
+ [
+ AC_CHECK_LIB(nl, nl_socket_modify_cb,
+ [
+ USE_NL="LIBIPVS_USE_NL"
+ CFLAGS="$CFLAGS -DFALLBACK_LIBNL1"
+ LIBS="$LIBS $(pkg-config --libs libnl-1)"
+ ],
+ [
+ USE_NL="LIBIPVS_DONTUSE_NL"
+ AC_MSG_WARN([keepalived will be built without libnl support.])
+ ])
])
dnl ----[ Kernel version check ]----
@@ -261,6 +264,19 @@
AC_SUBST(SHA1_SUPPORT)
+dnl ----[ check for SO_MARK support ]----
+if test "${enable_fwmark}" = "no"; then
+ SO_MARK_SUPPORT="_WITHOUT_SO_MARK_"
+else
+ AC_CHECK_DECL(SO_MARK,,AC_MSG_ERROR([No SO_MARK declaration in headers]),
+ #include <sys/socket.h>
+ )
+ SO_MARK_SUPPORT="_WITH_SO_MARK_"
+fi
+
+AC_SUBST(SO_MARK_SUPPORT)
+
+
dnl ----[ Debug or not ? ]----
if test "${enable_debug}" = "yes"; then
DFLAGS="-D_DEBUG_"
@@ -337,6 +353,12 @@
echo "IPVS sync daemon support : No"
fi
+if test "${SO_MARK_SUPPORT}" = "_WITH_SO_MARK_"; then
+ echo "fwmark socket support : Yes"
+else
+ echo "fwmark socket support : No"
+fi
+
if test "${VRRP_SUPPORT}" = "_WITH_VRRP_"; then
echo "Use VRRP Framework : Yes"
if test "${VRRP_VMAC}" = "_HAVE_VRRP_VMAC_"; then
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/doc/NOTE_vrrp_vmac.txt
^
|
@@ -51,6 +51,7 @@
interface eth0
virtual_router_id 250
use_vmac
+ vmac_xmit_base # Transmit VRRP adverts over physical interface
priority 150
advert_int 1
virtual_ipaddress {
@@ -66,6 +67,7 @@
you then need to configure interface with :
net.ipv4.conf.vrrp.250.arp_filter = 0
net.ipv4.conf.vrrp.250.accept_local = 1 (this is needed for the address owner case)
+net.ipv4.conf.vrrp.250.rp_filter = 0
you can create notify_master script to automate this configuration step for you :
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/doc/keepalived.conf.SYNOPSIS
^
|
@@ -176,8 +176,13 @@
lvs_sync_daemon_interface <STRING> # Binding interface for lvs syncd
garp_master_delay <INTEGER> # delay for gratuitous ARP after MASTER
# state transition
+ garp_master_repeat <INTEGER> # how often the gratuitous ARP after MASTER
+ # state transition should be repeated?
garp_master_refresh <INTEGER> # Periodic delay in seconds sending
# gratuitous ARP while in MASTER state
+ garp_master_refresh_repeat <INTEGER># how often the periodically repeated gratuitous ARP
+ # should be repeated?
+ # Default: once (per period)
virtual_router_id <INTEGER-0..255> # VRRP VRID
priority <INTEGER-0..255> # VRRP PRIO
advert_int <INTEGER> # VRRP Advert interval (use default)
@@ -324,6 +329,9 @@
sorry_server <IP ADDRESS> <PORT> # RS to add to LVS topology when all
# realserver are down
+ sorry_server_inhibit # applies inhibit_on_failure behaviour
+ # to the preceding sorry_server
+ # directive
real_server <IP ADDRESS> <PORT> { # RS declaration
weight <INTEGER> # weight to use (default: 1)
@@ -348,11 +356,15 @@
status_code <INTEGER>
}
...
- connect_port <PORT> # TCP port to connect
- bindto <IP ADDRESS> # IP address to bind to
- connect_timeout <INTEGER> # Timeout connection
- nb_get_retry <INTEGER> # number of get retry
+ connect_ip <IP ADDRESS> # IP address to connect
+ connect_port <PORT> # TCP port to connect
+ bindto <IP ADDRESS> # IP address to bind to
+ bind_port <PORT> # TCP port to bind to
+ connect_timeout <INTEGER> # Timeout connection
+ fwmark <INTEGER> # fwmark to set on socket (SO_MARK)
+ nb_get_retry <INTEGER> # number of get retry
delay_before_retry <INTEGER> # delay before retry
+ warmup <INTEGER> # random delay for maximum N seconds
}
}
@@ -363,9 +375,13 @@
notify_down <STRING>|<QUOTED-STRING> # Idem
TCP_CHECK { # TCP healthchecker
- connect_port <PORT> # TCP port to connect
- bindto <IP ADDRESS> # IP address to bind to
- connect_timeout <INTEGER> # Timeout connection
+ connect_ip <IP ADDRESS> # IP address to connect
+ connect_port <PORT> # TCP port to connect
+ bindto <IP ADDRESS> # IP address to bind to
+ bind_port <PORT> # TCP port to bind to
+ connect_timeout <INTEGER> # Timeout connection
+ fwmark <INTEGER> # fwmark to set on socket (SO_MARK)
+ warmup <INTEGER> # random delay for maximum N seconds
}
}
@@ -377,18 +393,24 @@
SMTP_CHECK { # SMTP healthchecker
host { # Optional additional host/port to check
- connect_ip <IP ADDRESS> # IP address to connect to
- connect_port <PORT> # Port to connect to
+ connect_ip <IP ADDRESS> # IP address to connect
+ connect_port <PORT> # TCP port to connect
bindto <IP ADDRESS> # IP address to bind to
-
+ bind_port <PORT> # TCP port to bind to
+ connect_timeout <INTEGER> # Timeout connection
+ fwmark <INTEGER> # fwmark to set on socket (SO_MARK)
}
host {
- connect_ip <IP ADDRESS>
- connect_port <PORT>
- bindto <IP ADDRESS>
+ connect_ip <IP ADDRESS> # IP address to connect
+ connect_port <PORT> # TCP port to connect
+ bindto <IP ADDRESS> # IP address to bind to
+ bind_port <PORT> # TCP port to bind to
+ connect_timeout <INTEGER> # Timeout connection
+ fwmark <INTEGER> # fwmark to set on socket (SO_MARK)
}
...
connect_timeout <INTEGER> # Connection and read/write timeout
+ warmup <INTEGER> # random delay for maximum N seconds
retry <INTEGER> # Number of times to retry a failed check
delay_before_retry <INTEGER> # Delay in seconds before retrying
helo_name <STRING>|<QUOTED-STRING> # Host to use for the HELO request
@@ -404,6 +426,7 @@
MISC_CHECK { # MISC healthchecker
misc_path <STRING>|<QUOTED-STRING> # External system script or program
misc_timeout <INTEGER> # Script execution timeout
+ warmup <INTEGER> # random delay for maximum N seconds
# If set, exit code from healthchecker is used
# to dynamically adjust the weight as follows:
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/doc/man/man5/keepalived.conf.5
^
|
@@ -363,6 +363,9 @@
# RS to add when all realservers are down
sorry_server <IPADDR> <PORT>
+ # applies inhibit_on_failure behaviour to the
+ # preceding sorry_server directive
+ sorry_server_inhibit
# one entry for each realserver
real_server <IPADDR> <PORT>
@@ -400,23 +403,68 @@
# eg status_code 200
status_code <INT>
}
- #IP, tcp port for service on realserver
- connect_port <PORT>
- bindto <IPADDR>
- # Timeout connection, sec
- connect_timeout <INT>
# number of get retry
nb_get_retry <INT>
# delay before retry
delay_before_retry <INT>
+
+ # ======== generic connection options
+ # Optional IP address to connect to.
+ # The default is real server's IP
+ connect_ip <IP ADDRESS>
+ # Optional port to connect to if not
+ # The default is real server's port
+ connect_port <PORT>
+ # Optional interface to use to
+ # originate the connection
+ bindto <IP ADDRESS>
+ # Optional source port to
+ # originate the connection from
+ bind_port <PORT>
+ # Optional connection timeout in seconds.
+ # The default is 5 seconds
+ connect_timeout <INTEGER>
+ # Optional fwmark to mark all outgoing
+ # checker pakets with
+ fwmark <INTEGER>
+
+ # Optional random delay to begin initial check for
+ # maximum N seconds.
+ # Useful to scatter multiple simultaneous
+ # checks to the same RS. Enabled by default, with
+ # the maximum at delay_loop. Specify 0 to disable
+ warmup <INT>
} #HTTP_GET|SSL_GET
#TCP healthchecker (bind to IP port)
TCP_CHECK
{
+ # ======== generic connection options
+ # Optional IP address to connect to.
+ # The default is real server's IP
+ connect_ip <IP ADDRESS>
+ # Optional port to connect to if not
+ # The default is real server's port
connect_port <PORT>
- bindto <IPADDR>
- connect_timeout <INT>
+ # Optional interface to use to
+ # originate the connection
+ bindto <IP ADDRESS>
+ # Optional source port to
+ # originate the connection from
+ bind_port <PORT>
+ # Optional connection timeout in seconds.
+ # The default is 5 seconds
+ connect_timeout <INTEGER>
+ # Optional fwmark to mark all outgoing
+ # checker pakets with
+ fwmark <INTEGER>
+
+ # Optional random delay to begin initial check for
+ # maximum N seconds.
+ # Useful to scatter multiple simultaneous
+ # checks to the same RS. Enabled by default, with
+ # the maximum at delay_loop. Specify 0 to disable
+ warmup <INT>
} #TCP_CHECK
# SMTP healthchecker
@@ -427,7 +475,9 @@
# the ip address of the real server will
# be checked.
host {
- # IP address to connect to
+ # ======== generic connection options
+ # Optional IP address to connect to.
+ # The default is real server's IP
connect_ip <IP ADDRESS>
# Optional port to connect to if not
# the default of 25
@@ -435,9 +485,18 @@
# Optional interface to use to
# originate the connection
bindto <IP ADDRESS>
+ # Optional source port to
+ # originate the connection from
+ bind_port <PORT>
+ # Optional per-host connection timeout.
+ # Default is outer-scope connect_timeout
+ connect_timeout <INTEGER>
+ # Optional fwmark to mark all outgoing
+ # checker pakets with
+ fwmark <INTEGER>
}
# Connection and read/write timeout
- # in seconds
+ # in seconds. The default is 5 seconds
connect_timeout <INTEGER>
# Number of times to retry a failed check
retry <INTEGER>
@@ -445,6 +504,13 @@
delay_before_retry <INTEGER>
# Optional string to use for the smtp HELO request
helo_name <STRING>|<QUOTED-STRING>
+
+ # Optional random delay to begin initial check for
+ # maximum N seconds.
+ # Useful to scatter multiple simultaneous
+ # checks to the same RS. Enabled by default, with
+ # the maximum at delay_loop. Specify 0 to disable
+ warmup <INT>
} #SMTP_CHECK
#MISC healthchecker, run a program
@@ -455,6 +521,13 @@
# Script execution timeout
misc_timeout <INT>
+ # Optional random delay to begin initial check for
+ # maximum N seconds.
+ # Useful to scatter multiple simultaneous
+ # checks to the same RS. Enabled by default, with
+ # the maximum at delay_loop. Specify 0 to disable
+ warmup <INT>
+
# If set, exit code from healthchecker is used
# to dynamically adjust the weight as follows:
# exit status 0: svc check success, weight
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/doc/man/man8/keepalived.8
^
|
@@ -91,6 +91,9 @@
Use specified pidfile for checkers child process. The default pidfile
for the checker child process is "/var/run/keepalived_checkers.pid".
.TP
+\fB -x, --snmp\fP
+Enable SNMP subsystem.
+.TP
\fB -v, --version\fP
Display the version and exit.
.TP
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/genhash/Makefile.in
^
|
@@ -14,7 +14,7 @@
CC = @CC@
STRIP = @STRIP@
INCLUDES = -I../lib
-CFLAGS = @CFLAGS@ @CPPFLAGS@ $(INCLUDES) \
+CFLAGS = @CFLAGS@ -D@SO_MARK_SUPPORT@ @CPPFLAGS@ $(INCLUDES) \
-Wall -Wunused -Wstrict-prototypes
LDFLAGS = @LIBS@ @LDFLAGS@
@@ -53,13 +53,13 @@
# Code dependencies
-main.o: main.c main.h ../lib/utils.h sock.h ../lib/timer.h \
- http.h ssl.h ../lib/scheduler.h ../lib/memory.h
-sock.o: sock.c sock.h ../lib/utils.h layer4.h ssl.h main.h \
+main.o: main.c include/main.h ../lib/utils.h include/sock.h ../lib/timer.h \
+ include/http.h include/ssl.h ../lib/scheduler.h ../lib/memory.h
+sock.o: sock.c include/sock.h ../lib/utils.h include/layer4.h include/ssl.h include/main.h \
../lib/memory.h
-layer4.o: layer4.c layer4.h ../lib/scheduler.h ../lib/utils.h \
- main.h ssl.h
-http.o: http.c http.h sock.h ../lib/scheduler.h ../lib/utils.h \
- layer4.h main.h ../lib/html.h ../lib/timer.h ../lib/scheduler.h \
+layer4.o: layer4.c include/layer4.h ../lib/scheduler.h ../lib/utils.h \
+ include/main.h include/ssl.h
+http.o: http.c include/http.h include/sock.h ../lib/scheduler.h ../lib/utils.h \
+ include/layer4.h include/main.h ../lib/html.h ../lib/timer.h ../lib/scheduler.h \
../lib/memory.h
-ssl.o: ssl.c ssl.h http.h main.h ../lib/utils.h ../lib/html.h
+ssl.o: ssl.c include/ssl.h include/http.h include/main.h ../lib/utils.h ../lib/html.h
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/genhash/http.c
^
|
@@ -22,16 +22,21 @@
* Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
+/* system includes */
#include <errno.h>
#include <openssl/err.h>
+
+/* keepalived includes */
#include "memory.h"
-#include "http.h"
-#include "layer4.h"
-#include "main.h"
#include "utils.h"
#include "html.h"
#include "timer.h"
+/* genhash includes */
+#include "include/http.h"
+#include "include/layer4.h"
+#include "include/main.h"
+
/*
* The global design of this checker is the following :
*
|
[-]
[+]
|
Added |
keepalived-1.2.16.tar.bz2/genhash/include
^
|
+(directory)
|
[-]
[+]
|
Added |
keepalived-1.2.16.tar.bz2/genhash/include/hash.h
^
|
@@ -0,0 +1,69 @@
+/*
+ * Soft: Perform a GET query to a remote HTTP/HTTPS server.
+ * Set a timer to compute global remote server response
+ * time.
+ *
+ * Part: Hash-related declarations (to break circular deps).
+ *
+ * Version: hash.h 2013/07/22
+ *
+ * Authors: Jan Pokorny, <jpokorny@redhat.com>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Copyright 2013 Red Hat, Inc.
+ */
+
+#ifndef _HASH_H
+#define _HASH_H
+
+/* system includes */
+#include <openssl/md5.h>
+#ifdef FEAT_SHA1
+#include <openssl/sha.h>
+#endif
+
+/* available hashes enumeration */
+enum feat_hashes {
+ hash_first,
+ hash_md5 = hash_first,
+#ifdef FEAT_SHA1
+ hash_sha1,
+#endif
+ hash_guard,
+ hash_default = hash_md5,
+};
+
+typedef union {
+ MD5_CTX md5;
+#ifdef FEAT_SHA1
+ SHA_CTX sha;
+#endif
+ /* this is due to poor C standard/draft wording (wrapped):
+ https://groups.google.com/forum/#!msg/comp.lang.c/
+ 1kQMGXhgn4I/0VBEYG_ji44J */
+ char *dummy;
+} hash_context_t;
+
+typedef void (*hash_init_f)(hash_context_t *);
+typedef void (*hash_update_f)(hash_context_t *, const void *, unsigned long);
+typedef void (*hash_final_f)(unsigned char *, hash_context_t *);
+
+typedef struct {
+ hash_init_f init;
+ hash_update_f update;
+ hash_final_f final;
+ unsigned char length; /* length of the digest */
+ const char *id; /* command-line handing + help */
+ const char *label; /* final output */
+} hash_t;
+
+#endif
|
[-]
[+]
|
Added |
keepalived-1.2.16.tar.bz2/genhash/include/http.h
^
|
@@ -0,0 +1,70 @@
+/*
+ * Soft: Perform a GET query to a remote HTTP/HTTPS server.
+ * Set a timer to compute global remote server response
+ * time.
+ *
+ * Part: http.c include file.
+ *
+ * Version: $Id: http.h,v 1.1.16 2009/02/14 03:25:07 acassen Exp $
+ *
+ * Authors: Alexandre Cassen, <acassen@linux-vs.org>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
+ */
+
+#ifndef _HTTP_H
+#define _HTTP_H
+
+/* system includes */
+#include <stdio.h>
+#include <openssl/ssl.h>
+
+/* local includes */
+#include "scheduler.h"
+#include "sock.h"
+
+/* global defs */
+#define GET_BUFFER_LENGTH 2048
+#define MAX_BUFFER_LENGTH 4096
+#define HTTP_CNX_TIMEOUT (5 * TIMER_HZ)
+#define PROTO_HTTP 0x01
+#define PROTO_SSL 0x02
+
+/* GET processing command */
+#define REQUEST_TEMPLATE "GET %s HTTP/1.0\r\n" \
+ "User-Agent: KeepAlive GenHash Client\r\n" \
+ "Host: %s%s\r\n\r\n"
+
+#define REQUEST_TEMPLATE_IPV6 "GET %s HTTP/1.0\r\n" \
+ "User-Agent: KeepAlive GenHash Client\r\n" \
+ "Host: [%s]%s\r\n\r\n"
+
+/* Output delimiters */
+#define DELIM_BEGIN "-----------------------["
+#define DELIM_END "]-----------------------\n"
+#define HTTP_HEADER_HEXA DELIM_BEGIN" HTTP Header Buffer "DELIM_END
+#define HTTP_HEADER_ASCII DELIM_BEGIN" HTTP Header Ascii Buffer "DELIM_END
+#define HTML_HEADER_HEXA DELIM_BEGIN" HTML Buffer "DELIM_END
+#define HTML_HASH DELIM_BEGIN" HTML hash resulting "DELIM_END
+#define HTML_HASH_FINAL DELIM_BEGIN" HTML hash final resulting "DELIM_END
+
+/* Globals exported */
+extern const hash_t hashes[];
+
+/* Define prototypes */
+extern int epilog(thread_t *);
+extern int finalize(thread_t *);
+extern int http_process_stream(SOCK *, int);
+extern int http_request_thread(thread_t *);
+
+#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/genhash/include/layer4.h
^
|
(renamed to genhash/include/layer4.h)
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/genhash/include/layer4.h
^
|
(renamed to genhash/include/layer4.h)
|
[-]
[+]
|
Added |
keepalived-1.2.16.tar.bz2/genhash/include/main.h
^
|
@@ -0,0 +1,91 @@
+/*
+ * Soft: Perform a GET query to a remote HTTP/HTTPS server.
+ * Set a timer to compute global remote server response
+ * time.
+ *
+ * Part: main.c include file.
+ *
+ * Version: $Id: main.h,v 1.1.16 2009/02/14 03:25:07 acassen Exp $
+ *
+ * Authors: Alexandre Cassen, <acassen@linux-vs.org>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
+ */
+
+#ifndef _MAIN_H
+#define _MAIN_H
+
+/* global includes */
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+#include <getopt.h>
+#include <openssl/ssl.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
+/* local includes */
+#include "memory.h"
+#include "timer.h"
+#include "http.h"
+#include "ssl.h"
+#include "list.h"
+#include "sock.h"
+
+/* Build version */
+#define PROG "genhash"
+
+#define VERSION_CODE 0x010000
+#define DATE_CODE 0x15070d
+
+#define GETMETER_VERSION(version) \
+ (version >> 16) & 0xFF, \
+ (version >> 8) & 0xFF, \
+ version & 0xFF
+
+#define VERSION_STRING PROG" v%d.%d.%d (%.2d/%.2d, 20%.2d)\n", \
+ GETMETER_VERSION(VERSION_CODE), \
+ GETMETER_VERSION(DATE_CODE)
+
+/* HTTP/HTTPS request structure */
+typedef struct {
+ struct addrinfo *dst;
+ char ipaddress[INET6_ADDRSTRLEN];
+ uint16_t addr_port;
+ char *url;
+ char *vhost;
+ int verbose;
+ int ssl;
+ SSL_CTX *ctx;
+ SSL_METHOD *meth;
+ enum feat_hashes hash;
+ unsigned long ref_time;
+ unsigned long response_time;
+ unsigned int mark;
+} REQ;
+
+/* Global variables */
+extern thread_master_t *master;
+extern REQ *req; /* Cmd line arguments */
+
+/* Data buffer length description */
+#define BUFSIZE 1024
+
+/* Command line error handling */
+#define CMD_LINE_ERROR 0
+#define CMD_LINE_SUCCESS 1
+
+#endif
|
[-]
[+]
|
Added |
keepalived-1.2.16.tar.bz2/genhash/include/sock.h
^
|
@@ -0,0 +1,56 @@
+/*
+ * Soft: Perform a GET query to a remote HTTP/HTTPS server.
+ * Set a timer to compute global remote server response
+ * time.
+ *
+ * Part: sock.c include file.
+ *
+ * Version: $Id: sock.h,v 1.1.16 2009/02/14 03:25:07 acassen Exp $
+ *
+ * Authors: Alexandre Cassen, <acassen@linux-vs.org>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
+ */
+
+#ifndef _SOCK_H
+#define _SOCK_H
+
+/* system includes */
+#include <openssl/ssl.h>
+
+/* local includes */
+#include "hash.h"
+
+/* Engine socket pool element structure */
+typedef struct {
+ int fd;
+ SSL *ssl;
+ BIO *bio;
+ const hash_t *hash;
+ hash_context_t context;
+ int status;
+ int lock;
+ char *buffer;
+ char *extracted;
+ int size;
+ int total_size;
+} SOCK;
+
+/* global vars exported */
+extern SOCK *sock;
+
+/* Prototypes */
+extern void free_sock(SOCK *);
+extern void init_sock(void);
+
+#endif
|
[-]
[+]
|
Added |
keepalived-1.2.16.tar.bz2/genhash/include/ssl.h
^
|
@@ -0,0 +1,38 @@
+/*
+ * Soft: Perform a GET query to a remote HTTP/HTTPS server.
+ * Set a timer to compute global remote server response
+ * time.
+ *
+ * Part: ssl.c include file.
+ *
+ * Version: $Id: ssl.h,v 1.1.16 2009/02/14 03:25:07 acassen Exp $
+ *
+ * Authors: Alexandre Cassen, <acassen@linux-vs.org>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
+ */
+
+#ifndef _SSL_H
+#define _SSL_H
+
+/* global includes */
+#include <openssl/ssl.h>
+
+/* Prototypes */
+extern void init_ssl(void);
+extern int ssl_connect(thread_t *);
+extern int ssl_printerr(int);
+extern int ssl_send_request(SSL *, char *, int);
+extern int ssl_read_thread(thread_t *);
+
+#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/genhash/layer4.c
^
|
@@ -22,12 +22,15 @@
* Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
-#include "layer4.h"
+/* keepalived include */
#include "utils.h"
-#include "main.h"
-#include "sock.h"
-#include "http.h"
-#include "ssl.h"
+
+/* genhash includes */
+#include "include/layer4.h"
+#include "include/main.h"
+#include "include/sock.h"
+#include "include/http.h"
+#include "include/ssl.h"
enum connect_result
tcp_connect(int fd, REQ * req_obj)
@@ -45,6 +48,15 @@
setsockopt(fd, SOL_SOCKET, SO_LINGER, (char *) &li,
sizeof (struct linger));
+#ifdef _WITH_SO_MARK_
+ if (req->mark) {
+ if (setsockopt (fd, SOL_SOCKET, SO_MARK, &req->mark, sizeof req->mark)) {
+ fprintf(stderr, "Error setting fwmark %u to socket: %s\n",
+ req->mark, strerror(errno));
+ return connect_error;
+ }
+ }
+#endif
/* Make socket non-block. */
val = fcntl(fd, F_GETFL, 0);
fcntl(fd, F_SETFL, val | O_NONBLOCK);
@@ -154,6 +166,7 @@
switch (status) {
case connect_error:
close(fd);
+ thread_add_terminate_event(thread->master);
break;
case connect_success:
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/genhash/main.c
^
|
@@ -22,18 +22,24 @@
* Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
+/* system includes */
#include <signal.h>
#include <sys/stat.h>
#include <sys/wait.h>
-#include "main.h"
-#include "utils.h"
-#include "signals.h"
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netdb.h>
+/* keepalived includes */
+#include "utils.h"
+#include "signals.h"
+
+/* genhash includes */
+#include "include/main.h"
+
+
/* global var */
REQ *req = NULL;
@@ -79,8 +85,9 @@
" %s --hash -H Use the specified hash algorithm.\n"
" %s --verbose -v Use verbose mode output.\n"
" %s --help -h Display this short inlined help screen.\n"
- " %s --release -r Display the release number\n",
- prog, prog, prog, prog, prog, prog, prog, prog, prog);
+ " %s --release -r Display the release number.\n"
+ " %s --fwmark -m Use the specified FW mark.\n",
+ prog, prog, prog, prog, prog, prog, prog, prog, prog, prog);
fprintf(stderr, "\nSupported hash algorithms:\n");
for (i = hash_first; i < hash_guard; i++)
fprintf(stderr, " %s%s\n",
@@ -112,11 +119,12 @@
{"use-virtualhost", required_argument, 0, 'V'},
{"port", required_argument, 0, 'p'},
{"url", required_argument, 0, 'u'},
+ {"fwmark", required_argument, 0, 'm'},
{0, 0, 0, 0}
};
/* Parse the command line arguments */
- while ((c = getopt_long (argc, argv, "rhvSs:H:V:p:u:", long_options, NULL)) != EOF) {
+ while ((c = getopt_long (argc, argv, "rhvSs:H:V:p:u:m:", long_options, NULL)) != EOF) {
switch (c) {
case 'r':
fprintf(stderr, VERSION_STRING);
@@ -169,6 +177,14 @@
case 'u':
req_obj->url = optarg;
break;
+ case 'm':
+#ifdef _WITH_SO_MARK_
+ req_obj->mark = atoi(optarg);
+#else
+ fprintf(stderr, "genhash built without fwmark support\n");
+ return CMD_LINE_ERROR;
+#endif
+ break;
default:
usage(argv[0]);
return CMD_LINE_ERROR;
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/genhash/sock.c
^
|
@@ -22,14 +22,19 @@
* Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
+/* system includes */
#include <string.h>
+
+/* keepalived includes */
#include "memory.h"
#include "utils.h"
#include "list.h"
-#include "sock.h"
-#include "layer4.h"
-#include "ssl.h"
-#include "main.h"
+
+/* genhash includes */
+#include "include/sock.h"
+#include "include/layer4.h"
+#include "include/ssl.h"
+#include "include/main.h"
/* global var */
SOCK *sock = NULL;
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/genhash/ssl.c
^
|
@@ -22,14 +22,19 @@
* Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
+/* system includes */
#include <openssl/err.h>
-#include "main.h"
-#include "sock.h"
-#include "http.h"
-#include "ssl.h"
+
+/* keepalived includes */
#include "utils.h"
#include "html.h"
+/* genhash includes */
+#include "include/main.h"
+#include "include/sock.h"
+#include "include/http.h"
+#include "include/ssl.h"
+
/* extern variables */
extern REQ *req;
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived.spec.in
^
|
@@ -6,7 +6,7 @@
Summary: HA monitor built upon LVS, VRRP and services poller
Name: keepalived
-Version: 1.2.10
+Version: 1.2.16
Release: 5
License: GPL
Group: Applications/System
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/Makefile.in
^
|
@@ -87,11 +87,11 @@
uninstall:
rm -f $(DESTDIR)$(sbindir)/$(EXEC)
- rm -f $(DESTDIR)$(init_dir)/keepalived.init
+ rm -f $(DESTDIR)$(init_dir)/keepalived
rm -f $(DESTDIR)$(sysconf_dir)/keepalived
rm -rf $(DESTDIR)$(sysconfdir)/keepalived
- rm -f $(DESTDIR)$(mandir)/man/man5/keepalived.conf.5
- rm -f $(DESTDIR)$(mandir)/man/man8/keepalived.8
+ rm -f $(DESTDIR)$(mandir)/man5/keepalived.conf.5
+ rm -f $(DESTDIR)$(mandir)/man8/keepalived.8
install:
install -d $(DESTDIR)$(sbindir)
@@ -99,7 +99,7 @@
install -d $(DESTDIR)$(init_dir)
install -m 755 etc/init.d/keepalived.init $(DESTDIR)$(init_dir)/keepalived
install -d $(DESTDIR)$(sysconf_dir)
- install -m 755 etc/init.d/keepalived.sysconfig $(DESTDIR)$(sysconf_dir)/keepalived
+ install -m 644 etc/init.d/keepalived.sysconfig $(DESTDIR)$(sysconf_dir)/keepalived
install -d $(DESTDIR)$(sysconfdir)/keepalived/samples
install -m 644 etc/keepalived/keepalived.conf $(DESTDIR)$(sysconfdir)/keepalived/
install -m 644 ../doc/samples/* $(DESTDIR)$(sysconfdir)/keepalived/samples/
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/check/Makefile.in
^
|
@@ -9,7 +9,7 @@
INCLUDES = -I../include -I../../lib
CFLAGS = @CFLAGS@ @CPPFLAGS@ $(INCLUDES) \
-Wall -Wunused -Wstrict-prototypes
-DEFS = -D@KERN@ -D@IPVS_SUPPORT@ -D@IPVS_SYNCD@ -D@VRRP_SUPPORT@ -D@SNMP_SUPPORT@ @DFLAGS@
+DEFS = -D@KERN@ -D@IPVS_SUPPORT@ -D@IPVS_SYNCD@ -D@VRRP_SUPPORT@ -D@SNMP_SUPPORT@ -D@SO_MARK_SUPPORT@ @DFLAGS@
COMPILE = $(CC) $(CFLAGS) $(DEFS)
OBJS = check_daemon.o check_data.o check_parser.o \
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/check/check_api.c
^
|
@@ -52,30 +52,50 @@
dump_checker(void *data)
{
checker_t *checker = data;
- log_message(LOG_INFO, " [%s]:%d"
- , inet_sockaddrtos(&checker->rs->addr)
- , ntohs(inet_sockaddrport(&checker->rs->addr)));
+ log_message(LOG_INFO, " %s", FMT_CHK(checker));
(*checker->dump_func) (checker);
}
+void
+dump_conn_opts (conn_opts_t *conn)
+{
+ log_message(LOG_INFO, " Connection dest = %s", inet_sockaddrtopair(&conn->dst));
+ if (conn->bindto.ss_family)
+ log_message(LOG_INFO, " Bind to = %s", inet_sockaddrtopair(&conn->bindto));
+#ifdef _WITH_SO_MARK_
+ if (conn->fwmark != 0)
+ log_message(LOG_INFO, " Connection mark = %u", conn->fwmark);
+#endif
+ log_message(LOG_INFO, " Connection timeout = %d", conn->connection_to/TIMER_HZ);
+}
+
/* Queue a checker into the checkers_queue */
void
queue_checker(void (*free_func) (void *), void (*dump_func) (void *)
, int (*launch) (thread_t *)
- , void *data)
+ , void *data
+ , conn_opts_t *co)
{
virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
real_server_t *rs = LIST_TAIL_DATA(vs->rs);
checker_t *checker = (checker_t *) MALLOC(sizeof (checker_t));
+ /* Set default dst = RS, timeout = 5 */
+ if (co) {
+ co->dst = rs->addr;
+ co->connection_to = 5 * TIMER_HZ;
+ }
+
checker->free_func = free_func;
checker->dump_func = dump_func;
checker->launch = launch;
checker->vs = vs;
checker->rs = rs;
checker->data = data;
+ checker->co = co;
checker->id = ncheckers++;
checker->enabled = (vs->vfwmark) ? 1 : 0;
+ checker->warmup = vs->delay_loop;
#ifdef _WITHOUT_VRRP_
checker->enabled = 1;
#endif
@@ -114,6 +134,80 @@
}
}
+/* "connect_ip" keyword */
+static void
+co_ip_handler(vector_t *strvec)
+{
+ conn_opts_t *co = CHECKER_GET_CO();
+ inet_stosockaddr(vector_slot(strvec, 1), 0, &co->dst);
+}
+
+/* "connect_port" keyword */
+static void
+co_port_handler(vector_t *strvec)
+{
+ conn_opts_t *co = CHECKER_GET_CO();
+ checker_set_dst_port(&co->dst, htons(CHECKER_VALUE_INT(strvec)));
+}
+
+/* "bindto" keyword */
+static void
+co_srcip_handler(vector_t *strvec)
+{
+ conn_opts_t *co = CHECKER_GET_CO();
+ inet_stosockaddr(vector_slot(strvec, 1), 0, &co->bindto);
+}
+
+/* "bind_port" keyword */
+static void
+co_srcport_handler(vector_t *strvec)
+{
+ conn_opts_t *co = CHECKER_GET_CO();
+ checker_set_dst_port(&co->bindto, htons(CHECKER_VALUE_INT(strvec)));
+}
+
+/* "connect_timeout" keyword */
+static void
+co_timeout_handler(vector_t *strvec)
+{
+ conn_opts_t *co = CHECKER_GET_CO();
+ co->connection_to = CHECKER_VALUE_INT(strvec) * TIMER_HZ;
+
+ /* do not allow 0 timeout */
+ if (! co->connection_to)
+ co->connection_to = TIMER_HZ;
+}
+
+#ifdef _WITH_SO_MARK_
+/* "fwmark" keyword */
+static void
+co_fwmark_handler(vector_t *strvec)
+{
+ conn_opts_t *co = CHECKER_GET_CO();
+ co->fwmark = CHECKER_VALUE_INT(strvec);
+}
+#endif
+
+void
+install_connect_keywords(void)
+{
+ install_keyword("connect_ip", &co_ip_handler);
+ install_keyword("connect_port", &co_port_handler);
+ install_keyword("bindto", &co_srcip_handler);
+ install_keyword("bind_port", &co_srcport_handler);
+ install_keyword("connect_timeout", &co_timeout_handler);
+#ifdef _WITH_SO_MARK_
+ install_keyword("fwmark", &co_fwmark_handler);
+#endif
+}
+
+/* "warmup" keyword */
+void warmup_handler(vector_t *strvec)
+{
+ checker_t *checker = CHECKER_GET_CURRENT();
+ checker->warmup = (long)CHECKER_VALUE_INT (strvec) * TIMER_HZ;
+}
+
/* dump the checkers_queue */
void
dump_checkers_queue(void)
@@ -146,16 +240,25 @@
{
checker_t *checker;
element e;
+ long warmup;
for (e = LIST_HEAD(checkers_queue); e; ELEMENT_NEXT(e)) {
checker = ELEMENT_DATA(e);
- log_message(LOG_INFO, "Activating healthchecker for service [%s]:%d"
- , inet_sockaddrtos(&checker->rs->addr)
- , ntohs(inet_sockaddrport(&checker->rs->addr)));
+ log_message(LOG_INFO, "Activating healthchecker for service %s"
+ , FMT_CHK(checker));
CHECKER_ENABLE(checker);
if (checker->launch)
+ {
+ /* wait for a random timeout to begin checker thread.
+ It helps avoiding multiple simultaneous checks to
+ the same RS.
+ */
+ warmup = checker->warmup;
+ if (warmup)
+ warmup = warmup * rand() / RAND_MAX;
thread_add_timer(master, checker->launch, checker,
- BOOTSTRAP_DELAY);
+ BOOTSTRAP_DELAY + warmup);
+ }
}
}
@@ -194,13 +297,11 @@
if (inaddr_equal(family, addr, address) &&
CHECKER_HA_SUSPEND(checker)) {
if (!CHECKER_ENABLED(checker) && enable)
- log_message(LOG_INFO, "Activating healthchecker for service [%s]:%d"
- , inet_sockaddrtos(&checker->rs->addr)
- , ntohs(inet_sockaddrport(&checker->rs->addr)));
+ log_message(LOG_INFO, "Activating healthchecker for service %s"
+ , FMT_CHK(checker));
if (CHECKER_ENABLED(checker) && !enable)
- log_message(LOG_INFO, "Suspending healthchecker for service [%s]:%d"
- , inet_sockaddrtos(&checker->rs->addr)
- , ntohs(inet_sockaddrport(&checker->rs->addr)));
+ log_message(LOG_INFO, "Suspending healthchecker for service %s"
+ , FMT_CHK(checker));
checker->enabled = enable;
}
}
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/check/check_daemon.c
^
|
@@ -90,7 +90,10 @@
start_check(void)
{
/* Initialize sub-system */
- ipvs_start();
+ if (ipvs_start() != IPVS_SUCCESS) {
+ stop_check();
+ return;
+ }
init_checkers_queue();
#ifdef _WITH_VRRP_
init_interface_queue();
@@ -119,11 +122,15 @@
return;
}
+ /* fill 'vsg' members of the virtual_server_t structure.
+ * We must do that after parsing config, because
+ * vs and vsg declarations may appear in any order
+ */
+ link_vsg_to_vs();
+
/* Processing differential configuration parsing */
- if (reload) {
+ if (reload)
clear_diff_services();
- copy_srv_states();
- }
/* Initialize IPVS topology */
if (!init_services()) {
@@ -187,6 +194,9 @@
signal_handler_destroy();
/* Destroy master thread */
+#ifdef _WITH_VRRP_
+ kernel_netlink_close();
+#endif
thread_destroy_master(master);
master = thread_make_master();
free_global_data(global_data);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/check/check_data.c
^
|
@@ -101,7 +101,7 @@
virtual_server_group_entry_t *vsg_entry = data;
if (vsg_entry->vfwmark)
- log_message(LOG_INFO, " FWMARK = %d", vsg_entry->vfwmark);
+ log_message(LOG_INFO, " FWMARK = %u", vsg_entry->vfwmark);
else if (vsg_entry->range)
log_message(LOG_INFO, " VIP Range = %s-%d, VPORT = %d"
, inet_sockaddrtos(&vsg_entry->addr)
@@ -169,7 +169,7 @@
if (vs->vsgname)
log_message(LOG_INFO, " VS GROUP = %s", vs->vsgname);
else if (vs->vfwmark)
- log_message(LOG_INFO, " VS FWMARK = %d", vs->vfwmark);
+ log_message(LOG_INFO, " VS FWMARK = %u", vs->vfwmark);
else
log_message(LOG_INFO, " VIP = %s, VPORT = %d"
, inet_sockaddrtos(&vs->addr), ntohs(inet_sockaddrport(&vs->addr)));
@@ -214,9 +214,8 @@
}
if (vs->s_svr) {
- log_message(LOG_INFO, " sorry server = [%s]:%d"
- , inet_sockaddrtos(&vs->s_svr->addr)
- , ntohs(inet_sockaddrport(&vs->s_svr->addr)));
+ log_message(LOG_INFO, " sorry server = %s"
+ , FMT_RS(vs->s_svr));
}
if (!LIST_ISEMPTY(vs->rs))
dump_list(vs->rs);
@@ -356,3 +355,22 @@
}
dump_checkers_queue();
}
+
+char *
+format_vs (virtual_server_t *vs)
+{
+ /* alloc large buffer because of unknown length of vs->vsgname */
+ static char ret[512];
+
+ if (vs->vsgname)
+ snprintf (ret, sizeof (ret) - 1, "[%s]:%d"
+ , vs->vsgname
+ , ntohs(inet_sockaddrport(&vs->addr)));
+ else if (vs->vfwmark)
+ snprintf (ret, sizeof (ret) - 1, "FWM %u", vs->vfwmark);
+ else
+ snprintf(ret, sizeof(ret) - 1, "%s"
+ , inet_sockaddrtopair(&vs->addr));
+
+ return ret;
+}
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/check/check_http.c
^
|
@@ -64,6 +64,7 @@
free_list(http_get_chk->url);
FREE(http_get_chk->arg);
FREE(http_get_chk);
+ FREE(CHECKER_CO(data));
FREE(data);
}
@@ -76,11 +77,7 @@
log_message(LOG_INFO, " Keepalive method = HTTP_GET");
else
log_message(LOG_INFO, " Keepalive method = SSL_GET");
- log_message(LOG_INFO, " Connection port = %d", ntohs(inet_sockaddrport(&http_get_chk->dst)));
- if (http_get_chk->bindto.ss_family)
- log_message(LOG_INFO, " Bind to = %s", inet_sockaddrtos(&http_get_chk->bindto));
- log_message(LOG_INFO, " Connection timeout = %lu",
- http_get_chk->connection_to/TIMER_HZ);
+ dump_conn_opts (CHECKER_GET_CO());
log_message(LOG_INFO, " Nb get retry = %d", http_get_chk->nb_get_retry);
log_message(LOG_INFO, " Delay before retry = %lu",
http_get_chk->delay_before_retry/TIMER_HZ);
@@ -97,7 +94,6 @@
(!strcmp(proto, "HTTP_GET")) ? PROTO_HTTP : PROTO_SSL;
http_get_chk->url = alloc_list(free_url, dump_url);
http_get_chk->nb_get_retry = 1;
- http_get_chk->connection_to = 5 * TIMER_HZ;
http_get_chk->delay_before_retry = 3 * TIMER_HZ;
return http_get_chk;
@@ -111,32 +107,8 @@
/* queue new checker */
http_get_chk = alloc_http_get(str);
- checker_set_dst(&http_get_chk->dst);
queue_checker(free_http_get_check, dump_http_get_check,
- http_connect_thread, http_get_chk);
-}
-
-void
-connect_p_handler(vector_t *strvec)
-{
- http_checker_t *http_get_chk = CHECKER_GET();
- checker_set_dst_port(&http_get_chk->dst, htons(CHECKER_VALUE_INT(strvec)));
-}
-
-void
-bindto_handler(vector_t *strvec)
-{
- http_checker_t *http_get_chk = CHECKER_GET();
- inet_stosockaddr(vector_slot(strvec, 1), 0, &http_get_chk->bindto);
-}
-
-void
-connect_to_handler(vector_t *strvec)
-{
- http_checker_t *http_get_chk = CHECKER_GET();
- http_get_chk->connection_to = CHECKER_VALUE_INT(strvec) * TIMER_HZ;
- if (http_get_chk->connection_to < TIMER_HZ)
- http_get_chk->connection_to = TIMER_HZ;
+ http_connect_thread, http_get_chk, CHECKER_NEW_CO());
}
void
@@ -197,9 +169,8 @@
{
install_keyword("HTTP_GET", &http_get_handler);
install_sublevel();
- install_keyword("connect_port", &connect_p_handler);
- install_keyword("bindto", &bindto_handler);
- install_keyword("connect_timeout", &connect_to_handler);
+ install_connect_keywords();
+ install_keyword("warmup", &warmup_handler);
install_keyword("nb_get_retry", &nb_get_retry_handler);
install_keyword("delay_before_retry", &delay_before_retry_handler);
install_keyword("url", &url_handler);
@@ -217,9 +188,8 @@
{
install_keyword("SSL_GET", &http_get_handler);
install_sublevel();
- install_keyword("connect_port", &connect_p_handler);
- install_keyword("bindto", &bindto_handler);
- install_keyword("connect_timeout", &connect_to_handler);
+ install_connect_keywords();
+ install_keyword("warmup", &warmup_handler);
install_keyword("nb_get_retry", &nb_get_retry_handler);
install_keyword("delay_before_retry", &delay_before_retry_handler);
install_keyword("url", &url_handler);
@@ -287,9 +257,9 @@
*/
if (http->retry_it > http_get_check->nb_get_retry-1) {
if (svr_checker_up(checker->id, checker->rs)) {
- log_message(LOG_INFO, "Check on service [%s]:%d failed after %d retry."
- , inet_sockaddrtos(&http_get_check->dst)
- , ntohs(inet_sockaddrport(&http_get_check->dst)), http->retry_it);
+ log_message(LOG_INFO, "Check on service %s failed after %d retry."
+ , FMT_HTTP_RS(checker)
+ , http->retry_it);
smtp_alert(checker->rs, NULL, NULL,
"DOWN",
"=> CHECK failed on service"
@@ -341,15 +311,13 @@
timeout_epilog(thread_t * thread, char *smtp_msg, char *debug_msg)
{
checker_t *checker = THREAD_ARG(thread);
- http_checker_t *http_get_check = CHECKER_ARG(checker);
- log_message(LOG_INFO, "Timeout %s server [%s]:%d."
- , debug_msg
- , inet_sockaddrtos(&http_get_check->dst)
- , ntohs(inet_sockaddrport(&http_get_check->dst)));
/* check if server is currently alive */
if (svr_checker_up(checker->id, checker->rs)) {
+ log_message(LOG_INFO, "Timeout %s server %s."
+ , debug_msg
+ , FMT_HTTP_RS(checker));
smtp_alert(checker->rs, NULL, NULL,
"DOWN", smtp_msg);
update_svr_checker_state(DOWN, checker->id
@@ -399,10 +367,9 @@
/* check if server is currently alive */
if (svr_checker_up(checker->id, checker->rs)) {
log_message(LOG_INFO,
- "HTTP status code error to [%s]:%d url(%s)"
+ "HTTP status code error to %s url(%s)"
", status_code [%d].",
- inet_sockaddrtos(&http_get_check->dst),
- ntohs(inet_sockaddrport(&http_get_check->dst)),
+ FMT_HTTP_RS(checker),
fetched_url->path,
req->status_code);
smtp_alert(checker->rs, NULL, NULL,
@@ -413,9 +380,8 @@
, checker->vs
, checker->rs);
} else {
- DBG("HTTP Status_code to [%s]:%d url(%d) = [%d]."
- , inet_sockaddrtos(&http_get_check->dst)
- , ntohs(inet_sockaddrport(&http_get_check->dst))
+ DBG("HTTP Status_code to %s url(%d) = [%d]."
+ , FMT_HTTP_RS(checker)
, http->url_it + 1
, req->status_code);
/*
@@ -443,10 +409,9 @@
/* check if server is currently alive */
if (svr_checker_up(checker->id, checker->rs)) {
log_message(LOG_INFO,
- "MD5 digest error to [%s]:%d url[%s]"
+ "MD5 digest error to %s url[%s]"
", MD5SUM [%s].",
- inet_sockaddrtos(&http_get_check->dst),
- ntohs(inet_sockaddrport(&http_get_check->dst)),
+ FMT_HTTP_RS(checker),
fetched_url->path,
digest_tmp);
smtp_alert(checker->rs, NULL, NULL,
@@ -457,9 +422,8 @@
, checker->vs
, checker->rs);
} else {
- DBG("MD5SUM to [%s]:%d url(%d) = [%s]."
- , inet_sockaddrtos(&http_get_check->dst)
- , ntohs(inet_sockaddrport(&http_get_check->dst))
+ DBG("MD5SUM to %s url(%d) = [%s]."
+ , FMT_HTTP_RS(checker)
, http->url_it + 1
, digest_tmp);
/*
@@ -482,16 +446,14 @@
break;
case on_status:
log_message(LOG_INFO,
- "HTTP status code success to [%s]:%d url(%d)."
- , inet_sockaddrtos(&http_get_check->dst)
- , ntohs(inet_sockaddrport(&http_get_check->dst))
+ "HTTP status code success to %s url(%d)."
+ , FMT_HTTP_RS(checker)
, http->url_it + 1);
return epilog(thread, 1, 1, 0) + 1;
case on_digest:
if (!svr_checker_up(checker->id, checker->rs))
- log_message(LOG_INFO, "MD5 digest success to [%s]:%d url(%d)."
- , inet_sockaddrtos(&http_get_check->dst)
- , ntohs(inet_sockaddrport(&http_get_check->dst))
+ log_message(LOG_INFO, "MD5 digest success to %s url(%d)."
+ , FMT_HTTP_RS(checker)
, http->url_it + 1);
return epilog(thread, 1, 1, 0) + 1;
}
@@ -534,6 +496,7 @@
http_checker_t *http_get_check = CHECKER_ARG(checker);
http_t *http = HTTP_ARG(http_get_check);
request_t *req = HTTP_REQ(http);
+ unsigned timeout = checker->co->connection_to;
unsigned char digest[16];
int r = 0;
int val;
@@ -556,12 +519,11 @@
/* Test if data are ready */
if (r == -1 && (errno == EAGAIN || errno == EINTR)) {
- log_message(LOG_INFO, "Read error with server [%s]:%d: %s"
- , inet_sockaddrtos(&http_get_check->dst)
- , ntohs(inet_sockaddrport(&http_get_check->dst))
+ log_message(LOG_INFO, "Read error with server %s: %s"
+ , FMT_HTTP_RS(checker)
, strerror(errno));
thread_add_read(thread->master, http_read_thread, checker,
- thread->u.fd, http_get_check->connection_to);
+ thread->u.fd, timeout);
return 0;
}
@@ -573,9 +535,8 @@
if (r == -1) {
/* We have encourred a real read error */
if (svr_checker_up(checker->id, checker->rs)) {
- log_message(LOG_INFO, "Read error with server [%s]:%d: %s"
- , inet_sockaddrtos(&http_get_check->dst)
- , ntohs(inet_sockaddrport(&http_get_check->dst))
+ log_message(LOG_INFO, "Read error with server %s: %s"
+ , FMT_HTTP_RS(checker)
, strerror(errno));
smtp_alert(checker->rs, NULL, NULL,
"DOWN",
@@ -601,7 +562,7 @@
* Register itself to not perturbe global I/O multiplexer.
*/
thread_add_read(thread->master, http_read_thread, checker,
- thread->u.fd, http_get_check->connection_to);
+ thread->u.fd, timeout);
}
return 0;
@@ -618,6 +579,7 @@
http_checker_t *http_get_check = CHECKER_ARG(checker);
http_t *http = HTTP_ARG(http_get_check);
request_t *req = HTTP_REQ(http);
+ unsigned timeout = checker->co->connection_to;
/* Handle read timeout */
if (thread->type == THREAD_READ_TIMEOUT)
@@ -634,10 +596,10 @@
/* Register asynchronous http/ssl read thread */
if (http_get_check->proto == PROTO_SSL)
thread_add_read(thread->master, ssl_read_thread, checker,
- thread->u.fd, http_get_check->connection_to);
+ thread->u.fd, timeout);
else
thread_add_read(thread->master, http_read_thread, checker,
- thread->u.fd, http_get_check->connection_to);
+ thread->u.fd, timeout);
return 0;
}
@@ -649,7 +611,8 @@
http_checker_t *http_get_check = CHECKER_ARG(checker);
http_t *http = HTTP_ARG(http_get_check);
request_t *req = HTTP_REQ(http);
- struct sockaddr_storage *addr = &http_get_check->dst;
+ struct sockaddr_storage *addr = &checker->co->dst;
+ unsigned timeout = checker->co->connection_to;
char *vhost = CHECKER_VHOST(checker);
char *request_host = 0;
char *request_host_port = 0;
@@ -668,19 +631,19 @@
str_request = (char *) MALLOC(GET_BUFFER_LENGTH);
fetched_url = fetch_next_url(http_get_check);
-
+
if (vhost) {
/* If vhost was defined we don't need to override it's port */
request_host = vhost;
request_host_port = (char*) MALLOC(1);
*request_host_port = 0;
} else {
- request_host = inet_sockaddrtos(&http_get_check->dst);
-
+ request_host = inet_sockaddrtos(addr);
+
/* Allocate a buffer for the port string ( ":" [0-9][0-9][0-9][0-9][0-9] "\0" ) */
request_host_port = (char*) MALLOC(7);
snprintf(request_host_port, 7, ":%d",
- ntohs(inet_sockaddrport(&http_get_check->dst)));
+ ntohs(inet_sockaddrport(addr)));
}
if(addr->ss_family == AF_INET6 && !vhost){
@@ -693,11 +656,10 @@
}
FREE(request_host_port);
-
- DBG("Processing url(%d) of [%s]:%d.",
+
+ DBG("Processing url(%d) of %s.",
http->url_it + 1
- , inet_sockaddrtos(&http_get_check->dst)
- , ntohs(inet_sockaddrport(&http_get_check->dst)));
+ , FMT_HTTP_RS(checker));
/* Set descriptor non blocking */
val = fcntl(thread->u.fd, F_GETFL, 0);
@@ -718,9 +680,8 @@
FREE(str_request);
if (!ret) {
- log_message(LOG_INFO, "Cannot send get request to [%s]:%d."
- , inet_sockaddrtos(&http_get_check->dst)
- , ntohs(inet_sockaddrport(&http_get_check->dst)));
+ log_message(LOG_INFO, "Cannot send get request to %s."
+ , FMT_HTTP_RS(checker));
/* check if server is currently alive */
if (svr_checker_up(checker->id, checker->rs)) {
@@ -737,7 +698,7 @@
/* Register read timeouted thread */
thread_add_read(thread->master, http_response_thread, checker,
- thread->u.fd, http_get_check->connection_to);
+ thread->u.fd, timeout);
return 1;
}
@@ -762,9 +723,8 @@
case connect_error:
/* check if server is currently alive */
if (svr_checker_up(checker->id, checker->rs)) {
- log_message(LOG_INFO, "Error connecting server [%s]:%d."
- , inet_sockaddrtos(&http_get_check->dst)
- , ntohs(inet_sockaddrport(&http_get_check->dst)));
+ log_message(LOG_INFO, "Error connecting server %s."
+ , FMT_HTTP_RS(checker));
smtp_alert(checker->rs, NULL, NULL,
"DOWN",
"=> CHECK failed on service"
@@ -829,17 +789,14 @@
/* Remote WEB server is connected.
* Register the next step thread ssl_request_thread.
*/
- DBG("Remote Web server [%s]:%d connected."
- , inet_sockaddrtos(&http_get_check->dst)
- , ntohs(inet_sockaddrport(&http_get_check->dst)));
+ DBG("Remote Web server %s connected.", FMT_HTTP_RS(checker));
thread_add_write(thread->master,
http_request_thread, checker,
thread->u.fd,
- http_get_check->connection_to);
+ checker->co->connection_to);
} else {
- DBG("Connection trouble to: [%s]:%d."
- , inet_sockaddrtos(&http_get_check->dst)
- , ntohs(inet_sockaddrport(&http_get_check->dst)));
+ DBG("Connection trouble to: %s."
+ , FMT_HTTP_RS(checker));
#ifdef _DEBUG_
if (http_get_check->proto == PROTO_SSL)
ssl_printerr(SSL_get_error
@@ -849,10 +806,9 @@
(svr_checker_up(checker->id, checker->rs))) {
log_message(LOG_INFO, "SSL handshake/communication error"
" connecting to server"
- " (openssl errno: %d) [%s]:%d."
+ " (openssl errno: %d) %s."
, SSL_get_error (http->req->ssl, ret)
- , inet_sockaddrtos(&http_get_check->dst)
- , ntohs(inet_sockaddrport(&http_get_check->dst)));
+ , FMT_HTTP_RS(checker));
smtp_alert(checker->rs, NULL, NULL,
"DOWN",
"=> CHECK failed on service"
@@ -877,6 +833,7 @@
checker_t *checker = THREAD_ARG(thread);
http_checker_t *http_get_check = CHECKER_ARG(checker);
http_t *http = HTTP_ARG(http_get_check);
+ conn_opts_t *co = checker->co;
url_t *fetched_url;
enum connect_result status;
int fd;
@@ -900,9 +857,8 @@
* check if server is currently alive.
*/
if (!svr_checker_up(checker->id, checker->rs)) {
- log_message(LOG_INFO, "Remote Web server [%s]:%d succeed on service."
- , inet_sockaddrtos(&http_get_check->dst)
- , ntohs(inet_sockaddrport(&http_get_check->dst)));
+ log_message(LOG_INFO, "Remote Web server %s succeed on service."
+ , FMT_HTTP_RS(checker));
smtp_alert(checker->rs, NULL, NULL, "UP",
"=> CHECK succeed on service <=");
update_svr_checker_state(UP, checker->id
@@ -914,19 +870,19 @@
}
/* Create the socket */
- if ((fd = socket(http_get_check->dst.ss_family, SOCK_STREAM, IPPROTO_TCP)) == -1) {
+ if ((fd = socket(co->dst.ss_family, SOCK_STREAM, IPPROTO_TCP)) == -1) {
log_message(LOG_INFO, "WEB connection fail to create socket. Rescheduling.");
thread_add_timer(thread->master, http_connect_thread, checker,
checker->vs->delay_loop);
-
+
return 0;
}
- status = tcp_bind_connect(fd, &http_get_check->dst, &http_get_check->bindto);
+ status = tcp_bind_connect(fd, co);
/* handle tcp connection status & register check worker thread */
if(tcp_connection_state(fd, status, thread, http_check_thread,
- http_get_check->connection_to)) {
+ co->connection_to)) {
close(fd);
log_message(LOG_INFO, "WEB socket bind failed. Rescheduling");
thread_add_timer(thread->master, http_connect_thread, checker,
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/check/check_misc.c
^
|
@@ -67,7 +67,7 @@
/* queue new checker */
queue_checker(free_misc_check, dump_misc_check, misc_check_thread,
- misck_checker);
+ misck_checker, NULL);
}
void
@@ -99,6 +99,7 @@
install_keyword("misc_path", &misc_path_handler);
install_keyword("misc_timeout", &misc_timeout_handler);
install_keyword("misc_dynamic", &misc_dynamic_handler);
+ install_keyword("warmup", &warmup_handler);
install_sublevel_end();
}
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/check/check_parser.c
^
|
@@ -169,6 +169,16 @@
{
alloc_ssvr(vector_slot(strvec, 1), vector_slot(strvec, 2));
}
+static void
+ssvri_handler(vector_t *strvec)
+{
+ virtual_server_t *vs = LIST_TAIL_DATA(check_data->vs);
+ if (vs->s_svr) {
+ vs->s_svr->inhibit = 1;
+ } else {
+ log_message(LOG_ERR, "Ignoring sorry_server_inhibit used before or without sorry_server");
+ }
+}
/* Real Servers handlers */
static void
@@ -312,6 +322,7 @@
/* Real server mapping */
install_keyword("sorry_server", &ssvr_handler);
+ install_keyword("sorry_server_inhibit", &ssvri_handler);
install_keyword("real_server", &rs_handler);
install_sublevel();
install_keyword("weight", &weight_handler);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/check/check_smtp.c
^
|
@@ -68,11 +68,7 @@
void
smtp_dump_host(void *data)
{
- smtp_host_t *smtp_host = data;
- log_message(LOG_INFO, " Checked ip = %s", inet_sockaddrtos(&smtp_host->dst));
- log_message(LOG_INFO, " port = %d", ntohs(inet_sockaddrport(&smtp_host->dst)));
- if (smtp_host->bindto.ss_family)
- log_message(LOG_INFO, " bindto = %s", inet_sockaddrtos(&smtp_host->bindto));
+ dump_conn_opts (data);
}
/*
@@ -96,6 +92,7 @@
smtp_alloc_host(void)
{
smtp_host_t *new;
+ smtp_checker_t *smtp_checker = CHECKER_GET();
/* Allocate the new host data structure */
new = (smtp_host_t *)MALLOC(sizeof(smtp_host_t));
@@ -106,6 +103,7 @@
*/
checker_set_dst(&new->dst);
checker_set_dst_port(&new->dst, htons(SMTP_DEFAULT_PORT));
+ new->connection_to = smtp_checker->timeout;
return new;
}
@@ -136,10 +134,10 @@
*
* queue_checker(void (*free) (void *), void (*dump) (void *),
* int (*launch) (thread_t *),
- * void *data)
+ * void *data, conn_opts_t *)
*/
queue_checker(free_smtp_check, dump_smtp_check, smtp_connect_thread,
- smtp_checker);
+ smtp_checker, NULL);
/*
* Last, allocate/setup the list that will hold all the per host
@@ -182,24 +180,6 @@
list_add(smtp_checker->host, smtp_alloc_host());
}
-/* "connect_ip" keyword */
-void
-smtp_ip_handler(vector_t *strvec)
-{
- smtp_checker_t *smtp_checker = CHECKER_GET();
- smtp_host_t *smtp_host = LIST_TAIL_DATA(smtp_checker->host);
- inet_stosockaddr(vector_slot(strvec, 1), NULL, &smtp_host->dst);
-}
-
-/* "connect_port" keyword */
-void
-smtp_port_handler(vector_t *strvec)
-{
- smtp_checker_t *smtp_checker = CHECKER_GET();
- smtp_host_t *smtp_host = LIST_TAIL_DATA(smtp_checker->host);
- checker_set_dst_port(&smtp_host->dst, htons(CHECKER_VALUE_INT(strvec)));
-}
-
/* "helo_name" keyword */
void
smtp_helo_name_handler(vector_t *strvec)
@@ -234,15 +214,6 @@
smtp_checker->db_retry = CHECKER_VALUE_INT(strvec) * TIMER_HZ;
}
-/* "bindto" keyword */
-void
-smtp_bindto_handler(vector_t *strvec)
-{
- smtp_checker_t *smtp_checker = CHECKER_GET();
- smtp_host_t *smtp_host = LIST_TAIL_DATA(smtp_checker->host);
- inet_stosockaddr(vector_slot(strvec, 1), 0, &smtp_host->bindto);
-}
-
/* Config callback installer */
void
install_smtp_check_keyword(void)
@@ -255,14 +226,17 @@
install_keyword("SMTP_CHECK", &smtp_check_handler);
install_sublevel();
install_keyword("helo_name", &smtp_helo_name_handler);
+
+ /* This is kept for backward compatibility.
+ Used as default value for per-host timeout */
install_keyword("connect_timeout", &smtp_timeout_handler);
+
+ install_keyword("warmup", &warmup_handler);
install_keyword("delay_before_retry", &smtp_db_retry_handler);
install_keyword("retry", &smtp_retry_handler);
install_keyword("host", &smtp_host_handler);
install_sublevel();
- install_keyword("connect_ip", &smtp_ip_handler);
- install_keyword("connect_port", &smtp_port_handler);
- install_keyword("bindto", &smtp_bindto_handler);
+ install_connect_keywords();
install_sublevel_end();
install_sublevel_end();
}
@@ -291,13 +265,14 @@
/* Always syslog the error when the real server is up */
if (svr_checker_up(checker->id, checker->rs)) {
if (format != NULL) {
- memcpy(error_buff, "SMTP_CHECK ", 11);
+ /* prepend format with the "SMTP_CHECK " string */
+ error_buff[0] = '\0';
+ strncat(error_buff, "SMTP_CHECK ", sizeof(error_buff) - 1);
+ strncat(error_buff, format, sizeof(error_buff) - 11 - 1);
+
va_start(varg_list, format);
- vsnprintf(error_buff + 11, 512 - 11, format, varg_list);
+ log_message(LOG_INFO, error_buff, varg_list);
va_end(varg_list);
- error_buff[512 - 1] = '\0';
-
- log_message(LOG_INFO, error_buff);
} else {
log_message(LOG_INFO, "SMTP_CHECK Unknown error");
}
@@ -384,18 +359,16 @@
/* Handle read timeout */
if (thread->type == THREAD_READ_TIMEOUT) {
- smtp_final(thread, 1, "Read timeout from server [%s]:%d"
- , inet_sockaddrtos(&smtp_host->dst)
- , ntohs(inet_sockaddrport(&smtp_host->dst)));
+ smtp_final(thread, 1, "Read timeout from server %s"
+ , FMT_SMTP_RS(smtp_host));
return 0;
}
/* wrap the buffer, if full, by clearing it */
if (SMTP_BUFF_MAX - smtp_checker->buff_ctr <= 0) {
- log_message(LOG_INFO, "SMTP_CHECK Buffer overflow reading from server [%s]:%d. "
+ log_message(LOG_INFO, "SMTP_CHECK Buffer overflow reading from server %s. "
"Increase SMTP_BUFF_MAX in smtp_check.h"
- , inet_sockaddrtos(&smtp_host->dst)
- , ntohs(inet_sockaddrport(&smtp_host->dst)));
+ , FMT_SMTP_RS(smtp_host));
smtp_clear_buff(thread);
}
@@ -409,7 +382,7 @@
if (r == -1 && (errno == EAGAIN || errno == EINTR)) {
thread_add_read(thread->master, smtp_get_line_cb, checker,
- thread->u.fd, smtp_checker->timeout);
+ thread->u.fd, smtp_host->connection_to);
fcntl(thread->u.fd, F_SETFL, f);
return 0;
} else if (r > 0)
@@ -422,10 +395,9 @@
for (x = 0; x < SMTP_BUFF_MAX; x++) {
if (smtp_checker->buff[x] == '\n') {
smtp_checker->buff[SMTP_BUFF_MAX - 1] = '\0';
-
- DBG("SMTP_CHECK [%s]:%d < %s"
- , inet_sockaddrtos(&smtp_host->dst)
- , ntohs(inet_sockaddrport(&smtp_host->dst))
+
+ DBG("SMTP_CHECK %s < %s"
+ , FMT_SMTP_RS(smtp_host)
, smtp_checker->buff);
(smtp_checker->buff_cb)(thread);
@@ -439,9 +411,8 @@
* some sort of error, notify smtp_final()
*/
if (r <= 0) {
- smtp_final(thread, 1, "Read failure from server [%s]:%d"
- , inet_sockaddrtos(&smtp_host->dst)
- , ntohs(inet_sockaddrport(&smtp_host->dst)));
+ smtp_final(thread, 1, "Read failure from server %s"
+ , FMT_SMTP_RS(smtp_host));
return 0;
}
@@ -451,7 +422,7 @@
* another round.
*/
thread_add_read(thread->master, smtp_get_line_cb, checker,
- thread->u.fd, smtp_checker->timeout);
+ thread->u.fd, smtp_host->connection_to);
return 0;
}
@@ -469,6 +440,7 @@
{
checker_t *checker = THREAD_ARG(thread);
smtp_checker_t *smtp_checker = CHECKER_ARG(checker);
+ smtp_host_t *smtp_host = smtp_checker->host_ptr;
/* clear the buffer */
smtp_clear_buff(thread);
@@ -478,7 +450,7 @@
/* schedule the I/O with our helper function */
thread_add_read(thread->master, smtp_get_line_cb, checker,
- thread->u.fd, smtp_checker->timeout);
+ thread->u.fd, smtp_host->connection_to);
return;
}
@@ -499,9 +471,8 @@
/* Handle read timeout */
if (thread->type == THREAD_WRITE_TIMEOUT) {
- smtp_final(thread, 1, "Write timeout to server [%s]:%d"
- , inet_sockaddrtos(&smtp_host->dst)
- , ntohs(inet_sockaddrport(&smtp_host->dst)));
+ smtp_final(thread, 1, "Write timeout to server %s"
+ , FMT_SMTP_RS(smtp_host));
return 0;
}
@@ -514,7 +485,7 @@
if (w == -1 && (errno == EAGAIN || errno == EINTR)) {
thread_add_write(thread->master, smtp_put_line_cb, checker,
- thread->u.fd, smtp_checker->timeout);
+ thread->u.fd, smtp_host->connection_to);
fcntl(thread->u.fd, F_SETFL, f);
return 0;
}
@@ -522,9 +493,8 @@
/* restore descriptor flags */
fcntl(thread->u.fd, F_SETFL, f);
- DBG("SMTP_CHECK [%s]:%d > %s"
- , inet_sockaddrtos(&smtp_host->dst)
- , ntohs(inet_sockaddrport(&smtp_host->dst))
+ DBG("SMTP_CHECK %s > %s"
+ , FMT_SMTP_RS(smtp_host)
, smtp_checker->buff);
/*
@@ -532,9 +502,8 @@
* some sort of error, notify smtp_final()
*/
if (w <= 0) {
- smtp_final(thread, 1, "Write failure to server [%s]:%d"
- , inet_sockaddrtos(&smtp_host->dst)
- , ntohs(inet_sockaddrport(&smtp_host->dst)));
+ smtp_final(thread, 1, "Write failure to server %s"
+ , FMT_SMTP_RS(smtp_host));
return 0;
}
@@ -552,6 +521,7 @@
{
checker_t *checker = THREAD_ARG(thread);
smtp_checker_t *smtp_checker = CHECKER_ARG(checker);
+ smtp_host_t *smtp_host = smtp_checker->host_ptr;
smtp_checker->buff[SMTP_BUFF_MAX - 1] = '\0';
smtp_checker->buff_ctr = strlen(smtp_checker->buff);
@@ -561,7 +531,7 @@
/* schedule the I/O with our helper function */
thread_add_write(thread->master, smtp_put_line_cb, checker,
- thread->u.fd, smtp_checker->timeout);
+ thread->u.fd, smtp_host->connection_to);
return;
}
@@ -620,9 +590,8 @@
case SMTP_HAVE_BANNER:
/* Check for "220 some.mailserver.com" in the greeting */
if (smtp_get_status(thread) != 220) {
- smtp_final(thread, 1, "Bad greeting banner from server [%s]:%d"
- , inet_sockaddrtos(&smtp_host->dst)
- , ntohs(inet_sockaddrport(&smtp_host->dst)));
+ smtp_final(thread, 1, "Bad greeting banner from server %s"
+ , FMT_SMTP_RS(smtp_host));
return 0;
}
@@ -649,9 +618,8 @@
case SMTP_RECV_HELO:
/* Check for "250 Please to meet you..." */
if (smtp_get_status(thread) != 250) {
- smtp_final(thread, 1, "Bad HELO response from server [%s]:%d"
- , inet_sockaddrtos(&smtp_host->dst)
- , ntohs(inet_sockaddrport(&smtp_host->dst)));
+ smtp_final(thread, 1, "Bad HELO response from server %s"
+ , FMT_SMTP_RS(smtp_host));
return 0;
}
@@ -696,23 +664,20 @@
status = tcp_socket_state(thread->u.fd, thread, smtp_check_thread);
switch (status) {
case connect_error:
- smtp_final(thread, 1, "Error connecting to server [%s]:%d"
- , inet_sockaddrtos(&smtp_host->dst)
- , ntohs(inet_sockaddrport(&smtp_host->dst)));
+ smtp_final(thread, 1, "Error connecting to server %s"
+ , FMT_SMTP_RS(smtp_host));
return 0;
break;
case connect_timeout:
- smtp_final(thread, 1, "Connection timeout to server [%s]:%d"
- , inet_sockaddrtos(&smtp_host->dst)
- , ntohs(inet_sockaddrport(&smtp_host->dst)));
+ smtp_final(thread, 1, "Connection timeout to server %s"
+ , FMT_SMTP_RS(smtp_host));
return 0;
break;
case connect_success:
- DBG("SMTP_CHECK Remote SMTP server [%s]:%d connected"
- , inet_sockaddrtos(&smtp_host->dst)
- , ntohs(inet_sockaddrport(&smtp_host->dst)));
+ DBG("SMTP_CHECK Remote SMTP server %s connected"
+ , FMT_SMTP_RS(smtp_host));
/* Enter the engine at SMTP_START */
smtp_checker->state = SMTP_START;
@@ -722,9 +687,8 @@
}
/* we shouldn't be here */
- smtp_final(thread, 1, "Unknown connection error to server [%s]:%d"
- , inet_sockaddrtos(&smtp_host->dst)
- , ntohs(inet_sockaddrport(&smtp_host->dst)));
+ smtp_final(thread, 1, "Unknown connection error to server %s"
+ , FMT_SMTP_RS(smtp_host));
return 0;
}
@@ -792,9 +756,8 @@
*/
if ((smtp_checker->host_ptr = list_element(smtp_checker->host, smtp_checker->host_ctr)) == NULL) {
if (!svr_checker_up(checker->id, checker->rs)) {
- log_message(LOG_INFO, "Remote SMTP server [%s]:%d succeed on service."
- , inet_sockaddrtos(&checker->rs->addr)
- , ntohs(inet_sockaddrport(&checker->rs->addr)));
+ log_message(LOG_INFO, "Remote SMTP server %s succeed on service."
+ , FMT_CHK(checker));
smtp_alert(checker->rs, NULL, NULL, "UP",
"=> CHECK succeed on service <=");
@@ -819,10 +782,10 @@
return 0;
}
- status = tcp_bind_connect(sd, &smtp_host->dst, &smtp_host->bindto);
+ status = tcp_bind_connect(sd, smtp_host);
/* handle tcp connection status & register callback the next setp in the process */
- if(tcp_connection_state(sd, status, thread, smtp_check_thread, smtp_checker->timeout)) {
+ if(tcp_connection_state(sd, status, thread, smtp_check_thread, smtp_host->connection_to)) {
close(sd);
log_message(LOG_INFO, "SMTP_CHECK socket bind failed. Rescheduling.");
thread_add_timer(thread->master, smtp_connect_thread, checker,
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/check/check_ssl.c
^
|
@@ -244,6 +244,7 @@
http_checker_t *http_get_check = CHECKER_ARG(checker);
http_t *http = HTTP_ARG(http_get_check);
request_t *req = HTTP_REQ(http);
+ unsigned timeout = checker->co->connection_to;
unsigned char digest[16];
int r = 0;
int val;
@@ -269,7 +270,7 @@
if (req->error == SSL_ERROR_WANT_READ) {
/* async read unfinished */
thread_add_read(thread->master, ssl_read_thread, checker,
- thread->u.fd, http_get_check->connection_to);
+ thread->u.fd, timeout);
} else if (r > 0 && req->error == 0) {
/* Handle response stream */
http_process_response(req, r);
@@ -279,7 +280,7 @@
* Register itself to not perturbe global I/O multiplexer.
*/
thread_add_read(thread->master, ssl_read_thread, checker,
- thread->u.fd, http_get_check->connection_to);
+ thread->u.fd, timeout);
} else if (req->error) {
/* All the SSL streal has been parsed */
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/check/check_tcp.c
^
|
@@ -36,54 +36,22 @@
void
free_tcp_check(void *data)
{
- tcp_checker_t *tcp_chk = CHECKER_DATA(data);
-
- FREE(tcp_chk);
+ FREE(CHECKER_CO(data));
FREE(data);
}
void
dump_tcp_check(void *data)
{
- tcp_checker_t *tcp_chk = CHECKER_DATA(data);
-
log_message(LOG_INFO, " Keepalive method = TCP_CHECK");
- log_message(LOG_INFO, " Connection port = %d", ntohs(inet_sockaddrport(&tcp_chk->dst)));
- if (tcp_chk->bindto.ss_family)
- log_message(LOG_INFO, " Bind to = %s", inet_sockaddrtos(&tcp_chk->bindto));
- log_message(LOG_INFO, " Connection timeout = %d", tcp_chk->connection_to/TIMER_HZ);
+ dump_conn_opts (CHECKER_GET_CO());
}
void
tcp_check_handler(vector_t *strvec)
{
- tcp_checker_t *tcp_chk = (tcp_checker_t *) MALLOC(sizeof (tcp_checker_t));
-
/* queue new checker */
- checker_set_dst(&tcp_chk->dst);
- queue_checker(free_tcp_check, dump_tcp_check, tcp_connect_thread, tcp_chk);
-}
-
-void
-connect_port_handler(vector_t *strvec)
-{
- tcp_checker_t *tcp_chk = CHECKER_GET();
-
- checker_set_dst_port(&tcp_chk->dst, htons(CHECKER_VALUE_INT(strvec)));
-}
-
-void
-bind_handler(vector_t *strvec)
-{
- tcp_checker_t *tcp_chk = CHECKER_GET();
- inet_stosockaddr(vector_slot(strvec, 1), 0, &tcp_chk->bindto);
-}
-
-void
-connect_timeout_handler(vector_t *strvec)
-{
- tcp_checker_t *tcp_chk = CHECKER_GET();
- tcp_chk->connection_to = CHECKER_VALUE_INT(strvec) * TIMER_HZ;
+ queue_checker(free_tcp_check, dump_tcp_check, tcp_connect_thread, NULL, CHECKER_NEW_CO());
}
void
@@ -91,9 +59,8 @@
{
install_keyword("TCP_CHECK", &tcp_check_handler);
install_sublevel();
- install_keyword("connect_port", &connect_port_handler);
- install_keyword("bindto", &bind_handler);
- install_keyword("connect_timeout", &connect_timeout_handler);
+ install_connect_keywords();
+ install_keyword("warmup", &warmup_handler);
install_sublevel_end();
}
@@ -101,11 +68,9 @@
tcp_check_thread(thread_t * thread)
{
checker_t *checker;
- tcp_checker_t *tcp_check;
int status;
checker = THREAD_ARG(thread);
- tcp_check = CHECKER_ARG(checker);
status = tcp_socket_state(thread->u.fd, thread, tcp_check_thread);
@@ -116,9 +81,8 @@
close(thread->u.fd);
if (!svr_checker_up(checker->id, checker->rs)) {
- log_message(LOG_INFO, "TCP connection to [%s]:%d success."
- , inet_sockaddrtos(&tcp_check->dst)
- , ntohs(inet_sockaddrport(&tcp_check->dst)));
+ log_message(LOG_INFO, "TCP connection to %s success."
+ , FMT_TCP_RS(checker));
smtp_alert(checker->rs, NULL, NULL,
"UP",
"=> TCP CHECK succeed on service <=");
@@ -130,9 +94,8 @@
} else {
if (svr_checker_up(checker->id, checker->rs)) {
- log_message(LOG_INFO, "TCP connection to [%s]:%d failed !!!"
- , inet_sockaddrtos(&tcp_check->dst)
- , ntohs(inet_sockaddrport(&tcp_check->dst)));
+ log_message(LOG_INFO, "TCP connection to %s failed !!!"
+ , FMT_TCP_RS(checker));
smtp_alert(checker->rs, NULL, NULL,
"DOWN",
"=> TCP CHECK failed on service <=");
@@ -154,7 +117,7 @@
tcp_connect_thread(thread_t * thread)
{
checker_t *checker = THREAD_ARG(thread);
- tcp_checker_t *tcp_check = CHECKER_ARG(checker);
+ conn_opts_t *co = checker->co;
int fd;
int status;
@@ -168,24 +131,24 @@
return 0;
}
- if ((fd = socket(tcp_check->dst.ss_family, SOCK_STREAM, IPPROTO_TCP)) == -1) {
+ if ((fd = socket(co->dst.ss_family, SOCK_STREAM, IPPROTO_TCP)) == -1) {
log_message(LOG_INFO, "TCP connect fail to create socket. Rescheduling.");
thread_add_timer(thread->master, tcp_connect_thread, checker,
checker->vs->delay_loop);
-
+
return 0;
}
- status = tcp_bind_connect(fd, &tcp_check->dst, &tcp_check->bindto);
+ status = tcp_bind_connect(fd, co);
/* handle tcp connection status & register check worker thread */
if(tcp_connection_state(fd, status, thread, tcp_check_thread,
- tcp_check->connection_to)) {
+ co->connection_to)) {
close(fd);
log_message(LOG_INFO, "TCP socket bind failed. Rescheduling.");
thread_add_timer(thread->master, tcp_connect_thread, checker,
checker->vs->delay_loop);
}
-
+
return 0;
}
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/check/ipvswrapper.c
^
|
@@ -140,9 +140,9 @@
/* set IPVS group rules */
static int
-ipvs_group_cmd(int cmd, list vs_group, real_server_t * rs, char * vsgname)
+ipvs_group_cmd(int cmd, virtual_server_t * vs, real_server_t * rs)
{
- virtual_server_group_t *vsg = ipvs_get_group_by_name(vsgname, vs_group);
+ virtual_server_group_t *vsg = vs->vsg;
virtual_server_group_entry_t *vsg_entry;
list l;
element e;
@@ -210,9 +210,8 @@
urule->protocol = vs->service_type;
if (!parse_timeout(vs->timeout_persistence, &urule->timeout))
- log_message(LOG_INFO, "IPVS : Virtual service [%s]:%d illegal timeout."
- , inet_ntop2(inet_sockaddrip4(&vs->addr))
- , ntohs(inet_sockaddrport(&vs->addr)));
+ log_message(LOG_INFO, "IPVS : Virtual service %s illegal timeout."
+ , FMT_VS(vs));
if (urule->timeout != 0 || vs->granularity_persistence)
urule->vs_flags = IP_VS_SVC_F_PERSISTENT;
@@ -235,7 +234,7 @@
/* Set/Remove a RS from a VS */
int
-ipvs_cmd(int cmd, list vs_group, virtual_server_t * vs, real_server_t * rs)
+ipvs_cmd(int cmd, virtual_server_t * vs, real_server_t * rs)
{
int err = 0;
@@ -258,7 +257,7 @@
/* Set vs rule and send to kernel */
if (vs->vsgname) {
- err = ipvs_group_cmd(cmd, vs_group, rs, vs->vsgname);
+ err = ipvs_group_cmd(cmd, vs, rs);
} else {
if (vs->vfwmark) {
urule->vfwmark = vs->vfwmark;
@@ -274,6 +273,51 @@
return err;
}
+
+/* add alive destinations to the newly created vsge */
+int
+ipvs_group_sync_entry(virtual_server_t *vs, virtual_server_group_entry_t *vsge)
+{
+ real_server_t *rs;
+ int err = 0;
+ element e;
+ list l = vs->rs;
+
+ /* Clean target rules */
+ memset(urule, 0, sizeof (struct ip_vs_rule_user));
+
+ /* Process realserver queue */
+ for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
+ rs = ELEMENT_DATA(e);
+
+ if (rs->reloaded && (rs->alive || rs->inhibit && rs->set)) {
+ /* Prepare the IPVS rule */
+ if (urule->daddr) {
+ /* Setting IPVS rule with vs root rs */
+ ipvs_set_rule(IP_VS_SO_SET_ADDDEST, vs, rs);
+ } else {
+ urule->daddr = inet_sockaddrip4(&rs->addr);
+ urule->dport = inet_sockaddrport(&rs->addr);
+ }
+ urule->weight = rs->inhibit && ! rs->alive ? 0: rs->weight;
+
+ /* Set vs rule */
+ if (vsge->range) {
+ ipvs_group_range_cmd(IP_VS_SO_SET_ADDDEST, vsge);
+ } else {
+ urule->vfwmark = vsge->vfwmark;
+ urule->vaddr = inet_sockaddrip4(&vsge->addr);
+ urule->vport = inet_sockaddrport(&vsge->addr);
+
+ /* Talk to the IPVS channel */
+ err = ipvs_talk(IP_VS_SO_SET_ADDDEST);
+ }
+ }
+ }
+
+ return IPVS_SUCCESS;
+}
+
/* Remove a specific vs group entry */
int
ipvs_group_remove_entry(virtual_server_t *vs, virtual_server_group_entry_t *vsge)
@@ -320,6 +364,7 @@
err = ipvs_group_range_cmd(IP_VS_SO_SET_DEL, vsge);
else
err = ipvs_talk(IP_VS_SO_SET_DEL);
+ UNSET_ALIVE(vsge);
return err;
}
@@ -455,9 +500,9 @@
/* set IPVS group rules */
static void
-ipvs_group_cmd(int cmd, list vs_group, real_server_t * rs, virtual_server_t * vs)
+ipvs_group_cmd(int cmd, virtual_server_t * vs, real_server_t * rs)
{
- virtual_server_group_t *vsg = ipvs_get_group_by_name(vs->vsgname, vs_group);
+ virtual_server_group_t *vsg = vs->vsg;
virtual_server_group_entry_t *vsg_entry;
list l;
element e;
@@ -538,9 +583,8 @@
srule->protocol = vs->service_type;
if (!parse_timeout(vs->timeout_persistence, &srule->timeout))
- log_message(LOG_INFO, "IPVS : Virtual service [%s]:%d illegal timeout."
- , inet_ntop2(inet_sockaddrip4(&vs->addr))
- , ntohs(inet_sockaddrport(&vs->addr)));
+ log_message(LOG_INFO, "IPVS : Virtual service %s illegal timeout."
+ , FMT_VS(vs));
if (srule->timeout != 0 || vs->granularity_persistence)
srule->flags |= IP_VS_SVC_F_PERSISTENT;
@@ -572,7 +616,7 @@
/* Set/Remove a RS from a VS */
int
-ipvs_cmd(int cmd, list vs_group, virtual_server_t * vs, real_server_t * rs)
+ipvs_cmd(int cmd, virtual_server_t * vs, real_server_t * rs)
{
/* Allocate the room */
memset(srule, 0, sizeof(ipvs_service_t));
@@ -594,7 +638,7 @@
/* Set vs rule and send to kernel */
if (vs->vsgname) {
- ipvs_group_cmd(cmd, vs_group, rs, vs);
+ ipvs_group_cmd(cmd, vs, rs);
} else {
if (vs->vfwmark) {
srule->af = AF_INET;
@@ -621,6 +665,60 @@
return IPVS_SUCCESS;
}
+/* add alive destinations to the newly created vsge */
+int
+ipvs_group_sync_entry(virtual_server_t *vs, virtual_server_group_entry_t *vsge)
+{
+ real_server_t *rs;
+ element e;
+ list l = vs->rs;
+
+ /* Clean target rules */
+ memset(srule, 0, sizeof(ipvs_service_t));
+ memset(drule, 0, sizeof(ipvs_dest_t));
+
+ /* Process realserver queue */
+ for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
+ rs = ELEMENT_DATA(e);
+
+ if (rs->reloaded && (rs->alive || (rs->inhibit && rs->set))) {
+ /* Prepare the IPVS rule */
+ if (!drule->addr.ip) {
+ /* Setting IPVS rule with vs root rs */
+ ipvs_set_rule(IP_VS_SO_SET_ADDDEST, vs, rs);
+ } else {
+ drule->af = rs->addr.ss_family;
+ if (rs->addr.ss_family == AF_INET6)
+ inet_sockaddrip6(&rs->addr, &drule->addr.in6);
+ else
+ drule->addr.ip = inet_sockaddrip4(&rs->addr);
+ drule->port = inet_sockaddrport(&rs->addr);
+ }
+ drule->weight = rs->inhibit && ! rs->alive ? 0: rs->weight;
+
+ /* Set vs rule */
+ if (vsge->range) {
+ ipvs_group_range_cmd(IP_VS_SO_SET_ADDDEST, vsge);
+ } else {
+ srule->af = vsge->addr.ss_family;
+ if (vsge->addr.ss_family == AF_INET6)
+ inet_sockaddrip6(&vsge->addr, &srule->addr.in6);
+ else
+ srule->addr.ip = inet_sockaddrip4(&vsge->addr);
+ srule->port = inet_sockaddrport(&vsge->addr);
+ srule->fwmark = vsge->vfwmark;
+ drule->u_threshold = rs->u_threshold;
+ drule->l_threshold = rs->l_threshold;
+
+ /* Talk to the IPVS channel */
+ ipvs_talk(IP_VS_SO_SET_ADDDEST);
+ }
+ }
+ }
+
+ return IPVS_SUCCESS;
+}
+
/* Remove a specific vs group entry */
int
ipvs_group_remove_entry(virtual_server_t *vs, virtual_server_group_entry_t *vsge)
@@ -677,6 +775,7 @@
ipvs_group_range_cmd(IP_VS_SO_SET_DEL, vsge);
else
ipvs_talk(IP_VS_SO_SET_DEL);
+ UNSET_ALIVE(vsge);
return IPVS_SUCCESS;
}
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/check/ipwrapper.c
^
|
@@ -35,12 +35,12 @@
static void update_quorum_state(virtual_server_t * vs);
/* Returns the sum of all RS weight in a virtual server. */
-long unsigned
+static long
weigh_live_realservers(virtual_server_t * vs)
{
element e;
real_server_t *svr;
- long unsigned count = 0;
+ long count = 0;
for (e = LIST_HEAD(vs->rs); e; ELEMENT_NEXT(e)) {
svr = ELEMENT_DATA(e);
@@ -52,22 +52,20 @@
/* Remove a realserver IPVS rule */
static int
-clear_service_rs(list vs_group, virtual_server_t * vs, list l)
+clear_service_rs(virtual_server_t * vs, list l)
{
element e;
real_server_t *rs;
- char rsip[INET6_ADDRSTRLEN];
- long unsigned weight_sum;
+ long weight_sum;
+ long down_threshold = vs->quorum - vs->hysteresis;
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
rs = ELEMENT_DATA(e);
if (ISALIVE(rs)) {
- log_message(LOG_INFO, "Removing service [%s]:%d from VS [%s]:%d"
- , inet_sockaddrtos2(&rs->addr, rsip)
- , ntohs(inet_sockaddrport(&rs->addr))
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
- if (!ipvs_cmd(LVS_CMD_DEL_DEST, vs_group, vs, rs))
+ log_message(LOG_INFO, "Removing service %s from VS %s"
+ , FMT_RS(rs)
+ , FMT_VS(vs));
+ if (!ipvs_cmd(LVS_CMD_DEL_DEST, vs, rs))
return 0;
UNSET_ALIVE(rs);
if (!vs->omega)
@@ -77,12 +75,10 @@
* all the way down the exit, as necessary.
*/
if (rs->notify_down) {
- log_message(LOG_INFO, "Executing [%s] for service [%s]:%d in VS [%s]:%d"
+ log_message(LOG_INFO, "Executing [%s] for service %s in VS %s"
, rs->notify_down
- , inet_sockaddrtos2(&rs->addr, rsip)
- , ntohs(inet_sockaddrport(&rs->addr))
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
+ , FMT_RS(rs)
+ , FMT_VS(vs));
notify_exec(rs->notify_down);
}
#ifdef _WITH_SNMP_
@@ -96,14 +92,13 @@
weight_sum = weigh_live_realservers(vs);
if (vs->quorum_state == UP && (
!weight_sum ||
- weight_sum < vs->quorum - vs->hysteresis)
+ weight_sum < down_threshold)
) {
vs->quorum_state = DOWN;
if (vs->quorum_down) {
- log_message(LOG_INFO, "Executing [%s] for VS [%s]:%d"
+ log_message(LOG_INFO, "Executing [%s] for VS %s"
, vs->quorum_down
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
+ , FMT_VS(vs));
notify_exec(vs->quorum_down);
}
#ifdef _WITH_SNMP_
@@ -118,20 +113,20 @@
/* Remove a virtualserver IPVS rule */
static int
-clear_service_vs(list vs_group, virtual_server_t * vs)
+clear_service_vs(virtual_server_t * vs)
{
/* Processing real server queue */
if (!LIST_ISEMPTY(vs->rs)) {
if (vs->s_svr) {
if (ISALIVE(vs->s_svr))
- if (!ipvs_cmd(LVS_CMD_DEL_DEST, vs_group, vs, vs->s_svr))
+ if (!ipvs_cmd(LVS_CMD_DEL_DEST, vs, vs->s_svr))
return 0;
- } else if (!clear_service_rs(vs_group, vs, vs->rs))
+ } else if (!clear_service_rs(vs, vs->rs))
return 0;
/* The above will handle Omega case for VS as well. */
}
- if (!ipvs_cmd(LVS_CMD_DEL, vs_group, vs, NULL))
+ if (!ipvs_cmd(LVS_CMD_DEL, vs, NULL))
return 0;
UNSET_ALIVE(vs);
@@ -148,7 +143,7 @@
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
vs = ELEMENT_DATA(e);
- if (!clear_service_vs(check_data->vs_group, vs))
+ if (!clear_service_vs(vs))
return 0;
}
return 1;
@@ -163,23 +158,15 @@
for (e = LIST_HEAD(vs->rs); e; ELEMENT_NEXT(e)) {
rs = ELEMENT_DATA(e);
+ /* Do not re-add failed RS instantly on reload */
+ if (rs->reloaded)
+ continue;
/* In alpha mode, be pessimistic (or realistic?) and don't
* add real servers into the VS pool. They will get there
* later upon healthchecks recovery (if ever).
*/
- if (vs->alpha) {
- if (! rs->reloaded)
- UNSET_ALIVE(rs);
- continue;
- }
- if (!ISALIVE(rs)) {
- if (!ipvs_cmd(LVS_CMD_ADD_DEST, check_data->vs_group, vs, rs))
- return 0;
- else
- SET_ALIVE(rs);
- } else if (vs->vsgname) {
- UNSET_ALIVE(rs);
- if (!ipvs_cmd(LVS_CMD_ADD_DEST, check_data->vs_group, vs, rs))
+ if (!vs->alpha && !ISALIVE(rs)) {
+ if (!ipvs_cmd(LVS_CMD_ADD_DEST, vs, rs))
return 0;
SET_ALIVE(rs);
}
@@ -188,29 +175,62 @@
return 1;
}
+static void
+sync_service_vsg(virtual_server_t * vs)
+{
+ virtual_server_group_t *vsg;
+ virtual_server_group_entry_t *vsge;
+ list *l;
+ element e;
+
+ vsg = vs->vsg;
+ list ll[] = {
+ vsg->addr_ip,
+ vsg->vfwmark,
+ vsg->range,
+ NULL,
+ };
+
+ for (l = ll; *l; l++)
+ for (e = LIST_HEAD(*l); e; ELEMENT_NEXT(e)) {
+ vsge = ELEMENT_DATA(e);
+ if (vs->reloaded && !vsge->reloaded) {
+ log_message(LOG_INFO, "VS [%s:%d:%u] added into group %s"
+ , inet_sockaddrtopair(&vsge->addr)
+ , vsge->range
+ , vsge->vfwmark
+ , vs->vsgname);
+ /* add all reloaded and alive/inhibit-set dests
+ * to the newly created vsg item */
+ ipvs_group_sync_entry(vs, vsge);
+ }
+ }
+}
+
/* Set a virtualserver IPVS rules */
static int
init_service_vs(virtual_server_t * vs)
{
/* Init the VS root */
if (!ISALIVE(vs) || vs->vsgname) {
- if (!ipvs_cmd(LVS_CMD_ADD, check_data->vs_group, vs, NULL))
+ if (!ipvs_cmd(LVS_CMD_ADD, vs, NULL))
return 0;
else
SET_ALIVE(vs);
}
/* Processing real server queue */
- if (!LIST_ISEMPTY(vs->rs)) {
- if (vs->alpha && ! vs->reloaded)
- vs->quorum_state = DOWN;
- if (!init_service_rs(vs))
- return 0;
- }
+ if (!init_service_rs(vs))
+ return 0;
- /* if the service was reloaded, we may have got/lost quorum due to quorum setting changed */
- if (vs->reloaded)
+ if (vs->reloaded) {
+ if (vs->vsgname)
+ /* add reloaded dests into new vsg entries */
+ sync_service_vsg(vs);
+
+ /* we may have got/lost quorum due to quorum setting changed */
update_quorum_state(vs);
+ }
return 1;
}
@@ -241,17 +261,16 @@
if (LIST_ISEMPTY(vs->rs))
return;
- log_message(LOG_INFO, "%s the pool for VS [%s]:%d"
+ log_message(LOG_INFO, "%s the pool for VS %s"
, add?"Adding alive servers to":"Removing alive servers from"
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
+ , FMT_VS(vs));
for (e = LIST_HEAD(vs->rs); e; ELEMENT_NEXT(e)) {
rs = ELEMENT_DATA(e);
if (!ISALIVE(rs)) /* We only handle alive servers */
continue;
if (add)
rs->alive = 0;
- ipvs_cmd(add?LVS_CMD_ADD_DEST:LVS_CMD_DEL_DEST, check_data->vs_group, vs, rs);
+ ipvs_cmd(add?LVS_CMD_ADD_DEST:LVS_CMD_DEL_DEST, vs, rs);
rs->alive = 1;
}
}
@@ -260,38 +279,36 @@
static void
update_quorum_state(virtual_server_t * vs)
{
- char rsip[INET6_ADDRSTRLEN];
- long unsigned weight_sum = weigh_live_realservers(vs);
+ long weight_sum = weigh_live_realservers(vs);
+ long up_threshold = vs->quorum + vs->hysteresis;
+ long down_threshold = vs->quorum - vs->hysteresis;
/* If we have just gained quorum, it's time to consider notify_up. */
if (vs->quorum_state == DOWN &&
- weight_sum >= vs->quorum + vs->hysteresis) {
+ weight_sum >= up_threshold) {
vs->quorum_state = UP;
- log_message(LOG_INFO, "Gained quorum %lu+%lu=%lu <= %u for VS [%s]:%d"
+ log_message(LOG_INFO, "Gained quorum %lu+%lu=%li <= %li for VS %s"
, vs->quorum
, vs->hysteresis
- , vs->quorum + vs->hysteresis
+ , up_threshold
, weight_sum
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
+ , FMT_VS(vs));
if (vs->s_svr && ISALIVE(vs->s_svr)) {
- log_message(LOG_INFO, "Removing sorry server [%s]:%d from VS [%s]:%d"
- , inet_sockaddrtos2(&vs->s_svr->addr, rsip)
- , ntohs(inet_sockaddrport(&vs->s_svr->addr))
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
+ log_message(LOG_INFO, "%s sorry server %s from VS %s"
+ , (vs->s_svr->inhibit ? "Disabling" : "Removing")
+ , FMT_RS(vs->s_svr)
+ , FMT_VS(vs));
- ipvs_cmd(LVS_CMD_DEL_DEST, check_data->vs_group, vs, vs->s_svr);
+ ipvs_cmd(LVS_CMD_DEL_DEST, vs, vs->s_svr);
vs->s_svr->alive = 0;
/* Adding back alive real servers */
perform_quorum_state(vs, 1);
}
if (vs->quorum_up) {
- log_message(LOG_INFO, "Executing [%s] for VS [%s]:%d"
+ log_message(LOG_INFO, "Executing [%s] for VS %s"
, vs->quorum_up
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
+ , FMT_VS(vs));
notify_exec(vs->quorum_up);
}
#ifdef _WITH_SNMP_
@@ -303,34 +320,30 @@
/* If we have just lost quorum for the VS, we need to consider
* VS notify_down and sorry_server cases
*/
- if (vs->quorum_state == UP && (
- !weight_sum ||
- weight_sum < vs->quorum - vs->hysteresis)
+ if (vs->quorum_state == UP &&
+ (!weight_sum || weight_sum < down_threshold)
) {
vs->quorum_state = DOWN;
- log_message(LOG_INFO, "Lost quorum %lu-%lu=%lu > %u for VS [%s]:%d"
+ log_message(LOG_INFO, "Lost quorum %lu-%lu=%li > %li for VS %s"
, vs->quorum
, vs->hysteresis
- , vs->quorum - vs->hysteresis
+ , down_threshold
, weight_sum
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
+ , FMT_VS(vs));
if (vs->quorum_down) {
- log_message(LOG_INFO, "Executing [%s] for VS [%s]:%d"
+ log_message(LOG_INFO, "Executing [%s] for VS %s"
, vs->quorum_down
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
+ , FMT_VS(vs));
notify_exec(vs->quorum_down);
}
if (vs->s_svr) {
- log_message(LOG_INFO, "Adding sorry server [%s]:%d to VS [%s]:%d"
- , inet_sockaddrtos2(&vs->s_svr->addr, rsip)
- , ntohs(inet_sockaddrport(&vs->s_svr->addr))
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
+ log_message(LOG_INFO, "%s sorry server %s to VS %s"
+ , (vs->s_svr->inhibit ? "Enabling" : "Adding")
+ , FMT_RS(vs->s_svr)
+ , FMT_VS(vs));
/* the sorry server is now up in the pool, we flag it alive */
- ipvs_cmd(LVS_CMD_ADD_DEST, check_data->vs_group, vs, vs->s_svr);
+ ipvs_cmd(LVS_CMD_ADD_DEST, vs, vs->s_svr);
vs->s_svr->alive = 1;
/* Remove remaining alive real servers */
@@ -347,8 +360,6 @@
void
perform_svr_state(int alive, virtual_server_t * vs, real_server_t * rs)
{
- char rsip[INET6_ADDRSTRLEN];
-
/*
* | ISALIVE(rs) | alive | context
* | 0 | 0 | first check failed under alpha mode, unreachable here
@@ -357,24 +368,20 @@
* | 1 | 1 | first check succeeded w/o alpha mode, unreachable here
*/
if (!ISALIVE(rs) && alive) {
- log_message(LOG_INFO, "%s service [%s]:%d to VS [%s]:%d"
+ log_message(LOG_INFO, "%s service %s to VS %s"
, (rs->inhibit) ? "Enabling" : "Adding"
- , inet_sockaddrtos2(&rs->addr, rsip)
- , ntohs(inet_sockaddrport(&rs->addr))
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
+ , FMT_RS(rs)
+ , FMT_VS(vs));
/* Add only if we have quorum or no sorry server */
if (vs->quorum_state == UP || !vs->s_svr || !ISALIVE(vs->s_svr)) {
- ipvs_cmd(LVS_CMD_ADD_DEST, check_data->vs_group, vs, rs);
+ ipvs_cmd(LVS_CMD_ADD_DEST, vs, rs);
}
rs->alive = alive;
if (rs->notify_up) {
- log_message(LOG_INFO, "Executing [%s] for service [%s]:%d in VS [%s]:%d"
+ log_message(LOG_INFO, "Executing [%s] for service %s in VS %s"
, rs->notify_up
- , inet_sockaddrtos2(&rs->addr, rsip)
- , ntohs(inet_sockaddrport(&rs->addr))
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
+ , FMT_RS(rs)
+ , FMT_VS(vs));
notify_exec(rs->notify_up);
}
#ifdef _WITH_SNMP_
@@ -386,27 +393,23 @@
}
if (ISALIVE(rs) && !alive) {
- log_message(LOG_INFO, "%s service [%s]:%d from VS [%s]:%d"
+ log_message(LOG_INFO, "%s service %s from VS %s"
, (rs->inhibit) ? "Disabling" : "Removing"
- , inet_sockaddrtos2(&rs->addr, rsip)
- , ntohs(inet_sockaddrport(&rs->addr))
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
+ , FMT_RS(rs)
+ , FMT_VS(vs));
/* server is down, it is removed from the LVS realserver pool
* Remove only if we have quorum or no sorry server
*/
if (vs->quorum_state == UP || !vs->s_svr || !ISALIVE(vs->s_svr)) {
- ipvs_cmd(LVS_CMD_DEL_DEST, check_data->vs_group, vs, rs);
+ ipvs_cmd(LVS_CMD_DEL_DEST, vs, rs);
}
rs->alive = alive;
if (rs->notify_down) {
- log_message(LOG_INFO, "Executing [%s] for service [%s]:%d in VS [%s]:%d"
+ log_message(LOG_INFO, "Executing [%s] for service %s in VS %s"
, rs->notify_down
- , inet_sockaddrtos2(&rs->addr, rsip)
- , ntohs(inet_sockaddrport(&rs->addr))
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
+ , FMT_RS(rs)
+ , FMT_VS(vs));
notify_exec(rs->notify_down);
}
#ifdef _WITH_SNMP_
@@ -422,17 +425,13 @@
void
update_svr_wgt(int weight, virtual_server_t * vs, real_server_t * rs)
{
- char rsip[INET6_ADDRSTRLEN];
-
if (weight != rs->weight) {
- log_message(LOG_INFO, "Changing weight from %d to %d for %s service [%s]:%d of VS [%s]:%d"
+ log_message(LOG_INFO, "Changing weight from %d to %d for %s service %s of VS %s"
, rs->weight
, weight
, ISALIVE(rs) ? "active" : "inactive"
- , inet_sockaddrtos2(&rs->addr, rsip)
- , ntohs(inet_sockaddrport(&rs->addr))
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
+ , FMT_RS(rs)
+ , FMT_VS(vs));
rs->weight = weight;
/*
* Have weight change take effect now only if rs is in
@@ -442,7 +441,7 @@
*/
if (rs->set && ISALIVE(rs) &&
(vs->quorum_state == UP || !vs->s_svr || !ISALIVE(vs->s_svr)))
- ipvs_cmd(LVS_CMD_EDIT_DEST, check_data->vs_group, vs, rs);
+ ipvs_cmd(LVS_CMD_EDIT_DEST, vs, rs);
update_quorum_state(vs);
}
}
@@ -507,7 +506,7 @@
}
/* Check if a vsg entry is in new data */
-static int
+static virtual_server_group_entry_t *
vsge_exist(virtual_server_group_entry_t *vsg_entry, list l)
{
element e;
@@ -515,33 +514,30 @@
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
vsge = ELEMENT_DATA(e);
- if (VSGE_ISEQ(vsg_entry, vsge)) {
- /*
- * If vsge exist this entry
- * is alive since only rs entries
- * are changing from alive state.
- */
- SET_ALIVE(vsge);
- return 1;
- }
+ if (VSGE_ISEQ(vsg_entry, vsge))
+ return vsge;
}
- return 0;
+ return NULL;
}
/* Clear the diff vsge of old group */
static int
clear_diff_vsge(list old, list new, virtual_server_t * old_vs)
{
- virtual_server_group_entry_t *vsge;
+ virtual_server_group_entry_t *vsge, *new_vsge;
element e;
for (e = LIST_HEAD(old); e; ELEMENT_NEXT(e)) {
vsge = ELEMENT_DATA(e);
- if (!vsge_exist(vsge, new)) {
- log_message(LOG_INFO, "VS [[%s]:%d:%d:%d] in group %s no longer exist"
- , inet_sockaddrtos(&vsge->addr)
- , ntohs(inet_sockaddrport(&vsge->addr))
+ new_vsge = vsge_exist(vsge, new);
+ if (new_vsge) {
+ new_vsge->alive = vsge->alive;
+ new_vsge->reloaded = 1;
+ }
+ else {
+ log_message(LOG_INFO, "VS [%s:%d:%u] in group %s no longer exist"
+ , inet_sockaddrtopair(&vsge->addr)
, vsge->range
, vsge->vfwmark
, old_vs->vsgname);
@@ -556,14 +552,10 @@
/* Clear the diff vsg of the old vs */
static int
-clear_diff_vsg(virtual_server_t * old_vs)
+clear_diff_vsg(virtual_server_t * old_vs, virtual_server_t * new_vs)
{
- virtual_server_group_t *old;
- virtual_server_group_t *new;
-
- /* Fetch group */
- old = ipvs_get_group_by_name(old_vs->vsgname, old_check_data->vs_group);
- new = ipvs_get_group_by_name(old_vs->vsgname, check_data->vs_group);
+ virtual_server_group_t *old = old_vs->vsg;
+ virtual_server_group_t *new = new_vs->vsg;
/* Diff the group entries */
if (!clear_diff_vsge(old->addr_ip, new->addr_ip, old_vs))
@@ -583,93 +575,45 @@
element e;
list l = check_data->vs;
virtual_server_t *vs;
- virtual_server_group_t *vsg;
if (LIST_ISEMPTY(l))
return NULL;
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
vs = ELEMENT_DATA(e);
- if (VS_ISEQ(old_vs, vs)) {
- /* Check if group exist */
- if (vs->vsgname) {
- vsg = ipvs_get_group_by_name(old_vs->vsgname,
- check_data->vs_group);
- if (!vsg)
- return NULL;
- else
- if (!clear_diff_vsg(old_vs))
- return NULL;
- }
-
- /*
- * Exist so set alive.
- */
- SET_ALIVE(vs);
+ if (VS_ISEQ(old_vs, vs))
return vs;
- }
}
return NULL;
}
/* Check if rs is in new vs data */
-static int
+static real_server_t *
rs_exist(real_server_t * old_rs, list l)
{
element e;
real_server_t *rs;
if (LIST_ISEMPTY(l))
- return 0;
-
- for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
- rs = ELEMENT_DATA(e);
- if (RS_ISEQ(rs, old_rs)) {
- /*
- * We reflect the previous alive
- * flag value to not try to set
- * already set IPVS rule.
- */
- rs->alive = old_rs->alive;
- rs->set = old_rs->set;
- rs->weight = old_rs->weight;
- return 1;
- }
- }
-
- return 0;
-}
-
-/* get rs list for a specific vs */
-static list
-get_rs_list(virtual_server_t * vs)
-{
- element e;
- list l = check_data->vs;
- virtual_server_t *vsvr;
-
- if (LIST_ISEMPTY(l))
return NULL;
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
- vsvr = ELEMENT_DATA(e);
- if (VS_ISEQ(vs, vsvr))
- return vsvr->rs;
+ rs = ELEMENT_DATA(e);
+ if (RS_ISEQ(rs, old_rs))
+ return rs;
}
- /* most of the time never reached */
return NULL;
}
/* Clear the diff rs of the old vs */
static int
-clear_diff_rs(list old_vs_group, virtual_server_t * old_vs)
+clear_diff_rs(virtual_server_t * old_vs, list new_rs_list)
{
element e;
list l = old_vs->rs;
- list new = get_rs_list(old_vs);
- real_server_t *rs;
+ real_server_t *rs, *new_rs;
/* If old vs didn't own rs then nothing return */
if (LIST_ISEMPTY(l))
@@ -679,28 +623,43 @@
list rs_to_remove = alloc_list (NULL, NULL);
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
rs = ELEMENT_DATA(e);
- if (!rs_exist(rs, new)) {
+ new_rs = rs_exist(rs, new_rs_list);
+ if (!new_rs) {
/* Reset inhibit flag to delete inhibit entries */
- log_message(LOG_INFO, "service [%s]:%d no longer exist"
- , inet_sockaddrtos(&rs->addr)
- , ntohs(inet_sockaddrport(&rs->addr)));
+ log_message(LOG_INFO, "service %s no longer exist"
+ , FMT_RS(rs));
rs->inhibit = 0;
list_add (rs_to_remove, rs);
+ } else {
+ /*
+ * We reflect the previous alive
+ * flag value to not try to set
+ * already set IPVS rule.
+ */
+ new_rs->alive = rs->alive;
+ new_rs->set = rs->set;
+ new_rs->weight = rs->weight;
+ new_rs->reloaded = 1;
+ if (new_rs->alive) {
+ /* clear failed_checkers list */
+ free_list_elements(new_rs->failed_checkers);
+ }
}
}
- int ret = clear_service_rs (old_vs_group, old_vs, rs_to_remove);
+ int ret = clear_service_rs (old_vs, rs_to_remove);
free_list (rs_to_remove);
return ret;
}
-/* When reloading configuration, remove negative diff entries */
+/* When reloading configuration, remove negative diff entries
+ * and copy status of existing entries to the new ones */
int
clear_diff_services(void)
{
element e;
list l = old_check_data->vs;
- virtual_server_t *vs;
+ virtual_server_t *vs, *new_vs;
/* If old config didn't own vs then nothing return */
if (LIST_ISEMPTY(l))
@@ -714,29 +673,36 @@
* Try to find this vs into the new conf data
* reloaded.
*/
- if (!vs_exist(vs)) {
+ new_vs = vs_exist(vs);
+ if (!new_vs) {
if (vs->vsgname)
log_message(LOG_INFO, "Removing Virtual Server Group [%s]"
, vs->vsgname);
else
- log_message(LOG_INFO, "Removing Virtual Server [%s]:%d"
- , inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
+ log_message(LOG_INFO, "Removing Virtual Server %s"
+ , FMT_VS(vs));
/* Clear VS entry */
- if (!clear_service_vs(old_check_data->vs_group, vs))
+ if (!clear_service_vs(vs))
return 0;
} else {
+ /* copy status fields from old VS */
+ SET_ALIVE(new_vs);
+ new_vs->quorum_state = vs->quorum_state;
+ new_vs->reloaded = 1;
+
+ if (vs->vsgname)
+ clear_diff_vsg(vs, new_vs);
+
/* If vs exist, perform rs pool diff */
/* omega = 0 must not prevent the notifiers from being called,
because the VS still exists in new configuration */
vs->omega = 1;
- if (!clear_diff_rs(old_check_data->vs_group, vs))
+ if (!clear_diff_rs(vs, new_vs->rs))
return 0;
if (vs->s_svr)
if (ISALIVE(vs->s_svr))
if (!ipvs_cmd(LVS_CMD_DEL_DEST
- , check_data->vs_group
, vs
, vs->s_svr))
return 0;
@@ -746,51 +712,15 @@
return 1;
}
-/* When reloading configuration, copy still alive RS/VS alive/set attributes into corresponding new config items */
-int
-copy_srv_states (void)
+void
+link_vsg_to_vs(void)
{
element e;
- list l = old_check_data->vs;
- virtual_server_t *old_vs, *new_vs;
-
- /* If old config didn't own vs then nothing return */
- if (LIST_ISEMPTY(l))
- return 1;
-
- for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
- old_vs = ELEMENT_DATA(e);
- new_vs = vs_exist (old_vs);
- if (new_vs) {
- /* copy quorum_state field of VS */
- new_vs->quorum_state = old_vs->quorum_state;
- new_vs->reloaded = 1;
+ virtual_server_t *vs;
- list old_rsl = old_vs->rs;
- list new_rsl = new_vs->rs;
- if (LIST_ISEMPTY(old_rsl) || LIST_ISEMPTY (new_rsl))
- continue;
- element oe, ne;
- real_server_t *old_rs, *new_rs;
- /* iterate over equal rs */
- for (oe = LIST_HEAD(old_rsl); oe; ELEMENT_NEXT (oe)) {
- old_rs = ELEMENT_DATA(oe);
- for (ne = LIST_HEAD(new_rsl); ne; ELEMENT_NEXT(ne)) {
- new_rs = ELEMENT_DATA(ne);
- if (RS_ISEQ (old_rs, new_rs)) {
- /* copy alive, set fields of RS */
- new_rs->alive = old_rs->alive;
- new_rs->set = old_rs->set;
- new_rs->reloaded = 1;
- if (new_rs->alive) {
- /* clear failed_checkers list */
- free_list_elements(new_rs->failed_checkers);
- }
- break;
- }
- }
- }
- }
+ for (e = LIST_HEAD(check_data->vs); e; ELEMENT_NEXT(e)) {
+ vs = ELEMENT_DATA(e);
+ if (vs->vsgname)
+ vs->vsg = ipvs_get_group_by_name(vs->vsgname, check_data->vs_group);
}
- return 0;
}
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/core/Makefile.in
^
|
@@ -9,7 +9,7 @@
INCLUDES = -I../include -I../../lib
CFLAGS = @CFLAGS@ @CPPFLAGS@ $(INCLUDES) \
-Wall -Wunused -Wstrict-prototypes
-DEFS = -D@KERN@ -D@IPVS_SUPPORT@ -D@VRRP_SUPPORT@ -D@SNMP_SUPPORT@ @DFLAGS@
+DEFS = -D@KERN@ -D@IPVS_SUPPORT@ -D@VRRP_SUPPORT@ -D@SNMP_SUPPORT@ -D@SO_MARK_SUPPORT@ @DFLAGS@
COMPILE = $(CC) $(CFLAGS) $(DEFS)
OBJS = main.o daemon.o pidfile.o layer4.o smtp.o \
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/core/global_data.c
^
|
@@ -38,18 +38,12 @@
set_default_router_id(data_t * data)
{
char *new_id = NULL;
- int len = 0;
new_id = get_local_name();
if (!new_id || !new_id[0])
return;
- len = strlen(new_id);
- data->router_id = MALLOC(len + 1);
- if (!data->router_id)
- return;
-
- memcpy(data->router_id, new_id, len);
+ data->router_id = new_id;
}
static void
@@ -65,14 +59,16 @@
pwd = getpwuid(getuid());
if (!pwd)
- return;
+ goto end;
len = strlen(hostname) + strlen(pwd->pw_name) + 2;
data->email_from = MALLOC(len);
if (!data->email_from)
- return;
+ goto end;
snprintf(data->email_from, len, "%s@%s", pwd->pw_name, hostname);
+ end:
+ FREE(hostname);
}
static void
@@ -178,7 +174,7 @@
}
if (data->vrrp_mcast_group6.ss_family) {
log_message(LOG_INFO, " VRRP IPv6 mcast group = %s"
- , inet_sockaddrtos(&data->vrrp_mcast_group4));
+ , inet_sockaddrtos(&data->vrrp_mcast_group6));
}
#ifdef _WITH_SNMP_
if (data->enable_traps)
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/core/global_parser.c
^
|
@@ -89,7 +89,7 @@
ret = inet_stosockaddr(vector_slot(strvec, 1), 0, mcast);
if (ret < 0) {
log_message(LOG_ERR, "Configuration error: Cant parse vrrp_mcast_group4 [%s]. Skipping"
- , vector_slot(strvec, 1));
+ , FMT_STR_VSLOT(strvec, 1));
}
}
static void
@@ -101,7 +101,7 @@
ret = inet_stosockaddr(vector_slot(strvec, 1), 0, mcast);
if (ret < 0) {
log_message(LOG_ERR, "Configuration error: Cant parse vrrp_mcast_group6 [%s]. Skipping"
- , vector_slot(strvec, 1));
+ , FMT_STR_VSLOT(strvec, 1));
}
}
#ifdef _WITH_SNMP_
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/core/layer4.c
^
|
@@ -22,16 +22,18 @@
*/
#include "layer4.h"
-#include "check_api.h"
#include "utils.h"
+#include "logger.h"
enum connect_result
-tcp_bind_connect(int fd, struct sockaddr_storage *addr, struct sockaddr_storage *bind_addr)
+tcp_bind_connect(int fd, conn_opts_t *co)
{
struct linger li = { 0 };
socklen_t addrlen;
int ret;
int val;
+ struct sockaddr_storage *addr = &co->dst;
+ struct sockaddr_storage *bind_addr = &co->bindto;
/* free the tcp port after closing the socket descriptor */
li.l_onoff = 1;
@@ -42,8 +44,17 @@
val = fcntl(fd, F_GETFL, 0);
fcntl(fd, F_SETFL, val | O_NONBLOCK);
+#ifdef _WITH_SO_MARK_
+ if (co->fwmark) {
+ if (setsockopt (fd, SOL_SOCKET, SO_MARK, &co->fwmark, sizeof (co->fwmark)) < 0) {
+ log_message(LOG_ERR, "Error setting fwmark %d to socket: %s", co->fwmark, strerror(errno));
+ return connect_error;
+ }
+ }
+#endif
+
/* Bind socket */
- if (bind_addr && ((struct sockaddr *) bind_addr)->sa_family != AF_UNSPEC) {
+ if (((struct sockaddr *) bind_addr)->sa_family != AF_UNSPEC) {
addrlen = sizeof(*bind_addr);
if (bind(fd, (struct sockaddr *) bind_addr, addrlen) != 0)
return connect_error;
@@ -73,7 +84,10 @@
enum connect_result
tcp_connect(int fd, struct sockaddr_storage *addr)
{
- return tcp_bind_connect(fd, addr, NULL);
+ conn_opts_t co;
+ memset(&co, 0, sizeof(co));
+ co.dst = *addr;
+ return tcp_bind_connect(fd, &co);
}
enum connect_result
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/core/smtp.c
^
|
@@ -96,8 +96,8 @@
{
smtp_t *smtp = THREAD_ARG(thread);
- log_message(LOG_INFO, "SMTP connection ERROR to [%s]:%d."
- , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
+ log_message(LOG_INFO, "SMTP connection ERROR to %s."
+ , FMT_SMTP_HOST());
free_smtp_all(smtp);
return 0;
}
@@ -106,8 +106,8 @@
{
smtp_t *smtp = THREAD_ARG(thread);
- log_message(LOG_INFO, "Timeout connecting SMTP server [%s]:%d."
- , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
+ log_message(LOG_INFO, "Timeout connecting SMTP server %s."
+ , FMT_SMTP_HOST());
free_smtp_all(smtp);
return 0;
}
@@ -116,8 +116,8 @@
{
int status;
- DBG("SMTP connection to [%s]:%d now IN_PROGRESS.",
- inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
+ DBG("SMTP connection to %s now IN_PROGRESS.",
+ FMT_SMTP_HOST());
/*
* Here we use the propriety of a union structure,
@@ -135,8 +135,8 @@
{
smtp_t *smtp = THREAD_ARG(thread);
- log_message(LOG_INFO, "Remote SMTP server [%s]:%d connected."
- , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
+ log_message(LOG_INFO, "Remote SMTP server %s connected."
+ , FMT_SMTP_HOST());
smtp->stage = connect_success;
thread_add_read(thread->master, smtp_read_thread, smtp,
@@ -157,8 +157,8 @@
smtp = THREAD_ARG(thread);
if (thread->type == THREAD_READ_TIMEOUT) {
- log_message(LOG_INFO, "Timeout reading data to remote SMTP server [%s]:%d."
- , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
+ log_message(LOG_INFO, "Timeout reading data to remote SMTP server %s."
+ , FMT_SMTP_HOST());
SMTP_FSM_READ(QUIT, thread, 0);
return -1;
}
@@ -171,17 +171,22 @@
if (rcv_buffer_size == -1) {
if (errno == EAGAIN)
goto end;
- log_message(LOG_INFO, "Error reading data from remote SMTP server [%s]:%d."
- , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
+ log_message(LOG_INFO, "Error reading data from remote SMTP server %s."
+ , FMT_SMTP_HOST());
+ SMTP_FSM_READ(QUIT, thread, 0);
+ return 0;
+ } else if (rcv_buffer_size == 0) {
+ log_message(LOG_INFO, "Remote SMTP server %s has closed the connection."
+ , FMT_SMTP_HOST());
SMTP_FSM_READ(QUIT, thread, 0);
return 0;
}
/* received data overflow buffer size ? */
if (smtp->buflen >= SMTP_BUFFER_MAX) {
- log_message(LOG_INFO, "Received buffer from remote SMTP server [%s]:%d"
+ log_message(LOG_INFO, "Received buffer from remote SMTP server %s"
" overflow our get read buffer length."
- , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
+ , FMT_SMTP_HOST());
SMTP_FSM_READ(QUIT, thread, 0);
return 0;
} else {
@@ -238,8 +243,8 @@
thread_add_write(thread->master, smtp_send_thread, smtp,
smtp->fd, global_data->smtp_connection_to);
} else {
- log_message(LOG_INFO, "Can not read data from remote SMTP server [%s]:%d."
- , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
+ log_message(LOG_INFO, "Can not read data from remote SMTP server %s."
+ , FMT_SMTP_HOST());
SMTP_FSM_READ(QUIT, thread, 0);
}
@@ -252,8 +257,8 @@
smtp_t *smtp = THREAD_ARG(thread);
if (thread->type == THREAD_WRITE_TIMEOUT) {
- log_message(LOG_INFO, "Timeout sending data to remote SMTP server [%s]:%d."
- , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
+ log_message(LOG_INFO, "Timeout sending data to remote SMTP server %s."
+ , FMT_SMTP_HOST());
SMTP_FSM_READ(QUIT, thread, 0);
return 0;
}
@@ -271,9 +276,8 @@
thread_add_read(thread->master, smtp_read_thread, smtp,
thread->u.fd, global_data->smtp_connection_to);
} else {
- log_message(LOG_INFO, "Can not send data to remote SMTP server [%s]:%d."
- , inet_sockaddrtos(&global_data->smtp_server)
- , SMTP_PORT);
+ log_message(LOG_INFO, "Can not send data to remote SMTP server %s."
+ , FMT_SMTP_HOST());
SMTP_FSM_READ(QUIT, thread, 0);
}
@@ -288,10 +292,10 @@
if (status == 220) {
smtp->stage++;
} else {
- log_message(LOG_INFO, "Error connecting SMTP server[%s]:%d."
+ log_message(LOG_INFO, "Error connecting SMTP server %s."
" SMTP status code = %d"
- , inet_sockaddrtos(&global_data->smtp_server)
- , SMTP_PORT, status);
+ , FMT_SMTP_HOST()
+ , status);
smtp->stage = ERROR;
}
@@ -303,13 +307,16 @@
helo_cmd(thread_t * thread)
{
smtp_t *smtp = THREAD_ARG(thread);
+ char *name;
char *buffer;
buffer = (char *) MALLOC(SMTP_BUFFER_MAX);
- snprintf(buffer, SMTP_BUFFER_MAX, SMTP_HELO_CMD, get_local_name());
+ name = get_local_name();
+ snprintf(buffer, SMTP_BUFFER_MAX, SMTP_HELO_CMD, (name) ? name : "localhost");
if (send(thread->u.fd, buffer, strlen(buffer), 0) == -1)
smtp->stage = ERROR;
FREE(buffer);
+ FREE_PTR(name);
return 0;
}
@@ -321,10 +328,10 @@
if (status == 250) {
smtp->stage++;
} else {
- log_message(LOG_INFO, "Error processing HELO cmd on SMTP server [%s]:%d."
+ log_message(LOG_INFO, "Error processing HELO cmd on SMTP server %s."
" SMTP status code = %d"
- , inet_sockaddrtos(&global_data->smtp_server)
- , SMTP_PORT, status);
+ , FMT_SMTP_HOST()
+ , status);
smtp->stage = ERROR;
}
@@ -354,10 +361,10 @@
if (status == 250) {
smtp->stage++;
} else {
- log_message(LOG_INFO, "Error processing MAIL cmd on SMTP server [%s]:%d."
+ log_message(LOG_INFO, "Error processing MAIL cmd on SMTP server %s."
" SMTP status code = %d"
- , inet_sockaddrtos(&global_data->smtp_server)
- , SMTP_PORT, status);
+ , FMT_SMTP_HOST()
+ , status);
smtp->stage = ERROR;
}
@@ -399,10 +406,10 @@
if (!fetched_email)
smtp->stage++;
} else {
- log_message(LOG_INFO, "Error processing RCPT cmd on SMTP server [%s]:%d."
+ log_message(LOG_INFO, "Error processing RCPT cmd on SMTP server %s."
" SMTP status code = %d"
- , inet_sockaddrtos(&global_data->smtp_server)
- , SMTP_PORT, status);
+ , FMT_SMTP_HOST()
+ , status);
smtp->stage = ERROR;
}
@@ -427,10 +434,10 @@
if (status == 354) {
smtp->stage++;
} else {
- log_message(LOG_INFO, "Error processing DATA cmd on SMTP server [%s]:%d."
+ log_message(LOG_INFO, "Error processing DATA cmd on SMTP server %s."
" SMTP status code = %d"
- , inet_sockaddrtos(&global_data->smtp_server)
- , SMTP_PORT, status);
+ , FMT_SMTP_HOST()
+ , status);
smtp->stage = ERROR;
}
@@ -485,11 +492,13 @@
char *buffer;
char rfc822[80];
time_t tm;
+ struct tm *t;
buffer = (char *) MALLOC(SMTP_BUFFER_MAX);
time(&tm);
- strftime(rfc822, sizeof(rfc822), "%a, %d %b %Y %H:%M:%S %z", gmtime(&tm));
+ t = localtime(&tm);
+ strftime(rfc822, sizeof(rfc822), "%a, %d %b %Y %H:%M:%S %z", t);
snprintf(buffer, SMTP_BUFFER_MAX, SMTP_HEADERS_CMD,
rfc822, global_data->email_from, smtp->subject, smtp->email_to);
@@ -521,10 +530,10 @@
log_message(LOG_INFO, "SMTP alert successfully sent.");
smtp->stage++;
} else {
- log_message(LOG_INFO, "Error processing DOT cmd on SMTP server [%s]:%d."
+ log_message(LOG_INFO, "Error processing DOT cmd on SMTP server %s."
" SMTP status code = %d"
- , inet_sockaddrtos(&global_data->smtp_server)
- , SMTP_PORT, status);
+ , FMT_SMTP_HOST()
+ , status);
smtp->stage = ERROR;
}
@@ -590,10 +599,9 @@
/* format subject if rserver is specified */
if (rs) {
- snprintf(smtp->subject, MAX_HEADERS_LENGTH, "[%s] Realserver [%s]:%d - %s"
+ snprintf(smtp->subject, MAX_HEADERS_LENGTH, "[%s] Realserver %s - %s"
, global_data->router_id
- , inet_sockaddrtos(&rs->addr)
- , ntohs(inet_sockaddrport(&rs->addr))
+ , FMT_RS(rs)
, subject);
} else if (vrrp)
snprintf(smtp->subject, MAX_HEADERS_LENGTH, "[%s] VRRP Instance %s - %s"
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/include/check_api.h
^
|
@@ -27,6 +27,16 @@
#include "check_data.h"
#include "scheduler.h"
+/* connection options structure definition */
+typedef struct _conn_opts {
+ struct sockaddr_storage dst;
+ struct sockaddr_storage bindto;
+ unsigned int connection_to; /* connection time-out */
+#ifdef _WITH_SO_MARK_
+ unsigned int fwmark; /* to mark packets going out of the socket using SO_MARK */
+#endif
+} conn_opts_t;
+
/* Checkers structure definition */
typedef struct _checker {
void (*free_func) (void *);
@@ -38,6 +48,8 @@
void *data;
checker_id_t id; /* Checker identifier */
int enabled;/* Activation flag */
+ conn_opts_t *co; /* connection options */
+ long warmup; /* max random timeout to start checker */
} checker_t;
/* Checkers queue */
@@ -45,8 +57,11 @@
/* utility macro */
#define CHECKER_ARG(X) ((X)->data)
+#define CHECKER_CO(X) (((checker_t *)X)->co)
#define CHECKER_DATA(X) (((checker_t *)X)->data)
-#define CHECKER_GET() (CHECKER_DATA(LIST_TAIL_DATA(checkers_queue)))
+#define CHECKER_GET_CURRENT() (LIST_TAIL_DATA(checkers_queue))
+#define CHECKER_GET() (CHECKER_DATA(CHECKER_GET_CURRENT()))
+#define CHECKER_GET_CO() (((checker_t *)CHECKER_GET_CURRENT())->co)
#define CHECKER_VALUE_INT(X) (atoi(vector_slot(X,1)))
#define CHECKER_VALUE_STRING(X) (set_value(X))
#define CHECKER_VHOST(C) (VHOST((C)->vs))
@@ -54,16 +69,22 @@
#define CHECKER_ENABLE(C) ((C)->enabled = 1)
#define CHECKER_DISABLE(C) ((C)->enabled = 0)
#define CHECKER_HA_SUSPEND(C) ((C)->vs->ha_suspend)
+#define CHECKER_NEW_CO() ((conn_opts_t *) MALLOC(sizeof (conn_opts_t)))
+#define FMT_CHK(C) FMT_RS((C)->rs)
/* Prototypes definition */
extern void init_checkers_queue(void);
+extern void dump_conn_opts (conn_opts_t *);
extern void queue_checker(void (*free_func) (void *), void (*dump_func) (void *)
, int (*launch) (thread_t *)
- , void *);
+ , void *
+ , conn_opts_t *);
extern void dump_checkers_queue(void);
extern void free_checkers_queue(void);
extern void register_checkers_thread(void);
extern void install_checkers_keyword(void);
+extern void install_connect_keywords(void);
+extern void warmup_handler(vector_t *);
extern void update_checker_activity(sa_family_t, void *, int);
extern void checker_set_dst(struct sockaddr_storage *);
extern void checker_set_dst_port(struct sockaddr_storage *, uint16_t);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/include/check_data.h
^
|
@@ -83,7 +83,7 @@
int alive;
list failed_checkers;/* List of failed checkers */
int set; /* in the IPVS table */
- int reloaded; /* active state was copied from old config while reloading */
+ int reloaded; /* active state was copied from old config while reloading */
#if defined(_WITH_SNMP_) && defined(_KRNL_2_6_) && defined(_WITH_LVS_)
/* Statistics */
uint32_t activeconns; /* active connections */
@@ -99,6 +99,7 @@
uint8_t range;
uint32_t vfwmark;
int alive;
+ int reloaded;
} virtual_server_group_entry_t;
typedef struct _virtual_server_group {
@@ -111,6 +112,7 @@
/* Virtual Server definition */
typedef struct _virtual_server {
char *vsgname;
+ virtual_server_group_t *vsg;
struct sockaddr_storage addr;
real_server_t *s_svr;
uint32_t vfwmark;
@@ -134,7 +136,7 @@
long unsigned hysteresis; /* up/down events "lag" WRT quorum. */
unsigned quorum_state; /* Reflects result of the last transition done. */
- int reloaded; /* quorum_state was copied from old config while reloading */
+ int reloaded; /* quorum_state was copied from old config while reloading */
#if defined(_WITH_SNMP_) && defined(_KRNL_2_6_) && defined(_WITH_LVS_)
/* Statistics */
time_t lastupdated;
@@ -210,6 +212,8 @@
#define SET_ALIVE(S) ((S)->alive = 1)
#define UNSET_ALIVE(S) ((S)->alive = 0)
#define VHOST(V) ((V)->virtualhost)
+#define FMT_RS(R) (inet_sockaddrtopair (&(R)->addr))
+#define FMT_VS(V) (format_vs((V)))
#define VS_ISEQ(X,Y) (sockstorage_equal(&(X)->addr,&(Y)->addr) &&\
(X)->vfwmark == (Y)->vfwmark &&\
@@ -251,5 +255,6 @@
extern check_data_t *alloc_check_data(void);
extern void free_check_data(check_data_t *);
extern void dump_check_data(check_data_t *);
+extern char *format_vs (virtual_server_t *);
#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/include/check_http.h
^
|
@@ -64,9 +64,6 @@
typedef struct _http_checker {
int proto;
- struct sockaddr_storage dst;
- struct sockaddr_storage bindto;
- long connection_to;
int nb_get_retry;
long delay_before_retry;
list url;
@@ -82,16 +79,17 @@
/* GET processing command */
#define REQUEST_TEMPLATE "GET %s HTTP/1.0\r\n" \
- "User-Agent:KeepAliveClient\r\n" \
+ "User-Agent: KeepAliveClient\r\n" \
"Host: %s%s\r\n\r\n"
#define REQUEST_TEMPLATE_IPV6 "GET %s HTTP/1.0\r\n" \
- "User-Agent:KeepAliveClient\r\n" \
- "Host: [%s]:%s\r\n\r\n"
+ "User-Agent: KeepAliveClient\r\n" \
+ "Host: [%s]%s\r\n\r\n"
/* macro utility */
#define HTTP_ARG(X) ((X)->arg)
#define HTTP_REQ(X) ((X)->req)
+#define FMT_HTTP_RS(C) FMT_CHK(C)
/* Define prototypes */
extern void install_http_check_keyword(void);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/include/check_smtp.h
^
|
@@ -31,6 +31,7 @@
#include "check_data.h"
#include "scheduler.h"
#include "list.h"
+#include "check_api.h"
#define SMTP_BUFF_MAX 512
@@ -45,10 +46,7 @@
#define SMTP_DEFAULT_PORT 25
/* Per host configuration structure */
-typedef struct _smtp_host {
- struct sockaddr_storage dst;
- struct sockaddr_storage bindto;
-} smtp_host_t;
+typedef conn_opts_t smtp_host_t;
/* Checker argument structure */
typedef struct _smtp_checker {
@@ -72,6 +70,9 @@
list host;
} smtp_checker_t;
+/* macro utility */
+#define FMT_SMTP_RS(H) (inet_sockaddrtopair (&(H)->dst))
+
/* Prototypes defs */
extern void install_smtp_check_keyword(void);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/include/check_tcp.h
^
|
@@ -31,12 +31,8 @@
/* local includes */
#include "scheduler.h"
-/* Checker argument structure */
-typedef struct _tcp_checker {
- struct sockaddr_storage dst;
- struct sockaddr_storage bindto;
- int connection_to;
-} tcp_checker_t;
+/* macro utility */
+#define FMT_TCP_RS(C) FMT_CHK(C)
/* Prototypes defs */
extern void install_tcp_check_keyword(void);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/include/ipvswrapper.h
^
|
@@ -92,8 +92,9 @@
extern int ipvs_start(void);
extern void ipvs_stop(void);
extern virtual_server_group_t *ipvs_get_group_by_name(char *, list);
+extern int ipvs_group_sync_entry(virtual_server_t *vs, virtual_server_group_entry_t *vsge);
extern int ipvs_group_remove_entry(virtual_server_t *, virtual_server_group_entry_t *);
-extern int ipvs_cmd(int, list, virtual_server_t *, real_server_t *);
+extern int ipvs_cmd(int, virtual_server_t *, real_server_t *);
extern int ipvs_syncd_cmd(int, char *, int, int);
extern void ipvs_syncd_master(char *, int);
extern void ipvs_syncd_backup(char *, int);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/include/ipwrapper.h
^
|
@@ -56,6 +56,6 @@
extern int init_services(void);
extern int clear_services(void);
extern int clear_diff_services(void);
-extern int copy_srv_states(void);
+extern void link_vsg_to_vs(void);
#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/include/layer4.h
^
|
@@ -34,6 +34,7 @@
/* local includes */
#include "scheduler.h"
+#include "check_api.h"
enum connect_result {
connect_error,
@@ -44,7 +45,7 @@
/* Prototypes defs */
extern enum connect_result
- tcp_bind_connect(int, struct sockaddr_storage *, struct sockaddr_storage *);
+ tcp_bind_connect(int, conn_opts_t *);
extern enum connect_result
tcp_connect(int, struct sockaddr_storage *);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/include/smtp.h
^
|
@@ -35,7 +35,6 @@
/* global defs */
#define SMTP_PORT_STR "25"
-#define SMTP_PORT 25
#define SMTP_BUFFER_LENGTH 512
#define SMTP_BUFFER_MAX 1024
#define SMTP_MAX_FSM_STATE 10
@@ -91,6 +90,8 @@
#define SMTP_SEND_CMD "\r\n.\r\n"
#define SMTP_QUIT_CMD "QUIT\r\n"
+#define FMT_SMTP_HOST() inet_sockaddrtopair(&global_data->smtp_server)
+
/* Prototypes defs */
extern void smtp_alert(real_server_t *, vrrp_t *, vrrp_sgroup_t *,
const char *, const char *);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/include/vrrp.h
^
|
@@ -64,6 +64,8 @@
#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_GARP_DELAY (5 * TIMER_HZ) /* Default delay to launch gratuitous arp */
+#define VRRP_GARP_REP 5 /* Default repeat value for MASTER state gratuitous arp */
+#define VRRP_GARP_REFRESH_REP 1 /* Default repeat value for refresh gratuitous arp */
/*
* parameters per vrrp sync group. A vrrp_sync_group is a set
@@ -100,14 +102,17 @@
list track_ifp; /* Interface state we monitor */
list track_script; /* Script state we monitor */
struct sockaddr_storage saddr; /* Src IP address to use in VRRP IP header */
+ struct sockaddr_storage pkt_saddr; /* Src IP address received in VRRP IP header */
list unicast_peer; /* List of Unicast peer to send advert to */
char *lvs_syncd_if; /* handle LVS sync daemon state using this
* instance FSM & running on specific interface
* => eth0 for example.
*/
int garp_delay; /* Delay to launch gratuitous ARP */
- int garp_refresh; /* Next scheduled gratuitous ARP refresh */
+ timeval_t garp_refresh; /* Next scheduled gratuitous ARP refresh */
timeval_t garp_refresh_timer; /* Next scheduled gratuitous ARP timer */
+ int garp_rep; /* gratuitous ARP repeat value */
+ int garp_refresh_rep; /* refresh gratuitous ARP repeat value */
int vrid; /* virtual id. from 1(!) to 255 */
int base_priority; /* configured priority value */
int effective_priority; /* effective priority value */
@@ -223,12 +228,12 @@
#define VRRP_ISUP(V) (VRRP_IF_ISUP(V) && VRRP_SCRIPT_ISUP(V))
/* prototypes */
-extern vrrphdr_t *vrrp_get_header(sa_family_t, char *, int *, uint32_t *);
+extern vrrphdr_t *vrrp_get_header(sa_family_t, char *, int *);
extern int open_vrrp_send_socket(sa_family_t, int, int, int);
extern int open_vrrp_socket(sa_family_t, int, int, int);
extern int new_vrrp_socket(vrrp_t *);
extern void close_vrrp_socket(vrrp_t *);
-extern void vrrp_send_link_update(vrrp_t *);
+extern void vrrp_send_link_update(vrrp_t *, int);
extern int vrrp_send_adv(vrrp_t *, int);
extern int vrrp_state_fault_rx(vrrp_t *, char *, int);
extern int vrrp_state_master_rx(vrrp_t *, char *, int);
@@ -238,6 +243,7 @@
extern void vrrp_state_leave_master(vrrp_t *);
extern int vrrp_ipsecah_len(void);
extern int vrrp_complete_init(void);
+extern int vrrp_ipvs_needed(void);
extern void shutdown_vrrp_instances(void);
extern void clear_diff_vrrp(void);
extern void clear_diff_script(void);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/include/vrrp_data.h
^
|
@@ -33,6 +33,7 @@
/* local includes */
#include "list.h"
#include "vector.h"
+#include "scheduler.h"
/*
* Our instance dispatcher use a socket pool.
@@ -41,11 +42,13 @@
*/
typedef struct _sock {
sa_family_t family;
+ struct sockaddr_storage saddr;
int proto;
int ifindex;
int unicast;
int fd_in;
int fd_out;
+ thread_t *thread;
} sock_t;
/* Configuration data root */
@@ -82,6 +85,5 @@
extern vrrp_data_t *alloc_vrrp_data(void);
extern void free_vrrp_data(vrrp_data_t *);
extern void dump_vrrp_data(vrrp_data_t *);
-extern void free_vrrp_sockpool(vrrp_data_t *);
#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/include/vrrp_ipaddress.h
^
|
@@ -78,7 +78,7 @@
(X)->ifa.ifa_scope == (Y)->ifa.ifa_scope && \
string_equal((X)->label, (Y)->label))
-#define IP_ISEQ(X,Y) ((IP_FAMILY(X) == IP_FAMILY(Y)) ? (IP_IS6(X) ? IP6_ISEQ(X, Y) : IP4_ISEQ(X, Y)) : 0)
+#define IP_ISEQ(X,Y) (((X) && (Y)) ? ((IP_FAMILY(X) == IP_FAMILY(Y)) ? (IP_IS6(X) ? IP6_ISEQ(X, Y) : IP4_ISEQ(X, Y)) : 0) : (((!(X) && (Y))||((X) && !(Y))) ? 0 : 1))
/* prototypes */
extern void netlink_iplist(list, int);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/include/vrrp_ipsecah.h
^
|
@@ -50,6 +50,7 @@
typedef struct { /* rfc2402.3.3.3.1.1.1 */
uint8_t tos;
+ uint8_t ttl;
uint16_t frag_off;
uint16_t check;
} ICV_mutable_fields; /* We need to zero this fields to compute the ICV */
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/include/vrrp_netlink.h
^
|
@@ -41,6 +41,7 @@
int fd;
struct sockaddr_nl snl;
__u32 seq;
+ thread_t *thread;
} nl_handle_t;
/* Define types */
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/libipvs-2.6/ip_vs.h
^
|
@@ -9,6 +9,7 @@
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
+#include <linux/types.h> /* For __beXX types in userland */
#ifdef LIBIPVS_USE_NL
#include <netlink/netlink.h>
@@ -16,13 +17,6 @@
#include <netlink/genl/ctrl.h>
#endif
-/* Userland compatibility with kernel */
-#define __u32 u_int32_t
-#define __be32 u_int32_t
-#define __u16 u_int16_t
-#define __be16 u_int16_t
-#define __u64 u_int64_t
-
#define IP_VS_VERSION_CODE 0x010201
#define NVERSION(version) \
(version >> 16) & 0xFF, \
@@ -476,6 +470,9 @@
IPVS_DEST_ATTR_PERSIST_CONNS, /* persistent connections */
IPVS_DEST_ATTR_STATS, /* nested attribute for dest stats */
+
+ IPVS_DEST_ATTR_ADDR_FAMILY, /* Address family of address */
+
__IPVS_DEST_ATTR_MAX,
};
@@ -540,10 +537,4 @@
/* End of Generic Netlink interface definitions */
-#undef __u32
-#undef __be32
-#undef __u16
-#undef __be16
-#undef __u64
-
#endif /* _IP_VS_H */
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/libipvs-2.6/ip_vs_nl_policy.c
^
|
@@ -40,6 +40,7 @@
[IPVS_DEST_ATTR_INACT_CONNS] = { .type = NLA_U32 },
[IPVS_DEST_ATTR_PERSIST_CONNS] = { .type = NLA_U32 },
[IPVS_DEST_ATTR_STATS] = { .type = NLA_NESTED },
+ [IPVS_DEST_ATTR_ADDR_FAMILY] = { .type = NLA_U16 },
};
struct nla_policy ipvs_stats_policy[IPVS_STATS_ATTR_MAX + 1] = {
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/libipvs-2.6/libipvs.c
^
|
@@ -54,6 +54,7 @@
CHECK_IPV4(s, ret); \
CHECK_PE(s, ret);
+#ifdef LIBIPVS_USE_NL
#ifndef FALLBACK_LIBNL1
static int nlerr2syserr(int err)
{
@@ -79,7 +80,6 @@
}
#endif
-#ifdef LIBIPVS_USE_NL
struct nl_msg *ipvs_nl_message(int cmd, int flags)
{
struct nl_msg *msg;
@@ -378,6 +378,7 @@
if (!nl_dest)
return -1;
+ NLA_PUT_U16(msg, IPVS_DEST_ATTR_ADDR_FAMILY, dst->af);
NLA_PUT(msg, IPVS_DEST_ATTR_ADDR, sizeof(dst->addr), &(dst->addr));
NLA_PUT_U16(msg, IPVS_DEST_ATTR_PORT, dst->port);
NLA_PUT_U32(msg, IPVS_DEST_ATTR_FWD_METHOD, dst->conn_flags & IP_VS_CONN_F_FWD_MASK);
@@ -779,6 +780,7 @@
struct nlmsghdr *nlh = nlmsg_hdr(msg);
struct nlattr *attrs[IPVS_CMD_ATTR_MAX + 1];
struct nlattr *dest_attrs[IPVS_DEST_ATTR_MAX + 1];
+ struct nlattr *attr_addr_family = NULL;
struct ip_vs_get_dests **dp = (struct ip_vs_get_dests **)arg;
struct ip_vs_get_dests *d = (struct ip_vs_get_dests *)*dp;
int i = d->num_dests;
@@ -816,7 +818,11 @@
d->entrytable[i].activeconns = nla_get_u32(dest_attrs[IPVS_DEST_ATTR_ACTIVE_CONNS]);
d->entrytable[i].inactconns = nla_get_u32(dest_attrs[IPVS_DEST_ATTR_INACT_CONNS]);
d->entrytable[i].persistconns = nla_get_u32(dest_attrs[IPVS_DEST_ATTR_PERSIST_CONNS]);
- d->entrytable[i].af = d->af;
+ attr_addr_family = dest_attrs[IPVS_DEST_ATTR_ADDR_FAMILY];
+ if (attr_addr_family)
+ d->entrytable[i].af = nla_get_u16(attr_addr_family);
+ else
+ d->entrytable[i].af = d->af;
if (ipvs_parse_stats(&(d->entrytable[i].stats),
dest_attrs[IPVS_DEST_ATTR_STATS]) != 0)
@@ -953,8 +959,7 @@
ipvs_service_entry_t *
-ipvs_get_service(u_int32_t fwmark, u_int16_t af, u_int16_t protocol, union nf_inet_addr addr,
- u_int16_t port)
+ipvs_get_service(__u32 fwmark, __u16 af, __u16 protocol, union nf_inet_addr addr, __u16 port)
{
ipvs_service_entry_t *svc;
socklen_t len;
@@ -971,6 +976,7 @@
if (!svc)
return NULL;
+ memset(&tsvc, 0, sizeof(tsvc));
tsvc.fwmark = fwmark;
tsvc.af = af;
tsvc.protocol= protocol;
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/libipvs-2.6/libipvs.h
^
|
@@ -111,8 +111,8 @@
ipvs_dest_cmp_t f);
/* get an ipvs service entry */
-extern ipvs_service_entry_t *ipvs_get_service(u_int32_t, u_int16_t, u_int16_t,
- union nf_inet_addr, u_int16_t);
+extern ipvs_service_entry_t *
+ipvs_get_service(__u32 fwmark, __u16 af, __u16 protocol, union nf_inet_addr addr, __u16 port);
/* get ipvs timeout */
extern ipvs_timeout_t *ipvs_get_timeout(void);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/vrrp/vrrp.c
^
|
@@ -96,14 +96,13 @@
/* VRRP header pointer from buffer */
vrrphdr_t *
-vrrp_get_header(sa_family_t family, char *buf, int *proto, uint32_t *saddr)
+vrrp_get_header(sa_family_t family, char *buf, int *proto)
{
struct iphdr *iph;
vrrphdr_t *hd = NULL;
if (family == AF_INET) {
iph = (struct iphdr *) buf;
- *saddr = iph->saddr;
/* Fill the VRRP header */
switch (iph->protocol) {
@@ -119,7 +118,6 @@
}
} else if (family == AF_INET6) {
*proto = IPPROTO_VRRP;
- *saddr = 0;
hd = (vrrphdr_t *) buf;
}
@@ -135,14 +133,13 @@
{
struct iphdr *ip = (struct iphdr *) (buffer);
ipsec_ah_t *ah = (ipsec_ah_t *) ((char *) ip + (ip->ihl << 2));
- unsigned char *digest;
+ unsigned char digest[16]; /*MD5_DIGEST_LENGTH */
uint32_t backup_auth_data[3];
/* first verify that the SPI value is equal to src IP */
if (ah->spi != ip->saddr) {
- log_message(LOG_INFO,
- "IPSEC AH : invalid IPSEC SPI value. %d and expect %d",
- ip->saddr, ah->spi);
+ log_message(LOG_INFO, "IPSEC AH : invalid IPSEC SPI value. %d and expect %d",
+ ip->saddr, ah->spi);
return 1;
}
@@ -155,10 +152,10 @@
if (ntohl(ah->seq_number) >= vrrp->ipsecah_counter->seq_number || vrrp->sync) {
vrrp->ipsecah_counter->seq_number = ntohl(ah->seq_number);
} else {
- log_message(LOG_INFO,
- "VRRP_Instance(%s) IPSEC-AH : sequence number %d"
- " already proceeded. Packet dropped. Local(%d)", vrrp->iname
- , ntohl(ah->seq_number), vrrp->ipsecah_counter->seq_number);
+ log_message(LOG_INFO, "VRRP_Instance(%s) IPSEC-AH : sequence number %d"
+ " already proceeded. Packet dropped. Local(%d)",
+ vrrp->iname, ntohl(ah->seq_number),
+ vrrp->ipsecah_counter->seq_number);
return 1;
}
@@ -166,14 +163,16 @@
* then compute a ICV to compare with the one present in AH pkt.
* alloc a temp memory space to stock the ip mutable fields
*/
- digest = (unsigned char *) MALLOC(16 * sizeof (unsigned char *));
/* zero the ip mutable fields */
ip->tos = 0;
ip->frag_off = 0;
ip->check = 0;
+ if (!LIST_ISEMPTY(vrrp->unicast_peer))
+ ip->ttl = 0;
memcpy(backup_auth_data, ah->auth_data, sizeof (ah->auth_data));
memset(ah->auth_data, 0, sizeof (ah->auth_data));
+ memset(digest, 0, 16);
/* Compute the ICV */
hmac_md5((unsigned char *) buffer,
@@ -183,12 +182,12 @@
if (memcmp(backup_auth_data, digest, HMAC_MD5_TRUNC) != 0) {
log_message(LOG_INFO, "VRRP_Instance(%s) IPSEC-AH : invalid"
- " IPSEC HMAC-MD5 value. Due to fields mutation"
- " or bad password !", vrrp->iname);
+ " IPSEC HMAC-MD5 value. Due to fields mutation"
+ " or bad password !",
+ vrrp->iname);
return 1;
}
- FREE(digest);
return 0;
}
@@ -259,7 +258,7 @@
*/
if ((ntohs(ip->tot_len) - ihl) <= sizeof(vrrphdr_t)) {
log_message(LOG_INFO,
- "ip payload too short. %d and expect at least %d",
+ "ip payload too short. %d and expect at least %lu",
ntohs(ip->tot_len) - ihl, sizeof(vrrphdr_t));
return VRRP_PACKET_KO;
}
@@ -301,7 +300,7 @@
/* check the authenicaion if it is ipsec ah */
if (hd->auth_type == VRRP_AUTH_AH)
- return (vrrp_in_chk_ipsecah(vrrp, buffer));
+ return vrrp_in_chk_ipsecah(vrrp, buffer);
/* Set expected vrrp packet lenght */
vrrphdr_len = sizeof(vrrphdr_t) + VRRP_AUTH_LEN + hd->naddr * sizeof(uint32_t);
@@ -418,6 +417,7 @@
/* backup the ip mutable fields */
ip_mutable_fields->tos = ip->tos;
+ ip_mutable_fields->ttl = ip->ttl;
ip_mutable_fields->frag_off = ip->frag_off;
ip_mutable_fields->check = ip->check;
@@ -425,6 +425,8 @@
ip->tos = 0;
ip->frag_off = 0;
ip->check = 0;
+ if (!LIST_ISEMPTY(vrrp->unicast_peer))
+ ip->ttl = 0;
/* fill in the Payload len field */
ah->payload_len = IPSEC_AH_PLEN;
@@ -463,7 +465,7 @@
=> No padding needed.
-- rfc2402.3.3.3.1.1.1 & rfc2401.5
*/
- digest = (unsigned char *) MALLOC(16 * sizeof (unsigned char *));
+ digest = (unsigned char *) MALLOC(16); /*MD5_DIGEST_LENGTH */
hmac_md5((unsigned char *) buffer, buflen, vrrp->auth_data, sizeof (vrrp->auth_data)
, digest);
memcpy(ah->auth_data, digest, HMAC_MD5_TRUNC);
@@ -472,6 +474,8 @@
ip->tos = ip_mutable_fields->tos;
ip->frag_off = ip_mutable_fields->frag_off;
ip->check = ip_mutable_fields->check;
+ if (!LIST_ISEMPTY(vrrp->unicast_peer))
+ ip->ttl = ip_mutable_fields->ttl;
FREE(ip_mutable_fields);
FREE(digest);
@@ -569,14 +573,37 @@
/* send VRRP packet */
static int
+vrrp_build_ancillary_data(struct msghdr *msg, char *cbuf, struct sockaddr_storage *src)
+{
+ struct cmsghdr *cmsg;
+ struct in6_pktinfo *pkt;
+
+ if (src->ss_family != AF_INET6)
+ return -1;
+
+ msg->msg_control = cbuf;
+ msg->msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
+
+ cmsg = CMSG_FIRSTHDR(msg);
+ cmsg->cmsg_level = IPPROTO_IPV6;
+ cmsg->cmsg_type = IPV6_PKTINFO;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
+
+ pkt = (struct in6_pktinfo *) CMSG_DATA(cmsg);
+ memset(pkt, 0, sizeof(struct in6_pktinfo));
+ pkt->ipi6_addr = ((struct sockaddr_in6 *) src)->sin6_addr;
+ pkt->ipi6_ifindex = ((struct sockaddr_in6 *) src)->sin6_scope_id;
+
+ return 0;
+}
+
+static int
vrrp_send_pkt(vrrp_t * vrrp, struct sockaddr_storage *addr)
{
struct sockaddr_storage *src = &vrrp->saddr;
struct sockaddr_in6 dst6;
- struct in6_pktinfo *pkt;
struct sockaddr_in dst4;
struct msghdr msg;
- struct cmsghdr *cmsg;
struct iovec iov;
char cbuf[256];
@@ -594,19 +621,7 @@
} else if (addr && addr->ss_family == AF_INET6) {
msg.msg_name = (struct sockaddr_in6 *) addr;
msg.msg_namelen = sizeof(struct sockaddr_in6);
- if (src->ss_family == AF_INET6) {
- msg.msg_control = cbuf;
- msg.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
-
- cmsg = CMSG_FIRSTHDR(&msg);
- cmsg->cmsg_level = IPPROTO_IPV6;
- cmsg->cmsg_type = IPV6_PKTINFO;
- cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
-
- pkt = (struct in6_pktinfo *) CMSG_DATA(cmsg);
- memset(pkt, 0, sizeof(struct in6_pktinfo));
- pkt->ipi6_addr = ((struct sockaddr_in6 *) src)->sin6_addr;
- }
+ vrrp_build_ancillary_data(&msg, cbuf, src);
} else if (vrrp->family == AF_INET) { /* Multicast sending path */
memset(&dst4, 0, sizeof(dst4));
dst4.sin_family = AF_INET;
@@ -619,6 +634,7 @@
dst6.sin6_addr = ((struct sockaddr_in6 *) &global_data->vrrp_mcast_group6)->sin6_addr;
msg.msg_name = &dst6;
msg.msg_namelen = sizeof(dst6);
+ vrrp_build_ancillary_data(&msg, cbuf, src);
}
/* Send the packet */
@@ -722,7 +738,7 @@
}
void
-vrrp_send_link_update(vrrp_t * vrrp)
+vrrp_send_link_update(vrrp_t * vrrp, int rep)
{
int j;
ip_address_t *ipaddress;
@@ -733,7 +749,7 @@
return;
/* send gratuitous arp for each virtual ip */
- for (j = 0; j < 5; j++) {
+ for (j = 0; j < rep; j++) {
if (!LIST_ISEMPTY(vrrp->vip)) {
for (e = LIST_HEAD(vrrp->vip); e; ELEMENT_NEXT(e)) {
ipaddress = ELEMENT_DATA(e);
@@ -766,11 +782,11 @@
vrrp_handle_iproutes(vrrp, IPROUTE_ADD);
/* remotes neighbour update */
- vrrp_send_link_update(vrrp);
+ vrrp_send_link_update(vrrp, vrrp->garp_rep);
/* set refresh timer */
- if (vrrp->garp_refresh) {
- vrrp->garp_refresh_timer = timer_add_long(time_now, vrrp->garp_refresh);
+ if (!timer_isnull(vrrp->garp_refresh)) {
+ vrrp->garp_refresh_timer = timer_add_now(vrrp->garp_refresh);
}
/* Check if notify is needed */
@@ -787,19 +803,9 @@
#endif
}
-/* If the preempt_delay is set we cannot yet transition to master state. We
- * must await the timeout of our preempt_delay. The preemption delay is used
- * when starting up, or rebooting, a node which needs time to sort out its
- * routing table (e.g., BGP or OSPF) before it can assume the master role.
- */
void
vrrp_state_goto_master(vrrp_t * vrrp)
{
- if (timer_cmp(vrrp->preempt_time, timer_now()) > 0) {
- vrrp->ms_down_timer = timer_tol(timer_sub(vrrp->preempt_time, timer_now()));
- return;
- }
-
/*
* Send an advertisement. To force a new master
* election.
@@ -896,11 +902,10 @@
vrrp_state_backup(vrrp_t * vrrp, char *buf, int buflen)
{
vrrphdr_t *hd;
- uint32_t saddr;
int ret = 0, proto;
/* Process the incoming packet */
- hd = vrrp_get_header(vrrp->family, buf, &proto, &saddr);
+ hd = vrrp_get_header(vrrp->family, buf, &proto);
ret = vrrp_check_packet(vrrp, buf, buflen);
if (ret == VRRP_PACKET_KO || ret == VRRP_PACKET_NULL) {
@@ -931,9 +936,10 @@
, vrrp->iname);
vrrp_state_become_master(vrrp);
ret = 1;
- } else if (vrrp->garp_refresh && timer_cmp(time_now, vrrp->garp_refresh_timer) > 0) {
- vrrp_send_link_update(vrrp);
- vrrp->garp_refresh_timer = timer_add_long(time_now, vrrp->garp_refresh);
+ } else if (!timer_isnull(vrrp->garp_refresh) &&
+ timer_cmp(time_now, vrrp->garp_refresh_timer) > 0) {
+ vrrp_send_link_update(vrrp, vrrp->garp_refresh_rep);
+ vrrp->garp_refresh_timer = timer_add_now(vrrp->garp_refresh);
}
vrrp_send_adv(vrrp,
@@ -942,12 +948,36 @@
return ret;
}
+static int
+vrrp_saddr_cmp(struct sockaddr_storage *addr, vrrp_t *vrrp)
+{
+ interface_t *ifp = vrrp->ifp;
+
+ /* Simple sanity */
+ if (vrrp->saddr.ss_family && addr->ss_family != vrrp->saddr.ss_family)
+ return 0;
+
+ /* Configured source IP address */
+ if (vrrp->saddr.ss_family)
+ return inet_sockaddrcmp(addr, &vrrp->saddr);
+
+ /* Default interface source IP address */
+ if (addr->ss_family == AF_INET)
+ return inet_inaddrcmp(addr->ss_family,
+ &((struct sockaddr_in *) addr)->sin_addr,
+ &ifp->sin_addr);
+ if (addr->ss_family == AF_INET6)
+ return inet_inaddrcmp(addr->ss_family,
+ &((struct sockaddr_in6 *) addr)->sin6_addr,
+ &ifp->sin6_addr);
+ return 0;
+}
+
int
vrrp_state_master_rx(vrrp_t * vrrp, char *buf, int buflen)
{
vrrphdr_t *hd = NULL;
int ret = 0, proto = 0;
- uint32_t saddr = 0;
ipsec_ah_t *ah;
/* return on link failure */
@@ -959,7 +989,7 @@
}
/* Process the incoming packet */
- hd = vrrp_get_header(vrrp->family, buf, &proto, &saddr);
+ hd = vrrp_get_header(vrrp->family, buf, &proto);
ret = vrrp_check_packet(vrrp, buf, buflen);
if (ret == VRRP_PACKET_KO ||
@@ -981,50 +1011,34 @@
vrrp->ipsecah_counter->cycle = 0;
}
vrrp_send_adv(vrrp, vrrp->effective_priority);
- vrrp_send_link_update(vrrp);
+ vrrp_send_link_update(vrrp, vrrp->garp_rep);
return 0;
} else if (hd->priority == 0) {
vrrp_send_adv(vrrp, vrrp->effective_priority);
return 0;
- } else if (vrrp->family == AF_INET) {
- if (hd->priority > vrrp->effective_priority ||
- (hd->priority == vrrp->effective_priority &&
- ntohl(saddr) > ntohl(VRRP_PKT_SADDR(vrrp)))) {
- /* We send a last advert here in order to refresh remote MASTER
- * coming up to force link update at MASTER side.
- */
- vrrp_send_adv(vrrp, vrrp->effective_priority);
+ } else if (hd->priority > vrrp->effective_priority ||
+ (hd->priority == vrrp->effective_priority &&
+ vrrp_saddr_cmp(&vrrp->pkt_saddr, vrrp) > 0)) {
+ /* We send a last advert here in order to refresh remote MASTER
+ * coming up to force link update at MASTER side.
+ */
+ vrrp_send_adv(vrrp, vrrp->effective_priority);
- log_message(LOG_INFO, "VRRP_Instance(%s) Received higher prio advert"
+ log_message(LOG_INFO, "VRRP_Instance(%s) Received higher prio advert"
+ , vrrp->iname);
+ if (proto == IPPROTO_IPSEC_AH) {
+ ah = (ipsec_ah_t *) (buf + sizeof(struct iphdr));
+ log_message(LOG_INFO, "VRRP_Instance(%s) IPSEC-AH : Syncing seq_num"
+ " - Decrement seq"
, vrrp->iname);
- if (proto == IPPROTO_IPSEC_AH) {
- ah = (ipsec_ah_t *) (buf + sizeof(struct iphdr));
- log_message(LOG_INFO, "VRRP_Instance(%s) IPSEC-AH : Syncing seq_num"
- " - Decrement seq"
- , vrrp->iname);
- vrrp->ipsecah_counter->seq_number = ntohl(ah->seq_number) - 1;
- vrrp->ipsecah_counter->cycle = 0;
- }
- vrrp->ms_down_timer = 3 * vrrp->adver_int + VRRP_TIMER_SKEW(vrrp);
- vrrp->wantstate = VRRP_STATE_BACK;
- vrrp->state = VRRP_STATE_BACK;
- return 1;
+ vrrp->ipsecah_counter->seq_number = ntohl(ah->seq_number) - 1;
+ vrrp->ipsecah_counter->cycle = 0;
}
- } else if (vrrp->family == AF_INET6) {
- /* FIXME: compare v6 saddr to link local when prio are equal !!! */
- if (hd->priority > vrrp->effective_priority) {
- /* We send a last advert here in order to refresh remote MASTER
- * coming up to force link update at MASTER side.
- */
- vrrp_send_adv(vrrp, vrrp->effective_priority);
- log_message(LOG_INFO, "VRRP_Instance(%s) Received higher prio advert"
- , vrrp->iname);
- vrrp->ms_down_timer = 3 * vrrp->adver_int + VRRP_TIMER_SKEW(vrrp);
- vrrp->wantstate = VRRP_STATE_BACK;
- vrrp->state = VRRP_STATE_BACK;
- return 1;
- }
+ vrrp->ms_down_timer = 3 * vrrp->adver_int + VRRP_TIMER_SKEW(vrrp);
+ vrrp->wantstate = VRRP_STATE_BACK;
+ vrrp->state = VRRP_STATE_BACK;
+ return 1;
}
return 0;
@@ -1034,11 +1048,10 @@
vrrp_state_fault_rx(vrrp_t * vrrp, char *buf, int buflen)
{
vrrphdr_t *hd;
- uint32_t saddr;
int ret = 0, proto;
/* Process the incoming packet */
- hd = vrrp_get_header(vrrp->family, buf, &proto, &saddr);
+ hd = vrrp_get_header(vrrp->family, buf, &proto);
ret = vrrp_check_packet(vrrp, buf, buflen);
if (ret == VRRP_PACKET_KO || ret == VRRP_PACKET_NULL || ret == VRRP_PACKET_DROP) {
@@ -1153,7 +1166,7 @@
void
close_vrrp_socket(vrrp_t * vrrp)
{
- if (!LIST_ISEMPTY(vrrp->unicast_peer)) {
+ if (LIST_ISEMPTY(vrrp->unicast_peer)) {
if_leave_vrrp_group(vrrp->family, vrrp->fd_in, vrrp->ifp);
} else {
close(vrrp->fd_in);
@@ -1262,6 +1275,25 @@
return 1;
}
+int
+vrrp_ipvs_needed(void)
+{
+ vrrp_t *vrrp;
+ element e;
+
+ if (!vrrp_data)
+ return 0;
+
+ for (e = LIST_HEAD(vrrp_data->vrrp); e; ELEMENT_NEXT(e)) {
+ vrrp = ELEMENT_DATA(e);
+ if (vrrp->lvs_syncd_if) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
/* Try to find a VRRP instance */
static vrrp_t *
vrrp_exist(vrrp_t * old_vrrp)
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/vrrp/vrrp_daemon.c
^
|
@@ -53,9 +53,7 @@
static void
stop_vrrp(void)
{
- /* Destroy master thread */
signal_handler_destroy();
- thread_destroy_master(master);
if (!(debug & 8))
shutdown_vrrp_instances();
@@ -64,9 +62,6 @@
netlink_rtlist(vrrp_data->static_routes, IPROUTE_DEL);
netlink_iplist(vrrp_data->static_addresses, IPADDRESS_DEL);
- free_interface_queue();
- gratuitous_arp_close();
- ndisc_close();
#ifdef _WITH_SNMP_
if (snmp)
vrrp_snmp_agent_close();
@@ -75,16 +70,23 @@
/* Stop daemon */
pidfile_rm(vrrp_pidfile);
+#ifdef _WITH_LVS_
+ if (vrrp_ipvs_needed()) {
+ /* Clean ipvs related */
+ ipvs_stop();
+ }
+#endif
+
/* Clean data */
free_global_data(global_data);
- free_vrrp_sockpool(vrrp_data);
+ vrrp_dispatcher_release(vrrp_data);
free_vrrp_data(vrrp_data);
free_vrrp_buffer();
-
-#ifdef _WITH_LVS_
- /* Clean ipvs related */
- ipvs_stop();
-#endif
+ free_interface_queue();
+ kernel_netlink_close();
+ thread_destroy_master(master);
+ gratuitous_arp_close();
+ ndisc_close();
#ifdef _DEBUG_
keepalived_free_final("VRRP Child process");
@@ -112,10 +114,6 @@
vrrp_snmp_agent_init();
#endif
-#ifdef _WITH_LVS_
- /* Initialize ipvs related */
- ipvs_start();
-#endif
/* Parse configuration file */
global_data = alloc_global_data();
vrrp_data = alloc_vrrp_data();
@@ -126,6 +124,16 @@
return;
}
+#ifdef _WITH_LVS_
+ if (vrrp_ipvs_needed()) {
+ /* Initialize ipvs related */
+ if (ipvs_start() != IPVS_SUCCESS) {
+ stop_vrrp();
+ return;
+ }
+ }
+#endif
+
if (reload) {
clear_diff_saddresses();
clear_diff_sroutes();
@@ -135,7 +143,9 @@
/* Complete VRRP initialization */
if (!vrrp_complete_init()) {
- stop_vrrp();
+ if (vrrp_ipvs_needed()) {
+ stop_vrrp();
+ }
return;
}
@@ -199,6 +209,8 @@
signal_handler_destroy();
/* Destroy master thread */
+ vrrp_dispatcher_release(vrrp_data);
+ kernel_netlink_close();
thread_destroy_master(master);
master = thread_make_master();
free_global_data(global_data);
@@ -207,24 +219,23 @@
gratuitous_arp_close();
ndisc_close();
+#ifdef _WITH_LVS_
+ if (vrrp_ipvs_needed()) {
+ /* Clean ipvs related */
+ ipvs_stop();
+ }
+#endif
+
/* Save previous conf data */
old_vrrp_data = vrrp_data;
vrrp_data = NULL;
-#ifdef _WITH_LVS_
- /* Clean ipvs related */
- ipvs_stop();
-#endif
-
/* Reload the conf */
mem_allocated = 0;
vrrp_signal_init();
signal_set(SIGCHLD, thread_child_handler, master);
start_vrrp();
- /* Close sockpool */
- free_vrrp_sockpool(old_vrrp_data);
-
/* free backup data */
free_vrrp_data(old_vrrp_data);
UNSET_RELOAD;
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/vrrp/vrrp_data.c
^
|
@@ -116,8 +116,8 @@
log_message(LOG_INFO, " VRRP Script = %s", vscript->sname);
log_message(LOG_INFO, " Command = %s", vscript->script);
- log_message(LOG_INFO, " Interval = %d sec", vscript->interval / TIMER_HZ);
- log_message(LOG_INFO, " Timeout = %d sec", vscript->timeout / TIMER_HZ);
+ log_message(LOG_INFO, " Interval = %d sec", (int)(vscript->interval / TIMER_HZ));
+ log_message(LOG_INFO, " Timeout = %d sec", (int)(vscript->timeout / TIMER_HZ));
log_message(LOG_INFO, " Weight = %d", vscript->weight);
log_message(LOG_INFO, " Rise = %d", vscript->rise);
log_message(LOG_INFO, " Fall = %d", vscript->fall);
@@ -141,6 +141,11 @@
{
sock_t *sock = sock_data;
interface_t *ifp;
+
+ /* First of all cancel pending thread */
+ thread_cancel(sock->thread);
+
+ /* Close related socket */
if (sock->fd_in > 0) {
ifp = if_get_by_ifindex(sock->ifindex);
if (sock->unicast) {
@@ -237,9 +242,11 @@
if (vrrp->garp_delay)
log_message(LOG_INFO, " Gratuitous ARP delay = %d",
vrrp->garp_delay/TIMER_HZ);
- if (vrrp->garp_refresh)
- log_message(LOG_INFO, " Gratuitous ARP refresh timer = %d",
- vrrp->garp_refresh/TIMER_HZ);
+ if (!timer_isnull(vrrp->garp_refresh))
+ log_message(LOG_INFO, " Gratuitous ARP refresh timer = %lu",
+ vrrp->garp_refresh.tv_sec);
+ log_message(LOG_INFO, " Gratuitous ARP repeat = %d", vrrp->garp_rep);
+ log_message(LOG_INFO, " Gratuitous ARP refresh repeat = %d", vrrp->garp_refresh_rep);
log_message(LOG_INFO, " Virtual Router ID = %d", vrrp->vrid);
log_message(LOG_INFO, " Priority = %d", vrrp->base_priority);
log_message(LOG_INFO, " Advert interval = %dsec",
@@ -343,6 +350,8 @@
new->iname = (char *) MALLOC(size + 1);
memcpy(new->iname, iname, size);
new->quick_sync = 0;
+ new->garp_rep = VRRP_GARP_REP;
+ new->garp_refresh_rep = VRRP_GARP_REFRESH_REP;
list_add(vrrp_data->vrrp, new);
}
@@ -363,7 +372,7 @@
if (ret < 0) {
log_message(LOG_ERR, "Configuration error: VRRP instance[%s] malformed unicast"
" peer address[%s]. Skipping..."
- , vrrp->iname, vector_slot(strvec, 0));
+ , vrrp->iname, FMT_STR_VSLOT(strvec, 0));
FREE(peer);
return;
}
@@ -371,7 +380,7 @@
if (peer->ss_family != vrrp->family) {
log_message(LOG_ERR, "Configuration error: VRRP instance[%s] and unicast peer address"
"[%s] MUST be of the same family !!! Skipping..."
- , vrrp->iname, vector_slot(strvec, 0));
+ , vrrp->iname, FMT_STR_VSLOT(strvec, 0));
FREE(peer);
return;
}
@@ -490,17 +499,10 @@
free_list(data->vrrp);
free_list(data->vrrp_sync_group);
free_list(data->vrrp_script);
-// free_list(data->vrrp_socket_pool);
FREE(data);
}
void
-free_vrrp_sockpool(vrrp_data_t * data)
-{
- free_list(data->vrrp_socket_pool);
-}
-
-void
dump_vrrp_data(vrrp_data_t * data)
{
if (!LIST_ISEMPTY(data->static_addresses)) {
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/vrrp/vrrp_if.c
^
|
@@ -23,11 +23,11 @@
/* global include */
#include <unistd.h>
#include <string.h>
-#include <sys/types.h>
-typedef __uint64_t u64;
-typedef __uint32_t u32;
-typedef __uint16_t u16;
-typedef __uint8_t u8;
+#include <stdint.h>
+typedef uint64_t u64;
+typedef uint32_t u32;
+typedef uint16_t u16;
+typedef uint8_t u8;
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
@@ -408,15 +408,14 @@
if (!LIST_ISEMPTY(if_queue))
free_list(if_queue);
if_queue = NULL;
- kernel_netlink_close();
}
void
init_interface_queue(void)
{
init_if_queue();
-// dump_list(if_queue);
netlink_interface_lookup();
+// dump_list(if_queue);
}
void
@@ -478,7 +477,7 @@
int
if_leave_vrrp_group(sa_family_t family, int sd, interface_t *ifp)
{
- struct ip_mreqn imr;
+ struct ip_mreq imr;
struct ipv6_mreq imr6;
int ret = 0;
@@ -489,19 +488,13 @@
/* Leaving the VRRP multicast group */
if (family == AF_INET) {
memset(&imr, 0, sizeof(imr));
- /* FIXME: change this to use struct ip_mreq */
- imr.imr_multiaddr.s_addr = htonl(INADDR_VRRP_GROUP);
- imr.imr_address.s_addr = IF_ADDR(ifp);
- imr.imr_ifindex = IF_INDEX(ifp);
+ imr.imr_multiaddr = ((struct sockaddr_in *) &global_data->vrrp_mcast_group4)->sin_addr;
+ imr.imr_interface.s_addr = IF_ADDR(ifp);
ret = setsockopt(sd, IPPROTO_IP, IP_DROP_MEMBERSHIP,
- (char *) &imr, sizeof (struct ip_mreqn));
+ (char *) &imr, sizeof(struct ip_mreq));
} else {
memset(&imr6, 0, sizeof(imr6));
- /* rfc5798.5.1.2.2 : destination IPv6 mcast group is
- * ff02:0:0:0:0:0:0:12.
- */
- imr6.ipv6mr_multiaddr.s6_addr16[0] = htons(0xff02);
- imr6.ipv6mr_multiaddr.s6_addr16[7] = htons(0x12);
+ imr6.ipv6mr_multiaddr = ((struct sockaddr_in6 *) &global_data->vrrp_mcast_group6)->sin6_addr;
imr6.ipv6mr_interface = IF_INDEX(ifp);
ret = setsockopt(sd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP,
(char *) &imr6, sizeof(struct ipv6_mreq));
@@ -577,7 +570,7 @@
if (*sd < 0)
return -1;
- /* Include IP header into RAW protocol packet */
+ /* Set Multicast loop */
if (family == AF_INET)
ret = setsockopt(*sd, IPPROTO_IP, IP_MULTICAST_LOOP, &loop, sizeof(loop));
else
@@ -603,7 +596,7 @@
if (*sd < 0 || family == AF_INET)
return -1;
- /* Include IP header into RAW protocol packet */
+ /* Set HOP limit */
ret = setsockopt(*sd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &hops, sizeof(hops));
if (ret < 0) {
log_message(LOG_INFO, "cant set IPV6_MULTICAST_HOPS IP option. errno=%d (%m)", errno);
@@ -624,7 +617,7 @@
if (*sd < 0 || family == AF_INET)
return -1;
- /* Include IP header into RAW protocol packet */
+ /* Set interface for sending outbound datagrams */
ifindex = IF_INDEX(ifp);
ret = setsockopt(*sd, IPPROTO_IPV6, IPV6_MULTICAST_IF, &ifindex, sizeof(ifindex));
if (ret < 0) {
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/vrrp/vrrp_index.c
^
|
@@ -91,6 +91,7 @@
element next;
list l = &vrrp_data->vrrp_index_fd[old_fd%1024 + 1];
+ /* Release old stalled entries */
for (e = LIST_HEAD(l); e; e = next) {
next = e->next;
vrrp_ptr = ELEMENT_DATA(e);
@@ -106,14 +107,21 @@
l->tail = e->prev;
l->count--;
FREE(e);
+ }
+ }
+ if (LIST_ISEMPTY(l))
+ l->head = l->tail = NULL;
+
+ /* Hash refreshed entries */
+ l = vrrp_data->vrrp;
+ for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
+ vrrp_ptr = ELEMENT_DATA(e);
+ if (vrrp_ptr->fd_in == old_fd) {
/* Update new hash */
vrrp_ptr->fd_in = vrrp->fd_in;
vrrp_ptr->fd_out = vrrp->fd_out;
alloc_vrrp_fd_bucket(vrrp_ptr);
}
}
-
- if (LIST_ISEMPTY(l))
- l->head = l->tail = NULL;
}
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/vrrp/vrrp_ipaddress.c
^
|
@@ -265,12 +265,12 @@
if (IP_IS6(new)) {
log_message(LOG_INFO, "VRRP is trying to assign a broadcast %s to the IPv6 address %s !!?? "
"WTF... skipping VIP..."
- , vector_slot(strvec, i), vector_slot(strvec, addr_idx));
+ , FMT_STR_VSLOT(strvec, i), FMT_STR_VSLOT(strvec, addr_idx));
FREE(new);
return;
} else if (!inet_pton(AF_INET, vector_slot(strvec, ++i), &new->u.sin.sin_brd)) {
log_message(LOG_INFO, "VRRP is trying to assign invalid broadcast %s. "
- "skipping VIP...", vector_slot(strvec, i));
+ "skipping VIP...", FMT_STR_VSLOT(strvec, i));
FREE(new);
return;
}
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/vrrp/vrrp_netlink.c
^
|
@@ -114,6 +114,8 @@
int
netlink_close(nl_handle_t *nl)
{
+ /* First of all release pending thread */
+ thread_cancel(nl->thread);
close(nl->fd);
return 0;
}
@@ -242,6 +244,25 @@
return -1;
}
+/*
+ * Reflect base interface flags on VMAC interface.
+ * VMAC interfaces should never update it own flags, only be reflected
+ * by the base interface flags.
+ */
+static void
+vmac_reflect_flags(struct ifinfomsg *ifi)
+{
+ interface_t *ifp;
+
+ /* find the VMAC interface (if any) */
+ ifp = if_get_by_vmac_base_ifindex(ifi->ifi_index);
+
+ /* if found, reflect base interface flags on VMAC interface */
+ if (ifp) {
+ ifp->flags = ifi->ifi_flags;
+ }
+}
+
/* Our netlink parser */
static int
netlink_parse_info(int (*filter) (struct sockaddr_nl *, struct nlmsghdr *),
@@ -462,7 +483,10 @@
/* Skip it if already exist */
ifp = if_get_by_ifname(name);
if (ifp) {
- ifp->flags = ifi->ifi_flags;
+ if (!ifp->vmac) {
+ vmac_reflect_flags(ifi);
+ ifp->flags = ifi->ifi_flags;
+ }
return 0;
}
@@ -470,11 +494,15 @@
ifp = (interface_t *) MALLOC(sizeof(interface_t));
memcpy(ifp->ifname, name, strlen(name));
ifp->ifindex = ifi->ifi_index;
- ifp->base_ifindex = ifi->ifi_index;
- ifp->flags = ifi->ifi_flags;
ifp->mtu = *(int *) RTA_DATA(tb[IFLA_MTU]);
ifp->hw_type = ifi->ifi_type;
+ if (!ifp->vmac) {
+ vmac_reflect_flags(ifi);
+ ifp->flags = ifi->ifi_flags;
+ ifp->base_ifindex = ifi->ifi_index;
+ }
+
if (tb[IFLA_ADDRESS]) {
int hw_addr_len = RTA_PAYLOAD(tb[IFLA_ADDRESS]);
@@ -654,20 +682,20 @@
if (ifi->ifi_type == ARPHRD_LOOPBACK)
return 0;
- /* find the VMAC interface (if any) */
- ifp = if_get_by_vmac_base_ifindex(ifi->ifi_index);
-
- /* if found, reflect base interface flags on VMAC interface */
- if (ifp)
- ifp->flags = ifi->ifi_flags;
-
/* find the interface_t */
ifp = if_get_by_ifindex(ifi->ifi_index);
if (!ifp)
return -1;
- /* Update flags */
- ifp->flags = ifi->ifi_flags;
+ /*
+ * Update flags.
+ * VMAC interfaces should never update it own flags, only be reflected
+ * by the base interface flags.
+ */
+ if (!ifp->vmac) {
+ vmac_reflect_flags(ifi);
+ ifp->flags = ifi->ifi_flags;
+ }
return 0;
}
@@ -697,10 +725,12 @@
int
kernel_netlink(thread_t * thread)
{
+ nl_handle_t *nl = THREAD_ARG(thread);
+
if (thread->type != THREAD_READ_TIMEOUT)
- netlink_parse_info(netlink_broadcast_filter, &nl_kernel, NULL);
- thread_add_read(master, kernel_netlink, NULL, nl_kernel.fd,
- NETLINK_TIMER);
+ netlink_parse_info(netlink_broadcast_filter, nl, NULL);
+ nl->thread = thread_add_read(master, kernel_netlink, nl, nl->fd,
+ NETLINK_TIMER);
return 0;
}
@@ -722,8 +752,8 @@
if (nl_kernel.fd > 0) {
log_message(LOG_INFO, "Registering Kernel netlink reflector");
- thread_add_read(master, kernel_netlink, NULL, nl_kernel.fd,
- NETLINK_TIMER);
+ nl_kernel.thread = thread_add_read(master, kernel_netlink, &nl_kernel, nl_kernel.fd,
+ NETLINK_TIMER);
} else
log_message(LOG_INFO, "Error while registering Kernel netlink reflector channel");
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/vrrp/vrrp_parser.c
^
|
@@ -110,9 +110,24 @@
vrrp_vmac_handler(vector_t *strvec)
{
vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
+ interface_t *ifp = vrrp->ifp;
+ struct sockaddr_storage *saddr = &vrrp->saddr;
+
vrrp->vmac_flags |= VRRP_VMAC_FL_SET;
- if (!vrrp->saddr.ss_family && vrrp->family == AF_INET)
- inet_ip4tosockaddr(IF_ADDR(vrrp->ifp), &vrrp->saddr);
+ if (!vrrp->saddr.ss_family) {
+ if (!ifp) {
+ log_message(LOG_INFO, "Please define interface keyword before use_vmac keyword");
+ return;
+ } else {
+ if (vrrp->family == AF_INET) {
+ inet_ip4tosockaddr(&ifp->sin_addr, saddr);
+ } else if (vrrp->family == AF_INET6) {
+ inet_ip6tosockaddr(&ifp->sin6_addr, saddr);
+ /* IPv6 use-case: Binding to link-local address requires an interface */
+ inet_ip6scopeid(IF_INDEX(ifp), saddr);
+ }
+ }
+ }
if (vector_size(strvec) == 2) {
strncpy(vrrp->vmac_ifname, vector_slot(strvec, 1),
IFNAMSIZ - 1);
@@ -142,6 +157,9 @@
vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
vrrp->family = AF_INET6;
+ if (vrrp->vmac_flags & VRRP_VMAC_FL_SET)
+ log_message(LOG_INFO, "You should declare native_ipv6 before use_vmac!");
+
if (vrrp->auth_type != VRRP_AUTH_NONE)
vrrp->auth_type = VRRP_AUTH_NONE;
}
@@ -198,6 +216,7 @@
vrrp_srcip_handler(vector_t *strvec)
{
vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
+ interface_t *ifp = vrrp->ifp;
struct sockaddr_storage *saddr = &vrrp->saddr;
int ret;
@@ -205,16 +224,26 @@
if (ret < 0) {
log_message(LOG_ERR, "Configuration error: VRRP instance[%s] malformed unicast"
" src address[%s]. Skipping..."
- , vrrp->iname, vector_slot(strvec, 1));
+ , vrrp->iname, FMT_STR_VSLOT(strvec, 1));
return;
}
if (saddr->ss_family != vrrp->family) {
log_message(LOG_ERR, "Configuration error: VRRP instance[%s] and unicast src address"
"[%s] MUST be of the same family !!! Skipping..."
- , vrrp->iname, vector_slot(strvec, 1));
+ , vrrp->iname, FMT_STR_VSLOT(strvec, 1));
memset(saddr, 0, sizeof(struct sockaddr_storage));
}
+
+ /* IPv6 use-case: Binding to link-local address requires an interface.
+ * Just specify scope_id for all address types */
+ if (saddr->ss_family == AF_INET6) {
+ if (!ifp) {
+ log_message(LOG_INFO, "Please define interface keyword before mcast_src_ip keyword");
+ return;
+ }
+ inet_ip6scopeid(IF_INDEX(ifp), saddr);
+ }
}
static void
vrrp_vrid_handler(vector_t *strvec)
@@ -363,7 +392,23 @@
vrrp_garp_refresh_handler(vector_t *strvec)
{
vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
- vrrp->garp_refresh = atoi(vector_slot(strvec, 1)) * TIMER_HZ;
+ vrrp->garp_refresh.tv_sec = atoi(vector_slot(strvec, 1));
+}
+static void
+vrrp_garp_rep_handler(vector_t *strvec)
+{
+ vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
+ vrrp->garp_rep = atoi(vector_slot(strvec, 1));
+ if (vrrp->garp_rep < 1)
+ vrrp->garp_rep = 1;
+}
+static void
+vrrp_garp_refresh_rep_handler(vector_t *strvec)
+{
+ vrrp_t *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
+ vrrp->garp_refresh_rep = atoi(vector_slot(strvec, 1));
+ if (vrrp->garp_refresh_rep < 1)
+ vrrp->garp_refresh_rep = 1;
}
static void
vrrp_auth_type_handler(vector_t *strvec)
@@ -542,6 +587,8 @@
install_keyword("lvs_sync_daemon_interface", &vrrp_lvs_syncd_handler);
install_keyword("garp_master_delay", &vrrp_garp_delay_handler);
install_keyword("garp_master_refresh", &vrrp_garp_refresh_handler);
+ install_keyword("garp_master_repeat", &vrrp_garp_rep_handler);
+ install_keyword("garp_master_refresh_repeat", &vrrp_garp_refresh_rep_handler);
install_keyword("authentication", NULL);
install_sublevel();
install_keyword("auth_type", &vrrp_auth_type_handler);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/vrrp/vrrp_scheduler.c
^
|
@@ -230,8 +230,7 @@
vrrp, vrrp->adver_int);
}
- if (vrrp->base_priority == VRRP_PRIO_OWNER ||
- vrrp->wantstate == VRRP_STATE_MAST) {
+ if (vrrp->wantstate == VRRP_STATE_MAST) {
#ifdef _HAVE_IPVS_SYNCD_
/* Check if sync daemon handling is needed */
if (vrrp->lvs_syncd_if)
@@ -399,11 +398,11 @@
/* Register a timer thread if interface is shut */
if (sock->fd_in == -1)
- thread_add_timer(master, vrrp_read_dispatcher_thread,
- sock, vrrp_timer);
+ sock->thread = thread_add_timer(master, vrrp_read_dispatcher_thread,
+ sock, vrrp_timer);
else
- thread_add_read(master, vrrp_read_dispatcher_thread,
- sock, sock->fd_in, vrrp_timer);
+ sock->thread = thread_add_read(master, vrrp_read_dispatcher_thread,
+ sock, sock->fd_in, vrrp_timer);
}
}
@@ -573,7 +572,20 @@
}
}
- vrrp_state_backup(vrrp, buffer, len);
+ if (!VRRP_ISUP(vrrp)) {
+ vrrp_log_int_down(vrrp);
+ log_message(LOG_INFO, "VRRP_Instance(%s) Now in FAULT state",
+ vrrp->iname);
+ if (vrrp->state != VRRP_STATE_FAULT) {
+ notify_instance_exec(vrrp, VRRP_STATE_FAULT);
+ vrrp->state = VRRP_STATE_FAULT;
+#ifdef _WITH_SNMP_
+ vrrp_snmp_instance_trap(vrrp);
+#endif
+ }
+ } else {
+ vrrp_state_backup(vrrp, buffer, len);
+ }
}
static void
@@ -709,7 +721,7 @@
vrrp_t *vrrp = THREAD_ARG(thread);
/* Simply broadcast the gratuitous ARP */
- vrrp_send_link_update(vrrp);
+ vrrp_send_link_update(vrrp, vrrp->garp_rep);
return 0;
}
@@ -886,14 +898,16 @@
vrrp_t *vrrp;
vrrphdr_t *hd;
int len = 0, prev_state = 0, proto = 0;
- uint32_t saddr;
+ struct sockaddr_storage src_addr;
+ socklen_t src_addr_len = sizeof(src_addr);
/* Clean the read buffer */
memset(vrrp_buffer, 0, VRRP_PACKET_TEMP_LEN);
/* read & affect received buffer */
- len = read(sock->fd_in, vrrp_buffer, VRRP_PACKET_TEMP_LEN);
- hd = vrrp_get_header(sock->family, vrrp_buffer, &proto, &saddr);
+ len = recvfrom(sock->fd_in, vrrp_buffer, VRRP_PACKET_TEMP_LEN, 0,
+ (struct sockaddr *) &src_addr, &src_addr_len);
+ hd = vrrp_get_header(sock->family, vrrp_buffer, &proto);
/* Searching for matching instance */
vrrp = vrrp_index_lookup(hd->vrid, sock->fd_in);
@@ -902,6 +916,8 @@
if (!vrrp)
return sock->fd_in;
+ vrrp->pkt_saddr = src_addr;
+
/* Run the FSM handler */
prev_state = vrrp->state;
VRRP_FSM_READ(vrrp, vrrp_buffer, len);
@@ -943,11 +959,11 @@
/* register next dispatcher thread */
vrrp_timer = vrrp_timer_fd(fd);
if (fd == -1)
- thread_add_timer(thread->master, vrrp_read_dispatcher_thread,
- sock, vrrp_timer);
+ sock->thread = thread_add_timer(thread->master, vrrp_read_dispatcher_thread,
+ sock, vrrp_timer);
else
- thread_add_read(thread->master, vrrp_read_dispatcher_thread,
- sock, fd, vrrp_timer);
+ sock->thread = thread_add_read(thread->master, vrrp_read_dispatcher_thread,
+ sock, fd, vrrp_timer);
return 0;
}
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/vrrp/vrrp_snmp.c
^
|
@@ -541,7 +541,7 @@
/* Commit: change values. There is no way to fail. */
log_message(LOG_INFO,
"VRRP_Instance(%s) base priority changed from"
- " %d to %d via SNMP.",
+ " %d to %ld via SNMP.",
vrrp->iname, vrrp->base_priority, (long)(*var_val));
vrrp->base_priority = (long)(*var_val);
/* If we the instance is not part of a sync group, the
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/keepalived/vrrp/vrrp_vmac.c
^
|
@@ -29,84 +29,10 @@
#include "utils.h"
#include "parser.h"
+#ifdef _HAVE_VRRP_VMAC_
/* private matter */
static const char *ll_kind = "macvlan";
-#ifdef _HAVE_VRRP_VMAC_
-/* Link layer handling */
-static int
-netlink_link_setlladdr(vrrp_t *vrrp)
-{
- int status = 1;
- u_char ll_addr[ETH_ALEN] = {0x00, 0x00, 0x5e, 0x00, 0x01, vrrp->vrid};
- struct {
- struct nlmsghdr n;
- struct ifinfomsg ifi;
- char buf[256];
- } req;
-
- memset(&req, 0, sizeof (req));
-
- req.n.nlmsg_len = NLMSG_LENGTH(sizeof (struct ifinfomsg));
- req.n.nlmsg_flags = NLM_F_REQUEST;
- req.n.nlmsg_type = RTM_NEWLINK;
- req.ifi.ifi_family = AF_INET;
- req.ifi.ifi_index = IF_INDEX(vrrp->ifp);
-
- addattr_l(&req.n, sizeof(req), IFLA_ADDRESS, ll_addr, ETH_ALEN);
-
- if (netlink_talk(&nl_cmd, &req.n) < 0)
- status = -1;
- else
- memcpy(vrrp->ifp->hw_addr, ll_addr, ETH_ALEN);
-
- return status;
-}
-
-static int
-netlink_link_setmode(vrrp_t *vrrp)
-{
- int status = 1;
- struct {
- struct nlmsghdr n;
- struct ifinfomsg ifi;
- char buf[256];
- } req;
- struct rtattr *linkinfo;
- struct rtattr *data;
-
- memset(&req, 0, sizeof (req));
-
- req.n.nlmsg_len = NLMSG_LENGTH(sizeof (struct ifinfomsg));
- req.n.nlmsg_flags = NLM_F_REQUEST;
- req.n.nlmsg_type = RTM_NEWLINK;
- req.ifi.ifi_family = AF_INET;
- req.ifi.ifi_index = IF_INDEX(vrrp->ifp);
-
- linkinfo = NLMSG_TAIL(&req.n);
- addattr_l(&req.n, sizeof(req), IFLA_LINKINFO, NULL, 0);
- addattr_l(&req.n, sizeof(req), IFLA_INFO_KIND, (void *) ll_kind,
- strlen(ll_kind));
-
- data = NLMSG_TAIL(&req.n);
- addattr_l(&req.n, sizeof(req), IFLA_INFO_DATA, NULL, 0);
-
- /*
- * In private mode, macvlan will receive frames with same MAC addr
- * as configured on the interface.
- */
- addattr32(&req.n, sizeof(req), IFLA_MACVLAN_MODE,
- MACVLAN_MODE_PRIVATE);
- data->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)data;
-
- linkinfo->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)linkinfo;
-
- if (netlink_talk(&nl_cmd, &req.n) < 0)
- status = -1;
-
- return status;
-}
-
static int
netlink_link_up(vrrp_t *vrrp)
{
@@ -139,9 +65,11 @@
{
#ifdef _HAVE_VRRP_VMAC_
struct rtattr *linkinfo;
+ struct rtattr *data;
unsigned int base_ifindex;
interface_t *ifp;
char ifname[IFNAMSIZ];
+ u_char ll_addr[ETH_ALEN] = {0x00, 0x00, 0x5e, 0x00, 0x01, vrrp->vrid};
struct {
struct nlmsghdr n;
struct ifinfomsg ifi;
@@ -160,6 +88,10 @@
* by a previous instance.
*/
if (reload && (ifp = if_get_by_ifname(ifname))) {
+ /* (re)set VMAC properties (if deleted on reload) */
+ ifp->base_ifindex = vrrp->ifp->ifindex;
+ ifp->vmac = 1;
+ ifp->flags = vrrp->ifp->flags; /* Copy base interface flags */
vrrp->ifp = ifp;
/* Save ifindex for use on delete */
vrrp->vmac_ifindex = IF_INDEX(vrrp->ifp);
@@ -176,15 +108,27 @@
linkinfo = NLMSG_TAIL(&req.n);
addattr_l(&req.n, sizeof(req), IFLA_LINKINFO, NULL, 0);
addattr_l(&req.n, sizeof(req), IFLA_INFO_KIND, (void *)ll_kind, strlen(ll_kind));
+ data = NLMSG_TAIL(&req.n);
+ addattr_l(&req.n, sizeof(req), IFLA_INFO_DATA, NULL, 0);
+
+ /*
+ * In private mode, macvlan will receive frames with same MAC addr
+ * as configured on the interface.
+ */
+ addattr32(&req.n, sizeof(req), IFLA_MACVLAN_MODE,
+ MACVLAN_MODE_PRIVATE);
+ data->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)data;
linkinfo->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)linkinfo;
addattr_l(&req.n, sizeof(req), IFLA_LINK, &IF_INDEX(vrrp->ifp), sizeof(uint32_t));
addattr_l(&req.n, sizeof(req), IFLA_IFNAME, ifname, strlen(ifname));
+ addattr_l(&req.n, sizeof(req), IFLA_ADDRESS, ll_addr, ETH_ALEN);
if (netlink_talk(&nl_cmd, &req.n) < 0) {
log_message(LOG_INFO, "vmac: Error creating VMAC interface %s for vrrp_instance %s!!!"
, ifname, vrrp->iname);
return -1;
}
+ memcpy(vrrp->ifp->hw_addr, ll_addr, ETH_ALEN);
log_message(LOG_INFO, "vmac: Success creating VMAC interface %s for vrrp_instance %s"
, ifname, vrrp->iname);
@@ -198,21 +142,13 @@
if (!ifp)
return -1;
base_ifindex = vrrp->ifp->ifindex;
+ ifp->flags = vrrp->ifp->flags; /* Copy base interface flags */
vrrp->ifp = ifp;
vrrp->ifp->base_ifindex = base_ifindex;
vrrp->ifp->vmac = 1;
vrrp->vmac_ifindex = IF_INDEX(vrrp->ifp); /* For use on delete */
vrrp->vmac_flags |= VRRP_VMAC_FL_UP;
- netlink_link_setlladdr(vrrp);
netlink_link_up(vrrp);
-
- /*
- * By default MACVLAN interface are in VEPA mode which filters
- * out received packets whose MAC source address matches that
- * of the MACVLAN interface. Setting MACVLAN interface in private
- * mode will not filter based on source MAC address.
- */
- netlink_link_setmode(vrrp);
#endif
return 1;
}
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/Makefile.in
^
|
@@ -29,7 +29,7 @@
rm -f Makefile
memory.o: memory.c memory.h utils.h
-utils.o: utils.c utils.h
+utils.o: utils.c utils.h memory.h
notify.o: notify.c notify.h
timer.o: timer.c timer.h
scheduler.o: scheduler.c scheduler.h memory.h utils.h
@@ -42,6 +42,6 @@
list_head.o: list_head.c list_head.h
buffer.o: buffer.c buffer.h memory.h
command.o: command.c command.h vector.h memory.h vty.h timer.h \
- config.h
+ config.h logger.h
vty.o: vty.c vty.h scheduler.h timer.h utils.h command.h logger.h \
memory.h
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/command.c
^
|
@@ -33,9 +33,10 @@
#include "vty.h"
#include "command.h"
#include "timer.h"
+#include "logger.h"
/* Command vector which includes some level of command lists. Normally
- * each daemon maintains each own cmdvec. */
+ * each daemon maintains its own cmdvec. */
vector_t *cmdvec = NULL;
desc_t desc_cr;
@@ -156,7 +157,9 @@
/* Breaking up string into each command piece. I assume given
* character is separated by a space character. Return value is a
- * vector which includes char ** data element. */
+ * vector which includes char ** data element. It supports
+ * quoted string as a single slot and commented string at
+ * the end of parsed string */
vector_t *
cmd_make_strvec(const char *string)
{
@@ -187,20 +190,30 @@
/* Copy each command piece and set into vector. */
while (1) {
start = cp;
- while (!(isspace((int) *cp) || *cp == '\r' || *cp == '\n') &&
- *cp != '\0')
+ if (*cp == '"') {
cp++;
- strlen = cp - start;
- token = (char *) MALLOC(strlen + 1);
- memcpy(token, start, strlen);
- *(token + strlen) = '\0';
- vector_set(strvec, token);
+ token = MALLOC(2);
+ *(token) = '"';
+ *(token + 1) = '\0';
+ } else {
+ while (!(isspace((int) *cp) || *cp == '\r' || *cp == '\n') &&
+ *cp != '\0' && *cp != '"')
+ cp++;
+ strlen = cp - start;
+ token = (char *) MALLOC(strlen + 1);
+ memcpy(token, start, strlen);
+ *(token + strlen) = '\0';
+ }
+
+ /* Alloc & set the slot */
+ vector_alloc_slot(strvec);
+ vector_set_slot(strvec, token);
- while ((isspace ((int) *cp) || *cp == '\n' || *cp == '\r') &&
+ while ((isspace((int) *cp) || *cp == '\n' || *cp == '\r') &&
*cp != '\0')
cp++;
- if (*cp == '\0')
+ if (*cp == '\0' || *cp == '!' || *cp == '#')
return strvec;
}
}
@@ -298,8 +311,8 @@
if (*cp == '|') {
if (!multiple) {
- fprintf (stderr, "Command parse error!: %s\n", string);
- exit (1);
+ log_message(LOG_ERR, "Command parse error!: %s\n", string);
+ exit(1);
}
cp++;
}
@@ -395,9 +408,9 @@
cnode = vector_slot(cmdvec, ntype);
if (cnode == NULL) {
- fprintf (stderr, "Command node %d doesn't exist, please check it\n",
- ntype);
- exit (1);
+ log_message(LOG_ERR, "Command node %d doesn't exist, please check it\n"
+ , ntype);
+ exit(1);
}
vector_set(cnode->cmd_vector, cmd);
@@ -405,7 +418,7 @@
if (cmd->strvec == NULL)
cmd->strvec = cmd_make_descvec(cmd->string, cmd->doc);
- cmd->cmdsize = cmd_cmdsize (cmd->strvec);
+ cmd->cmdsize = cmd_cmdsize(cmd->strvec);
}
static const unsigned char itoa64[] =
@@ -477,9 +490,9 @@
static vector_t *
cmd_node_vector(vector_t *v, node_type_t ntype)
{
- cmd_node_t *cnode = vector_slot(v, ntype);
+ cmd_node_t *cnode = vector_slot(v, ntype);
- return cnode->cmd_vector;
+ return cnode->cmd_vector;
}
/* Completion match types. */
@@ -813,8 +826,8 @@
/* If command and cmd_element string does not match set NULL to vector */
for (i = 0; i < vector_active (v); i++) {
- if ((cmd_element = vector_slot (v, i)) != NULL) {
- if (index >= vector_active (cmd_element->strvec)) {
+ if ((cmd_element = vector_slot(v, i)) != NULL) {
+ if (index >= vector_active(cmd_element->strvec)) {
vector_slot(v, i) = NULL;
} else {
unsigned int j;
@@ -899,12 +912,12 @@
match_type = no_match;
/* If command and cmd_element string does not match set NULL to vector */
- for (i = 0; i < vector_active (v); i++) {
+ for (i = 0; i < vector_active(v); i++) {
if ((cmd_element = vector_slot (v, i)) != NULL) {
/* If given index is bigger than max string vector of command,
* set NULL */
- if (index >= vector_active (cmd_element->strvec)) {
- vector_slot (v, i) = NULL;
+ if (index >= vector_active(cmd_element->strvec)) {
+ vector_slot(v, i) = NULL;
} else {
unsigned int j;
int matched = 0;
@@ -1149,9 +1162,9 @@
unsigned int i;
char *match;
- for (i = 0; i < vector_active (v); i++) {
- if ((match = vector_slot (v, i)) != NULL) {
- if (strcmp (match, str) == 0) {
+ for (i = 0; i < vector_active(v); i++) {
+ if ((match = vector_slot(v, i)) != NULL) {
+ if (strcmp(match, str) == 0) {
return 0;
}
}
@@ -1168,9 +1181,9 @@
unsigned int i;
desc_t *desc;
- for (i = 0; i < vector_active (v); i++) {
- if ((desc = vector_slot (v, i)) != NULL) {
- if (strcmp (desc->cmd, str) == 0) {
+ for (i = 0; i < vector_active(v); i++) {
+ if ((desc = vector_slot(v, i)) != NULL) {
+ if (strcmp(desc->cmd, str) == 0) {
return 1;
}
}
@@ -1406,7 +1419,7 @@
int ret;
/* First try completion match, if there is exactly match return 1 */
- match = cmd_filter_by_completion (command, cmd_vector, i);
+ match = cmd_filter_by_completion(command, cmd_vector, i);
/* If there is exact match then filter ambiguous match else check
* ambiguousness. */
@@ -1422,8 +1435,8 @@
matchvec = vector_init(INIT_MATCHVEC_SIZE);
/* Now we got into completion */
- for (i = 0; i < vector_active (cmd_vector); i++) {
- if ((cmd_element = vector_slot (cmd_vector, i))) {
+ for (i = 0; i < vector_active(cmd_vector); i++) {
+ if ((cmd_element = vector_slot(cmd_vector, i))) {
const char *string;
vector_t *strvec = cmd_element->strvec;
@@ -1548,28 +1561,6 @@
node_type_t
node_parent(node_type_t node)
{
-#if 0
- node_type_t ret;
-
- assert(node > CONFIG_NODE);
-
- switch (node) {
- case BGP_VPNV4_NODE:
- case BGP_IPV4_NODE:
- case BGP_IPV4M_NODE:
- case BGP_IPV6_NODE:
- case BGP_IPV6M_NODE:
- ret = BGP_NODE;
- break;
- case KEYCHAIN_KEY_NODE:
- ret = KEYCHAIN_NODE;
- break;
- default:
- ret = CONFIG_NODE;
- }
-
- return ret;
-#endif
return CONFIG_NODE;
}
@@ -1616,8 +1607,8 @@
matched_count = 0;
incomplete_count = 0;
- for (i = 0; i < vector_active (cmd_vector); i++) {
- if ((cmd_element = vector_slot (cmd_vector, i))) {
+ for (i = 0; i < vector_active(cmd_vector); i++) {
+ if ((cmd_element = vector_slot(cmd_vector, i))) {
if (match == vararg_match || index >= cmd_element->cmdsize) {
matched_element = cmd_element;
matched_count++;
@@ -1706,7 +1697,7 @@
}
- saved_ret = ret = cmd_execute_command_real (vline, vty, cmd);
+ saved_ret = ret = cmd_execute_command_real(vline, vty, cmd);
if (vtysh)
return saved_ret;
@@ -1945,10 +1936,10 @@
}
/* quit is alias of exit. */
-ALIAS (config_exit,
- config_quit_cmd,
- "quit",
- "Exit current mode and down to previous mode\n")
+ALIAS(config_exit,
+ config_quit_cmd,
+ "quit",
+ "Exit current mode and down to previous mode\n")
/* End of configuration. */
DEFUN(config_end,
@@ -2026,7 +2017,7 @@
for (i = 0; i < vector_active (cnode->cmd_vector); i++)
if ((cmd = vector_slot (cnode->cmd_vector, i)) != NULL &&
- !(cmd->attr == CMD_ATTR_DEPRECATED || cmd->attr == CMD_ATTR_HIDDEN))
+ cmd->attr != CMD_ATTR_HIDDEN)
vty_out(vty, " %s%s", cmd->string, VTY_NEWLINE);
return CMD_SUCCESS;
@@ -2600,7 +2591,6 @@
install_element(VIEW_NODE, &config_terminal_no_length_cmd);
install_element(VIEW_NODE, &echo_cmd);
-// install_element(ENABLE_NODE, &config_exit_cmd);
install_default(ENABLE_NODE);
install_element(ENABLE_NODE, &config_disable_cmd);
install_element(ENABLE_NODE, &config_terminal_cmd);
@@ -2614,8 +2604,6 @@
install_element(ENABLE_NODE, &echo_cmd);
install_default(CONFIG_NODE);
-// install_element(CONFIG_NODE, &config_exit_cmd);
-
install_element(CONFIG_NODE, &hostname_cmd);
install_element(CONFIG_NODE, &no_hostname_cmd);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/command.h
^
|
@@ -64,6 +64,7 @@
VTY_NODE, /* Vty node. */
+ GLOBAL_NODE, /* Global daemon commands. */
CHECK_NODE, /* Checker framework commands. */
VRRP_NODE, /* VRRP framework commands. */
} node_type_t;
@@ -118,8 +119,7 @@
*/
enum {
- CMD_ATTR_DEPRECATED = 1,
- CMD_ATTR_HIDDEN,
+ CMD_ATTR_HIDDEN = 1,
};
#define CMD_SUCCESS 0
@@ -187,9 +187,6 @@
#define DEFUN_HIDDEN(funcname, cmdname, cmdstr, helpstr) \
DEFUN_ATTR (funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN)
-#define DEFUN_DEPRECATED(funcname, cmdname, cmdstr, helpstr) \
- DEFUN_ATTR (funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED)
-
/* DEFUN_NOSH for commands that vtysh should ignore */
#define DEFUN_NOSH(funcname, cmdname, cmdstr, helpstr) \
DEFUN(funcname, cmdname, cmdstr, helpstr)
@@ -213,9 +210,6 @@
#define DEFUNSH_HIDDEN(daemon, funcname, cmdname, cmdstr, helpstr) \
DEFUNSH_ATTR (daemon, funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN)
-#define DEFUNSH_DEPRECATED(daemon, funcname, cmdname, cmdstr, helpstr) \
- DEFUNSH_ATTR (daemon, funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED)
-
/* ALIAS macro which define existing command's alias. */
#define ALIAS(funcname, cmdname, cmdstr, helpstr) \
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, 0)
@@ -226,27 +220,21 @@
#define ALIAS_HIDDEN(funcname, cmdname, cmdstr, helpstr) \
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN, 0)
-#define ALIAS_DEPRECATED(funcname, cmdname, cmdstr, helpstr) \
- DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED, 0)
-
#define ALIAS_SH(daemon, funcname, cmdname, cmdstr, helpstr) \
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, 0, daemon)
#define ALIAS_SH_HIDDEN(daemon, funcname, cmdname, cmdstr, helpstr) \
DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_HIDDEN, daemon)
-#define ALIAS_SH_DEPRECATED(daemon, funcname, cmdname, cmdstr, helpstr) \
- DEFUN_CMD_ELEMENT(funcname, cmdname, cmdstr, helpstr, CMD_ATTR_DEPRECATED, daemon)
-
#define CMD_OPTION(S) ((S[0]) == '[')
#define CMD_VARIABLE(S) (((S[0]) >= 'A' && (S[0]) <= 'Z') || ((S[0]) == '<'))
#define CMD_VARARG(S) ((S[0]) == '.')
#define CMD_RANGE(S) ((S[0] == '<'))
-#define CMD_IPV4(S) ((strcmp ((S), "A.B.C.D") == 0))
-#define CMD_IPV4_PREFIX(S) ((strcmp ((S), "A.B.C.D/M") == 0))
-#define CMD_IPV6(S) ((strcmp ((S), "X:X::X:X") == 0))
-#define CMD_IPV6_PREFIX(S) ((strcmp ((S), "X:X::X:X/M") == 0))
+#define CMD_IPV4(S) ((strcmp((S), "A.B.C.D") == 0))
+#define CMD_IPV4_PREFIX(S) ((strcmp((S), "A.B.C.D/M") == 0))
+#define CMD_IPV6(S) ((strcmp((S), "X:X::X:X") == 0))
+#define CMD_IPV6_PREFIX(S) ((strcmp((S), "X:X::X:X/M") == 0))
/* Common descriptions. */
#define SHOW_STR "Show running system information\n"
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/html.c
^
|
@@ -34,13 +34,13 @@
int inc = 0;
int i;
- /* Allocate the room */
- buf_len = (char *)MALLOC(40);
-
/* Pattern not found */
if (!clen)
return 0;
+ /* Allocate the room */
+ buf_len = (char *)MALLOC(40);
+
/* Content-Length extraction */
while (*(clen++) != ':');
content_buffer = clen;
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/logger.h
^
|
@@ -23,7 +23,15 @@
#ifndef _LOGGER_H
#define _LOGGER_H
+#include <stdio.h>
+
void enable_console_log(void);
-void log_message(int priority, char* format, ...);
+void log_message(int priority, const char* format, ...);
+
+/* wrapper around the real log_message() to emit -Wformat= warnings */
+#define log_message(priority, format, ...) do {\
+ if (0) fprintf (NULL, format, ##__VA_ARGS__); \
+ (log_message) (priority, format, ##__VA_ARGS__); \
+} while (0)
#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/memory.c
^
|
@@ -31,20 +31,29 @@
void *
xalloc(unsigned long size)
{
- void *mem;
- if ((mem = malloc(size)))
- mem_allocated += size;
+ void *mem = malloc(size);
+
+ if (mem == NULL) {
+ perror("Keepalived");
+ exit(EXIT_FAILURE);
+ }
+
+ mem_allocated += size;
return mem;
}
void *
zalloc(unsigned long size)
{
- void *mem;
- if ((mem = malloc(size))) {
- memset(mem, 0, size);
- mem_allocated += size;
+ void *mem = malloc(size);
+
+ if (mem == NULL) {
+ perror("Keepalived");
+ exit(EXIT_FAILURE);
}
+
+ memset(mem, 0, size);
+ mem_allocated += size;
return mem;
}
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/parser.c
^
|
@@ -276,6 +276,7 @@
log_message(LOG_INFO, "chdir(%s) error (%s)\n"
, prev_path, strerror(errno));
}
+ free_strvec(strvec);
return 1;
}
free_strvec(strvec);
@@ -382,12 +383,9 @@
str = vector_slot(strvec, i);
len += strlen(str);
if (!alloc)
- alloc =
- (char *) MALLOC(sizeof (char *) *
- (len + 1));
+ alloc = (char *) MALLOC(len + 1);
else {
- alloc =
- REALLOC(alloc, sizeof (char *) * (len + 1));
+ alloc = (char *) REALLOC(alloc, 2 * (len + 1));
tmp = vector_slot(strvec, i-1);
if (*str != '"' && *tmp != '"')
strncat(alloc, " ", 1);
@@ -397,7 +395,7 @@
strncat(alloc, str, strlen(str));
}
} else {
- alloc = MALLOC(sizeof (char *) * (size + 1));
+ alloc = (char *) MALLOC(size + 1);
memcpy(alloc, str, size);
}
return alloc;
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/scheduler.c
^
|
@@ -392,9 +392,12 @@
}
/* Cancel thread from scheduler. */
-void
+int
thread_cancel(thread_t * thread)
{
+ if (!thread)
+ return -1;
+
switch (thread->type) {
case THREAD_READ:
assert(FD_ISSET(thread->u.fd, &thread->master->readfd));
@@ -429,6 +432,7 @@
thread->type = THREAD_UNUSED;
thread_add_unuse(thread->master, thread);
+ return 0;
}
/* Delete all events which has argument value arg. */
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/scheduler.h
^
|
@@ -112,7 +112,7 @@
extern thread_t *thread_add_timer(thread_master_t *, int (*func) (thread_t *), void *, long);
extern thread_t *thread_add_child(thread_master_t *, int (*func) (thread_t *), void *, pid_t, long);
extern thread_t *thread_add_event(thread_master_t *, int (*func) (thread_t *), void *, int);
-extern void thread_cancel(thread_t *);
+extern int thread_cancel(thread_t *);
extern void thread_cancel_event(thread_master_t *, void *);
extern thread_t *thread_fetch(thread_master_t *, thread_t *);
extern void thread_child_handler(void *, int);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/timer.c
^
|
@@ -75,6 +75,23 @@
/* timer add */
timeval_t
+timer_add(timeval_t a, timeval_t b)
+{
+ timeval_t ret;
+
+ timer_reset(ret);
+ ret.tv_usec = a.tv_usec + b.tv_usec;
+ ret.tv_sec = a.tv_sec + b.tv_sec;
+
+ if (ret.tv_usec >= TIMER_HZ) {
+ ret.tv_sec++;
+ ret.tv_usec -= TIMER_HZ;
+ }
+
+ return ret;
+}
+
+timeval_t
timer_add_long(timeval_t a, long b)
{
timeval_t ret;
@@ -209,6 +226,17 @@
return timer_sub(time_now, a);
}
+/* timer add to current time */
+timeval_t
+timer_add_now(timeval_t a)
+{
+ /* Init current time if needed */
+ if (timer_isnull(time_now))
+ set_time_now();
+
+ return timer_add(time_now, a);
+}
+
/* print timer value */
void
timer_dump(timeval_t a)
@@ -225,4 +253,3 @@
timer = a.tv_sec * TIMER_HZ + a.tv_usec;
return timer;
}
-
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/timer.h
^
|
@@ -47,8 +47,10 @@
extern timeval_t timer_dup(timeval_t);
extern int timer_cmp(timeval_t, timeval_t);
extern timeval_t timer_sub(timeval_t, timeval_t);
+extern timeval_t timer_add(timeval_t, timeval_t);
extern timeval_t timer_add_long(timeval_t, long);
extern timeval_t timer_sub_now(timeval_t);
+extern timeval_t timer_add_now(timeval_t);
extern void timer_dump(timeval_t);
extern unsigned long timer_tol(timeval_t);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/utils.c
^
|
@@ -20,6 +20,7 @@
* Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
+#include "memory.h"
#include "utils.h"
/* global vars */
@@ -200,11 +201,29 @@
/* IPv4 to sockaddr_storage */
int
-inet_ip4tosockaddr(uint32_t addr_ip, struct sockaddr_storage *addr)
+inet_ip4tosockaddr(struct in_addr *sin_addr, struct sockaddr_storage *addr)
{
struct sockaddr_in *addr4 = (struct sockaddr_in *) addr;
addr4->sin_family = AF_INET;
- addr4->sin_addr.s_addr = addr_ip;
+ addr4->sin_addr = *sin_addr;
+ return 0;
+}
+
+/* IPv6 to sockaddr_storage */
+int
+inet_ip6tosockaddr(struct in6_addr *sin_addr, struct sockaddr_storage *addr)
+{
+ struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) addr;
+ addr6->sin6_family = AF_INET6;
+ addr6->sin6_addr = *sin_addr;
+ return 0;
+}
+
+int
+inet_ip6scopeid(uint32_t scope_id, struct sockaddr_storage *addr)
+{
+ struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) addr;
+ addr6->sin6_scope_id = scope_id;
return 0;
}
@@ -252,6 +271,19 @@
return port;
}
+char *
+inet_sockaddrtopair(struct sockaddr_storage *addr)
+{
+ static char addr_str[INET6_ADDRSTRLEN + 1];
+ static char ret[sizeof(addr_str) + 16];
+
+ inet_sockaddrtos2(addr, addr_str);
+ snprintf(ret, sizeof(ret) - 1, "[%s]:%d"
+ , addr_str
+ , ntohs(inet_sockaddrport(addr)));
+ return ret;
+}
+
uint32_t
inet_sockaddrip4(struct sockaddr_storage *addr)
{
@@ -271,6 +303,72 @@
return 0;
}
+/* IPv6 address compare */
+int
+inet_inaddrcmp(int family, void *a, void *b)
+{
+ if (family == AF_INET) {
+ if (ntohl(*((const uint32_t *) a)) >
+ ntohl(*((const uint32_t *) b)))
+ return 1;
+ if (ntohl(*((const uint32_t *) a)) <
+ ntohl(*((const uint32_t *) b)))
+ return -1;
+ return 0;
+ }
+
+ if (family == AF_INET6) {
+ if (ntohl(((const uint32_t *) (a))[0]) >
+ ntohl(((const uint32_t *) (b))[0]))
+ return 1;
+ if (ntohl(((const uint32_t *) (a))[0]) <
+ ntohl(((const uint32_t *) (b))[0]))
+ return -1;
+
+ if (ntohl(((const uint32_t *) (a))[1]) >
+ ntohl(((const uint32_t *) (b))[1]))
+ return 1;
+ if (ntohl(((const uint32_t *) (a))[1]) <
+ ntohl(((const uint32_t *) (b))[1]))
+ return -1;
+
+ if (ntohl(((const uint32_t *) (a))[2]) >
+ ntohl(((const uint32_t *) (b))[2]))
+ return 1;
+ if (ntohl(((const uint32_t *) (a))[2]) <
+ ntohl(((const uint32_t *) (b))[2]))
+ return -1;
+
+ if (ntohl(((const uint32_t *) (a))[3]) >
+ ntohl(((const uint32_t *) (b))[3]))
+ return 1;
+ if (ntohl(((const uint32_t *) (a))[3]) <
+ ntohl(((const uint32_t *) (b))[3]))
+ return -1;
+
+ return 0;
+ }
+
+ return -2;
+}
+
+int
+inet_sockaddrcmp(struct sockaddr_storage *a, struct sockaddr_storage *b)
+{
+ if (a->ss_family != b->ss_family)
+ return -2;
+
+ if (a->ss_family == AF_INET)
+ return inet_inaddrcmp(a->ss_family,
+ &((struct sockaddr_in *) a)->sin_addr,
+ &((struct sockaddr_in *) b)->sin_addr);
+ if (a->ss_family == AF_INET6)
+ return inet_inaddrcmp(a->ss_family,
+ &((struct sockaddr_in6 *) a)->sin6_addr,
+ &((struct sockaddr_in6 *) b)->sin6_addr);
+ return 0;
+}
+
/*
* IP string to network representation
@@ -342,16 +440,31 @@
char *
get_local_name(void)
{
- struct hostent *host;
struct utsname name;
+ struct addrinfo hints, *res = NULL;
+ char *canonname = NULL;
+ int len = 0;
+
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_flags = AI_CANONNAME;
if (uname(&name) < 0)
return NULL;
- if (!(host = gethostbyname(name.nodename)))
+ if (getaddrinfo(name.nodename, NULL, &hints, &res) != 0)
return NULL;
- return host->h_name;
+ if (res && res->ai_canonname) {
+ len = strlen(res->ai_canonname);
+ canonname = MALLOC(len + 1);
+ if (canonname) {
+ memcpy(canonname, res->ai_canonname, len);
+ }
+ }
+
+ freeaddrinfo(res);
+
+ return canonname;
}
/* String compare with NULL string handling */
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/utils.h
^
|
@@ -41,6 +41,8 @@
#define DBG(fmt, msg...)
#endif
+#define STR(x) #x
+
/* global vars exported */
extern int debug;
@@ -52,12 +54,17 @@
extern uint8_t inet_stom(char *);
extern uint8_t inet_stor(char *);
extern int inet_stosockaddr(char *, char *, struct sockaddr_storage *);
-extern int inet_ip4tosockaddr(uint32_t, struct sockaddr_storage *);
+extern int inet_ip4tosockaddr(struct in_addr *, struct sockaddr_storage *);
+extern int inet_ip6tosockaddr(struct in6_addr *, struct sockaddr_storage *);
+extern int inet_ip6scopeid(uint32_t, struct sockaddr_storage *);
extern char *inet_sockaddrtos(struct sockaddr_storage *);
extern char *inet_sockaddrtos2(struct sockaddr_storage *, char *);
+extern char *inet_sockaddrtopair(struct sockaddr_storage *addr);
extern uint16_t inet_sockaddrport(struct sockaddr_storage *);
extern uint32_t inet_sockaddrip4(struct sockaddr_storage *);
extern int inet_sockaddrip6(struct sockaddr_storage *, struct in6_addr *);
+extern int inet_inaddrcmp(int, void *, void *);
+extern int inet_sockaddrcmp(struct sockaddr_storage *, struct sockaddr_storage *);
extern int inet_ston(const char *, uint32_t *);
uint32_t inet_broadcast(uint32_t, uint32_t);
uint32_t inet_cidrtomask(uint8_t);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/vector.h
^
|
@@ -39,6 +39,7 @@
#define vector_active(V) ((V)->active)
#define vector_foreach_slot(v,p,i) \
for (i = 0; i < (v)->allocated && ((p) = (v)->slot[i]); i++)
+#define FMT_STR_VSLOT(V,E) ((char*)vector_slot(V,E))
/* Prototypes */
extern vector_t *vector_alloc(void);
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/vty.c
^
|
@@ -76,6 +76,7 @@
int len = 0;
int size = 1024;
char buf[1024];
+ char *tmp = NULL;
char *p = NULL;
if (vty_shell (vty)) {
@@ -96,9 +97,12 @@
else
size = size * 2;
- p = REALLOC(p, size);
- if (! p)
+ tmp = REALLOC(p, size);
+ if (! tmp) {
+ FREE(p);
return -1;
+ }
+ p = tmp;
va_start(args, format);
len = vsnprintf(p, size, format, args);
@@ -1482,9 +1486,8 @@
/* Socket */
accept_sock = socket(addr->ss_family, SOCK_STREAM, 0);
if (accept_sock < 0) {
- log_message(LOG_INFO, "Vty error creating listening socket on [%s]:%d (%s)"
- , inet_sockaddrtos(addr)
- , ntohs(inet_sockaddrport(addr))
+ log_message(LOG_INFO, "Vty error creating listening socket on %s (%s)"
+ , inet_sockaddrtopair(addr)
, strerror(errno));
return -1;
}
@@ -1503,9 +1506,8 @@
len = sizeof(*addr);
ret = bind(accept_sock, (struct sockaddr *) addr, len);
if (ret < 0) {
- log_message(LOG_INFO, "Vty error cant bind to [%s]:%d (%s)"
- , inet_sockaddrtos(addr)
- , ntohs(inet_sockaddrport(addr))
+ log_message(LOG_INFO, "Vty error cant bind to %s (%s)"
+ , inet_sockaddrtopair(addr)
, strerror(errno));
close(accept_sock);
return -1;
@@ -1514,9 +1516,8 @@
/* Socket listen */
ret = listen(accept_sock, 3);
if (ret < 0) {
- log_message(LOG_INFO, "Vty error cant listen to [%s]:%d (%s)"
- , inet_sockaddrtos(addr)
- , ntohs(inet_sockaddrport(addr))
+ log_message(LOG_INFO, "Vty error cant listen to %s (%s)"
+ , inet_sockaddrtopair(addr)
, strerror(errno));
close(accept_sock);
return -1;
@@ -1526,9 +1527,8 @@
/* Restore old mask */
umask(old_mask);
- log_message(LOG_INFO, "Vty start listening on [%s]:%d"
- , inet_sockaddrtos(addr)
- , ntohs(inet_sockaddrport(addr)));
+ log_message(LOG_INFO, "Vty start listening on %s"
+ , inet_sockaddrtopair(addr));
vty_event(VTY_SERV, accept_sock, NULL);
return accept_sock;
@@ -1600,7 +1600,7 @@
}
/* Read up configuration file from file_name. */
-static void
+static int
vty_read_file(FILE *confp)
{
int ret;
@@ -1617,19 +1617,20 @@
if (!((ret == CMD_SUCCESS) || (ret == CMD_ERR_NOTHING_TODO))) {
switch (ret) {
case CMD_ERR_AMBIGUOUS:
- fprintf(stderr, "Ambiguous command.\n");
+ log_message(LOG_ERR, "Ambiguous command.\n");
break;
case CMD_ERR_NO_MATCH:
- fprintf(stderr, "There is no such command.\n");
+ log_message(LOG_ERR, "There is no such command.\n");
break;
}
- fprintf(stderr, "Error occured during reading below line.\n%s\n"
- , vty->buf);
+ log_message(LOG_ERR, "Error occured during reading below line.\n%s\n"
+ , vty->buf);
vty_close(vty);
- exit(1);
+ return -1;
}
vty_close(vty);
+ return 0;
}
static FILE *
@@ -1688,7 +1689,6 @@
unlink(fullpath_tmp);
FREE(fullpath_sav);
FREE(fullpath_tmp);
- close(sav);
return NULL;
}
@@ -1703,7 +1703,7 @@
}
/* Read up configuration file from file_name. */
-void
+int
vty_read_config(char *config_file, char *config_default_dir)
{
char cwd[MAXPATHLEN];
@@ -1717,9 +1717,9 @@
if (!IS_DIRECTORY_SEP(config_file[0])) {
retpath = getcwd(cwd, MAXPATHLEN);
if (!retpath) {
- fprintf(stderr, "%s: failed to get current working directory: %s\n"
- , __func__, strerror(errno));
- exit(1);
+ log_message(LOG_ERR, "%s: failed to get current working directory: %s\n"
+ , __func__, strerror(errno));
+ return -1;
}
tmp = MALLOC(strlen(cwd) + strlen(config_file) + 2);
sprintf(tmp, "%s/%s", cwd, config_file);
@@ -1731,32 +1731,33 @@
confp = fopen(fullpath, "r");
if (confp == NULL) {
- fprintf(stderr, "%s: failed to open configuration file %s: %s\n"
- , __func__, fullpath, strerror (errno));
+ log_message(LOG_ERR, "%s: failed to open configuration file %s: %s\n"
+ , __func__, fullpath, strerror (errno));
confp = vty_use_backup_config(fullpath);
if (confp) {
- fprintf(stderr, "WARNING: using backup configuration file!\n");
+ log_message(LOG_ERR, "WARNING: using backup configuration file!\n");
} else {
- fprintf(stderr, "can't open configuration file [%s]\n"
- , config_file);
- exit(1);
+ log_message(LOG_ERR, "can't open configuration file [%s]\n"
+ , config_file);
+ FREE_PTR(tmp);
+ return -1;
}
}
} else {
confp = fopen(config_default_dir, "r");
if (confp == NULL) {
- fprintf(stderr, "%s: failed to open configuration file %s: %s\n"
- , __func__, config_default_dir, strerror(errno));
+ log_message(LOG_ERR, "%s: failed to open configuration file %s: %s\n"
+ , __func__, config_default_dir, strerror(errno));
confp = vty_use_backup_config(config_default_dir);
if (confp) {
- fprintf(stderr, "WARNING: using backup configuration file!\n");
+ log_message(LOG_ERR, "WARNING: using backup configuration file!\n");
fullpath = config_default_dir;
} else {
- fprintf(stderr, "can't open configuration file [%s]\n"
- , config_default_dir);
- exit (1);
+ log_message(LOG_ERR, "can't open configuration file [%s]\n"
+ , config_default_dir);
+ return -1;
}
} else {
fullpath = config_default_dir;
@@ -1764,12 +1765,10 @@
}
vty_read_file(confp);
-
fclose(confp);
-
host_config_set(fullpath);
-
FREE_PTR(tmp);
+ return 0;
}
int
@@ -2038,8 +2037,7 @@
return CMD_SUCCESS;
}
-cmd_node_t vty_node =
-{
+cmd_node_t vty_node = {
VTY_NODE,
"%s(config-line)# ",
1,
|
[-]
[+]
|
Changed |
keepalived-1.2.16.tar.bz2/lib/vty.h
^
|
@@ -181,7 +181,7 @@
extern void vty_reset(void);
extern vty_t *vty_new(void);
extern int vty_out(vty_t *, const char *, ...) PRINTF_ATTRIBUTE(2, 3);
-extern void vty_read_config(char *, char *);
+extern int vty_read_config(char *, char *);
extern void vty_time_print(vty_t *, int);
extern void vty_serv_sock(const char *, unsigned short, const char *);
extern void vty_close(vty_t *);
|
|
Deleted |
keepalived-1.2.7.tar.bz2
^
|
|
Deleted |
keepalived-1.2.8.tar.bz2
^
|
|
Deleted |
keepalived-1.2.9.tar.bz2
^
|