[-]
[+]
|
Changed |
keepalived.changes
|
|
[-]
[+]
|
Changed |
keepalived.spec
^
|
|
[-]
[+]
|
Deleted |
keepalived-1.2.2git.tar.bz2/.indent.pro
^
|
@@ -1,8 +0,0 @@
--kr
--i8
--ts8
--sob
--l80
--ss
--bs
--psl
|
[-]
[+]
|
Deleted |
keepalived-1.2.2git.tar.bz2/goodies
^
|
-(directory)
|
[-]
[+]
|
Deleted |
keepalived-1.2.2git.tar.bz2/goodies/arpreset.pl
^
|
@@ -1,97 +0,0 @@
-#!/usr/bin/perl -w
-
-###################################################################
-# arpreset 0.2
-# Copyright (C) 2005 Steve Milton (milton AT isomedia.com)
-#
-# Utility for deleting a single ARP entry from a cisco router.
-# Script adapted from description on Cisco tech article.
-# http://www.cisco.com/warp/public/477/SNMP/clear_arp.shtml
-#
-# The Cisco router needs to have a read/write community setup
-# for the utility to work. I recommend using the following
-# IOS commands to setup a restricted community that can only
-# work with the MAC table. You will need ENABLE level access
-# to the router to execute these commands.
-#
-# access-list 50 permit 123.123.123.123
-# access-list 50 permit 123.123.123.124
-# access-list 50 deny any
-# snmp-server view arpchange ipNetToMediaEntry.4 included
-# snmp-server community blahblah view arpchange RW 50
-#
-# Set the access-list permit to the IP addresses of the systems
-# you want to be able to make changes to the MAC table. Set
-# the community name (above blahblah) to something random and
-# password-like.
-###################################################################
-# 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.
-#
-# 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.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-###################################################################
-
-use strict;
-use Getopt::Long;
-&Getopt::Long::config('auto_abbrev');
-
-my ($router,$community,$address,$help,$check);
-$router=$community=$address=$help=$check="";
-
-my $status = GetOptions("router:s" => \$router,
- "community:s" => \$community,
- "address:s" => \$address,
- "help" => \$help,
- "check" => \$check);
-
-if (($status == 0) or $help) {
- &PrintUsage;
- exit 1;
-}
-
-if (!$router or !$community or !$address) {
- &PrintUsage;
- exit 1;
-}
-
-# OID for the ARP table entries
-my $ciscoOID = ".1.3.6.1.2.1.4.22.1.4";
-my $target = "";
-
-# Walk the SNMP ARP table on the router to locate the target address
-open(GET, "/usr/bin/snmpwalk -v1 -c $community $router $ciscoOID |");
-while(<GET>) {
- if (/^(.*?\.$address)\s/) {
- $target = $1;
- print $_;
- }
-}
-close(GET);
-if ($target and !$check) {
- print "-- changed to --\n";
- # set the target address to "invalid"
- system("/usr/bin/snmpset -v1 -c $community $router $target i 2");
-} elsif (!$check) {
- print "No target OID located.";
- exit 1;
-}
-exit;
-
-sub PrintUsage {
- print "arpreset 0.2\nCopyright (c) 2005 by Steve Milton\narpreset comes with ABSOLUTELY NO WARRANTY\n\n";
- print "Usage: arpreset --router=routeraddress --community=rwcommunity --address=ipaddress\n";
- print " arpreset --help\n";
- print "\nWhere ipaddress is the IP address in the Cisco router that you want to invalidate\nfrom the MAC address cache.\n";
- print "\nYou can add --check to the command to make it NOT update the router, but check for\nthe entry only.\n";
- exit;
-}
|
|
Deleted |
keepalived-1.2.4.tar.bz2
^
|
|
Deleted |
keepalived-1.2.5.tar.bz2
^
|
|
Deleted |
keepalived-1.2.6.tar.bz2
^
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/ChangeLog
^
|
@@ -1,3 +1,183 @@
+2012-08-29 Alexandre Cassen <acassen@linux-vs.org>
+ * keepalived-1.2.7 released.
+ * vrrp: fix issue in while using vrrp_script.
+ Previous patch introduced by Ryan O'Hara about removing
+ shadow declaration was kind of too much hunting.
+ Removing element e in this block simply create inconsitency
+ in upper list walk. So resurected element declaration with e2.
+ * snmp: Mikhail Gaydamaka extended MIB and both vrrp and check
+ frameworkds to support routerId to var bind.
+ * snmp: Mikhail Gaydamaka fixed oid for vrrpSyncGroupStateChange
+ var bind.
+ * some cosmetics again and again.
+
+2012-08-20 Alexandre Cassen <acassen@linux-vs.org>
+ * keepalived-1.2.6 released.
+ * Rename global config data variable 'global_data'.
+ From Ryan O'Hara :
+ This patch renames the global configuration data
+ variable from 'data' to 'global_data'. Three reasons for
+ renaming this varibale:
+ - Fixes shadow declaration of 'data' in several locations.
+ - Is more consistent with other global data variables
+ (ie. vrrp_data, check_data).
+ - Functions like free_global_data and dump_global_data were
+ ignoring conf_data_t argument and using global variable
+ instead.
+ * Ryan O'Hara: Fix shadow declaration of 'vrrp_data' variable.
+ * Ryan O'Hara: Fix shadow declaration of 'check_data' variable.
+ * Ryan O'Hara: Remove shadow declaration of 'element e' in
+ vrrp_init_state.
+ * check: Avoid the use of kernel defines in libipvs userland
+ prototypes.
+ * vrrp: Correctly handle macvlan interface when config file is
+ re-loaded. From Bob Gilligan :
+ Testing with the 1.2.0 branch, bring keepalived up with a
+ vrrp_instance that is configured with use_vmac. Then delete
+ that vrrp_instance from the config file. Then tell keepalived
+ to re-read its config file with SIGHUP. The vrrp_instance will
+ be stopped, but the macvlan interface will remain. The obvious
+ fix would be to add code to call netlink_link_del_vmac() in
+ clear_diff_vrrp(). There's one problem with that: the code
+ needs the ifindex of the macvlan interface to delete it, but
+ that resides in the interface structure that was freed earlier
+ in the reload process. My fix is to add a field to the
+ vrrp_rt struct to remember the macvlan ifindex. This patch
+ addresses this problem plus two others that can occur in
+ reloading the config file: 1) If the vrrp_instance
+ configuration is kept, but the use_vmac entry is removed, the
+ macvlan interface will not be deleted; 2) If a vrrp_instance
+ with use_vmac is left unchanged, the code will attempt to
+ re-create the macvlan interface, but this will fail and the
+ program will end up not using the macvlan interface.
+ * vrrp: VRRP should notify other routers before it does any
+ action that effects traffic flow. From John Southworth:
+ Move the shutdown_vrrp_instances code to before the deletion
+ of sock_pool. Move sending priority 0 adverts to before address
+ removal occurs
+ * vrrp: From John Southworth: Stop timers before shutting down
+ vrrp instances. This is to avoid a possible condition where
+ a priority 0 advertisement is sent and before the master
+ thread is killed another advertisement can be generated and sent.
+ * vrrp: Change when socket fd's are freed.
+ From John Southworth:
+ Priority 0 advertisements were not being sent as desired on
+ config reload. This was causing long delays on manually failed
+ over instances. The socket pool was being freed too early, as a
+ result the file descriptor for the socket was no longer valid at
+ the time the priority 0 advertisment was attempted.
+ * vrrp: Added a separate timeout parameter for vrrp_script checks
+ From Jonathan Harden:
+ I've added a timeout parameter to the vrrp check scripts which
+ allow you to have the check timeout different to the interval.
+ When no timeout has been specified the interval is used (which
+ mimics the current behaviour). To explain the reasoning: We
+ wanted to have check scripts time out faster than our check
+ interval. Doing the check we need to perform is a little load
+ intensive and so we don't want to perform it every few seconds.
+ With this patch we set an interval of 60 seconds but a timeout
+ of 5 seconds (if the check takes more than a few seconds then
+ the service is not working correctly).
+ * Extended vector lib for futur work
+ * some cosmetics.
+
+2012-08-13 Alexandre Cassen <acassen@linux-vs.org>
+ * keepalived-1.2.5 released.
+ * Merge SNMP support from Vincent Bernat.
+ * SNMP is not compiled nor activated by default.
+ * Updated autoconf script
+ * Created Keepalived MIB
+ * Integration of NetSNMP into main scheduling loop
+ * vrrp: Most internal data can be queried with SNMP.
+ * check: Most internal values can be queried using SNMP.
+ The main exception is the ability to query checkers
+ which is not present.
+ * check: SNMP support for IPVS stats. IPVS stats are
+ exported with SNMP. A cache is used to avoid to query
+ the kernel too much.
+ * Created core framework for SNMP trap
+ * vrrp: SNMP traps are sent when instance state changes
+ and when sync group state changes
+ * check: SNMP traprs are sent when real server state changes
+ and when virtual server quorum state changes
+ * vrrp: add support to write/update operations from SNMP.
+ Write/update support is available for changing the base priority
+ and for changing instance preemption.
+ * check: add support to write/update operations from SNMP.
+ Write support is available for changing the weight of a real
+ server.
+ * workaround for AgentX ping blocking Keepalived. When establishing
+ AgentX session with the master agent, we setup low timeout and
+ retries values. If the master agent is blocked, we will wait for
+ less than 1 second for them and therefore, there will be no
+ disruption for VRRP.
+ * Copyright update
+ * some cosmetics.
+
+2012-07-27 Alexandre Cassen <acassen@linux-vs.org>
+ * keepalived-1.2.4 released.
+ * Please look at git repo for credits.
+ * remove CR from manpage
+ * check: fix pid display in syslog messages
+ * vrrp: better documentation of the limitation on password
+ length
+ * cosmetics to be pleasant with GCC4
+ * Update autoconf script to properly detect VRRP VMAC
+ support
+ * security: Fix exploitable issue in sighandler !
+ * Add datarootdir to Makefile.in files.
+ * Fix logging to console.
+ * Remove newlines from log_message calls.
+
+2012-07-13 Alexandre Cassen <acassen@linux-vs.org>
+ * keepalived-1.2.3 released.
+ * Please look at git repo for credits.
+ * VRRP : allow group to use priority with 'global_tracking'
+ group keyword
+ * VRRP : Adjust TOS values. The TOS value used by other
+ vendors is ip precedence 6, so change that. Use socket
+ priority option to force packets into band 0 of pfifo_fast.
+ * VRRP : Fix sync-group thrashing.The sync group implementation
+ was not very robust. If one synced instance lost communication
+ without going to fault state then all synced intances would
+ transition to master. Following this all instances would
+ transition back to backup because they heard higher priority
+ advertisements. This thrashing would continue indefinitely.
+ To fix this the sync-group code was made to prefer backup state.
+ That is, the sync-groups don't sync to master state unless
+ every instance wants to be master.
+ * VRRP : Fix dst lladdr in IPv6 Unsollicited NA.
+ * VRRP : fix pid display in syslog messages.
+ * Fix configure script to correctly identify kernel version.
+ * check : handle unspecified sockaddr_storage when comparing
+ * VRRP : ensure VRRP script interval and GARP delay is not 0.
+ * check: ensure non 0 default values for timeouts.
+ * VRRP : Fix priority not changing on reload.
+ * check : Fix IPv4 address comparison routine.
+ * Don't use bind() with AF_UNSPEC.
+ * check : enable the use of fwmark with IPv6 virtual servers.
+ * Fix modprobe arguments.
+ * Fix double ntohs() in SMTP checker.
+ * Pretty-print IP:port as [%s]:%d.
+ * check : keep retry in case of early TCP failures in checks.
+ * when specifying an IPv6 range, range is hexadecimal value.
+ * Only define kernel types for ip_vs.h header to avoid problems
+ when loading other headers.
+ * When respawning VRRP or check process, use LOG_ALERT.
+ * Do not set reload flag in the main process.
+ * Set correct rights on PID file.
+ * fix 'gratuitous' typos.
+ * ipvs: don't include linux/types.h or asm/types.h.
+ * configure: check for nl_socket_modify_cb for libnl.
+ * configure: don't check for IPVS support with kernel 2.6.x.
+ * VRRP : On shutdown, release sockets later to be able to send
+ shutdown packet.
+ * fix documentation on linkbeat_use_polling keyword.
+ * Fix a typo for healthchecker.
+ * fix syslog message if bogous vrrp packet (wrong auth type)
+ received.
+ * manpage update.
+
2011-01-09 Alexandre Cassen <acassen@linux-vs.org>
* keepalived-1.2.2 released.
* IPv6 : extended autoconf script to support libnl detection.
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/Makefile.in
^
|
@@ -2,7 +2,7 @@
#
# Keepalived OpenSource project.
#
-# Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+# Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
TARFILES = AUTHOR bin ChangeLog configure configure.in CONTRIBUTORS COPYING \
doc genhash INSTALL install-sh keepalived keepalived.spec.in lib Makefile.in \
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/TODO
^
|
@@ -1,15 +1 @@
-* Insert LDAP, FTP, SSH, IMAP, POP, RADIUS checkers.
-* documentation:
- - hackers guide
-* code cleanup:
- - check_ssl.c audit the password_cb() call back func
- for buffer overflow.
- - check smtp.c to release allocated buffer when terminate
- thread is registered. Occur when sigint is receive when
- smtp alertes have not been able to finish the whole sending
- sequence.
-* more choice with parameters, less hardcoded values
-* functionality:
- - hooks in VRRP framework for external checktools.
- As state transition decision
- - a VTYSH to administrate keepalived on the fly
+Whatever you want !
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/VERSION
^
|
@@ -1 +1 @@
-1.2.2
+1.2.7
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/configure
^
|
@@ -599,6 +599,9 @@
VERSION_DATE
VERSION
DFLAGS
+SNMP_SUPPORT
+NETSNMP_CONFIG
+VRRP_VMAC
IPVS_SYNCD
KERN
EGREP
@@ -661,6 +664,7 @@
enable_vrrp
with_kernel_dir
with_kernel_version
+enable_snmp
enable_debug
enable_profile
'
@@ -1284,6 +1288,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
+ --enable-snmp compile with SNMP support
--enable-debug compile with debugging flags
--enable-profile compile with profiling flags
@@ -3209,6 +3214,11 @@
kernelversion=""
fi
+# Check whether --enable-snmp was given.
+if test "${enable_snmp+set}" = set; then :
+ enableval=$enable_snmp;
+fi
+
# Check whether --enable-debug was given.
if test "${enable_debug+set}" = set; then :
enableval=$enable_debug;
@@ -3842,9 +3852,9 @@
as_fn_error "Popt libraries is required" "$LINENO" 5
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_handle_alloc in -lnl" >&5
-$as_echo_n "checking for nl_handle_alloc in -lnl... " >&6; }
-if test "${ac_cv_lib_nl_nl_handle_alloc+set}" = set; then :
+{ $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 test "${ac_cv_lib_nl_nl_socket_modify_cb+set}" = set; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
@@ -3858,27 +3868,27 @@
#ifdef __cplusplus
extern "C"
#endif
-char nl_handle_alloc ();
+char nl_socket_modify_cb ();
int
main ()
{
-return nl_handle_alloc ();
+return nl_socket_modify_cb ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_nl_nl_handle_alloc=yes
+ ac_cv_lib_nl_nl_socket_modify_cb=yes
else
- ac_cv_lib_nl_nl_handle_alloc=no
+ 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_handle_alloc" >&5
-$as_echo "$ac_cv_lib_nl_nl_handle_alloc" >&6; }
-if test "x$ac_cv_lib_nl_nl_handle_alloc" = x""yes; then :
+{ $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" = x""yes; then :
USE_NL="LIBIPVS_USE_NL"
LIBS="$LIBS -lnl"
@@ -3956,9 +3966,9 @@
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LINUX_MAJOR.$LINUX_MINOR.$LINUX_PATCH" >&5
$as_echo "$LINUX_MAJOR.$LINUX_MINOR.$LINUX_PATCH" >&6; }
- if test "$LINUX_MINOR" = "6"; then
+ if test "$LINUX_MAJOR" = "2" && test "$LINUX_MINOR" = "6"; then
KERN="_KRNL_2_6_"
- elif test "$LINUX_MINOR" = "4"; then
+ elif test "$LINUX_MAJOR" = "2" && test "$LINUX_MINOR" = "4"; then
KERN="_KRNL_2_4_"
else
KERN="_KRNL_2_6_"
@@ -3973,18 +3983,22 @@
IPVS_SUPPORT="_WITHOUT_LVS_"
if test "$enable_lvs" != "no"; then
- ac_fn_c_check_header_mongrel "$LINENO" "net/ip_vs.h" "ac_cv_header_net_ip_vs_h" "$ac_includes_default"
+ if test "$KERN" = "_KRNL_2_6_"; then
+ IPVS_SUPPORT="_WITH_LVS_"
+ else
+ ac_fn_c_check_header_mongrel "$LINENO" "net/ip_vs.h" "ac_cv_header_net_ip_vs_h" "$ac_includes_default"
if test "x$ac_cv_header_net_ip_vs_h" = x""yes; then :
IPVS_SUPPORT="_WITH_LVS_"
else
- IPVS_SUPPORT="_WITHOUT_LVS_"
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: keepalived will be built without LVS support." >&5
+ IPVS_SUPPORT="_WITHOUT_LVS_"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: keepalived will be built without LVS support." >&5
$as_echo "$as_me: WARNING: keepalived will be built without LVS support." >&2;}
fi
+ fi
fi
if test "$IPVS_SUPPORT" = "_WITHOUT_LVS_" -a "$enable_vrrp" = "no"; then
@@ -4023,6 +4037,209 @@
VRRP_SUPPORT="_WITH_VRRP_"
fi
+CPPFLAGS="$CPPFLAGS -I$kernelinc"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for kernel macvlan support" >&5
+$as_echo_n "checking for kernel macvlan support... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #include <bits/sockaddr.h>
+ #include <linux/if_link.h>
+ int macvlan;
+
+int
+main ()
+{
+
+ macvlan = IFLA_MACVLAN_MODE;
+ macvlan = MACVLAN_MODE_PRIVATE;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+ MACVLAN_SUPPORT=yes
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext;
+
+ if test "$MACVLAN_SUPPORT" = "yes"; then
+ VRRP_VMAC="_HAVE_VRRP_VMAC_"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ else
+ VRRP_VMAC="_WITHOUT_VRRP_VMAC_"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ fi
+
+
+
+SNMP_SUPPORT="_WITHOUT_SNMP_"
+if test "$enable_snmp" = "yes"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}net-snmp-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}net-snmp-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_NETSNMP_CONFIG+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $NETSNMP_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_NETSNMP_CONFIG="$NETSNMP_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_path_NETSNMP_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+NETSNMP_CONFIG=$ac_cv_path_NETSNMP_CONFIG
+if test -n "$NETSNMP_CONFIG"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NETSNMP_CONFIG" >&5
+$as_echo "$NETSNMP_CONFIG" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_NETSNMP_CONFIG"; then
+ ac_pt_NETSNMP_CONFIG=$NETSNMP_CONFIG
+ # Extract the first word of "net-snmp-config", so it can be a program name with args.
+set dummy net-snmp-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_ac_pt_NETSNMP_CONFIG+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $ac_pt_NETSNMP_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_ac_pt_NETSNMP_CONFIG="$ac_pt_NETSNMP_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_path_ac_pt_NETSNMP_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+ac_pt_NETSNMP_CONFIG=$ac_cv_path_ac_pt_NETSNMP_CONFIG
+if test -n "$ac_pt_NETSNMP_CONFIG"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_NETSNMP_CONFIG" >&5
+$as_echo "$ac_pt_NETSNMP_CONFIG" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_pt_NETSNMP_CONFIG" = x; then
+ NETSNMP_CONFIG="no"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ NETSNMP_CONFIG=$ac_pt_NETSNMP_CONFIG
+ fi
+else
+ NETSNMP_CONFIG="$ac_cv_path_NETSNMP_CONFIG"
+fi
+
+ if test x"$NETSNMP_CONFIG" = x"no"; then
+ as_fn_error "unable to find net-snmp-config" "$LINENO" 5
+ fi
+ NETSNMP_LIBS=`${NETSNMP_CONFIG} --agent-libs`
+ #NETSNMP_CFLAGS="`${NETSNMP_CONFIG} --base-cflags`"
+ #CFLAGS="${NETSNMP_CFLAGS} $CFLAGS"
+ LIBS="${NETSNMP_LIBS} $LIBS"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler supports flag \"${NETSNMP_LIBS}\" from Net-SNMP" >&5
+$as_echo_n "checking whether C compiler supports flag \"${NETSNMP_LIBS}\" from Net-SNMP... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int main(void);
+
+int
+main ()
+{
+
+{
+ return 0;
+}
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ as_fn_error "incorrect CFLAGS from net-snmp-config" "$LINENO" 5
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ # Do we have a usable <net-snmp/agent/util_funcs.h> header?
+ for ac_header in net-snmp/agent/util_funcs.h
+do :
+ ac_fn_c_check_header_compile "$LINENO" "net-snmp/agent/util_funcs.h" "ac_cv_header_net_snmp_agent_util_funcs_h" "
+#include <net-snmp/net-snmp-config.h>
+#include <net-snmp/net-snmp-includes.h>
+#include <net-snmp/library/snmp_transport.h>
+#include <net-snmp/agent/net-snmp-agent-includes.h>
+#include <net-snmp/agent/snmp_vars.h>
+
+"
+if test "x$ac_cv_header_net_snmp_agent_util_funcs_h" = x""yes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_NET_SNMP_AGENT_UTIL_FUNCS_H 1
+_ACEOF
+
+fi
+
+done
+
+ SNMP_SUPPORT="_WITH_SNMP_"
+fi
+
+
+
if test "${enable_debug}" = "yes"; then
DFLAGS="-D_DEBUG_"
@@ -5507,9 +5724,19 @@
if test "${VRRP_SUPPORT}" = "_WITH_VRRP_"; then
echo "Use VRRP Framework : Yes"
+ if test "${VRRP_VMAC}" = "_HAVE_VRRP_VMAC_"; then
+ echo "Use VRRP VMAC : Yes"
+ else
+ echo "Use VRRP VMAC : No"
+ fi
else
echo "Use VRRP Framework : No"
fi
+if test "${SNMP_SUPPORT}" = "_WITH_SNMP_"; then
+ echo "SNMP support : Yes"
+else
+ echo "SNMP support : No"
+fi
if test "${DFLAGS}" = "-D_DEBUG_"; then
echo "Use Debug flags : Yes"
else
|
[-]
[+]
|
Changed |
keepalived-1.2.7.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(snmp,
+ [ --enable-snmp compile with SNMP support])
AC_ARG_ENABLE(debug,
[ --enable-debug compile with debugging flags])
AC_ARG_ENABLE(profile,
@@ -107,9 +109,9 @@
AC_MSG_RESULT([2.6])
else
AC_MSG_RESULT([$LINUX_MAJOR.$LINUX_MINOR.$LINUX_PATCH])
- if test "$LINUX_MINOR" = "6"; then
+ if test "$LINUX_MAJOR" = "2" && test "$LINUX_MINOR" = "6"; then
KERN="_KRNL_2_6_"
- elif test "$LINUX_MINOR" = "4"; then
+ elif test "$LINUX_MAJOR" = "2" && test "$LINUX_MINOR" = "4"; then
KERN="_KRNL_2_4_"
else
KERN="_KRNL_2_6_"
@@ -171,11 +173,73 @@
VRRP_SUPPORT="_WITH_VRRP_"
fi
+dnl ----[ Checks for kernel VMAC support ]----
+CPPFLAGS="$CPPFLAGS -I$kernelinc"
+AC_MSG_CHECKING([for kernel macvlan support])
+AC_TRY_COMPILE([
+ #include <bits/sockaddr.h>
+ #include <linux/if_link.h>
+ int macvlan;
+ ], [
+ macvlan = IFLA_MACVLAN_MODE;
+ macvlan = MACVLAN_MODE_PRIVATE;
+ ], [
+ MACVLAN_SUPPORT=yes
+ ], []);
+
+ if test "$MACVLAN_SUPPORT" = "yes"; then
+ VRRP_VMAC="_HAVE_VRRP_VMAC_"
+ AC_MSG_RESULT([yes])
+ else
+ VRRP_VMAC="_WITHOUT_VRRP_VMAC_"
+ AC_MSG_RESULT([no])
+ fi
+
+AC_SUBST(VRRP_VMAC)
+
+dnl ----[ Checks for SNMP support ]----
+SNMP_SUPPORT="_WITHOUT_SNMP_"
+if test "$enable_snmp" = "yes"; then
+ AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], [no])
+ if test x"$NETSNMP_CONFIG" = x"no"; then
+ AC_MSG_ERROR([unable to find net-snmp-config])
+ fi
+ NETSNMP_LIBS=`${NETSNMP_CONFIG} --agent-libs`
+ #NETSNMP_CFLAGS="`${NETSNMP_CONFIG} --base-cflags`"
+ #CFLAGS="${NETSNMP_CFLAGS} $CFLAGS"
+ LIBS="${NETSNMP_LIBS} $LIBS"
+ AC_MSG_CHECKING([whether C compiler supports flag "${NETSNMP_LIBS}" from Net-SNMP])
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([
+int main(void);
+],
+[
+{
+ return 0;
+}
+])],[AC_MSG_RESULT(yes)],[
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR([incorrect CFLAGS from net-snmp-config])])
+
+ # Do we have a usable <net-snmp/agent/util_funcs.h> header?
+ AC_CHECK_HEADERS([net-snmp/agent/util_funcs.h],,,[
+@%:@include <net-snmp/net-snmp-config.h>
+@%:@include <net-snmp/net-snmp-includes.h>
+@%:@include <net-snmp/library/snmp_transport.h>
+@%:@include <net-snmp/agent/net-snmp-agent-includes.h>
+@%:@include <net-snmp/agent/snmp_vars.h>
+ ])
+ SNMP_SUPPORT="_WITH_SNMP_"
+fi
+
+AC_SUBST(SNMP_SUPPORT)
+
+dnl ----[ Debug or not ? ]----
if test "${enable_debug}" = "yes"; then
DFLAGS="-D_DEBUG_"
AC_SUBST(DFLAGS)
fi
+dnl ----[ Profiling or not ? ]----
if test "${enable_profile}" = "yes"; then
CFLAGS="$CFLAGS -pg"
fi
@@ -247,9 +311,19 @@
if test "${VRRP_SUPPORT}" = "_WITH_VRRP_"; then
echo "Use VRRP Framework : Yes"
+ if test "${VRRP_VMAC}" = "_HAVE_VRRP_VMAC_"; then
+ echo "Use VRRP VMAC : Yes"
+ else
+ echo "Use VRRP VMAC : No"
+ fi
else
echo "Use VRRP Framework : No"
fi
+if test "${SNMP_SUPPORT}" = "_WITH_SNMP_"; then
+ echo "SNMP support : Yes"
+else
+ echo "SNMP support : No"
+fi
if test "${DFLAGS}" = "-D_DEBUG_"; then
echo "Use Debug flags : Yes"
else
|
[-]
[+]
|
Added |
keepalived-1.2.7.tar.bz2/doc/KEEPALIVED-MIB
^
|
@@ -0,0 +1,2213 @@
+-- ----------------------------------------------------------------------
+-- MIB file for keepalived (http://www.keepalived.org)
+-- ----------------------------------------------------------------------
+--
+-- There are two sections in this MIB: vrrp and check.
+
+KEEPALIVED-MIB DEFINITIONS ::= BEGIN
+
+IMPORTS
+ OBJECT-TYPE, MODULE-IDENTITY,
+ Integer32, Unsigned32, Counter32, Counter64,
+ Gauge32, enterprises, NOTIFICATION-TYPE
+ FROM SNMPv2-SMI
+ OBJECT-GROUP, MODULE-COMPLIANCE, NOTIFICATION-GROUP
+ FROM SNMPv2-CONF
+ InetAddressType, InetAddress, InetPortNumber,
+ InetAddressPrefixLength, InetScopeType
+ FROM INET-ADDRESS-MIB
+ InterfaceIndex, ifIndex
+ FROM IF-MIB
+ DisplayString, TEXTUAL-CONVENTION, TruthValue
+ FROM SNMPv2-TC;
+
+keepalived MODULE-IDENTITY
+ LAST-UPDATED "201208240000Z"
+ ORGANIZATION "Keepalived"
+ CONTACT-INFO "http://www.keepalived.org"
+ DESCRIPTION
+ "This MIB describes objects used by keepalived, both
+ for VRRP and health checker."
+ REVISION "201208240000Z"
+ DESCRIPTION "routerId added to traps variables"
+ REVISION "200904080000Z"
+ DESCRIPTION "Initial revision"
+
+ ::= { project 5 }
+
+-- We are hosted under Debian OID. See http://dsa.debian.org/iana/
+debian OBJECT IDENTIFIER ::= { enterprises 9586 }
+project OBJECT IDENTIFIER ::= { debian 100 }
+
+VrrpState ::= TEXTUAL-CONVENTION
+ STATUS current
+ DESCRIPTION
+ "Represents a VRRP state."
+ SYNTAX INTEGER {
+ init(0),
+ backup(1),
+ master(2),
+ fault(3),
+ unknown(4)
+ }
+
+global OBJECT IDENTIFIER ::= { keepalived 1 }
+vrrp OBJECT IDENTIFIER ::= { keepalived 2 }
+check OBJECT IDENTIFIER ::= { keepalived 3 }
+conformance OBJECT IDENTIFIER ::= { keepalived 4 }
+
+-- ----------------------------------------------------------------------
+-- Global part
+-- ----------------------------------------------------------------------
+
+version OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Version of keepalived"
+ ::= { global 1 }
+
+routerId OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Router ID"
+ ::= { global 2 }
+
+mail OBJECT IDENTIFIER ::= { global 3 }
+
+smtpServerAddressType OBJECT-TYPE
+ SYNTAX InetAddressType
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Address type for SMTP server."
+ ::= { mail 1 }
+
+smtpServerAddress OBJECT-TYPE
+ SYNTAX InetAddress
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Address of SMTP server."
+ ::= { mail 2 }
+
+smtpServerTimeout OBJECT-TYPE
+ SYNTAX Unsigned32
+ UNITS "seconds"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "SMTP server connection timeout."
+ ::= { mail 3 }
+
+emailFrom OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Email address for the From field."
+ ::= { mail 4 }
+
+emailTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF EmailEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of email notification addresses."
+ ::= { mail 5 }
+
+emailEntry OBJECT-TYPE
+ SYNTAX EmailEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Email address to be notified with an alert."
+ INDEX { emailIndex }
+ ::= { emailTable 1 }
+
+EmailEntry ::= SEQUENCE {
+ emailIndex Integer32,
+ emailAddress DisplayString
+}
+
+emailIndex OBJECT-TYPE
+ SYNTAX Integer32 (1..2147483647)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Index for the email address."
+ ::= { emailEntry 1 }
+
+emailAddress OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Email address to be notified when an alert is raised."
+ ::= { emailEntry 2 }
+
+trapEnable OBJECT-TYPE
+ SYNTAX INTEGER { enabled(1), disabled(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Indicate whether traps should be sent for various events."
+ ::= { global 4 }
+
+linkBeat OBJECT-TYPE
+ SYNTAX INTEGER { netlink(1), polling(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Indicate which method is used to check if a link is up or
+ down. netlink(1) means that the kernel will push a link state
+ change while polling(2) means that the status of the link is
+ checked periodically."
+ ::= { global 5 }
+
+-- ----------------------------------------------------------------------
+-- VRRP part
+-- ----------------------------------------------------------------------
+
+-- Sync groups
+-- see vrrp.h
+
+vrrpSyncGroupTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF VrrpSyncGroupEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of sync groups"
+ ::= { vrrp 1 }
+
+vrrpSyncGroupEntry OBJECT-TYPE
+ SYNTAX VrrpSyncGroupEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Information describing a sync group"
+ INDEX { vrrpSyncGroupIndex }
+ ::= { vrrpSyncGroupTable 1 }
+
+VrrpSyncGroupEntry ::= SEQUENCE {
+ vrrpSyncGroupIndex Integer32,
+ vrrpSyncGroupName DisplayString,
+ vrrpSyncGroupState VrrpState,
+ vrrpSyncGroupSmtpAlert INTEGER,
+ vrrpSyncGroupNotifyExec INTEGER,
+ vrrpSyncGroupScriptMaster DisplayString,
+ vrrpSyncGroupScriptBackup DisplayString,
+ vrrpSyncGroupScriptFault DisplayString,
+ vrrpSyncGroupScript DisplayString
+}
+
+vrrpSyncGroupIndex OBJECT-TYPE
+ SYNTAX Integer32 (1..2147483647)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Index of the synchronisation group."
+ ::= { vrrpSyncGroupEntry 1 }
+
+vrrpSyncGroupName OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Name of the synchronisation group."
+ ::= {vrrpSyncGroupEntry 2 }
+
+vrrpSyncGroupState OBJECT-TYPE
+ SYNTAX VrrpState
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current state of the synchronisation group."
+ ::= {vrrpSyncGroupEntry 3 }
+
+vrrpSyncGroupSmtpAlert OBJECT-TYPE
+ SYNTAX INTEGER { enabled(1), disabled(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Will SMTP alert be sent for this synchronisation group?"
+ ::= {vrrpSyncGroupEntry 4 }
+
+vrrpSyncGroupNotifyExec OBJECT-TYPE
+ SYNTAX INTEGER { enabled(1), disabled(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Will we execute notification script for this group?"
+ ::= {vrrpSyncGroupEntry 5 }
+
+vrrpSyncGroupScriptMaster OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Script to execute when the group becomes master."
+ ::= {vrrpSyncGroupEntry 6 }
+
+vrrpSyncGroupScriptBackup OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Script to execute when the group becomes backup."
+ ::= {vrrpSyncGroupEntry 7 }
+
+vrrpSyncGroupScriptFault OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Script to execute when the group is in fault state."
+ ::= {vrrpSyncGroupEntry 8 }
+
+vrrpSyncGroupScript OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Script to execute whenever a state change occurs."
+ ::= {vrrpSyncGroupEntry 9 }
+
+vrrpSyncGroupMemberTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF VrrpSyncGroupMemberEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of instances contained in sync groups"
+ ::= { vrrp 2 }
+
+vrrpSyncGroupMemberEntry OBJECT-TYPE
+ SYNTAX VrrpSyncGroupMemberEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Information describing a member of a sync group"
+ INDEX { vrrpSyncGroupIndex, vrrpSyncGroupMemberInstanceIndex }
+ ::= { vrrpSyncGroupMemberTable 1 }
+
+VrrpSyncGroupMemberEntry ::= SEQUENCE {
+ vrrpSyncGroupMemberInstanceIndex Integer32,
+ vrrpSyncGroupMemberName DisplayString
+}
+
+vrrpSyncGroupMemberInstanceIndex OBJECT-TYPE
+ SYNTAX Integer32 (1..2147483647)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Index of an instance in a synchronisation group.
+ There is no relation with this index and the index of the
+ corresponding instance in vrrpInstanceTable. Use the name
+ to find out the corresponding instance."
+ ::= { vrrpSyncGroupMemberEntry 1 }
+
+vrrpSyncGroupMemberName OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Name of the instance contained in the synchronisation group."
+ ::= { vrrpSyncGroupMemberEntry 2 }
+
+-- VRRP instances
+-- see vrrp.h
+
+vrrpInstanceTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF VrrpInstanceEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of VRRP instances"
+ ::= { vrrp 3 }
+
+vrrpInstanceEntry OBJECT-TYPE
+ SYNTAX VrrpInstanceEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Information describing a sync group"
+ INDEX { vrrpInstanceIndex }
+ ::= { vrrpInstanceTable 1 }
+
+VrrpInstanceEntry ::= SEQUENCE {
+ vrrpInstanceIndex INTEGER,
+ vrrpInstanceName DisplayString,
+ vrrpInstanceVirtualRouterId Unsigned32,
+ vrrpInstanceState VrrpState,
+ vrrpInstanceInitialState VrrpState,
+ vrrpInstanceWantedState VrrpState,
+ vrrpInstanceBasePriority Integer32,
+ vrrpInstanceEffectivePriority Integer32,
+ vrrpInstanceVipsStatus INTEGER,
+ vrrpInstancePrimaryInterface DisplayString,
+ vrrpInstanceTrackPrimaryIf INTEGER,
+ vrrpInstanceAdvertisementsInt Unsigned32,
+ vrrpInstancePreempt INTEGER,
+ vrrpInstancePreemptDelay Unsigned32,
+ vrrpInstanceAuthType INTEGER,
+ vrrpInstanceLvsSyncDaemon INTEGER,
+ vrrpInstanceLvsSyncInterface DisplayString,
+ vrrpInstanceSyncGroup DisplayString,
+ vrrpInstanceGarpDelay Unsigned32,
+ vrrpInstanceSmtpAlert INTEGER,
+ vrrpInstanceNotifyExec INTEGER,
+ vrrpInstanceScriptMaster DisplayString,
+ vrrpInstanceScriptBackup DisplayString,
+ vrrpInstanceScriptFault DisplayString,
+ vrrpInstanceScriptStop DisplayString,
+ vrrpInstanceScript DisplayString
+}
+
+vrrpInstanceIndex OBJECT-TYPE
+ SYNTAX INTEGER {
+ static(0)
+ }
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Index of the VRRP instance.
+
+ Instance 0 is for static IP and static routes."
+ ::= { vrrpInstanceEntry 1 }
+
+vrrpInstanceName OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Name of the VRRP instance."
+ ::= { vrrpInstanceEntry 2 }
+
+vrrpInstanceVirtualRouterId OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Virtual Router ID (VRID) for this VRRP instance."
+ ::= { vrrpInstanceEntry 3 }
+
+vrrpInstanceState OBJECT-TYPE
+ SYNTAX VrrpState
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current state of this VRRP instance."
+ ::= { vrrpInstanceEntry 4 }
+
+vrrpInstanceInitialState OBJECT-TYPE
+ SYNTAX VrrpState
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Initial state of this VRRP instance."
+ ::= { vrrpInstanceEntry 5 }
+
+vrrpInstanceWantedState OBJECT-TYPE
+ SYNTAX VrrpState
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "State wanted by the operator for this VRRP instance."
+ ::= { vrrpInstanceEntry 6 }
+
+vrrpInstanceBasePriority OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Base priority (as defined in the configuration file) for this
+ VRRP instance.
+
+ This value can be modified to force the virtual router
+ instance to become backup or master.
+ "
+ ::= { vrrpInstanceEntry 7 }
+
+vrrpInstanceEffectivePriority OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Effective priority for this VRRP instance. Status of
+ interfaces and script results are used to compute this value
+ from the base priority."
+ ::= { vrrpInstanceEntry 8 }
+
+vrrpInstanceVipsStatus OBJECT-TYPE
+ SYNTAX INTEGER { allSet(1), notAllSet(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Are all VIP of this VRRP instance enabled?"
+ ::= { vrrpInstanceEntry 9 }
+
+vrrpInstancePrimaryInterface OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Primary interface of this VRRP instance."
+ ::= { vrrpInstanceEntry 10 }
+
+vrrpInstanceTrackPrimaryIf OBJECT-TYPE
+ SYNTAX INTEGER { tracked(1), notTracked(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Do we track the status of the primary interface?"
+ ::= { vrrpInstanceEntry 11 }
+
+vrrpInstanceAdvertisementsInt OBJECT-TYPE
+ SYNTAX Unsigned32
+ UNITS "seconds"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Delay in seconds between two VRRP advertisements."
+ ::= { vrrpInstanceEntry 12 }
+
+vrrpInstancePreempt OBJECT-TYPE
+ SYNTAX INTEGER { preempt(1), noPreempt(2) }
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Will a higher priority advertisement preempt a lower instance?"
+ ::= { vrrpInstanceEntry 13 }
+
+vrrpInstancePreemptDelay OBJECT-TYPE
+ SYNTAX Unsigned32
+ UNITS "seconds"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Delay after startup until preemption can happen. 0 means that
+ there is no delay."
+ ::= { vrrpInstanceEntry 14 }
+
+vrrpInstanceAuthType OBJECT-TYPE
+ SYNTAX INTEGER {
+ none(0),
+ password(1),
+ ah(2)
+ }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Authentication method to authenticate other peers."
+ ::= { vrrpInstanceEntry 15 }
+
+vrrpInstanceLvsSyncDaemon OBJECT-TYPE
+ SYNTAX INTEGER { enabled(1), disabled(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Is LVS sync daemon enabled for this VRRP instance?"
+ ::= { vrrpInstanceEntry 16 }
+
+vrrpInstanceLvsSyncInterface OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "If LVS sync daemon is enabled, which interface to use for syncing?"
+ ::= { vrrpInstanceEntry 17 }
+
+vrrpInstanceSyncGroup OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Name of the synchronisation group this VRRP instance belongs, if any."
+ ::= { vrrpInstanceEntry 18 }
+
+vrrpInstanceGarpDelay OBJECT-TYPE
+ SYNTAX Unsigned32
+ UNITS "seconds"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Delay to launch gratuitous ARP (GARP)."
+ ::= { vrrpInstanceEntry 19 }
+
+vrrpInstanceSmtpAlert OBJECT-TYPE
+ SYNTAX INTEGER { enabled(1), disabled(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Will SMTP alert be sent for this VRRP instance?"
+ ::= { vrrpInstanceEntry 20 }
+
+vrrpInstanceNotifyExec OBJECT-TYPE
+ SYNTAX INTEGER { enabled(1), disabled(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Will we execute notification script for this instance?"
+ ::= { vrrpInstanceEntry 21 }
+
+vrrpInstanceScriptMaster OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Script to execute when the instance becomes master."
+ ::= { vrrpInstanceEntry 22 }
+
+vrrpInstanceScriptBackup OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Script to execute when the instance becomes backup."
+ ::= { vrrpInstanceEntry 23 }
+
+vrrpInstanceScriptFault OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Script to execute when the instance is in fault state."
+ ::= { vrrpInstanceEntry 24 }
+
+vrrpInstanceScriptStop OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Script to execute when the instance is stopped."
+ ::= { vrrpInstanceEntry 25 }
+
+vrrpInstanceScript OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Script to execute whenever a state change occurs."
+ ::= { vrrpInstanceEntry 26 }
+
+vrrpTrackedInterfaceTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF VrrpTrackedInterfaceEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of tracked interfaces for each VRRP instance."
+ ::= { vrrp 4 }
+
+vrrpTrackedInterfaceEntry OBJECT-TYPE
+ SYNTAX VrrpTrackedInterfaceEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Information describing a tracked interface"
+ INDEX { vrrpInstanceIndex, ifIndex }
+ ::= { vrrpTrackedInterfaceTable 1 }
+
+VrrpTrackedInterfaceEntry ::= SEQUENCE {
+ vrrpTrackedInterfaceName DisplayString,
+ vrrpTrackedInterfaceWeight Integer32
+}
+
+vrrpTrackedInterfaceName OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Name of the tracked interface."
+ ::= { vrrpTrackedInterfaceEntry 1 }
+
+vrrpTrackedInterfaceWeight OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Weight of the tracked interface."
+ ::= { vrrpTrackedInterfaceEntry 2 }
+
+vrrpTrackedScriptTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF VrrpTrackedScriptEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of tracked interfaces for each VRRP instance."
+ ::= { vrrp 5 }
+
+vrrpTrackedScriptEntry OBJECT-TYPE
+ SYNTAX VrrpTrackedScriptEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Information describing a tracked script"
+ INDEX { vrrpInstanceIndex, vrrpTrackedScriptIndex }
+ ::= { vrrpTrackedScriptTable 1 }
+
+VrrpTrackedScriptEntry ::= SEQUENCE {
+ vrrpTrackedScriptIndex Integer32,
+ vrrpTrackedScriptName DisplayString,
+ vrrpTrackedScriptWeight Integer32
+}
+
+vrrpTrackedScriptIndex OBJECT-TYPE
+ SYNTAX Integer32 (1..2147483647)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Index of the tracked script in the set of tracked scripts for
+ the given VRRP instance. This index has no relation with the
+ index of vrrpScriptTable."
+ ::= { vrrpTrackedScriptEntry 1 }
+
+vrrpTrackedScriptName OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Name of the tracked interface."
+ ::= { vrrpTrackedScriptEntry 2 }
+
+vrrpTrackedScriptWeight OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Weight of the tracked interface."
+ ::= { vrrpTrackedScriptEntry 3 }
+
+-- IP addresses
+-- see vrrp_ipaddress.h
+
+vrrpAddressTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF VrrpAddressEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of static and virtual addresses"
+ ::= { vrrp 6 }
+
+vrrpAddressEntry OBJECT-TYPE
+ SYNTAX VrrpAddressEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Information describing an address. This can be a static
+ address or a virtual address. In case of static address, the
+ VRRP instance index is 0."
+ INDEX { vrrpInstanceIndex, vrrpAddressIndex }
+ ::= { vrrpAddressTable 1 }
+
+VrrpAddressEntry ::= SEQUENCE {
+ vrrpAddressIndex Integer32,
+ vrrpAddressType InetAddressType,
+ vrrpAddressValue InetAddress,
+ vrrpAddressBroadcast InetAddress,
+ vrrpAddressMask InetAddressPrefixLength,
+ vrrpAddressScope InetScopeType,
+ vrrpAddressIfIndex InterfaceIndex,
+ vrrpAddressIfName DisplayString,
+ vrrpAddressIfAlias DisplayString,
+ vrrpAddressStatus INTEGER,
+ vrrpAddressAdvertising INTEGER
+}
+
+vrrpAddressIndex OBJECT-TYPE
+ SYNTAX Integer32 (1..2147483647)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Address index."
+ ::= { vrrpAddressEntry 1 }
+
+vrrpAddressType OBJECT-TYPE
+ SYNTAX InetAddressType
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "A value that represents a type of Internet address."
+ ::= { vrrpAddressEntry 2 }
+
+vrrpAddressValue OBJECT-TYPE
+ SYNTAX InetAddress
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Actual IP address."
+ ::= { vrrpAddressEntry 3 }
+
+vrrpAddressBroadcast OBJECT-TYPE
+ SYNTAX InetAddress
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Broadcast address associated with the IP address."
+ ::= { vrrpAddressEntry 4 }
+
+vrrpAddressMask OBJECT-TYPE
+ SYNTAX InetAddressPrefixLength
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Address mask."
+ ::= { vrrpAddressEntry 5 }
+
+vrrpAddressScope OBJECT-TYPE
+ SYNTAX InetScopeType
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Address scope."
+ ::= { vrrpAddressEntry 6 }
+
+vrrpAddressIfIndex OBJECT-TYPE
+ SYNTAX InterfaceIndex
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Index of the interface to which the IP address is linked to."
+ ::= { vrrpAddressEntry 7 }
+
+vrrpAddressIfName OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Name of the interface to which the IP address is linked to."
+ ::= { vrrpAddressEntry 8 }
+
+vrrpAddressIfAlias OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Alias name of the interface."
+ ::= { vrrpAddressEntry 9 }
+
+vrrpAddressStatus OBJECT-TYPE
+ SYNTAX INTEGER { set(1), unset(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Is the IP address set?"
+ ::= { vrrpAddressEntry 10 }
+
+vrrpAddressAdvertising OBJECT-TYPE
+ SYNTAX INTEGER { advertised(1), notAdvertised(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Status of VRRP advertising for this IP address."
+ ::= { vrrpAddressEntry 11 }
+
+-- Routes
+-- see vrrp_iproute.h
+
+vrrpRouteTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF VrrpRouteEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of static and virtual routes."
+ ::= { vrrp 7 }
+
+vrrpRouteEntry OBJECT-TYPE
+ SYNTAX VrrpRouteEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Information describing a route. In case of a static route,
+ the instance index is 0."
+ INDEX { vrrpInstanceIndex, vrrpRouteIndex }
+ ::= { vrrpRouteTable 1 }
+
+VrrpRouteEntry ::= SEQUENCE {
+ vrrpRouteIndex Integer32,
+ vrrpRouteAddressType InetAddressType,
+ vrrpRouteDestination InetAddress,
+ vrrpRouteDestinationMask InetAddressPrefixLength,
+ vrrpRouteGateway InetAddress,
+ vrrpRouteSecondaryGateway InetAddress,
+ vrrpRouteSource InetAddress,
+ vrrpRouteMetric Unsigned32,
+ vrrpRouteScope InetScopeType,
+ vrrpRouteType INTEGER,
+ vrrpRouteIfIndex InterfaceIndex,
+ vrrpRouteIfName DisplayString,
+ vrrpRouteRoutingTable Unsigned32,
+ vrrpRouteStatus INTEGER
+}
+
+vrrpRouteIndex OBJECT-TYPE
+ SYNTAX Integer32 (1..2147483647)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Route index."
+ ::= { vrrpRouteEntry 1 }
+
+vrrpRouteAddressType OBJECT-TYPE
+ SYNTAX InetAddressType
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Route type of internet address."
+ ::= { vrrpRouteEntry 2 }
+
+vrrpRouteDestination OBJECT-TYPE
+ SYNTAX InetAddress
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Route destination."
+ ::= { vrrpRouteEntry 3 }
+
+vrrpRouteDestinationMask OBJECT-TYPE
+ SYNTAX InetAddressPrefixLength
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Route destination mask."
+ ::= { vrrpRouteEntry 4 }
+
+vrrpRouteGateway OBJECT-TYPE
+ SYNTAX InetAddress
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Gateway for the given destination."
+ ::= { vrrpRouteEntry 5 }
+
+vrrpRouteSecondaryGateway OBJECT-TYPE
+ SYNTAX InetAddress
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "An optional second gateway for the given destination."
+ ::= { vrrpRouteEntry 6 }
+
+vrrpRouteSource OBJECT-TYPE
+ SYNTAX InetAddress
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Which source IP address to use with this route."
+ ::= { vrrpRouteEntry 7 }
+
+vrrpRouteMetric OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Metric of this route."
+ ::= { vrrpRouteEntry 8 }
+
+vrrpRouteScope OBJECT-TYPE
+ SYNTAX InetScopeType
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Scope of this route."
+ ::= { vrrpRouteEntry 9 }
+
+vrrpRouteType OBJECT-TYPE
+ SYNTAX INTEGER { normal(1), ecmp(2), blackhole(3) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Kind of route."
+ ::= { vrrpRouteEntry 10 }
+
+vrrpRouteIfIndex OBJECT-TYPE
+ SYNTAX InterfaceIndex
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Interface attached to this route."
+ ::= { vrrpRouteEntry 11 }
+
+vrrpRouteIfName OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Name of the interface of attached to this route."
+ ::= { vrrpRouteEntry 12 }
+
+vrrpRouteRoutingTable OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Routing table where to route should be inserted."
+ ::= { vrrpRouteEntry 13 }
+
+vrrpRouteStatus OBJECT-TYPE
+ SYNTAX INTEGER { set(1), unset(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Is this route set in the kernel?"
+ ::= { vrrpRouteEntry 14 }
+
+-- VRRP scripts
+-- see vrrp_track.h
+
+vrrpScriptTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF VrrpScriptEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of VRRP scripts"
+ ::= { vrrp 8 }
+
+vrrpScriptEntry OBJECT-TYPE
+ SYNTAX VrrpScriptEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Information describing a VRRP script"
+ INDEX { vrrpScriptIndex }
+ ::= { vrrpScriptTable 1 }
+
+VrrpScriptEntry ::= SEQUENCE {
+ vrrpScriptIndex Integer32,
+ vrrpScriptName DisplayString,
+ vrrpScriptCommand DisplayString,
+ vrrpScriptInterval Integer32,
+ vrrpScriptWeight Integer32,
+ vrrpScriptResult INTEGER,
+ vrrpScriptRise Unsigned32,
+ vrrpScriptFall Unsigned32
+}
+
+vrrpScriptIndex OBJECT-TYPE
+ SYNTAX Integer32 (1..2147483647)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Script index."
+ ::= { vrrpScriptEntry 1 }
+
+vrrpScriptName OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Symbolic name of the script."
+ ::= { vrrpScriptEntry 2 }
+
+vrrpScriptCommand OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Command executed when running the script."
+ ::= { vrrpScriptEntry 3 }
+
+vrrpScriptInterval OBJECT-TYPE
+ SYNTAX Integer32
+ UNITS "seconds"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Interval between two runs of the script."
+ ::= { vrrpScriptEntry 4 }
+
+vrrpScriptWeight OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Weight of the script if successful."
+ ::= { vrrpScriptEntry 5 }
+
+vrrpScriptResult OBJECT-TYPE
+ SYNTAX INTEGER {
+ disabled(0),
+ init(1),
+ bad(2),
+ good(3),
+ initgood(4)
+ }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current status of the script."
+ ::= { vrrpScriptEntry 6 }
+
+vrrpScriptRise OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "How many times the script should succeed before OK."
+ ::= { vrrpScriptEntry 7 }
+
+vrrpScriptFall OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "How many times the script should fail before KO."
+ ::= { vrrpScriptEntry 8 }
+
+-- Traps
+
+vrrpTrap OBJECT IDENTIFIER ::= { vrrp 9 }
+vrrpTraps OBJECT IDENTIFIER ::= { vrrpTrap 0 } -- Reverse-mappable
+vrrpTrapControl OBJECT IDENTIFIER ::= { vrrpTrap 1 }
+
+vrrpSyncGroupStateChange NOTIFICATION-TYPE
+ OBJECTS {
+ vrrpSyncGroupName,
+ vrrpSyncGroupState,
+ routerId
+ }
+ STATUS current
+ DESCRIPTION
+ "This trap signifies that the state of the whole vrrp sync
+ group changed."
+ ::= { vrrpTraps 1 }
+
+vrrpInstanceStateChange NOTIFICATION-TYPE
+ OBJECTS {
+ vrrpInstanceName,
+ vrrpInstanceState,
+ vrrpInstanceInitialState,
+ routerId
+ }
+ STATUS current
+ DESCRIPTION
+ "This trap signifies that the state of a vrrp instance changed."
+ ::= { vrrpTraps 2 }
+
+-- ----------------------------------------------------------------------
+-- Healthchecker part
+-- ----------------------------------------------------------------------
+
+-- Virtual server group
+
+virtualServerGroupTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF VirtualServerGroupEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of virtual server groups."
+ ::= { check 1 }
+
+virtualServerGroupEntry OBJECT-TYPE
+ SYNTAX VirtualServerGroupEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Information describing a virtual server group."
+ INDEX { virtualServerGroupIndex }
+ ::= { virtualServerGroupTable 1 }
+
+VirtualServerGroupEntry ::= SEQUENCE {
+ virtualServerGroupIndex Integer32,
+ virtualServerGroupName DisplayString
+}
+
+virtualServerGroupIndex OBJECT-TYPE
+ SYNTAX Integer32 (1..2147483647)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Index of the virtual server group."
+ ::= { virtualServerGroupEntry 1 }
+
+virtualServerGroupName OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Name of the virtual server group."
+ ::= { virtualServerGroupEntry 2 }
+
+virtualServerGroupMemberTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF VirtualServerGroupMemberEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of members of a virtual server group."
+ ::= { check 2 }
+
+virtualServerGroupMemberEntry OBJECT-TYPE
+ SYNTAX VirtualServerGroupMemberEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Description of a member of a virtual server group."
+ INDEX { virtualServerGroupIndex, virtualServerGroupMemberIndex }
+ ::= { virtualServerGroupMemberTable 1 }
+
+VirtualServerGroupMemberEntry ::= SEQUENCE {
+ virtualServerGroupMemberIndex Integer32,
+ virtualServerGroupMemberType INTEGER,
+ virtualServerGroupMemberFwMark Unsigned32,
+ virtualServerGroupMemberAddrType InetAddressType,
+ virtualServerGroupMemberAddress InetAddress,
+ virtualServerGroupMemberAddr1 InetAddress,
+ virtualServerGroupMemberAddr2 InetAddress,
+ virtualServerGroupMemberPort InetPortNumber
+}
+
+virtualServerGroupMemberIndex OBJECT-TYPE
+ SYNTAX Integer32 (1..2147483647)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Index of the member into virtual server group."
+ ::= { virtualServerGroupMemberEntry 1 }
+
+virtualServerGroupMemberType OBJECT-TYPE
+ SYNTAX INTEGER { fwmark(1), ip(2), iprange(3) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Kind of entry: firewall mark, address with port or range of
+ addresses with port."
+ ::= { virtualServerGroupMemberEntry 2 }
+
+virtualServerGroupMemberFwMark OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Firewall mark for this member.
+
+ If the kind of this member is not fwmark(1), then this entry
+ should not exist for the current row."
+ ::= { virtualServerGroupMemberEntry 3 }
+
+virtualServerGroupMemberAddrType OBJECT-TYPE
+ SYNTAX InetAddressType
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Type of IP address for this member.
+
+ If the kind of this member is neither address(2) or range(3),
+ then this entry should not exist for the current row."
+ ::= { virtualServerGroupMemberEntry 4 }
+
+virtualServerGroupMemberAddress OBJECT-TYPE
+ SYNTAX InetAddress
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "IP address of this member.
+
+ If the kind of this member is not address(2), then this entry
+ should not exist for the current row."
+ ::= { virtualServerGroupMemberEntry 5 }
+
+virtualServerGroupMemberAddr1 OBJECT-TYPE
+ SYNTAX InetAddress
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "First IP address of the range for this member.
+
+ If the kind of this member is not range(3), then this entry
+ should not exist for the current row."
+ ::= { virtualServerGroupMemberEntry 6 }
+
+virtualServerGroupMemberAddr2 OBJECT-TYPE
+ SYNTAX InetAddress
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Second IP address of the range for this member.
+
+ If the kind of this member is not range(3), then this entry
+ should not exist for the current row."
+ ::= { virtualServerGroupMemberEntry 7 }
+
+virtualServerGroupMemberPort OBJECT-TYPE
+ SYNTAX InetPortNumber
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "V port for this member.
+
+ If the kind of this member is neither address(2) nor range(3),
+ then this entry should not exist for the current row."
+ ::= { virtualServerGroupMemberEntry 8 }
+
+-- virtual server
+
+virtualServerTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF VirtualServerEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of virtual servers."
+ ::= { check 3 }
+
+virtualServerEntry OBJECT-TYPE
+ SYNTAX VirtualServerEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Information describing a virtual server."
+ INDEX { virtualServerIndex }
+ ::= { virtualServerTable 1 }
+
+VirtualServerEntry ::= SEQUENCE {
+ virtualServerIndex Integer32,
+ virtualServerType INTEGER,
+ virtualServerNameOfGroup DisplayString,
+ virtualServerFwMark Unsigned32,
+ virtualServerAddrType InetAddressType,
+ virtualServerAddress InetAddress,
+ virtualServerPort InetPortNumber,
+ virtualServerProtocol INTEGER,
+ virtualServerLoadBalancingAlgo INTEGER,
+ virtualServerLoadBalancingKind INTEGER,
+ virtualServerStatus INTEGER,
+ virtualServerVirtualHost DisplayString,
+ virtualServerPersist INTEGER,
+ virtualServerPersistTimeout Unsigned32,
+ virtualServerPersistGranularity InetAddress,
+ virtualServerDelayLoop Unsigned32,
+ virtualServerHaSuspend TruthValue,
+ virtualServerAlpha INTEGER,
+ virtualServerOmega INTEGER,
+ virtualServerRealServersTotal Unsigned32,
+ virtualServerRealServersUp Unsigned32,
+ virtualServerQuorum Unsigned32,
+ virtualServerQuorumStatus INTEGER,
+ virtualServerQuorumUp DisplayString,
+ virtualServerQuorumDown DisplayString,
+ virtualServerHysteresis Unsigned32,
+ virtualServerStatsConns Gauge32,
+ virtualServerStatsInPkts Counter32,
+ virtualServerStatsOutPkts Counter32,
+ virtualServerStatsInBytes Counter64,
+ virtualServerStatsOutBytes Counter64,
+ virtualServerRateCps Gauge32,
+ virtualServerRateInPPS Gauge32,
+ virtualServerRateOutPPS Gauge32,
+ virtualServerRateInBPS Gauge32,
+ virtualServerRateOutBPS Gauge32
+}
+
+virtualServerIndex OBJECT-TYPE
+ SYNTAX Integer32 (1..2147483647)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Index of the virtual server."
+ ::= { virtualServerEntry 1 }
+
+virtualServerType OBJECT-TYPE
+ SYNTAX INTEGER { fwmark(1), ip(2), group(3) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Type of virtual server. A virtual server can either be
+ defined from a firewall mark, an IP and a port
+ or from a virtual server group."
+ ::= { virtualServerEntry 2 }
+
+virtualServerNameOfGroup OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "If the virtual is defined from a group, this is the name of the group."
+ ::= { virtualServerEntry 3 }
+
+virtualServerFwMark OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "If the virtual server is defined from a firewall mark, this
+ is the value of the mark. Otherwise, this column should not
+ exist in the current row."
+ ::= { virtualServerEntry 4 }
+
+virtualServerAddrType OBJECT-TYPE
+ SYNTAX InetAddressType
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "If the virtual server is defined from an IP, this
+ is the address family. Otherwise, this column should not
+ exist in the current row."
+ ::= { virtualServerEntry 5 }
+
+virtualServerAddress OBJECT-TYPE
+ SYNTAX InetAddress
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "If the virtual server is defined from an IP address, this
+ is the value of the IP. Otherwise, this column should not
+ exist in the current row."
+ ::= { virtualServerEntry 6 }
+
+virtualServerPort OBJECT-TYPE
+ SYNTAX InetPortNumber
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "If the virtual server is defined from an IP, this is
+ the value of the port to listen for requests. Otherwise, this column
+ should not exist in the current row."
+ ::= { virtualServerEntry 7 }
+
+virtualServerProtocol OBJECT-TYPE
+ SYNTAX INTEGER { tcp(1), udp(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Which transport protocol should be used for this virtual server."
+ ::= { virtualServerEntry 8 }
+
+virtualServerLoadBalancingAlgo OBJECT-TYPE
+ SYNTAX INTEGER {
+ rr(1),
+ wrr(2),
+ lc(3),
+ wlc(4),
+ lblc(5),
+ lblcr(6),
+ dh(7),
+ sh(8),
+ sed(9),
+ nq(10),
+ unknown(99)
+ }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Which load balancing algorithm (or scheduler) should be used
+ for this virtual server."
+ ::= { virtualServerEntry 9 }
+
+virtualServerLoadBalancingKind OBJECT-TYPE
+ SYNTAX INTEGER { nat(1), dr(2), tun(3) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Forwarding method to use for this virtual server."
+ ::= { virtualServerEntry 10 }
+
+virtualServerStatus OBJECT-TYPE
+ SYNTAX INTEGER { alive(1), dead(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current status of this virtual server."
+ ::= { virtualServerEntry 11 }
+
+virtualServerVirtualHost OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Virtualhost of this server for HTTP like requests."
+ ::= { virtualServerEntry 12 }
+
+virtualServerPersist OBJECT-TYPE
+ SYNTAX INTEGER { enabled(1), disabled(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Is the virtual service persistence enabled?"
+ ::= { virtualServerEntry 13 }
+
+virtualServerPersistTimeout OBJECT-TYPE
+ SYNTAX Unsigned32
+ UNITS "seconds"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "If this virtual service is persistence, what is the timeout."
+ ::= { virtualServerEntry 14 }
+
+virtualServerPersistGranularity OBJECT-TYPE
+ SYNTAX InetAddress
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Netmask specifying the granularity of the persistence mechanism."
+ ::= { virtualServerEntry 15 }
+
+virtualServerDelayLoop OBJECT-TYPE
+ SYNTAX Unsigned32
+ UNITS "seconds"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Delay in seconds between two checks."
+ ::= { virtualServerEntry 16 }
+
+virtualServerHaSuspend OBJECT-TYPE
+ SYNTAX TruthValue
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "If set to true(1), checks will be suspended if the IP of the
+ virtual server is currently not set."
+ ::= { virtualServerEntry 17 }
+
+virtualServerAlpha OBJECT-TYPE
+ SYNTAX INTEGER { enabled(1), disabled(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Is alpha mode enabled?"
+ ::= { virtualServerEntry 18 }
+
+virtualServerOmega OBJECT-TYPE
+ SYNTAX INTEGER { enabled(1), disabled(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Is omega mode enabled?"
+ ::= { virtualServerEntry 19 }
+
+virtualServerRealServersTotal OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total number of real servers for this virtual server."
+ ::= { virtualServerEntry 20 }
+
+virtualServerRealServersUp OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Real servers actually up for this virtual server."
+ ::= { virtualServerEntry 21 }
+
+virtualServerQuorum OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Quorum to get amond real servers to consider this virtual server up."
+ ::= { virtualServerEntry 22 }
+
+virtualServerQuorumStatus OBJECT-TYPE
+ SYNTAX INTEGER { met(1), notMet(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current status of the quorum for this virtual server."
+ ::= { virtualServerEntry 23 }
+
+virtualServerQuorumUp OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Command to execute when the quorum is met."
+ ::= { virtualServerEntry 24 }
+
+virtualServerQuorumDown OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Command to execute when the quorum is not met."
+ ::= { virtualServerEntry 25 }
+
+virtualServerHysteresis OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Hysteresis with respect to quorum count."
+ ::= { virtualServerEntry 26 }
+
+virtualServerStatsConns OBJECT-TYPE
+ SYNTAX Gauge32
+ UNITS "connections"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total number of connections scheduled for this virtual server."
+ ::= { virtualServerEntry 27 }
+
+virtualServerStatsInPkts OBJECT-TYPE
+ SYNTAX Counter32
+ UNITS "packets"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total number of incoming packets for this virtual server."
+ ::= { virtualServerEntry 28 }
+
+virtualServerStatsOutPkts OBJECT-TYPE
+ SYNTAX Counter32
+ UNITS "packets"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total number of outgoing packets for this virtual server."
+ ::= { virtualServerEntry 29 }
+
+virtualServerStatsInBytes OBJECT-TYPE
+ SYNTAX Counter64
+ UNITS "bytes"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total number of incoming bytes for this virtual server."
+ ::= { virtualServerEntry 30 }
+
+virtualServerStatsOutBytes OBJECT-TYPE
+ SYNTAX Counter64
+ UNITS "bytes"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total number of outgoing bytes for this virtual server."
+ ::= { virtualServerEntry 31 }
+
+virtualServerRateCps OBJECT-TYPE
+ SYNTAX Gauge32
+ UNITS "connections/s"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current connection rate for this virtual server."
+ ::= { virtualServerEntry 32 }
+
+virtualServerRateInPPS OBJECT-TYPE
+ SYNTAX Gauge32
+ UNITS "packets/s"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current in packet rate for this virtual server."
+ ::= { virtualServerEntry 33 }
+
+virtualServerRateOutPPS OBJECT-TYPE
+ SYNTAX Gauge32
+ UNITS "packets/s"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current out packet rate for this virtual server."
+ ::= { virtualServerEntry 34 }
+
+virtualServerRateInBPS OBJECT-TYPE
+ SYNTAX Gauge32
+ UNITS "bytes/s"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current incoming rate for this virtual server."
+ ::= { virtualServerEntry 35 }
+
+virtualServerRateOutBPS OBJECT-TYPE
+ SYNTAX Gauge32
+ UNITS "bytes/s"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current outgoing rate for this virtual server."
+ ::= { virtualServerEntry 36 }
+
+
+-- real servers
+
+realServerTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF RealServerEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Table of real servers. This includes regular real servers and sorry servers."
+ ::= { check 4 }
+
+realServerEntry OBJECT-TYPE
+ SYNTAX RealServerEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Information describing a real server."
+ INDEX { virtualServerIndex, realServerIndex }
+ ::= { realServerTable 1 }
+
+RealServerEntry ::= SEQUENCE {
+ realServerIndex Integer32,
+ realServerType INTEGER,
+ realServerAddrType InetAddressType,
+ realServerAddress InetAddress,
+ realServerPort InetPortNumber,
+ realServerStatus INTEGER,
+ realServerWeight Integer32,
+ realServerUpperConnectionLimit Unsigned32,
+ realServerLowerConnectionLimit Unsigned32,
+ realServerActionWhenDown INTEGER,
+ realServerNotifyUp DisplayString,
+ realServerNotifyDown DisplayString,
+ realServerFailedChecks Unsigned32,
+ realServerStatsConns Gauge32,
+ realServerStatsActiveConns Gauge32,
+ realServerStatsInactiveConns Gauge32,
+ realServerStatsPersistentConns Gauge32,
+ realServerStatsInPkts Counter32,
+ realServerStatsOutPkts Counter32,
+ realServerStatsInBytes Counter64,
+ realServerStatsOutBytes Counter64,
+ realServerRateCps Gauge32,
+ realServerRateInPPS Gauge32,
+ realServerRateOutPPS Gauge32,
+ realServerRateInBPS Gauge32,
+ realServerRateOutBPS Gauge32
+}
+
+realServerIndex OBJECT-TYPE
+ SYNTAX Integer32 (1..2147483647)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "Index of the real server."
+ ::= { realServerEntry 1 }
+
+realServerType OBJECT-TYPE
+ SYNTAX INTEGER { regular(1), sorry(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Type of real server: either a regular real server or a sorry server."
+ ::= { realServerEntry 2 }
+
+realServerAddrType OBJECT-TYPE
+ SYNTAX InetAddressType
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Address family for this real server."
+ ::= { realServerEntry 3 }
+
+realServerAddress OBJECT-TYPE
+ SYNTAX InetAddress
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "IP address of this real server."
+ ::= { realServerEntry 4 }
+
+realServerPort OBJECT-TYPE
+ SYNTAX InetPortNumber
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Port of the service."
+ ::= { realServerEntry 5 }
+
+realServerStatus OBJECT-TYPE
+ SYNTAX INTEGER { alive(1), dead(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Status of this real server."
+ ::= { realServerEntry 6 }
+
+realServerWeight OBJECT-TYPE
+ SYNTAX Integer32
+ MAX-ACCESS read-write
+ STATUS current
+ DESCRIPTION
+ "Weight of this real server.
+
+ This value can be set to 0 to disable the real server."
+ ::= { realServerEntry 7 }
+
+realServerUpperConnectionLimit OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Maximum number of connections for this real server."
+ ::= { realServerEntry 8 }
+
+realServerLowerConnectionLimit OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Minimum number of connections for this real server."
+ ::= { realServerEntry 9 }
+
+realServerActionWhenDown OBJECT-TYPE
+ SYNTAX INTEGER { remove(1), inhibit(2) }
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "What action is performed when this server is down. Its weight
+ can be set to 0 (inhibit) or it can be removed from the pool."
+ ::= { realServerEntry 10 }
+
+realServerNotifyUp OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Command to execute when this server becomes alive."
+ ::= { realServerEntry 11 }
+
+realServerNotifyDown OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Command to execute when this server becomes dead."
+ ::= { realServerEntry 12 }
+
+realServerFailedChecks OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "How many failed checks for this real server."
+ ::= { realServerEntry 13 }
+
+realServerStatsConns OBJECT-TYPE
+ SYNTAX Gauge32
+ UNITS "connections"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total number of connections scheduled for this real server."
+ ::= { realServerEntry 14 }
+
+realServerStatsActiveConns OBJECT-TYPE
+ SYNTAX Gauge32
+ UNITS "connections"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current active connections for this real server."
+ ::= { realServerEntry 15 }
+
+realServerStatsInactiveConns OBJECT-TYPE
+ SYNTAX Gauge32
+ UNITS "connections"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current inactive connections for this real server."
+ ::= { realServerEntry 16 }
+
+realServerStatsPersistentConns OBJECT-TYPE
+ SYNTAX Gauge32
+ UNITS "connections"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current persistent connections for this real server."
+ ::= { realServerEntry 17 }
+
+realServerStatsInPkts OBJECT-TYPE
+ SYNTAX Counter32
+ UNITS "packets"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total number of incoming packets for this real server."
+ ::= { realServerEntry 18 }
+
+realServerStatsOutPkts OBJECT-TYPE
+ SYNTAX Counter32
+ UNITS "packets"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total number of outgoing packets for this real server."
+ ::= { realServerEntry 19 }
+
+realServerStatsInBytes OBJECT-TYPE
+ SYNTAX Counter64
+ UNITS "bytes"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total number of incoming bytes for this real server."
+ ::= { realServerEntry 20 }
+
+realServerStatsOutBytes OBJECT-TYPE
+ SYNTAX Counter64
+ UNITS "bytes"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Total number of outgoing bytes for this real server."
+ ::= { realServerEntry 21 }
+
+realServerRateCps OBJECT-TYPE
+ SYNTAX Gauge32
+ UNITS "connections/s"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current connection rate for this real server."
+ ::= { realServerEntry 22 }
+
+realServerRateInPPS OBJECT-TYPE
+ SYNTAX Gauge32
+ UNITS "packets/s"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current in packet rate for this real server."
+ ::= { realServerEntry 23 }
+
+realServerRateOutPPS OBJECT-TYPE
+ SYNTAX Gauge32
+ UNITS "packets/s"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current out packet rate for this real server."
+ ::= { realServerEntry 24 }
+
+realServerRateInBPS OBJECT-TYPE
+ SYNTAX Gauge32
+ UNITS "bytes/s"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current incoming rate for this real server."
+ ::= { realServerEntry 25 }
+
+realServerRateOutBPS OBJECT-TYPE
+ SYNTAX Gauge32
+ UNITS "bytes/s"
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "Current outgoing rate for this real server."
+ ::= { realServerEntry 26 }
+
+-- Traps
+
+checkTrap OBJECT IDENTIFIER ::= { check 5 }
+checkTraps OBJECT IDENTIFIER ::= { checkTrap 0 } -- Reverse-mappable
+checkTrapControl OBJECT IDENTIFIER ::= { checkTrap 1 }
+
+realServerStateChange NOTIFICATION-TYPE
+ OBJECTS {
+ realServerAddrType,
+ realServerAddress,
+ realServerPort,
+ realServerStatus,
+ virtualServerType,
+ virtualServerProtocol,
+ virtualServerRealServersUp,
+ virtualServerRealServersTotal,
+ routerId
+ }
+ STATUS current
+ DESCRIPTION
+ "This trap signifies that the state of a real server has
+ changed. Additional varbinds will be added depending on the
+ value of virtualServerType: virtualServerNameOfGroup,
+ virtualServerFwMark, virtualServerAddrType,
+ virtualServerAddress, virtualServerPort."
+ ::= { checkTraps 1 }
+
+virtualServerQuorumStateChange NOTIFICATION-TYPE
+ OBJECTS {
+ virtualServerType,
+ virtualServerProtocol,
+ virtualServerQuorumStatus,
+ virtualServerQuorum,
+ virtualServerRealServersUp,
+ virtualServerRealServersTotal,
+ routerId
+ }
+ STATUS current
+ DESCRIPTION
+ "This trap signifies that the quorum of a virtual server has
+ changed. Additional varbinds will be added depending on the
+ value of virtualServerType: virtualServerNameOfGroup,
+ virtualServerFwMark, virtualServerAddrType,
+ virtualServerAddress, virtualServerPort."
+ ::= { checkTraps 2 }
+
+-- ----------------------------------------------------------------------
+-- Conformance
+-- ----------------------------------------------------------------------
+
+compliances OBJECT IDENTIFIER ::= { conformance 1 }
+groups OBJECT IDENTIFIER ::= { conformance 2 }
+
+globalCompliances MODULE-COMPLIANCE
+ STATUS current
+ DESCRIPTION
+ "Compliance statement for global data"
+ MODULE -- this module
+ MANDATORY-GROUPS {
+ globalGroup
+ }
+ ::= { compliances 1 }
+
+vrrpCompliances MODULE-COMPLIANCE
+ STATUS current
+ DESCRIPTION
+ "The VRRP compliance statement"
+ MODULE -- this module
+ MANDATORY-GROUPS {
+ vrrpScriptGroup,
+ vrrpSyncGroup,
+ vrrpInstanceGroup,
+ vrrpTrapsGroup
+ }
+ ::= { compliances 2 }
+
+checkCompliances MODULE-COMPLIANCE
+ STATUS current
+ DESCRIPTION
+ "The check compliance statement"
+ MODULE -- this module
+ MANDATORY-GROUPS {
+ virtualServerGroupGroup,
+ virtualServerGroup,
+ realServerGroup,
+ checkTrapsGroup
+ }
+ ::= { compliances 3 }
+
+globalGroup OBJECT-GROUP
+ OBJECTS {
+ version,
+ routerId,
+ smtpServerAddressType,
+ smtpServerAddress,
+ smtpServerTimeout,
+ emailFrom,
+ emailAddress,
+ trapEnable,
+ linkBeat
+ }
+ STATUS current
+ DESCRIPTION
+ "Conformance group for global data."
+ ::= { groups 1 }
+
+vrrpGroups OBJECT IDENTIFIER ::= { groups 2 }
+
+vrrpSyncGroup OBJECT-GROUP
+ OBJECTS {
+ vrrpSyncGroupName,
+ vrrpSyncGroupState,
+ vrrpSyncGroupSmtpAlert,
+ vrrpSyncGroupNotifyExec,
+ vrrpSyncGroupScriptMaster,
+ vrrpSyncGroupScriptBackup,
+ vrrpSyncGroupScriptFault,
+ vrrpSyncGroupScript,
+ vrrpSyncGroupMemberName
+ }
+ STATUS current
+ DESCRIPTION
+ "Conformance group for synchronisation groups."
+ ::= { vrrpGroups 1 }
+
+vrrpInstanceGroup OBJECT-GROUP
+ OBJECTS {
+ vrrpInstanceName,
+ vrrpInstanceVirtualRouterId,
+ vrrpInstanceState,
+ vrrpInstanceInitialState,
+ vrrpInstanceWantedState,
+ vrrpInstanceBasePriority,
+ vrrpInstanceEffectivePriority,
+ vrrpInstanceVipsStatus,
+ vrrpInstancePrimaryInterface,
+ vrrpInstanceTrackPrimaryIf,
+ vrrpInstanceAdvertisementsInt,
+ vrrpInstancePreempt,
+ vrrpInstancePreemptDelay,
+ vrrpInstanceAuthType,
+ vrrpInstanceLvsSyncDaemon,
+ vrrpInstanceLvsSyncInterface,
+ vrrpInstanceSyncGroup,
+ vrrpInstanceGarpDelay,
+ vrrpInstanceSmtpAlert,
+ vrrpInstanceNotifyExec,
+ vrrpInstanceScriptMaster,
+ vrrpInstanceScriptBackup,
+ vrrpInstanceScriptFault,
+ vrrpInstanceScriptStop,
+ vrrpInstanceScript,
+ vrrpTrackedInterfaceName,
+ vrrpTrackedInterfaceWeight,
+ vrrpTrackedScriptName,
+ vrrpTrackedScriptWeight,
+ vrrpAddressType,
+ vrrpAddressValue,
+ vrrpAddressBroadcast,
+ vrrpAddressMask,
+ vrrpAddressScope,
+ vrrpAddressIfIndex,
+ vrrpAddressIfName,
+ vrrpAddressIfAlias,
+ vrrpAddressStatus,
+ vrrpAddressAdvertising,
+ vrrpRouteAddressType,
+ vrrpRouteDestination,
+ vrrpRouteDestinationMask,
+ vrrpRouteGateway,
+ vrrpRouteSecondaryGateway,
+ vrrpRouteSource,
+ vrrpRouteMetric,
+ vrrpRouteScope,
+ vrrpRouteType,
+ vrrpRouteIfIndex,
+ vrrpRouteIfName,
+ vrrpRouteRoutingTable,
+ vrrpRouteStatus
+ }
+ STATUS current
+ DESCRIPTION
+ "Conformance group for VRRP instances."
+ ::= { vrrpGroups 2 }
+
+vrrpScriptGroup OBJECT-GROUP
+ OBJECTS {
+ vrrpScriptName,
+ vrrpScriptCommand,
+ vrrpScriptInterval,
+ vrrpScriptWeight,
+ vrrpScriptResult,
+ vrrpScriptRise,
+ vrrpScriptFall
+ }
+ STATUS current
+ DESCRIPTION
+ "Conformance group for VRRP scripts."
+ ::= { vrrpGroups 3 }
+
+vrrpTrapsGroup NOTIFICATION-GROUP
+ NOTIFICATIONS {
+ vrrpSyncGroupStateChange,
+ vrrpInstanceStateChange
+ }
+ STATUS current
+ DESCRIPTION
+ "Conformance group for VRRP traps."
+ ::= { vrrpGroups 4 }
+
+checkGroups OBJECT IDENTIFIER ::= { groups 3 }
+
+virtualServerGroupGroup OBJECT-GROUP
+ OBJECTS {
+ virtualServerGroupName,
+ virtualServerGroupMemberType,
+ virtualServerGroupMemberFwMark,
+ virtualServerGroupMemberAddrType,
+ virtualServerGroupMemberAddress,
+ virtualServerGroupMemberAddr1,
+ virtualServerGroupMemberAddr2,
+ virtualServerGroupMemberPort
+ }
+ STATUS current
+ DESCRIPTION
+ "Conformance group for virtual server groups."
+ ::= { checkGroups 1 }
+
+virtualServerGroup OBJECT-GROUP
+ OBJECTS {
+ virtualServerType,
+ virtualServerNameOfGroup,
+ virtualServerFwMark,
+ virtualServerAddrType,
+ virtualServerAddress,
+ virtualServerPort,
+ virtualServerProtocol,
+ virtualServerLoadBalancingAlgo,
+ virtualServerLoadBalancingKind,
+ virtualServerStatus,
+ virtualServerVirtualHost,
+ virtualServerPersist,
+ virtualServerPersistTimeout,
+ virtualServerPersistGranularity,
+ virtualServerDelayLoop,
+ virtualServerHaSuspend,
+ virtualServerAlpha,
+ virtualServerOmega,
+ virtualServerRealServersTotal,
+ virtualServerRealServersUp,
+ virtualServerQuorum,
+ virtualServerQuorumStatus,
+ virtualServerQuorumUp,
+ virtualServerQuorumDown,
+ virtualServerHysteresis,
+ virtualServerStatsConns,
+ virtualServerStatsInPkts,
+ virtualServerStatsOutPkts,
+ virtualServerStatsInBytes,
+ virtualServerStatsOutBytes,
+ virtualServerRateCps,
+ virtualServerRateInPPS,
+ virtualServerRateOutPPS,
+ virtualServerRateInBPS,
+ virtualServerRateOutBPS
+ }
+ STATUS current
+ DESCRIPTION
+ "Conformance group for virtual servers."
+ ::= { checkGroups 2 }
+
+realServerGroup OBJECT-GROUP
+ OBJECTS {
+ realServerType,
+ realServerAddrType,
+ realServerAddress,
+ realServerPort,
+ realServerStatus,
+ realServerWeight,
+ realServerUpperConnectionLimit,
+ realServerLowerConnectionLimit,
+ realServerActionWhenDown,
+ realServerNotifyUp,
+ realServerNotifyDown,
+ realServerFailedChecks,
+ realServerStatsConns,
+ realServerStatsActiveConns,
+ realServerStatsInactiveConns,
+ realServerStatsPersistentConns,
+ realServerStatsInPkts,
+ realServerStatsOutPkts,
+ realServerStatsInBytes,
+ realServerStatsOutBytes,
+ realServerRateCps,
+ realServerRateInPPS,
+ realServerRateOutPPS,
+ realServerRateInBPS,
+ realServerRateOutBPS
+ }
+ STATUS current
+ DESCRIPTION
+ "Conformance group for real servers."
+ ::= { checkGroups 3 }
+
+checkTrapsGroup NOTIFICATION-GROUP
+ NOTIFICATIONS {
+ realServerStateChange,
+ virtualServerQuorumStateChange
+ }
+ STATUS current
+ DESCRIPTION
+ "Conformance group for check traps."
+ ::= { checkGroups 4 }
+
+END
|
[-]
[+]
|
Added |
keepalived-1.2.7.tar.bz2/doc/NOTE_vrrp_vmac.txt
^
|
@@ -0,0 +1,82 @@
+
+
+ Note on using VRRP with Virtual MAC address
+ =============================================
+ Alexandre Cassen
+ July 11th 2012
+
+
+To reduce takeover impact, some networking environment would require using
+VRRP with VMAC address. To reach that goal Keepalived VRRP framework implements
+VMAC support by the invocation of 'use_vmac' keyword in configuration file.
+
+Internally, Keepalived code will bring up virtual interfaces, each interface
+dedicated to a specific virtual_router. Keepalived uses Liunx kernel macvlan
+driver to defines thoses interfaces. It is then mandatory to use kernel
+compiled with macvlan support.
+
+In addition we can mention that VRRP VMAC will work only with kernel including
+the following patch :
+
+http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff;h=729e72a10930ef765c11a5a35031ba47f18221c4
+
+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.
+
+You also need to tweak your physical interfaces to play around with well knwon
+ARP issue. I would recommand using the following configurations :
+
+1) Global configuration
+
+ net.ipv4.conf.all.arp_ignore = 1
+ net.ipv4.conf.all.arp_announce = 1
+ net.ipv4.conf.all.arp_filter = 0
+
+2) Physical interface configuration
+
+For the physical ethernet interface running VRRP instance use:
+
+net.ipv4.conf.eth0.arp_filter = 1
+
+3) VMAC interface
+
+consider the following VRRP configuration :
+
+vrrp_instance instance1 {
+ state BACKUP
+ interface eth0
+ virtual_router_id 250
+ use_vmac
+ priority 150
+ advert_int 1
+ virtual_ipaddress {
+ 10.0.0.254
+ }
+}
+
+The 'use_vmac' keyword will drive keepalived code to create a macvlan interface
+named 'vrrp.250' (default internal paradigm is vrrp.{virtual_router_id}, you can
+override this naming by giving an argument to 'use_vmac' keyword, eg: use_vmac
+vrrp250).
+
+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)
+
+you can create notify_master script to automate this configuration step for you :
+
+vrrp_instance instance1 {
+ state BACKUP
+ interface eth0
+ virtual_router_id 250
+ use_vmac
+ priority 150
+ advert_int 1
+ virtual_ipaddress {
+ 10.0.0.254
+ }
+ notify_master "/usr/local/bin/vmac_tweak.sh vrrp.250"
+}
+
+
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/doc/keepalived.conf.SYNOPSIS
^
|
@@ -144,6 +144,7 @@
The configuration block looks like :
vrrp_instance <STRING> { # VRRP instance declaration
+ use_vmac # Use VRRP Virtual MAC
native_ipv6 # Force instance to use IPv6
# when using mixed IPv4&IPv6 conf
state MASTER|BACKUP # Start-up default state
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/doc/man/man5/keepalived.conf.5
^
|
@@ -1,460 +1,464 @@
-.TH KEEPALIVED.CONF 5 "Jan 2004" V1.0
-.UC 4
-.SH NAME
-/etc/keepalived/keepalived.conf - configuration file for keepalived
-.br
-.SH DESCRIPTION
-.B keepalived.conf
-is the configuration file which describes all the keepalived keywords.
-keywords are placed in hierachies of blocks (and subblocks),
-each layer being delimited by '{' and '}' pairs.
-.PP
-Comments start with '#' or '!' to the end of the line and can start
-anywhere in a line.
-.SH TOP HIERACHY
-.PP
-.B GLOBAL CONFIGURATION
-.PP
-.B VRRPD CONFIGURATION
-.PP
-.B LVS CONFIGURATION
-.PP
-.SH GLOBAL CONFIGURATION
-contains subblocks of
-.B Global definitions
-and
-.B Static routes
-.PP
-.SH Global definitions
-.PP
- global_defs # Block id
- {
- notification_email # To:
- {
- admin@example1.com
- ...
- }
- # From: from address that will be in header
- notification_email_from admin@example.com
- smtp_server 127.0.0.1 # IP
- smtp_connect_timeout 30 # integer, seconds
- router_id my_hostname # string identifying the machine,
- # (doesn't have to be hostname).
- }
-
-
-.SH Static routes/addresses
-.PP
-keepalived can configure static addresses and routes. These addresses are
-.B NOT
-moved by vrrpd, they stay on the machine.
-If you already have IPs and routes on your machines and
-your machines can ping each other, you don't need this section.
-.PP
-The syntax is the same as for virtual addresses and virtual routes.
-.PP
- static_ipaddress
- {
- 192.168.1.1/24 dev eth0 scope global
- ...
- }
-.PP
- static_routes
- {
- 192.168.2.0/24 via 192.168.1.100 dev eth0
- ...
- }
-.PP
-.SH VRRPD CONFIGURATION
-contains subblocks of
-.B VRRP synchronization group(s)
-and
-.B VRRP instance(s)
-.PP
-.SH VRRP synchronization group(s)
-.PP
- #string, name of group of IPs that failover together
- vrrp_sync_group VG_1 {
- group {
- inside_network # name of vrrp_instance (below)
- outside_network # One for each moveable IP.
- ...
- }
-
- # notify scripts and alerts are optional
- #
- # filenames of scripts to run on transitions
- # can be unquoted (if just filename)
- # or quoted (if has parameters)
- # to MASTER transition
- notify_master /path/to_master.sh
- # to BACKUP transition
- notify_backup /path/to_backup.sh
- # FAULT transition
- notify_fault "/path/fault.sh VG_1"
-
- # for ANY state transition.
- # "notify" script is called AFTER the
- # notify_* script(s) and is executed
- # with 3 arguments provided by keepalived
- # (ie don't include parameters in the notify line).
- # arguments
- # $1 = "GROUP"|"INSTANCE"
- # $2 = name of group or instance
- # $3 = target state of transition
- # ("MASTER"|"BACKUP"|"FAULT")
- notify /path/notify.sh
-
- # Send email notifcation during state transition,
- # using addresses in global_defs above.
- smtp_alert
- }
-
-.SH VRRP instance(s)
-.PP
-describes the moveable IP for each instance of a group in vrrp_sync_group.
-Here are described two IPs (on inside_network and on outside_network),
-on machine "my_hostname", which belong to the group VG_1 and
-which will transition together on any state change.
-.PPa
- #You will need to write another block for outside_network.
- vrrp_instance inside_network {
- # Initial state, MASTER|BACKUP
- # As soon as the other machine(s) come up,
- # an election will be held and the machine
- # with the highest "priority" will become MASTER.
- # So the entry here doesn't matter a whole lot.
- state MASTER
-
- # interface for inside_network, bound by vrrp
- interface eth0
-
- # Ignore VRRP interface faults (default unset)
- dont_track_primary
-
- # optional, monitor these as well.
- # go to FAULT state if any of these go down.
- track_interface {
- eth0
- eth1
- ...
- }
-
- #default IP for binding vrrpd is the primary IP
- #on interface. If you want to hide location of vrrpd,
- #use this IP as src_addr for multicast vrrp packets.
- #(since it's multicast, vrrpd will get the reply
- #packet no matter what src_addr is used).
- #optional
- mcast_src_ip <IPADDR>
-
- # Binding interface for lvs syncd
- lvs_sync_daemon_interface eth1
-
- # delay for gratuitous ARP after transition to MASTER
- garp_master_delay 10 # secs, default 5
-
- # arbitary unique number 0..255
- # used to differentiate multiple instances of vrrpd
- # running on the same NIC (and hence same socket).
- virtual_router_id 51
-
- # for electing MASTER, highest priority wins.
- # to be MASTER, make 50 more than other machines.
- priority 100
-
- # VRRP Advert interval, secs (use default)
- advert_int 1
- authentication { # Authentication block
- # PASS||AH
- # PASS - Simple Passwd (suggested)
- # AH - IPSEC (not recommended))
- auth_type PASS
- # Password for accessing vrrpd.
- # should be the same for all machines.
- # Only the first eight (8) characters are used.
- auth_pass 1234
-
- #addresses add|del on change to MASTER, to BACKUP.
- #With the same entries on other machines,
- #the opposite transition will be occuring.
- virtual_ipaddress {
- <IPADDR>/<MASK> brd <IPADDR> dev <STRING> scope <SCOPE> label <LABEL>
- 192.168.200.17/24 dev eth1
- 192.168.200.18/24 dev eth2 label eth2:1
- }
-
- #VRRP IP excluded from VRRP
- #optional.
- #For cases with large numbers (eg 200) of IPs
- #on the same interface. To decrease the number
- #of packets sent in adverts, you can exclude
- #most IPs from adverts.
- #The IPs are add|del as for virtual_ipaddress.
- virtual_ipaddress_excluded {
- <IPADDR>/<MASK> brd <IPADDR> dev <STRING> scope <SCOPE>
- <IPADDR>/<MASK> brd <IPADDR> dev <STRING> scope <SCOPE>
- ...
- }
- # routes add|del when changing to MASTER, to BACKUP
- virtual_routes {
- # src <IPADDR> [to] <IPADDR>/<MASK> via|gw <IPADDR> [or <IPADDR>] dev <STRING> scope <SCOPE> tab
- src 192.168.100.1 to 192.168.109.0/24 via 192.168.200.254 dev eth1
- 192.168.110.0/24 via 192.168.200.254 dev eth1
- 192.168.111.0/24 dev eth2
- 192.168.112.0/24 via 192.168.100.254
- 192.168.113.0/24 via 192.168.200.254 or 192.168.100.254 dev eth1
- blackhole 192.168.114.0/24
- }
-
- # VRRP will normally preempt a lower priority
- # machine when a higher priority machine comes
- # online. "nopreempt" allows the lower priority
- # machine to maintain the master role, even when
- # a higher priority machine comes back online.
- # NOTE: For this to work, the initial state of this
- # entry must be BACKUP.
- nopreempt
-
- # Seconds after startup until preemption
- # (if not disabled by "nopreempt").
- # Range: 0 (default) to 1,000
- # NOTE: For this to work, the initial state of this
- # entry must be BACKUP.
- preempt_delay 300 # waits 5 minutes
-
- # Debug level, not implemented yet.
- debug
-
- # notify scripts, alert as above
- notify_master <STRING>|<QUOTED-STRING>
- notify_backup <STRING>|<QUOTED-STRING>
- notify_fault <STRING>|<QUOTED-STRING>
- notify <STRING>|<QUOTED-STRING>
- smtp_alert
- }
-
-.SH LVS CONFIGURATION
-contains subblocks of
-.B Virtual server group(s)
-and
-.B Virtual server(s)
-.PP
-The subblocks contain arguments for
-.I ipvsadm(8).
-A knowlege of
-.I ipvsadm(8)
-will be helpful here.
-.PP
-.SH Virtual server group(s)
-.PP
- # optional
- # this groups allows a service on a real_server
- # to belong to multiple virtual services
- # and to be only health checked once.
- # Only for very large LVSs.
- virtual_server_group <STRING> {
- #VIP port
- <IPADDR> <PORT>
- <IPADDR> <PORT>
- ...
- #
- # <IPADDR RANGE> has the form
- # XXX.YYY.ZZZ.WWW-VVV eg 192.168.200.1-10
- # range includes both .1 and .10 address
- <IPADDR RANGE> <PORT># VIP range VPORT
- <IPADDR RANGE> <PORT>
- ...
- fwmark <INT> # fwmark
- fwmark <INT>
- ...
-}
-
-.SH Virtual server(s)
-.PP
-A virtual_server can be a declaration of one of
-.TP
-.B vip vport (IPADDR PORT pair)
-.TP
-.B fwmark <INT>
-.TP
-.B (virtual server) group <STRING>
-
- #setup service
- virtual_server IP port |
- virtual_server fwmark int |
- virtual_server group string
- {
- # delay timer for service polling
- delay_loop <INT>
-
- # LVS scheduler
- lb_algo rr|wrr|lc|wlc|lblc|sh|dh
- # LVS forwarding method
- lb_kind NAT|DR|TUN
- # LVS persistence timeout, sec
- persistence_timeout <INT>
- # LVS granularity mask (-M in ipvsadm)
- persistence_granularity <NETMASK>
- # Only TCP is implemented
- protocol TCP
- # If VS IP address is not set,
- # suspend healthchecker's activity
- ha_suspend
-
- # VirtualHost string for HTTP_GET or SSL_GET
- # eg virtualhost www.firewall.loc
- virtualhost <STRING>
-
- # Assume silently all RSs down and healthchecks
- # failed on start. This helps preventing false
- # positive actions on startup. Alpha mode is
- # disabled by default.
- alpha
-
- # On daemon shutdown, consider quorum and RS
- # down notifiers for execution, where appropriate.
- # Omega mode is disabled by default.
- omega
-
- # Minimum total weight of all live servers in
- # the pool necessary to operate VS with no
- # quality regression. Defaults to 1.
- quorum <INT>
-
- # Tolerate this much weight units compared to the
- # nominal quorum, when considering quorum gain
- # or loss. A flap dampener. Defaults to 0.
- hysteresis <INT>
-
- # Script to launch when quorum is gained.
- quorum_up <STRING>|<QUOTED-STRING>
-
- # Script to launch when quorum is lost.
- quorum_down <STRING>|<QUOTED-STRING>
-
-
- # setup realserver(s)
-
- # RS to add when all realservers are down
- sorry_server <IPADDR> <PORT>
-
- # one entry for each realserver
- real_server <IPADDR> <PORT>
- {
- # relative weight to use, default: 1
- weight <INT>
- # Set weight to 0
- # when healthchecker detects failure
- inhibit_on_failure
-
- # Script to launch when healthchecker
- # considers service as up.
- notify_up <STRING>|<QUOTED-STRING>
- # Script to launch when healthchecker
- # considers service as down.
- notify_down <STRING>|<QUOTED-STRING>
-
- # pick one healthchecker
- # HTTP_GET|SSL_GET|TCP_CHECK|SMTP_CHECK|MISC_CHECK
-
- # HTTP and SSL healthcheckers
- HTTP_GET|SSL_GET
- {
- # A url to test
- # can have multiple entries here
- url {
- #eg path / , or path /mrtg2/
- path <STRING>
- # healthcheck needs status_code
- # or status_code and digest
- # Digest computed with genhash
- # eg digest 9b3a0c85a887a256d6939da88aabd8cd
- digest <STRING>
- # status code returned in the HTTP header
- # 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>
- } #HTTP_GET|SSL_GET
-
- #TCP healthchecker (bind to IP port)
- TCP_CHECK
- {
- connect_port <PORT>
- bindto <IPADDR>
- connect_timeout <INT>
- } #TCP_CHECK
-
- # SMTP healthchecker
- SMTP_CHECK
- {
- # An optional host interface to check.
- # If no host directives are present, only
- # the ip address of the real server will
- # be checked.
- host {
- # IP address to connect to
- connect_ip <IP ADDRESS>
- # Optional port to connect to if not
- # the default of 25
- connect_port <PORT>
- # Optional interface to use to
- # originate the connection
- bindto <IP ADDRESS>
- }
- # Connection and read/write timeout
- # in seconds
- connect_timeout <INTEGER>
- # Number of times to retry a failed check
- retry <INTEGER>
- # Delay in seconds before retrying
- delay_before_retry <INTEGER>
- # Optional string to use for the smtp HELO request
- helo_name <STRING>|<QUOTED-STRING>
- } #SMTP_CHECK
-
- #MISC healthchecker, run a program
- MISC_CHECK
- {
- # External system script or program
- misc_path <STRING>|<QUOTED-STRING>
- # Script execution timeout
- misc_timeout <INT>
-
- # If set, exit code from healthchecker is used
- # to dynamically adjust the weight as follows:
- # exit status 0: svc check success, weight
- # unchanged.
- # exit status 1: svc check failed.
- # exit status 2-255: svc check success, weight
- # changed to 2 less than exit status.
- # (for example: exit status of 255 would set
- # weight to 253)
- misc_dynamic
- }
- } # realserver defn
- } # virtual service
-
-
-.SH AUTHOR
-.br
-Joseph Mack.
-.br
-Information derived from doc/keepalived.conf.SYNOPSIS,
-doc/samples/keepalived.conf.* and Changelog by Alexandre Cassen
-for keepalived-1.1.4,
-and from HOWTOs by Adam Fletcher and Vince Worthington.
-.SH "SEE ALSO"
-ipvsadm(8), ip --help.
-.\" Local Variables:
-.\" mode: nroff
-.\" End:
+.TH KEEPALIVED.CONF 5 "Jan 2004" V1.0
+.UC 4
+.SH NAME
+/etc/keepalived/keepalived.conf - configuration file for keepalived
+.br
+.SH DESCRIPTION
+.B keepalived.conf
+is the configuration file which describes all the keepalived keywords.
+keywords are placed in hierachies of blocks (and subblocks),
+each layer being delimited by '{' and '}' pairs.
+.PP
+Comments start with '#' or '!' to the end of the line and can start
+anywhere in a line.
+.SH TOP HIERACHY
+.PP
+.B GLOBAL CONFIGURATION
+.PP
+.B VRRPD CONFIGURATION
+.PP
+.B LVS CONFIGURATION
+.PP
+.SH GLOBAL CONFIGURATION
+contains subblocks of
+.B Global definitions
+and
+.B Static routes
+.PP
+.SH Global definitions
+.PP
+ global_defs # Block id
+ {
+ notification_email # To:
+ {
+ admin@example1.com
+ ...
+ }
+ # From: from address that will be in header
+ notification_email_from admin@example.com
+ smtp_server 127.0.0.1 # IP
+ smtp_connect_timeout 30 # integer, seconds
+ router_id my_hostname # string identifying the machine,
+ # (doesn't have to be hostname).
+ enable_traps # enable SNMP traps
+ }
+
+
+.SH Static routes/addresses
+.PP
+keepalived can configure static addresses and routes. These addresses are
+.B NOT
+moved by vrrpd, they stay on the machine.
+If you already have IPs and routes on your machines and
+your machines can ping each other, you don't need this section.
+.PP
+The syntax is the same as for virtual addresses and virtual routes.
+.PP
+ static_ipaddress
+ {
+ 192.168.1.1/24 dev eth0 scope global
+ ...
+ }
+.PP
+ static_routes
+ {
+ 192.168.2.0/24 via 192.168.1.100 dev eth0
+ ...
+ }
+.PP
+.SH VRRPD CONFIGURATION
+contains subblocks of
+.B VRRP synchronization group(s)
+and
+.B VRRP instance(s)
+.PP
+.SH VRRP synchronization group(s)
+.PP
+ #string, name of group of IPs that failover together
+ vrrp_sync_group VG_1 {
+ group {
+ inside_network # name of vrrp_instance (below)
+ outside_network # One for each moveable IP.
+ ...
+ }
+
+ # notify scripts and alerts are optional
+ #
+ # filenames of scripts to run on transitions
+ # can be unquoted (if just filename)
+ # or quoted (if has parameters)
+ # to MASTER transition
+ notify_master /path/to_master.sh
+ # to BACKUP transition
+ notify_backup /path/to_backup.sh
+ # FAULT transition
+ notify_fault "/path/fault.sh VG_1"
+
+ # for ANY state transition.
+ # "notify" script is called AFTER the
+ # notify_* script(s) and is executed
+ # with 3 arguments provided by keepalived
+ # (ie don't include parameters in the notify line).
+ # arguments
+ # $1 = "GROUP"|"INSTANCE"
+ # $2 = name of group or instance
+ # $3 = target state of transition
+ # ("MASTER"|"BACKUP"|"FAULT")
+ notify /path/notify.sh
+
+ # Send email notifcation during state transition,
+ # using addresses in global_defs above.
+ smtp_alert
+ }
+
+.SH VRRP instance(s)
+.PP
+describes the moveable IP for each instance of a group in vrrp_sync_group.
+Here are described two IPs (on inside_network and on outside_network),
+on machine "my_hostname", which belong to the group VG_1 and
+which will transition together on any state change.
+.PPa
+ #You will need to write another block for outside_network.
+ vrrp_instance inside_network {
+ # Initial state, MASTER|BACKUP
+ # As soon as the other machine(s) come up,
+ # an election will be held and the machine
+ # with the highest "priority" will become MASTER.
+ # So the entry here doesn't matter a whole lot.
+ state MASTER
+
+ # interface for inside_network, bound by vrrp
+ interface eth0
+
+ # Use VRRP Virtual MAC.
+ use_vmac <VMAC_INTERFACE>
+
+ # Ignore VRRP interface faults (default unset)
+ dont_track_primary
+
+ # optional, monitor these as well.
+ # go to FAULT state if any of these go down.
+ track_interface {
+ eth0
+ eth1
+ ...
+ }
+
+ #default IP for binding vrrpd is the primary IP
+ #on interface. If you want to hide location of vrrpd,
+ #use this IP as src_addr for multicast vrrp packets.
+ #(since it's multicast, vrrpd will get the reply
+ #packet no matter what src_addr is used).
+ #optional
+ mcast_src_ip <IPADDR>
+
+ # Binding interface for lvs syncd
+ lvs_sync_daemon_interface eth1
+
+ # delay for gratuitous ARP after transition to MASTER
+ garp_master_delay 10 # secs, default 5
+
+ # arbitary unique number 0..255
+ # used to differentiate multiple instances of vrrpd
+ # running on the same NIC (and hence same socket).
+ virtual_router_id 51
+
+ # for electing MASTER, highest priority wins.
+ # to be MASTER, make 50 more than other machines.
+ priority 100
+
+ # VRRP Advert interval, secs (use default)
+ advert_int 1
+ authentication { # Authentication block
+ # PASS||AH
+ # PASS - Simple Passwd (suggested)
+ # AH - IPSEC (not recommended))
+ auth_type PASS
+ # Password for accessing vrrpd.
+ # should be the same for all machines.
+ # Only the first eight (8) characters are used.
+ auth_pass 1234
+
+ #addresses add|del on change to MASTER, to BACKUP.
+ #With the same entries on other machines,
+ #the opposite transition will be occuring.
+ virtual_ipaddress {
+ <IPADDR>/<MASK> brd <IPADDR> dev <STRING> scope <SCOPE> label <LABEL>
+ 192.168.200.17/24 dev eth1
+ 192.168.200.18/24 dev eth2 label eth2:1
+ }
+
+ #VRRP IP excluded from VRRP
+ #optional.
+ #For cases with large numbers (eg 200) of IPs
+ #on the same interface. To decrease the number
+ #of packets sent in adverts, you can exclude
+ #most IPs from adverts.
+ #The IPs are add|del as for virtual_ipaddress.
+ virtual_ipaddress_excluded {
+ <IPADDR>/<MASK> brd <IPADDR> dev <STRING> scope <SCOPE>
+ <IPADDR>/<MASK> brd <IPADDR> dev <STRING> scope <SCOPE>
+ ...
+ }
+ # routes add|del when changing to MASTER, to BACKUP
+ virtual_routes {
+ # src <IPADDR> [to] <IPADDR>/<MASK> via|gw <IPADDR> [or <IPADDR>] dev <STRING> scope <SCOPE> tab
+ src 192.168.100.1 to 192.168.109.0/24 via 192.168.200.254 dev eth1
+ 192.168.110.0/24 via 192.168.200.254 dev eth1
+ 192.168.111.0/24 dev eth2
+ 192.168.112.0/24 via 192.168.100.254
+ 192.168.113.0/24 via 192.168.200.254 or 192.168.100.254 dev eth1
+ blackhole 192.168.114.0/24
+ }
+
+ # VRRP will normally preempt a lower priority
+ # machine when a higher priority machine comes
+ # online. "nopreempt" allows the lower priority
+ # machine to maintain the master role, even when
+ # a higher priority machine comes back online.
+ # NOTE: For this to work, the initial state of this
+ # entry must be BACKUP.
+ nopreempt
+
+ # Seconds after startup until preemption
+ # (if not disabled by "nopreempt").
+ # Range: 0 (default) to 1,000
+ # NOTE: For this to work, the initial state of this
+ # entry must be BACKUP.
+ preempt_delay 300 # waits 5 minutes
+
+ # Debug level, not implemented yet.
+ debug
+
+ # notify scripts, alert as above
+ notify_master <STRING>|<QUOTED-STRING>
+ notify_backup <STRING>|<QUOTED-STRING>
+ notify_fault <STRING>|<QUOTED-STRING>
+ notify <STRING>|<QUOTED-STRING>
+ smtp_alert
+ }
+
+.SH LVS CONFIGURATION
+contains subblocks of
+.B Virtual server group(s)
+and
+.B Virtual server(s)
+.PP
+The subblocks contain arguments for
+.I ipvsadm(8).
+A knowlege of
+.I ipvsadm(8)
+will be helpful here.
+.PP
+.SH Virtual server group(s)
+.PP
+ # optional
+ # this groups allows a service on a real_server
+ # to belong to multiple virtual services
+ # and to be only health checked once.
+ # Only for very large LVSs.
+ virtual_server_group <STRING> {
+ #VIP port
+ <IPADDR> <PORT>
+ <IPADDR> <PORT>
+ ...
+ #
+ # <IPADDR RANGE> has the form
+ # XXX.YYY.ZZZ.WWW-VVV eg 192.168.200.1-10
+ # range includes both .1 and .10 address
+ <IPADDR RANGE> <PORT># VIP range VPORT
+ <IPADDR RANGE> <PORT>
+ ...
+ fwmark <INT> # fwmark
+ fwmark <INT>
+ ...
+}
+
+.SH Virtual server(s)
+.PP
+A virtual_server can be a declaration of one of
+.TP
+.B vip vport (IPADDR PORT pair)
+.TP
+.B fwmark <INT>
+.TP
+.B (virtual server) group <STRING>
+
+ #setup service
+ virtual_server IP port |
+ virtual_server fwmark int |
+ virtual_server group string
+ {
+ # delay timer for service polling
+ delay_loop <INT>
+
+ # LVS scheduler
+ lb_algo rr|wrr|lc|wlc|lblc|sh|dh
+ # LVS forwarding method
+ lb_kind NAT|DR|TUN
+ # LVS persistence timeout, sec
+ persistence_timeout <INT>
+ # LVS granularity mask (-M in ipvsadm)
+ persistence_granularity <NETMASK>
+ # Only TCP is implemented
+ protocol TCP
+ # If VS IP address is not set,
+ # suspend healthchecker's activity
+ ha_suspend
+
+ # VirtualHost string for HTTP_GET or SSL_GET
+ # eg virtualhost www.firewall.loc
+ virtualhost <STRING>
+
+ # Assume silently all RSs down and healthchecks
+ # failed on start. This helps preventing false
+ # positive actions on startup. Alpha mode is
+ # disabled by default.
+ alpha
+
+ # On daemon shutdown, consider quorum and RS
+ # down notifiers for execution, where appropriate.
+ # Omega mode is disabled by default.
+ omega
+
+ # Minimum total weight of all live servers in
+ # the pool necessary to operate VS with no
+ # quality regression. Defaults to 1.
+ quorum <INT>
+
+ # Tolerate this much weight units compared to the
+ # nominal quorum, when considering quorum gain
+ # or loss. A flap dampener. Defaults to 0.
+ hysteresis <INT>
+
+ # Script to launch when quorum is gained.
+ quorum_up <STRING>|<QUOTED-STRING>
+
+ # Script to launch when quorum is lost.
+ quorum_down <STRING>|<QUOTED-STRING>
+
+
+ # setup realserver(s)
+
+ # RS to add when all realservers are down
+ sorry_server <IPADDR> <PORT>
+
+ # one entry for each realserver
+ real_server <IPADDR> <PORT>
+ {
+ # relative weight to use, default: 1
+ weight <INT>
+ # Set weight to 0
+ # when healthchecker detects failure
+ inhibit_on_failure
+
+ # Script to launch when healthchecker
+ # considers service as up.
+ notify_up <STRING>|<QUOTED-STRING>
+ # Script to launch when healthchecker
+ # considers service as down.
+ notify_down <STRING>|<QUOTED-STRING>
+
+ # pick one healthchecker
+ # HTTP_GET|SSL_GET|TCP_CHECK|SMTP_CHECK|MISC_CHECK
+
+ # HTTP and SSL healthcheckers
+ HTTP_GET|SSL_GET
+ {
+ # A url to test
+ # can have multiple entries here
+ url {
+ #eg path / , or path /mrtg2/
+ path <STRING>
+ # healthcheck needs status_code
+ # or status_code and digest
+ # Digest computed with genhash
+ # eg digest 9b3a0c85a887a256d6939da88aabd8cd
+ digest <STRING>
+ # status code returned in the HTTP header
+ # 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>
+ } #HTTP_GET|SSL_GET
+
+ #TCP healthchecker (bind to IP port)
+ TCP_CHECK
+ {
+ connect_port <PORT>
+ bindto <IPADDR>
+ connect_timeout <INT>
+ } #TCP_CHECK
+
+ # SMTP healthchecker
+ SMTP_CHECK
+ {
+ # An optional host interface to check.
+ # If no host directives are present, only
+ # the ip address of the real server will
+ # be checked.
+ host {
+ # IP address to connect to
+ connect_ip <IP ADDRESS>
+ # Optional port to connect to if not
+ # the default of 25
+ connect_port <PORT>
+ # Optional interface to use to
+ # originate the connection
+ bindto <IP ADDRESS>
+ }
+ # Connection and read/write timeout
+ # in seconds
+ connect_timeout <INTEGER>
+ # Number of times to retry a failed check
+ retry <INTEGER>
+ # Delay in seconds before retrying
+ delay_before_retry <INTEGER>
+ # Optional string to use for the smtp HELO request
+ helo_name <STRING>|<QUOTED-STRING>
+ } #SMTP_CHECK
+
+ #MISC healthchecker, run a program
+ MISC_CHECK
+ {
+ # External system script or program
+ misc_path <STRING>|<QUOTED-STRING>
+ # Script execution timeout
+ misc_timeout <INT>
+
+ # If set, exit code from healthchecker is used
+ # to dynamically adjust the weight as follows:
+ # exit status 0: svc check success, weight
+ # unchanged.
+ # exit status 1: svc check failed.
+ # exit status 2-255: svc check success, weight
+ # changed to 2 less than exit status.
+ # (for example: exit status of 255 would set
+ # weight to 253)
+ misc_dynamic
+ }
+ } # realserver defn
+ } # virtual service
+
+
+.SH AUTHOR
+.br
+Joseph Mack.
+.br
+Information derived from doc/keepalived.conf.SYNOPSIS,
+doc/samples/keepalived.conf.* and Changelog by Alexandre Cassen
+for keepalived-1.1.4,
+and from HOWTOs by Adam Fletcher and Vince Worthington.
+.SH "SEE ALSO"
+ipvsadm(8), ip --help.
+.\" Local Variables:
+.\" mode: nroff
+.\" End:
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/doc/man/man8/keepalived.8
^
|
@@ -53,7 +53,10 @@
--log-facility, -S
0-7 Set syslog facility to LOG_LOCAL[0-7] (default=LOG_DAEMON)
.TP
---help, -h
+--snmp, -x
+Enable SNMP support
+.TP
+--help, -h
Display a short inlined help screen.
.TP
--version, -v
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/genhash/Makefile.in
^
|
@@ -1,6 +1,6 @@
# Makefile.in
#
-# Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+# Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
EXEC = genhash
BIN = ../bin
@@ -9,6 +9,7 @@
exec_prefix = @exec_prefix@
bindir = @bindir@
mandir = @mandir@
+datarootdir = @datarootdir@
CC = @CC@
STRIP = @STRIP@
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/genhash/http.c
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include <errno.h>
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/genhash/http.h
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _HTTP_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/genhash/layer4.c
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include "layer4.h"
@@ -81,7 +81,7 @@
int status;
socklen_t slen;
int ret = 0;
- TIMEVAL timer_min;
+ timeval_t timer_min;
/* Handle connection timeout */
if (thread->type == THREAD_WRITE_TIMEOUT) {
@@ -116,7 +116,7 @@
timer_min = timer_sub_now(thread->sands);
thread_add_write(thread->master, func, THREAD_ARG(thread)
- , thread->u.fd, TIMER_LONG(timer_min));
+ , thread->u.fd, timer_long(timer_min));
return connect_in_progress;
}
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/genhash/layer4.h
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _LAYER4_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/genhash/main.c
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include <signal.h>
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/genhash/main.h
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _MAIN_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/genhash/sock.c
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include <string.h>
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/genhash/sock.h
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _SOCK_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/genhash/ssl.c
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include <openssl/err.h>
@@ -47,7 +47,7 @@
SSL_load_error_strings();
bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
/* Initialize SSL context for SSL v2/3 */
- req->meth = SSLv23_method();
+ req->meth = (SSL_METHOD *) SSLv23_method();
req->ctx = SSL_CTX_new(req->meth);
#if (OPENSSL_VERSION_NUMBER < 0x00905100L)
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/genhash/ssl.h
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _SSL_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/Makefile.in
^
|
@@ -2,7 +2,7 @@
#
# Keepalived OpenSource project.
#
-# Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+# Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
EXEC = keepalived
BIN = ../bin
@@ -14,6 +14,7 @@
exec_prefix = @exec_prefix@
sbindir = @sbindir@
sysconfdir = @sysconfdir@
+datarootdir = @datarootdir@
mandir = @mandir@
init_dir = $(sysconfdir)/rc.d/init.d
conf_dir = $(sysconfdir)/keepalived
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/check/Makefile.in
^
|
@@ -2,19 +2,23 @@
#
# Keepalived OpenSource project.
#
-# Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+# Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
KERNEL = @KERN@
CC = @CC@
+SNMP_FLAG = @SNMP_SUPPORT@
INCLUDES = -I../include -I../../lib
CFLAGS = @CFLAGS@ @CPPFLAGS@ $(INCLUDES) \
-Wall -Wunused -Wstrict-prototypes
-DEFS = -D$(KERNEL) -D@IPVS_SUPPORT@ -D@IPVS_SYNCD@ -D@VRRP_SUPPORT@ @DFLAGS@
+DEFS = -D$(KERNEL) -D@IPVS_SUPPORT@ -D@IPVS_SYNCD@ -D@VRRP_SUPPORT@ -D@SNMP_SUPPORT@ @DFLAGS@
COMPILE = $(CC) $(CFLAGS) $(DEFS)
OBJS = check_daemon.o check_data.o check_parser.o \
check_api.o check_tcp.o check_http.o check_ssl.o \
check_smtp.o check_misc.o ipwrapper.o ipvswrapper.o
+ifeq ($(SNMP_FLAG),_WITH_SNMP_)
+ OBJS += check_snmp.o
+endif
HEADERS = $(OBJS:.o=.h)
@@ -34,7 +38,7 @@
../include/global_data.h ../include/ipwrapper.h ../include/ipwrapper.h \
../include/pidfile.h ../include/daemon.h ../../lib/list.h ../../lib/memory.h \
../../lib/parser.h ../../lib/signals.h ../include/vrrp_netlink.h \
- ../include/vrrp_if.h
+ ../include/vrrp_if.h ../include/snmp.h ../include/check_snmp.h
check_data.o: check_data.c ../include/check_data.h \
../include/check_api.h ../../lib/memory.h ../../lib/utils.h
check_parser.o: check_parser.c ../include/check_parser.h \
@@ -60,6 +64,8 @@
../../lib/memory.h ../include/ipwrapper.h ../include/smtp.h \
../../lib/utils.h ../../lib/notify.h ../../lib/parser.h ../include/daemon.h
ipwrapper.o: ipwrapper.c ../include/ipwrapper.h ../../lib/memory.h \
- ../../lib/utils.h ../../lib/notify.h
+ ../../lib/utils.h ../../lib/notify.h ../include/snmp.h ../include/check_snmp.h
ipvswrapper.o: ipvswrapper.c ../include/ipvswrapper.h ../../lib/utils.h \
../../lib/memory.h
+check_snmp.o: check_snmp.c ../include/check_snmp.h ../include/check_data.h \
+ ../../lib/list.h ../include/ipvswrapper.h ../include/ipwrapper.h ../include/global_data.h
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/check/check_api.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include <dirent.h>
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/check/check_daemon.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include "check_daemon.h"
@@ -40,6 +40,9 @@
#include "parser.h"
#include "vrrp_netlink.h"
#include "vrrp_if.h"
+#ifdef _WITH_SNMP_
+ #include "check_snmp.h"
+#endif
extern char *checkers_pidfile;
@@ -55,12 +58,16 @@
if (!(debug & 16))
clear_services();
ipvs_stop();
+#ifdef _WITH_SNMP_
+ if (snmp)
+ check_snmp_agent_close();
+#endif
/* Stop daemon */
pidfile_rm(checkers_pidfile);
/* Clean data */
- free_global_data(data);
+ free_global_data(global_data);
free_check_data(check_data);
#ifdef _WITH_VRRP_
free_interface_queue();
@@ -89,9 +96,13 @@
init_interface_queue();
kernel_netlink_init();
#endif
+#ifdef _WITH_SNMP_
+ if (!reload && snmp)
+ check_snmp_agent_init();
+#endif
/* Parse configuration file */
- data = alloc_global_data();
+ global_data = alloc_global_data();
check_data = alloc_check_data();
init_data(conf_file, check_init_keywords);
if (!check_data) {
@@ -120,7 +131,7 @@
/* Dump configuration */
if (debug & 4) {
- dump_global_data(data);
+ dump_global_data(global_data);
dump_check_data(check_data);
}
@@ -138,8 +149,6 @@
void
sighup_check(void *v, int sig)
{
- log_message(LOG_INFO, "Reloading Healthchecker child process(%d) on signal",
- getpid());
thread_add_event(master, reload_check_thread, NULL, 0);
}
@@ -147,7 +156,6 @@
void
sigend_check(void *v, int sig)
{
- log_message(LOG_INFO, "Terminating Healthchecker child process on signal");
if (master)
thread_add_terminate_event(master);
}
@@ -177,7 +185,7 @@
/* Destroy master thread */
thread_destroy_master(master);
master = thread_make_master();
- free_global_data(data);
+ free_global_data(global_data);
free_checkers_queue();
#ifdef _WITH_VRRP_
free_interface_queue();
@@ -251,7 +259,7 @@
}
/* Opening local CHECK syslog channel */
- openlog(PROG_CHECK, LOG_PID | (debug & 1) ? LOG_CONS : 0,
+ openlog(PROG_CHECK, LOG_PID | ((debug & 1) ? LOG_CONS : 0),
(log_facility==LOG_DAEMON) ? LOG_LOCAL2 : log_facility);
/* Child process part, write pidfile */
@@ -267,6 +275,9 @@
/* change to / dir */
ret = chdir("/");
+ if (ret < 0) {
+ log_message(LOG_INFO, "Healthcheck child process: error chdir");
+ }
/* Set mask */
umask(0);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/check/check_data.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include <netdb.h>
@@ -33,16 +33,16 @@
check_conf_data *old_check_data = NULL;
/* SSL facility functions */
-SSL_DATA *
+ssl_data_t *
alloc_ssl(void)
{
- SSL_DATA *ssl = (SSL_DATA *) MALLOC(sizeof (SSL_DATA));
+ ssl_data_t *ssl = (ssl_data_t *) MALLOC(sizeof(ssl_data_t));
return ssl;
}
void
free_ssl(void)
{
- SSL_DATA *ssl = check_data->ssl;
+ ssl_data_t *ssl = check_data->ssl;
if (!ssl)
return;
@@ -55,7 +55,7 @@
static void
dump_ssl(void)
{
- SSL_DATA *ssl = check_data->ssl;
+ ssl_data_t *ssl = check_data->ssl;
if (ssl->password)
log_message(LOG_INFO, " Password : %s", ssl->password);
@@ -128,19 +128,19 @@
list_add(check_data->vs_group, new);
}
void
-alloc_vsg_entry(vector strvec)
+alloc_vsg_entry(vector_t *strvec)
{
virtual_server_group *vsg = LIST_TAIL_DATA(check_data->vs_group);
virtual_server_group_entry *new;
new = (virtual_server_group_entry *) MALLOC(sizeof (virtual_server_group_entry));
- if (!strcmp(VECTOR_SLOT(strvec, 0), "fwmark")) {
- new->vfwmark = atoi(VECTOR_SLOT(strvec, 1));
+ if (!strcmp(vector_slot(strvec, 0), "fwmark")) {
+ new->vfwmark = atoi(vector_slot(strvec, 1));
list_add(vsg->vfwmark, new);
} else {
- new->range = inet_stor(VECTOR_SLOT(strvec, 0));
- inet_stosockaddr(VECTOR_SLOT(strvec, 0), VECTOR_SLOT(strvec, 1), &new->addr);
+ new->range = inet_stor(vector_slot(strvec, 0));
+ inet_stosockaddr(vector_slot(strvec, 0), vector_slot(strvec, 1), &new->addr);
if (!new->range)
list_add(vsg->addr_ip, new);
else
@@ -332,27 +332,27 @@
}
void
-free_check_data(check_conf_data *check_data)
+free_check_data(check_conf_data *data)
{
- free_list(check_data->vs);
- free_list(check_data->vs_group);
- FREE(check_data);
+ free_list(data->vs);
+ free_list(data->vs_group);
+ FREE(data);
}
void
-dump_check_data(check_conf_data *check_data)
+dump_check_data(check_conf_data *data)
{
- if (check_data->ssl) {
+ if (data->ssl) {
log_message(LOG_INFO, "------< SSL definitions >------");
dump_ssl();
}
- if (!LIST_ISEMPTY(check_data->vs)) {
+ if (!LIST_ISEMPTY(data->vs)) {
log_message(LOG_INFO, "------< LVS Topology >------");
log_message(LOG_INFO, " System is compiled with LVS v%d.%d.%d",
NVERSION(IP_VS_VERSION_CODE));
- if (!LIST_ISEMPTY(check_data->vs_group))
- dump_list(check_data->vs_group);
- dump_list(check_data->vs);
+ if (!LIST_ISEMPTY(data->vs_group))
+ dump_list(data->vs_group);
+ dump_list(data->vs);
}
dump_checkers_queue();
}
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/check/check_http.c
^
|
@@ -18,7 +18,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include <openssl/err.h>
@@ -104,10 +104,10 @@
}
void
-http_get_handler(vector strvec)
+http_get_handler(vector_t *strvec)
{
http_checker_t *http_get_chk;
- char *str = VECTOR_SLOT(strvec, 0);
+ char *str = vector_slot(strvec, 0);
/* queue new checker */
http_get_chk = alloc_http_get(str);
@@ -117,21 +117,21 @@
}
void
-connect_p_handler(vector strvec)
+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 strvec)
+bindto_handler(vector_t *strvec)
{
http_checker_t *http_get_chk = CHECKER_GET();
- inet_stosockaddr(VECTOR_SLOT(strvec, 1), 0, &http_get_chk->bindto);
+ inet_stosockaddr(vector_slot(strvec, 1), 0, &http_get_chk->bindto);
}
void
-connect_to_handler(vector strvec)
+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;
@@ -140,21 +140,21 @@
}
void
-nb_get_retry_handler(vector strvec)
+nb_get_retry_handler(vector_t *strvec)
{
http_checker_t *http_get_chk = CHECKER_GET();
http_get_chk->nb_get_retry = CHECKER_VALUE_INT(strvec);
}
void
-delay_before_retry_handler(vector strvec)
+delay_before_retry_handler(vector_t *strvec)
{
http_checker_t *http_get_chk = CHECKER_GET();
http_get_chk->delay_before_retry = CHECKER_VALUE_INT(strvec) * TIMER_HZ;
}
void
-url_handler(vector strvec)
+url_handler(vector_t *strvec)
{
http_checker_t *http_get_chk = CHECKER_GET();
url_t *new;
@@ -166,7 +166,7 @@
}
void
-path_handler(vector strvec)
+path_handler(vector_t *strvec)
{
http_checker_t *http_get_chk = CHECKER_GET();
url_t *url = LIST_TAIL_DATA(http_get_chk->url);
@@ -175,7 +175,7 @@
}
void
-digest_handler(vector strvec)
+digest_handler(vector_t *strvec)
{
http_checker_t *http_get_chk = CHECKER_GET();
url_t *url = LIST_TAIL_DATA(http_get_chk->url);
@@ -184,7 +184,7 @@
}
void
-status_code_handler(vector strvec)
+status_code_handler(vector_t *strvec)
{
http_checker_t *http_get_chk = CHECKER_GET();
url_t *url = LIST_TAIL_DATA(http_get_chk->url);
@@ -750,7 +750,7 @@
new_req = 0;
if (http_get_check->proto == PROTO_SSL) {
- timeout = TIMER_LONG(thread->sands)-TIMER_LONG(time_now);
+ timeout = timer_long(thread->sands) - timer_long(time_now);
if (thread->type != THREAD_WRITE_TIMEOUT &&
thread->type != THREAD_READ_TIMEOUT)
ret = ssl_connect(thread, new_req);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/check/check_misc.c
^
|
@@ -20,7 +20,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include "check_misc.h"
@@ -61,7 +61,7 @@
}
void
-misc_check_handler(vector strvec)
+misc_check_handler(vector_t *strvec)
{
misc_checker_t *misck_checker = (misc_checker_t *) MALLOC(sizeof (misc_checker_t));
@@ -71,21 +71,21 @@
}
void
-misc_path_handler(vector strvec)
+misc_path_handler(vector_t *strvec)
{
misc_checker_t *misck_checker = CHECKER_GET();
misck_checker->path = CHECKER_VALUE_STRING(strvec);
}
void
-misc_timeout_handler(vector strvec)
+misc_timeout_handler(vector_t *strvec)
{
misc_checker_t *misck_checker = CHECKER_GET();
misck_checker->timeout = CHECKER_VALUE_INT(strvec) * TIMER_HZ;
}
void
-misc_dynamic_handler(vector strvec)
+misc_dynamic_handler(vector_t *strvec)
{
misc_checker_t *misck_checker = CHECKER_GET();
misck_checker->dynamic = 1;
@@ -153,7 +153,14 @@
open("/dev/null", O_RDWR);
ret = dup(0);
+ if (ret < 0) {
+ log_message(LOG_INFO, "dup(0) error");
+ }
+
ret = dup(0);
+ if (ret < 0) {
+ log_message(LOG_INFO, "dup(0) error");
+ }
status = system_call(misck_checker->path);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/check/check_parser.c
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include "check_parser.h"
@@ -35,57 +35,57 @@
/* SSL handlers */
static void
-ssl_handler(vector strvec)
+ssl_handler(vector_t *strvec)
{
check_data->ssl = alloc_ssl();
}
static void
-sslpass_handler(vector strvec)
+sslpass_handler(vector_t *strvec)
{
check_data->ssl->password = set_value(strvec);
}
static void
-sslca_handler(vector strvec)
+sslca_handler(vector_t *strvec)
{
check_data->ssl->cafile = set_value(strvec);
}
static void
-sslcert_handler(vector strvec)
+sslcert_handler(vector_t *strvec)
{
check_data->ssl->certfile = set_value(strvec);
}
static void
-sslkey_handler(vector strvec)
+sslkey_handler(vector_t *strvec)
{
check_data->ssl->keyfile = set_value(strvec);
}
/* Virtual Servers handlers */
static void
-vsg_handler(vector strvec)
+vsg_handler(vector_t *strvec)
{
/* Fetch queued vsg */
- alloc_vsg(VECTOR_SLOT(strvec, 1));
+ alloc_vsg(vector_slot(strvec, 1));
alloc_value_block(strvec, alloc_vsg_entry);
}
static void
-vs_handler(vector strvec)
+vs_handler(vector_t *strvec)
{
- alloc_vs(VECTOR_SLOT(strvec, 1), VECTOR_SLOT(strvec, 2));
+ alloc_vs(vector_slot(strvec, 1), vector_slot(strvec, 2));
}
static void
-delay_handler(vector strvec)
+delay_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
- vs->delay_loop = atoi(VECTOR_SLOT(strvec, 1)) * TIMER_HZ;
+ vs->delay_loop = atoi(vector_slot(strvec, 1)) * TIMER_HZ;
if (vs->delay_loop < TIMER_HZ)
vs->delay_loop = TIMER_HZ;
}
static void
-lbalgo_handler(vector strvec)
+lbalgo_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
- char *str = VECTOR_SLOT(strvec, 1);
+ char *str = vector_slot(strvec, 1);
int size = sizeof (vs->sched);
int str_len = strlen(str);
@@ -95,10 +95,10 @@
memcpy(vs->sched, str, size);
}
static void
-lbkind_handler(vector strvec)
+lbkind_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
- char *str = VECTOR_SLOT(strvec, 1);
+ char *str = vector_slot(strvec, 1);
if (!strcmp(str, "NAT"))
vs->loadbalancing_kind = IP_VS_CONN_F_MASQ;
@@ -110,16 +110,16 @@
log_message(LOG_INFO, "PARSER : unknown [%s] routing method.", str);
}
static void
-natmask_handler(vector strvec)
+natmask_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
- inet_ston(VECTOR_SLOT(strvec, 1), &vs->nat_mask);
+ inet_ston(vector_slot(strvec, 1), &vs->nat_mask);
}
static void
-pto_handler(vector strvec)
+pto_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
- char *str = VECTOR_SLOT(strvec, 1);
+ char *str = vector_slot(strvec, 1);
int size = sizeof (vs->timeout_persistence);
int str_len = strlen(str);
@@ -129,29 +129,29 @@
memcpy(vs->timeout_persistence, str, size);
}
static void
-pgr_handler(vector strvec)
+pgr_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
if (vs->addr.ss_family == AF_INET6)
- vs->granularity_persistence = atoi(VECTOR_SLOT(strvec, 1));
+ vs->granularity_persistence = atoi(vector_slot(strvec, 1));
else
- inet_ston(VECTOR_SLOT(strvec, 1), &vs->granularity_persistence);
+ inet_ston(vector_slot(strvec, 1), &vs->granularity_persistence);
}
static void
-proto_handler(vector strvec)
+proto_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
- char *str = VECTOR_SLOT(strvec, 1);
+ char *str = vector_slot(strvec, 1);
vs->service_type = (!strcmp(str, "TCP")) ? IPPROTO_TCP : IPPROTO_UDP;
}
static void
-hasuspend_handler(vector strvec)
+hasuspend_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
vs->ha_suspend = 1;
}
static void
-virtualhost_handler(vector strvec)
+virtualhost_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
vs->virtualhost = set_value(strvec);
@@ -159,116 +159,116 @@
/* Sorry Servers handlers */
static void
-ssvr_handler(vector strvec)
+ssvr_handler(vector_t *strvec)
{
- alloc_ssvr(VECTOR_SLOT(strvec, 1), VECTOR_SLOT(strvec, 2));
+ alloc_ssvr(vector_slot(strvec, 1), vector_slot(strvec, 2));
}
/* Real Servers handlers */
static void
-rs_handler(vector strvec)
+rs_handler(vector_t *strvec)
{
- alloc_rs(VECTOR_SLOT(strvec, 1), VECTOR_SLOT(strvec, 2));
+ alloc_rs(vector_slot(strvec, 1), vector_slot(strvec, 2));
}
static void
-weight_handler(vector strvec)
+weight_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
real_server *rs = LIST_TAIL_DATA(vs->rs);
- rs->weight = atoi(VECTOR_SLOT(strvec, 1));
+ rs->weight = atoi(vector_slot(strvec, 1));
rs->iweight = rs->weight;
}
#ifdef _KRNL_2_6_
static void
-uthreshold_handler(vector strvec)
+uthreshold_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
real_server *rs = LIST_TAIL_DATA(vs->rs);
- rs->u_threshold = atoi(VECTOR_SLOT(strvec, 1));
+ rs->u_threshold = atoi(vector_slot(strvec, 1));
}
static void
-lthreshold_handler(vector strvec)
+lthreshold_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
real_server *rs = LIST_TAIL_DATA(vs->rs);
- rs->l_threshold = atoi(VECTOR_SLOT(strvec, 1));
+ rs->l_threshold = atoi(vector_slot(strvec, 1));
}
#endif
static void
-inhibit_handler(vector strvec)
+inhibit_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
real_server *rs = LIST_TAIL_DATA(vs->rs);
rs->inhibit = 1;
}
static void
-notify_up_handler(vector strvec)
+notify_up_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
real_server *rs = LIST_TAIL_DATA(vs->rs);
rs->notify_up = set_value(strvec);
}
static void
-notify_down_handler(vector strvec)
+notify_down_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
real_server *rs = LIST_TAIL_DATA(vs->rs);
rs->notify_down = set_value(strvec);
}
static void
-alpha_handler(vector strvec)
+alpha_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
vs->alpha = 1;
vs->quorum_state = DOWN;
}
static void
-omega_handler(vector strvec)
+omega_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
vs->omega = 1;
}
static void
-quorum_up_handler(vector strvec)
+quorum_up_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
vs->quorum_up = set_value(strvec);
}
static void
-quorum_down_handler(vector strvec)
+quorum_down_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
vs->quorum_down = set_value(strvec);
}
static void
-quorum_handler(vector strvec)
+quorum_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
- long tmp = atol (VECTOR_SLOT(strvec, 1));
+ long tmp = atol (vector_slot(strvec, 1));
if (tmp < 1) {
log_message(LOG_ERR, "Condition not met: Quorum >= 1");
log_message(LOG_ERR, "Ignoring requested value %s, using 1 instead",
- (char *) VECTOR_SLOT(strvec, 1));
+ (char *) vector_slot(strvec, 1));
tmp = 1;
}
vs->quorum = tmp;
}
static void
-hysteresis_handler(vector strvec)
+hysteresis_handler(vector_t *strvec)
{
virtual_server *vs = LIST_TAIL_DATA(check_data->vs);
- long tmp = atol (VECTOR_SLOT(strvec, 1));
+ long tmp = atol (vector_slot(strvec, 1));
if (tmp < 0 || tmp >= vs->quorum) {
log_message(LOG_ERR, "Condition not met: 0 <= Hysteresis <= Quorum - 1");
log_message(LOG_ERR, "Ignoring requested value %s, using 0 instead",
- (char *) VECTOR_SLOT(strvec, 1));
+ (char *) vector_slot(strvec, 1));
log_message(LOG_ERR, "Hint: try defining hysteresis after quorum");
tmp = 0;
}
vs->hysteresis = tmp;
}
-vector
+vector_t *
check_init_keywords(void)
{
/* global definitions mapping */
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/check/check_smtp.c
^
|
@@ -18,7 +18,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include <ctype.h>
@@ -114,7 +114,7 @@
* in the config file.
*/
void
-smtp_check_handler(vector strvec)
+smtp_check_handler(vector_t *strvec)
{
smtp_checker_t *smtp_checker = (smtp_checker_t *)MALLOC(sizeof(smtp_checker_t));
@@ -164,7 +164,7 @@
* in the config file.
*/
void
-smtp_host_handler(vector strvec)
+smtp_host_handler(vector_t *strvec)
{
smtp_checker_t *smtp_checker = CHECKER_GET();
@@ -184,16 +184,16 @@
/* "connect_ip" keyword */
void
-smtp_ip_handler(vector strvec)
+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);
+ inet_stosockaddr(vector_slot(strvec, 1), NULL, &smtp_host->dst);
}
/* "connect_port" keyword */
void
-smtp_port_handler(vector strvec)
+smtp_port_handler(vector_t *strvec)
{
smtp_checker_t *smtp_checker = CHECKER_GET();
smtp_host_t *smtp_host = LIST_TAIL_DATA(smtp_checker->host);
@@ -202,7 +202,7 @@
/* "helo_name" keyword */
void
-smtp_helo_name_handler(vector strvec)
+smtp_helo_name_handler(vector_t *strvec)
{
smtp_checker_t *smtp_checker = CHECKER_GET();
smtp_checker->helo_name = CHECKER_VALUE_STRING(strvec);
@@ -210,7 +210,7 @@
/* "connect_timeout" keyword */
void
-smtp_timeout_handler(vector strvec)
+smtp_timeout_handler(vector_t *strvec)
{
smtp_checker_t *smtp_checker = CHECKER_GET();
smtp_checker->timeout = CHECKER_VALUE_INT(strvec) * TIMER_HZ;
@@ -220,7 +220,7 @@
/* "retry" keyword */
void
-smtp_retry_handler(vector strvec)
+smtp_retry_handler(vector_t *strvec)
{
smtp_checker_t *smtp_checker = CHECKER_GET();
smtp_checker->retry = CHECKER_VALUE_INT(strvec);
@@ -228,7 +228,7 @@
/* "delay_before_retry" keyword */
void
-smtp_db_retry_handler(vector strvec)
+smtp_db_retry_handler(vector_t *strvec)
{
smtp_checker_t *smtp_checker = CHECKER_GET();
smtp_checker->db_retry = CHECKER_VALUE_INT(strvec) * TIMER_HZ;
@@ -236,11 +236,11 @@
/* "bindto" keyword */
void
-smtp_bindto_handler(vector strvec)
+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);
+ inet_stosockaddr(vector_slot(strvec, 1), 0, &smtp_host->bindto);
}
/* Config callback installer */
|
[-]
[+]
|
Added |
keepalived-1.2.7.tar.bz2/keepalived/check/check_snmp.c
^
|
@@ -0,0 +1,1090 @@
+/*
+ * Soft: Keepalived is a failover program for the LVS project
+ * <www.linuxvirtualserver.org>. It monitor & manipulate
+ * a loadbalanced server pool using multi-layer checks.
+ *
+ * Part: SNMP agent
+ *
+ * Author: Vincent Bernat <bernat@luffy.cx>
+ *
+ * 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>
+ */
+
+#include "check_data.h"
+#include "check_snmp.h"
+#include "list.h"
+#include "ipvswrapper.h"
+#include "ipwrapper.h"
+#include "global_data.h"
+
+static u_char*
+check_snmp_vsgroup(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method)
+{
+ virtual_server_group *g;
+
+ if ((g = (virtual_server_group *)
+ snmp_header_list_table(vp, name, length, exact,
+ var_len, write_method,
+ check_data->vs_group)) == NULL)
+ return NULL;
+
+ switch (vp->magic) {
+ case CHECK_SNMP_VSGROUPNAME:
+ *var_len = strlen(g->gname);
+ return (u_char *)g->gname;
+ default:
+ break;
+ }
+ return NULL;
+}
+
+static u_char*
+check_snmp_vsgroupmember(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method)
+{
+ static unsigned long long_ret;
+ static uint32_t ip;
+ static struct in6_addr ip6;
+ oid *target, current[2], best[2];
+ int result, target_len;
+ int curgroup = 0, curentry;
+ element e1, e2;
+ virtual_server_group *group;
+ virtual_server_group_entry *e, *be = NULL;
+ int state;
+ list l;
+
+
+ if ((result = snmp_oid_compare(name, *length, vp->name, vp->namelen)) < 0) {
+ memcpy(name, vp->name, sizeof(oid) * vp->namelen);
+ *length = vp->namelen;
+ }
+
+ *write_method = 0;
+ *var_len = sizeof(long);
+
+ if (LIST_ISEMPTY(check_data->vs_group))
+ return NULL;
+
+ /* We search the best match: equal if exact, the lower OID in
+ the set of the OID strictly superior to the target
+ otherwise. */
+ best[0] = best[1] = MAX_SUBID; /* Our best match */
+ target = &name[vp->namelen]; /* Our target match */
+ target_len = *length - vp->namelen;
+ for (e1 = LIST_HEAD(check_data->vs_group); e1; ELEMENT_NEXT(e1)) {
+ group = ELEMENT_DATA(e1);
+ curgroup++;
+ curentry = 0;
+ if (target_len && (curgroup < target[0]))
+ continue; /* Optimization: cannot be part of our set */
+ if (be)
+ break; /* Optimization: cannot be the lower anymore */
+ state = STATE_VSGM_FWMARK;
+ while (state != STATE_VSGM_END) {
+ switch (state) {
+ case STATE_VSGM_FWMARK:
+ l = group->vfwmark;
+ break;
+ case STATE_VSGM_ADDRESS:
+ l = group->addr_ip;
+ break;
+ case STATE_VSGM_RANGE:
+ l = group->range;
+ break;
+ default:
+ /* Dunno? */
+ return NULL;
+ }
+ state++;
+ if (LIST_ISEMPTY(l))
+ continue;
+ for (e2 = LIST_HEAD(l); e2; ELEMENT_NEXT(e2)) {
+ e = ELEMENT_DATA(e2);
+ curentry++;
+ /* We build our current match */
+ current[0] = curgroup;
+ current[1] = curentry;
+ /* And compare it to our target match */
+ if ((result = snmp_oid_compare(current, 2, target,
+ target_len)) < 0)
+ continue;
+ if ((result == 0) && !exact)
+ continue;
+ if (result == 0) {
+ /* Got an exact match and asked for it */
+ be = e;
+ goto vsgmember_found;
+ }
+ if (snmp_oid_compare(current, 2, best, 2) < 0) {
+ /* This is our best match */
+ memcpy(best, current, sizeof(oid) * 2);
+ be = e;
+ goto vsgmember_be_found;
+ }
+ }
+ }
+ }
+ if (be == NULL)
+ /* No best match */
+ return NULL;
+ if (exact)
+ /* No exact match */
+ return NULL;
+ vsgmember_be_found:
+ /* Let's use our best match */
+ memcpy(target, best, sizeof(oid) * 2);
+ *length = vp->namelen + 2;
+ vsgmember_found:
+ switch (vp->magic) {
+ case CHECK_SNMP_VSGROUPMEMBERTYPE:
+ if (be->vfwmark)
+ long_ret = 1;
+ else if (be->range)
+ long_ret = 3;
+ else
+ long_ret = 2;
+ return (u_char *)&long_ret;
+ case CHECK_SNMP_VSGROUPMEMBERFWMARK:
+ if (!be->vfwmark) break;
+ long_ret = be->vfwmark;
+ return (u_char *)&long_ret;
+ case CHECK_SNMP_VSGROUPMEMBERADDRTYPE:
+ if (be->vfwmark) break;
+ long_ret = (be->addr.ss_family == AF_INET6) ? 2:1;
+ return (u_char *)&long_ret;
+ case CHECK_SNMP_VSGROUPMEMBERADDRESS:
+ if (be->vfwmark || be->range) break;
+ RETURN_IP46ADDRESS(be);
+ break;
+ case CHECK_SNMP_VSGROUPMEMBERADDR1:
+ if (!be->range) break;
+ RETURN_IP46ADDRESS(be);
+ break;
+ case CHECK_SNMP_VSGROUPMEMBERADDR2:
+ if (!be->range) break;
+ if (be->addr.ss_family == AF_INET6) {
+ struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&be->addr;
+ *var_len = 16;
+ memcpy(&ip6, &addr6->sin6_addr, sizeof(ip6));
+ ip6.s6_addr32[3] &= htonl(0xFFFFFF00);
+ ip6.s6_addr32[3] += htonl(be->range);
+ return (u_char *)&ip6;
+ } else {
+ struct sockaddr_in *addr4 = (struct sockaddr_in *)&be->addr;
+ *var_len = 4;
+ ip = (*(u_int32_t *)&addr4->sin_addr) & htonl(0xFFFFFF00);
+ ip += htonl(be->range);
+ return (u_char *)&ip;
+ }
+ break;
+ case CHECK_SNMP_VSGROUPMEMBERPORT:
+ if (be->vfwmark) break;
+ long_ret = htons(inet_sockaddrport(&be->addr));
+ return (u_char *)&long_ret;
+ default:
+ return NULL;
+ }
+ /* If we are here, we asked for a non existent data. Try the
+ next one. */
+ if (!exact && (name[*length-1] < MAX_SUBID))
+ return check_snmp_vsgroupmember(vp, name, length,
+ exact, var_len, write_method);
+ return NULL;
+}
+
+static u_char*
+check_snmp_virtualserver(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method)
+{
+ static unsigned long long_ret;
+#ifdef _KRNL_2_6_
+ static U64 counter64_ret;
+#endif
+ virtual_server *v;
+ element e;
+
+ if ((v = (virtual_server *)
+ snmp_header_list_table(vp, name, length, exact,
+ var_len, write_method,
+ check_data->vs)) == NULL)
+ return NULL;
+
+ switch (vp->magic) {
+ case CHECK_SNMP_VSTYPE:
+ if (v->vsgname)
+ long_ret = 3;
+ else if (v->vfwmark)
+ long_ret = 1;
+ else
+ long_ret = 2;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSNAMEGROUP:
+ if (!v->vsgname) break;
+ *var_len = strlen(v->vsgname);
+ return (u_char*)v->vsgname;
+ case CHECK_SNMP_VSFWMARK:
+ if (!v->vfwmark) break;
+ long_ret = v->vfwmark;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSADDRTYPE:
+ if (v->vfwmark || v->vsgname) break;
+ long_ret = (v->addr.ss_family == AF_INET6) ? 2:1;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSADDRESS:
+ if (v->vfwmark || v->vsgname) break;
+ RETURN_IP46ADDRESS(v);
+ break;
+ case CHECK_SNMP_VSPORT:
+ if (v->vfwmark || v->vsgname) break;
+ long_ret = htons(inet_sockaddrport(&v->addr));
+ return (u_char *)&long_ret;
+ case CHECK_SNMP_VSPROTOCOL:
+ long_ret = (v->service_type == IPPROTO_TCP)?1:2;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSLOADBALANCINGALGO:
+ if (strncmp(v->sched, "rr", SCHED_MAX_LENGTH) == 0)
+ long_ret = 1;
+ else if (strncmp(v->sched, "wrr", SCHED_MAX_LENGTH) == 0)
+ long_ret = 2;
+ else if (strncmp(v->sched, "lc", SCHED_MAX_LENGTH) == 0)
+ long_ret = 3;
+ else if (strncmp(v->sched, "wlc", SCHED_MAX_LENGTH) == 0)
+ long_ret = 4;
+ else if (strncmp(v->sched, "lblc", SCHED_MAX_LENGTH) == 0)
+ long_ret = 5;
+ else if (strncmp(v->sched, "lblcr", SCHED_MAX_LENGTH) == 0)
+ long_ret = 6;
+ else if (strncmp(v->sched, "dh", SCHED_MAX_LENGTH) == 0)
+ long_ret = 7;
+ else if (strncmp(v->sched, "sh", SCHED_MAX_LENGTH) == 0)
+ long_ret = 8;
+ else if (strncmp(v->sched, "sed", SCHED_MAX_LENGTH) == 0)
+ long_ret = 9;
+ else if (strncmp(v->sched, "nq", SCHED_MAX_LENGTH) == 0)
+ long_ret = 10;
+ else long_ret = 99;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSLOADBALANCINGKIND:
+ long_ret = 0;
+ switch (v->loadbalancing_kind) {
+#ifdef _WITH_LVS_
+#ifdef _KRNL_2_2_
+ case 0:
+ long_ret = 1;
+ break;
+ case IP_MASQ_F_VS_DROUTE:
+ long_ret = 2;
+ break;
+ case IP_MASQ_F_VS_TUNNEL:
+ long_ret = 3;
+ break;
+#else
+ case IP_VS_CONN_F_MASQ:
+ long_ret = 1;
+ break;
+ case IP_VS_CONN_F_DROUTE:
+ long_ret = 2;
+ break;
+ case IP_VS_CONN_F_TUNNEL:
+ long_ret = 3;
+ break;
+#endif
+#endif
+ }
+ if (!long_ret) break;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSSTATUS:
+ long_ret = v->alive?1:2;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSVIRTUALHOST:
+ if (!v->virtualhost) break;
+ *var_len = strlen(v->virtualhost);
+ return (u_char*)v->virtualhost;
+ case CHECK_SNMP_VSPERSIST:
+ long_ret = (atol(v->timeout_persistence) > 0)?1:2;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSPERSISTTIMEOUT:
+ if (atol(v->timeout_persistence) <= 0) break;
+ long_ret = atol(v->timeout_persistence);
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSPERSISTGRANULARITY:
+ if (atol(v->timeout_persistence) <= 0) break;
+ if (!v->granularity_persistence) break;
+ *var_len = 4;
+ return (u_char*)&v->granularity_persistence;
+ case CHECK_SNMP_VSDELAYLOOP:
+ if (v->delay_loop >= TIMER_MAX_SEC)
+ long_ret = v->delay_loop/TIMER_HZ;
+ else
+ long_ret = v->delay_loop;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSHASUSPEND:
+ long_ret = v->ha_suspend?1:2;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSALPHA:
+ long_ret = v->alpha?1:2;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSOMEGA:
+ long_ret = v->omega?1:2;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSQUORUM:
+ long_ret = v->quorum;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSQUORUMSTATUS:
+ long_ret = v->quorum_state?1:2;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSQUORUMUP:
+ if (!v->quorum_up) break;
+ *var_len = strlen(v->quorum_up);
+ return (u_char*)v->quorum_up;
+ case CHECK_SNMP_VSQUORUMDOWN:
+ if (!v->quorum_down) break;
+ *var_len = strlen(v->quorum_down);
+ return (u_char*)v->quorum_down;
+ case CHECK_SNMP_VSHYSTERESIS:
+ long_ret = v->hysteresis;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSREALTOTAL:
+ if (LIST_ISEMPTY(v->rs))
+ long_ret = 0;
+ else
+ long_ret = LIST_SIZE(v->rs);
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSREALUP:
+ long_ret = 0;
+ if (!LIST_ISEMPTY(v->rs))
+ for (e = LIST_HEAD(v->rs); e; ELEMENT_NEXT(e))
+ if (((real_server *)ELEMENT_DATA(e))->alive)
+ long_ret++;
+ return (u_char*)&long_ret;
+#if defined(_KRNL_2_6_) && defined(_WITH_LVS_)
+ case CHECK_SNMP_VSSTATSCONNS:
+ ipvs_update_stats(v);
+ long_ret = v->stats.conns;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSSTATSINPKTS:
+ ipvs_update_stats(v);
+ long_ret = v->stats.inpkts;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSSTATSOUTPKTS:
+ ipvs_update_stats(v);
+ long_ret = v->stats.outpkts;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSSTATSINBYTES:
+ ipvs_update_stats(v);
+ counter64_ret.low = v->stats.inbytes & 0xffffffff;
+ counter64_ret.high = v->stats.inbytes >> 32;
+ *var_len = sizeof(U64);
+ return (u_char*)&counter64_ret;
+ case CHECK_SNMP_VSSTATSOUTBYTES:
+ ipvs_update_stats(v);
+ counter64_ret.low = v->stats.outbytes & 0xffffffff;
+ counter64_ret.high = v->stats.outbytes >> 32;
+ *var_len = sizeof(U64);
+ return (u_char*)&counter64_ret;
+ case CHECK_SNMP_VSRATECPS:
+ ipvs_update_stats(v);
+ long_ret = v->stats.cps;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSRATEINPPS:
+ ipvs_update_stats(v);
+ long_ret = v->stats.inpps;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSRATEOUTPPS:
+ ipvs_update_stats(v);
+ long_ret = v->stats.outpps;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSRATEINBPS:
+ ipvs_update_stats(v);
+ long_ret = v->stats.inbps;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_VSRATEOUTBPS:
+ ipvs_update_stats(v);
+ long_ret = v->stats.outbps;
+ return (u_char*)&long_ret;
+#endif
+ default:
+ return NULL;
+ }
+ if (!exact && (name[*length-1] < MAX_SUBID))
+ return check_snmp_virtualserver(vp, name, length,
+ exact, var_len, write_method);
+ return NULL;
+}
+
+static int
+check_snmp_realserver_weight(int action,
+ u_char *var_val, u_char var_val_type, size_t var_val_len,
+ u_char *statP, oid *name, size_t name_len)
+{
+ element e1, e2;
+ virtual_server *vs = NULL;
+ real_server *rs = NULL;
+ int ivs, irs;
+ switch (action) {
+ case RESERVE1:
+ /* Check that the proposed value is acceptable */
+ if (var_val_type != ASN_INTEGER)
+ return SNMP_ERR_WRONGTYPE;
+ if (var_val_len > sizeof(long))
+ return SNMP_ERR_WRONGLENGTH;
+ if ((long)(*var_val) < 0)
+ return SNMP_ERR_WRONGVALUE;
+ break;
+ case RESERVE2: /* Check that we can find the instance. We should. */
+ case COMMIT:
+ /* Find the instance */
+ if (name_len < 2) return SNMP_ERR_NOSUCHNAME;
+ irs = name[name_len - 1];
+ ivs = name[name_len - 2];
+ if (LIST_ISEMPTY(check_data->vs)) return SNMP_ERR_NOSUCHNAME;
+ for (e1 = LIST_HEAD(check_data->vs); e1; ELEMENT_NEXT(e1)) {
+ vs = ELEMENT_DATA(e1);
+ if (--ivs == 0) {
+ if (LIST_ISEMPTY(vs->rs)) return SNMP_ERR_NOSUCHNAME;
+ if (vs->s_svr) {
+ /* We don't want to set weight
+ of sorry server */
+ rs = NULL;
+ if (--irs == 0) break;
+ }
+ for (e2 = LIST_HEAD(vs->rs); e2; ELEMENT_NEXT(e2)) {
+ rs = ELEMENT_DATA(e2);
+ if (--irs == 0) break;
+ }
+ break;
+ }
+ }
+ /* Did not find a RS or this is a sorry server (this
+ should not happen) */
+ if (!rs) return SNMP_ERR_NOSUCHNAME;
+ if (action == RESERVE2)
+ break;
+ /* Commit: change values. There is no way to fail. */
+ update_svr_wgt((long)(*var_val), vs, rs);
+ break;
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+static u_char*
+check_snmp_realserver(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method)
+{
+ static unsigned long long_ret;
+#ifdef _KRNL_2_6_
+ static U64 counter64_ret;
+#endif
+ oid *target, current[2], best[2];
+ int result, target_len;
+ int curvirtual = 0, curreal;
+ real_server *e = NULL, *be = NULL;
+ element e1, e2 = NULL;
+ virtual_server *vs, *bvs = NULL;
+ int state;
+ int type, btype;
+
+ if ((result = snmp_oid_compare(name, *length, vp->name, vp->namelen)) < 0) {
+ memcpy(name, vp->name, sizeof(oid) * vp->namelen);
+ *length = vp->namelen;
+ }
+
+ *write_method = 0;
+ *var_len = sizeof(long);
+
+ if (LIST_ISEMPTY(check_data->vs))
+ return NULL;
+
+ /* We search the best match: equal if exact, the lower OID in
+ the set of the OID strictly superior to the target
+ otherwise. */
+ best[0] = best[1] = MAX_SUBID; /* Our best match */
+ target = &name[vp->namelen]; /* Our target match */
+ target_len = *length - vp->namelen;
+ for (e1 = LIST_HEAD(check_data->vs); e1; ELEMENT_NEXT(e1)) {
+ vs = ELEMENT_DATA(e1);
+ curvirtual++;
+ curreal = 0;
+ if (target_len && (curvirtual < target[0]))
+ continue; /* Optimization: cannot be part of our set */
+ if (be)
+ break; /* Optimization: cannot be the lower anymore */
+ state = STATE_RS_SORRY;
+ while (state != STATE_RS_END) {
+ switch (state) {
+ case STATE_RS_SORRY:
+ e = vs->s_svr;
+ type = state++;
+ break;
+ case STATE_RS_REGULAR_FIRST:
+ if (LIST_ISEMPTY(vs->rs)) {
+ e = NULL;
+ state = STATE_RS_END;
+ break;
+ }
+ e2 = LIST_HEAD(vs->rs);
+ e = ELEMENT_DATA(e2);
+ type = state++;
+ break;
+ case STATE_RS_REGULAR_NEXT:
+ type = state;
+ ELEMENT_NEXT(e2);
+ if (!e2) {
+ e = NULL;
+ state++;
+ break;
+ }
+ e = ELEMENT_DATA(e2);
+ break;
+ default:
+ /* Dunno? */
+ return NULL;
+ }
+ if (!e)
+ continue;
+ curreal++;
+ /* We build our current match */
+ current[0] = curvirtual;
+ current[1] = curreal;
+ /* And compare it to our target match */
+ if ((result = snmp_oid_compare(current, 2, target,
+ target_len)) < 0)
+ continue;
+ if ((result == 0) && !exact)
+ continue;
+ if (result == 0) {
+ /* Got an exact match and asked for it */
+ be = e;
+ bvs = vs;
+ btype = type;
+ goto real_found;
+ }
+ if (snmp_oid_compare(current, 2, best, 2) < 0) {
+ /* This is our best match */
+ memcpy(best, current, sizeof(oid) * 2);
+ be = e;
+ bvs = vs;
+ btype = type;
+ goto real_be_found;
+ }
+ }
+ }
+ if (be == NULL)
+ /* No best match */
+ return NULL;
+ if (exact)
+ /* No exact match */
+ return NULL;
+ real_be_found:
+ /* Let's use our best match */
+ memcpy(target, best, sizeof(oid) * 2);
+ *length = vp->namelen + 2;
+ real_found:
+ switch (vp->magic) {
+ case CHECK_SNMP_RSTYPE:
+ long_ret = (btype == STATE_RS_SORRY)?2:1;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_RSADDRTYPE:
+ long_ret = (be->addr.ss_family == AF_INET6) ? 2:1;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_RSADDRESS:
+ RETURN_IP46ADDRESS(be);
+ break;
+ case CHECK_SNMP_RSPORT:
+ long_ret = htons(inet_sockaddrport(&be->addr));
+ return (u_char *)&long_ret;
+ case CHECK_SNMP_RSSTATUS:
+ if (btype == STATE_RS_SORRY) break;
+ long_ret = be->alive?1:2;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_RSWEIGHT:
+ if (btype == STATE_RS_SORRY) break;
+ long_ret = be->weight;
+ *write_method = check_snmp_realserver_weight;
+ return (u_char*)&long_ret;
+#ifdef _KRNL_2_6_
+ case CHECK_SNMP_RSUPPERCONNECTIONLIMIT:
+ if (btype == STATE_RS_SORRY) break;
+ if (!be->u_threshold) break;
+ long_ret = be->u_threshold;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_RSLOWERCONNECTIONLIMIT:
+ if (btype == STATE_RS_SORRY) break;
+ if (!be->l_threshold) break;
+ long_ret = be->l_threshold;
+ return (u_char*)&long_ret;
+#endif
+ case CHECK_SNMP_RSACTIONWHENDOWN:
+ if (btype == STATE_RS_SORRY) break;
+ long_ret = be->inhibit?2:1;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_RSNOTIFYUP:
+ if (btype == STATE_RS_SORRY) break;
+ if (!be->notify_up) break;
+ *var_len = strlen(be->notify_up);
+ return (u_char*)be->notify_up;
+ case CHECK_SNMP_RSNOTIFYDOWN:
+ if (btype == STATE_RS_SORRY) break;
+ if (!be->notify_down) break;
+ *var_len = strlen(be->notify_down);
+ return (u_char*)be->notify_down;
+ case CHECK_SNMP_RSFAILEDCHECKS:
+ if (btype == STATE_RS_SORRY) break;
+ if (LIST_ISEMPTY(be->failed_checkers))
+ long_ret = 0;
+ else
+ long_ret = LIST_SIZE(be->failed_checkers);
+ return (u_char*)&long_ret;
+#if defined(_KRNL_2_6_) && defined(_WITH_LVS_)
+ case CHECK_SNMP_RSSTATSCONNS:
+ ipvs_update_stats(bvs);
+ long_ret = be->stats.conns;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_RSSTATSACTIVECONNS:
+ ipvs_update_stats(bvs);
+ long_ret = be->activeconns;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_RSSTATSINACTIVECONNS:
+ ipvs_update_stats(bvs);
+ long_ret = be->inactconns;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_RSSTATSPERSISTENTCONNS:
+ ipvs_update_stats(bvs);
+ long_ret = be->persistconns;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_RSSTATSINPKTS:
+ ipvs_update_stats(bvs);
+ long_ret = be->stats.inpkts;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_RSSTATSOUTPKTS:
+ ipvs_update_stats(bvs);
+ long_ret = be->stats.outpkts;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_RSSTATSINBYTES:
+ ipvs_update_stats(bvs);
+ counter64_ret.low = be->stats.inbytes & 0xffffffff;
+ counter64_ret.high = be->stats.inbytes >> 32;
+ *var_len = sizeof(U64);
+ return (u_char*)&counter64_ret;
+ case CHECK_SNMP_RSSTATSOUTBYTES:
+ ipvs_update_stats(bvs);
+ counter64_ret.low = be->stats.outbytes & 0xffffffff;
+ counter64_ret.high = be->stats.outbytes >> 32;
+ *var_len = sizeof(U64);
+ return (u_char*)&counter64_ret;
+ case CHECK_SNMP_RSRATECPS:
+ ipvs_update_stats(bvs);
+ long_ret = be->stats.cps;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_RSRATEINPPS:
+ ipvs_update_stats(bvs);
+ long_ret = be->stats.inpps;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_RSRATEOUTPPS:
+ ipvs_update_stats(bvs);
+ long_ret = be->stats.outpps;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_RSRATEINBPS:
+ ipvs_update_stats(bvs);
+ long_ret = be->stats.inbps;
+ return (u_char*)&long_ret;
+ case CHECK_SNMP_RSRATEOUTBPS:
+ ipvs_update_stats(bvs);
+ long_ret = be->stats.outbps;
+ return (u_char*)&long_ret;
+#endif
+ default:
+ return NULL;
+ }
+ /* If we are here, we asked for a non existent data. Try the
+ next one. */
+ if (!exact && (name[*length-1] < MAX_SUBID))
+ return check_snmp_realserver(vp, name, length,
+ exact, var_len, write_method);
+ return NULL;
+}
+
+static oid check_oid[] = {CHECK_OID};
+static struct variable8 check_vars[] = {
+ /* virtualServerGroupTable */
+ {CHECK_SNMP_VSGROUPNAME, ASN_OCTET_STR, RONLY,
+ check_snmp_vsgroup, 3, {1, 1, 2}},
+ /* virtualServerGroupMemberTable */
+ {CHECK_SNMP_VSGROUPMEMBERTYPE, ASN_INTEGER, RONLY,
+ check_snmp_vsgroupmember, 3, {2, 1, 2}},
+ {CHECK_SNMP_VSGROUPMEMBERFWMARK, ASN_UNSIGNED, RONLY,
+ check_snmp_vsgroupmember, 3, {2, 1, 3}},
+ {CHECK_SNMP_VSGROUPMEMBERADDRTYPE, ASN_INTEGER, RONLY,
+ check_snmp_vsgroupmember, 3, {2, 1, 4}},
+ {CHECK_SNMP_VSGROUPMEMBERADDRESS, ASN_OCTET_STR, RONLY,
+ check_snmp_vsgroupmember, 3, {2, 1, 5}},
+ {CHECK_SNMP_VSGROUPMEMBERADDR1, ASN_OCTET_STR, RONLY,
+ check_snmp_vsgroupmember, 3, {2, 1, 6}},
+ {CHECK_SNMP_VSGROUPMEMBERADDR2, ASN_OCTET_STR, RONLY,
+ check_snmp_vsgroupmember, 3, {2, 1, 7}},
+ {CHECK_SNMP_VSGROUPMEMBERPORT, ASN_UNSIGNED, RONLY,
+ check_snmp_vsgroupmember, 3, {2, 1, 8}},
+ /* virtualServerTable */
+ {CHECK_SNMP_VSTYPE, ASN_INTEGER, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 2}},
+ {CHECK_SNMP_VSNAMEGROUP, ASN_OCTET_STR, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 3}},
+ {CHECK_SNMP_VSFWMARK, ASN_UNSIGNED, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 4}},
+ {CHECK_SNMP_VSADDRTYPE, ASN_INTEGER, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 5}},
+ {CHECK_SNMP_VSADDRESS, ASN_OCTET_STR, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 6}},
+ {CHECK_SNMP_VSPORT, ASN_UNSIGNED, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 7}},
+ {CHECK_SNMP_VSPROTOCOL, ASN_INTEGER, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 8}},
+ {CHECK_SNMP_VSLOADBALANCINGALGO, ASN_INTEGER, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 9}},
+ {CHECK_SNMP_VSLOADBALANCINGKIND, ASN_INTEGER, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 10}},
+ {CHECK_SNMP_VSSTATUS, ASN_INTEGER, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 11}},
+ {CHECK_SNMP_VSVIRTUALHOST, ASN_OCTET_STR, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 12}},
+ {CHECK_SNMP_VSPERSIST, ASN_INTEGER, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 13}},
+ {CHECK_SNMP_VSPERSISTTIMEOUT, ASN_UNSIGNED, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 14}},
+ {CHECK_SNMP_VSPERSISTGRANULARITY, ASN_OCTET_STR, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 15}},
+ {CHECK_SNMP_VSDELAYLOOP, ASN_UNSIGNED, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 16}},
+ {CHECK_SNMP_VSHASUSPEND, ASN_INTEGER, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 17}},
+ {CHECK_SNMP_VSALPHA, ASN_INTEGER, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 18}},
+ {CHECK_SNMP_VSOMEGA, ASN_INTEGER, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 19}},
+ {CHECK_SNMP_VSREALTOTAL, ASN_UNSIGNED, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 20}},
+ {CHECK_SNMP_VSREALUP, ASN_UNSIGNED, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 21}},
+ {CHECK_SNMP_VSQUORUM, ASN_UNSIGNED, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 22}},
+ {CHECK_SNMP_VSQUORUMSTATUS, ASN_INTEGER, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 23}},
+ {CHECK_SNMP_VSQUORUMUP, ASN_OCTET_STR, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 24}},
+ {CHECK_SNMP_VSQUORUMDOWN, ASN_OCTET_STR, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 25}},
+ {CHECK_SNMP_VSHYSTERESIS, ASN_UNSIGNED, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 26}},
+#if defined(_KRNL_2_6_) && defined(_WITH_LVS_)
+ {CHECK_SNMP_VSSTATSCONNS, ASN_GAUGE, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 27}},
+ {CHECK_SNMP_VSSTATSINPKTS, ASN_COUNTER, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 28}},
+ {CHECK_SNMP_VSSTATSOUTPKTS, ASN_COUNTER, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 29}},
+ {CHECK_SNMP_VSSTATSINBYTES, ASN_COUNTER64, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 30}},
+ {CHECK_SNMP_VSSTATSOUTBYTES, ASN_COUNTER64, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 31}},
+ {CHECK_SNMP_VSRATECPS, ASN_GAUGE, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 32}},
+ {CHECK_SNMP_VSRATEINPPS, ASN_GAUGE, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 33}},
+ {CHECK_SNMP_VSRATEOUTPPS, ASN_GAUGE, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 34}},
+ {CHECK_SNMP_VSRATEINBPS, ASN_GAUGE, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 35}},
+ {CHECK_SNMP_VSRATEOUTBPS, ASN_GAUGE, RONLY,
+ check_snmp_virtualserver, 3, {3, 1, 36}},
+#endif
+ /* realServerTable */
+ {CHECK_SNMP_RSTYPE, ASN_INTEGER, RONLY,
+ check_snmp_realserver, 3, {4, 1, 2}},
+ {CHECK_SNMP_RSADDRTYPE, ASN_INTEGER, RONLY,
+ check_snmp_realserver, 3, {4, 1, 3}},
+ {CHECK_SNMP_RSADDRESS, ASN_OCTET_STR, RONLY,
+ check_snmp_realserver, 3, {4, 1, 4}},
+ {CHECK_SNMP_RSPORT, ASN_UNSIGNED, RONLY,
+ check_snmp_realserver, 3, {4, 1, 5}},
+ {CHECK_SNMP_RSSTATUS, ASN_INTEGER, RONLY,
+ check_snmp_realserver, 3, {4, 1, 6}},
+ {CHECK_SNMP_RSWEIGHT, ASN_INTEGER, RWRITE,
+ check_snmp_realserver, 3, {4, 1, 7}},
+#ifdef _KRNL_2_6_
+ {CHECK_SNMP_RSUPPERCONNECTIONLIMIT, ASN_UNSIGNED, RONLY,
+ check_snmp_realserver, 3, {4, 1, 8}},
+ {CHECK_SNMP_RSLOWERCONNECTIONLIMIT, ASN_UNSIGNED, RONLY,
+ check_snmp_realserver, 3, {4, 1, 9}},
+#endif
+ {CHECK_SNMP_RSACTIONWHENDOWN, ASN_INTEGER, RONLY,
+ check_snmp_realserver, 3, {4, 1, 10}},
+ {CHECK_SNMP_RSNOTIFYUP, ASN_OCTET_STR, RONLY,
+ check_snmp_realserver, 3, {4, 1, 11}},
+ {CHECK_SNMP_RSNOTIFYDOWN, ASN_OCTET_STR, RONLY,
+ check_snmp_realserver, 3, {4, 1, 12}},
+ {CHECK_SNMP_RSFAILEDCHECKS, ASN_UNSIGNED, RONLY,
+ check_snmp_realserver, 3, {4, 1, 13}},
+#if defined(_KRNL_2_6_) && defined(_WITH_LVS_)
+ {CHECK_SNMP_RSSTATSCONNS, ASN_GAUGE, RONLY,
+ check_snmp_realserver, 3, {4, 1, 14}},
+ {CHECK_SNMP_RSSTATSACTIVECONNS, ASN_GAUGE, RONLY,
+ check_snmp_realserver, 3, {4, 1, 15}},
+ {CHECK_SNMP_RSSTATSINACTIVECONNS, ASN_GAUGE, RONLY,
+ check_snmp_realserver, 3, {4, 1, 16}},
+ {CHECK_SNMP_RSSTATSPERSISTENTCONNS, ASN_GAUGE, RONLY,
+ check_snmp_realserver, 3, {4, 1, 17}},
+ {CHECK_SNMP_RSSTATSINPKTS, ASN_COUNTER, RONLY,
+ check_snmp_realserver, 3, {4, 1, 18}},
+ {CHECK_SNMP_RSSTATSOUTPKTS, ASN_COUNTER, RONLY,
+ check_snmp_realserver, 3, {4, 1, 19}},
+ {CHECK_SNMP_RSSTATSINBYTES, ASN_COUNTER64, RONLY,
+ check_snmp_realserver, 3, {4, 1, 20}},
+ {CHECK_SNMP_RSSTATSOUTBYTES, ASN_COUNTER64, RONLY,
+ check_snmp_realserver, 3, {4, 1, 21}},
+ {CHECK_SNMP_RSRATECPS, ASN_GAUGE, RONLY,
+ check_snmp_realserver, 3, {4, 1, 22}},
+ {CHECK_SNMP_RSRATEINPPS, ASN_GAUGE, RONLY,
+ check_snmp_realserver, 3, {4, 1, 23}},
+ {CHECK_SNMP_RSRATEOUTPPS, ASN_GAUGE, RONLY,
+ check_snmp_realserver, 3, {4, 1, 24}},
+ {CHECK_SNMP_RSRATEINBPS, ASN_GAUGE, RONLY,
+ check_snmp_realserver, 3, {4, 1, 25}},
+ {CHECK_SNMP_RSRATEOUTBPS, ASN_GAUGE, RONLY,
+ check_snmp_realserver, 3, {4, 1, 26}},
+#endif
+};
+
+void
+check_snmp_agent_init()
+{
+ snmp_agent_init(check_oid, OID_LENGTH(check_oid), "Healthchecker",
+ (struct variable *)check_vars,
+ sizeof(struct variable8),
+ sizeof(check_vars)/sizeof(struct variable8));
+}
+
+void
+check_snmp_agent_close()
+{
+ snmp_agent_close(check_oid, OID_LENGTH(check_oid), "Healthchecker");
+}
+
+void
+check_snmp_rs_trap(real_server *rs, virtual_server *vs)
+{
+ element e;
+
+ /* OID of the notification */
+ oid notification_oid[] = { CHECK_OID, 5, 0, 1 };
+ size_t notification_oid_len = OID_LENGTH(notification_oid);
+ /* OID for snmpTrapOID.0 */
+ oid objid_snmptrap[] = { SNMPTRAP_OID };
+ size_t objid_snmptrap_len = OID_LENGTH(objid_snmptrap);
+
+ /* Other OID */
+ oid addrtype_oid[] = { CHECK_OID, 4, 1, 3 };
+ size_t addrtype_oid_len = OID_LENGTH(addrtype_oid);
+ static unsigned long addrtype = 1;
+ oid address_oid[] = { CHECK_OID, 4, 1, 4 };
+ size_t address_oid_len = OID_LENGTH(address_oid);
+ oid port_oid[] = { CHECK_OID, 4, 1, 5 };
+ size_t port_oid_len = OID_LENGTH(port_oid);
+ static unsigned long port;
+ oid status_oid[] = { CHECK_OID, 4, 1, 6 };
+ size_t status_oid_len = OID_LENGTH(status_oid);
+ static unsigned long status;
+ oid vstype_oid[] = { CHECK_OID, 3, 1, 2 };
+ size_t vstype_oid_len = OID_LENGTH(vstype_oid);
+ static unsigned long vstype;
+ oid vsgroupname_oid[] = { CHECK_OID, 3, 1, 3 };
+ size_t vsgroupname_oid_len = OID_LENGTH(vsgroupname_oid);
+ oid vsfwmark_oid[] = { CHECK_OID, 3, 1, 4 };
+ size_t vsfwmark_oid_len = OID_LENGTH(vsfwmark_oid);
+ static unsigned long vsfwmark;
+ oid vsaddrtype_oid[] = {CHECK_OID, 3, 1, 5 };
+ size_t vsaddrtype_oid_len = OID_LENGTH(vsaddrtype_oid);
+ oid vsaddress_oid[] = {CHECK_OID, 3, 1, 6 };
+ size_t vsaddress_oid_len = OID_LENGTH(vsaddress_oid);
+ oid vsport_oid[] = {CHECK_OID, 3, 1, 7 };
+ size_t vsport_oid_len = OID_LENGTH(vsport_oid);
+ static unsigned long vsport;
+ oid vsprotocol_oid[] = {CHECK_OID, 3, 1, 8 };
+ size_t vsprotocol_oid_len = OID_LENGTH(vsprotocol_oid);
+ static unsigned long vsprotocol;
+ oid realup_oid[] = {CHECK_OID, 3, 1, 21 };
+ size_t realup_oid_len = OID_LENGTH(realup_oid);
+ static unsigned long realup;
+ oid realtotal_oid[] = {CHECK_OID, 3, 1, 20 };
+ size_t realtotal_oid_len = OID_LENGTH(realtotal_oid);
+ static unsigned long realtotal;
+ oid quorumstatus_oid[] = {CHECK_OID, 3, 1, 23 };
+ size_t quorumstatus_oid_len = OID_LENGTH(quorumstatus_oid);
+ static unsigned long quorumstatus;
+ oid quorum_oid[] = {CHECK_OID, 3, 1, 22 };
+ size_t quorum_oid_len = OID_LENGTH(quorum_oid);
+ static unsigned long quorum;
+ oid routerId_oid[] = { KEEPALIVED_OID, 1, 2, 0 };
+ size_t routerId_oid_len = OID_LENGTH(routerId_oid);
+
+ netsnmp_variable_list *notification_vars = NULL;
+
+ if (!global_data->enable_traps) return;
+
+ if (!rs)
+ notification_oid[notification_oid_len - 1] = 2;
+
+ /* Initialize data */
+ if (LIST_ISEMPTY(vs->rs))
+ realtotal = 0;
+ else
+ realtotal = LIST_SIZE(vs->rs);
+ realup = 0;
+ if (!LIST_ISEMPTY(vs->rs))
+ for (e = LIST_HEAD(vs->rs); e; ELEMENT_NEXT(e))
+ if (((real_server *)ELEMENT_DATA(e))->alive)
+ realup++;
+
+ /* snmpTrapOID */
+ snmp_varlist_add_variable(¬ification_vars,
+ objid_snmptrap, objid_snmptrap_len,
+ ASN_OBJECT_ID,
+ (u_char *) notification_oid,
+ notification_oid_len * sizeof(oid));
+ if (rs) {
+ /* realServerAddrType */
+ addrtype = (rs->addr.ss_family == AF_INET6)?2:1;
+ snmp_varlist_add_variable(¬ification_vars,
+ addrtype_oid, addrtype_oid_len,
+ ASN_INTEGER,
+ (u_char *)&addrtype,
+ sizeof(addrtype));
+ /* realServerAddress */
+ snmp_varlist_add_variable(¬ification_vars,
+ address_oid, address_oid_len,
+ ASN_OCTET_STR,
+ (rs->addr.ss_family == AF_INET6)?
+ ((u_char *)&((struct sockaddr_in6 *)&rs->addr)->sin6_addr):
+ ((u_char *)&((struct sockaddr_in *)&rs->addr)->sin_addr),
+ (rs->addr.ss_family == AF_INET6)?16:4);
+ /* realServerPort */
+ port = htons(inet_sockaddrport(&rs->addr));
+ snmp_varlist_add_variable(¬ification_vars,
+ port_oid, port_oid_len,
+ ASN_UNSIGNED,
+ (u_char *)&port,
+ sizeof(port));
+ /* realServerStatus */
+ status = rs->alive?1:2;
+ snmp_varlist_add_variable(¬ification_vars,
+ status_oid, status_oid_len,
+ ASN_INTEGER,
+ (u_char *)&status,
+ sizeof(status));
+ }
+
+ /* virtualServerType */
+ if (vs->vsgname)
+ vstype = 3;
+ else if (vs->vfwmark)
+ vstype = 1;
+ else
+ vstype = 2;
+ snmp_varlist_add_variable(¬ification_vars,
+ vstype_oid, vstype_oid_len,
+ ASN_INTEGER,
+ (u_char *)&vstype,
+ sizeof(vstype));
+ if (vs->vsgname) {
+ /* virtualServerNameOfGroup */
+ snmp_varlist_add_variable(¬ification_vars,
+ vsgroupname_oid, vsgroupname_oid_len,
+ ASN_OCTET_STR,
+ (u_char *)vs->vsgname,
+ strlen(vs->vsgname));
+ } else if (vs->vfwmark) {
+ vsfwmark = vs->vfwmark;
+ snmp_varlist_add_variable(¬ification_vars,
+ vsfwmark_oid, vsfwmark_oid_len,
+ ASN_UNSIGNED,
+ (u_char *)&vsfwmark,
+ sizeof(vsfwmark));
+ } else {
+ addrtype = (vs->addr.ss_family == AF_INET6)?2:1;
+ snmp_varlist_add_variable(¬ification_vars,
+ vsaddrtype_oid, vsaddrtype_oid_len,
+ ASN_INTEGER,
+ (u_char *)&addrtype,
+ sizeof(addrtype));
+ snmp_varlist_add_variable(¬ification_vars,
+ vsaddress_oid, vsaddress_oid_len,
+ ASN_OCTET_STR,
+ (vs->addr.ss_family == AF_INET6)?
+ ((u_char *)&((struct sockaddr_in6 *)&vs->addr)->sin6_addr):
+ ((u_char *)&((struct sockaddr_in *)&vs->addr)->sin_addr),
+ (vs->addr.ss_family == AF_INET6)?16:4);
+ vsport = htons(inet_sockaddrport(&vs->addr));
+ snmp_varlist_add_variable(¬ification_vars,
+ vsport_oid, vsport_oid_len,
+ ASN_UNSIGNED,
+ (u_char *)&vsport,
+ sizeof(vsport));
+ }
+ vsprotocol = (vs->service_type == IPPROTO_TCP)?1:2;
+ snmp_varlist_add_variable(¬ification_vars,
+ vsprotocol_oid, vsprotocol_oid_len,
+ ASN_INTEGER,
+ (u_char *)&vsprotocol,
+ sizeof(vsprotocol));
+ if (!rs) {
+ quorumstatus = vs->quorum_state?1:2;
+ snmp_varlist_add_variable(¬ification_vars,
+ quorumstatus_oid, quorumstatus_oid_len,
+ ASN_INTEGER,
+ (u_char *)&quorumstatus,
+ sizeof(quorumstatus));
+ quorum = vs->quorum;
+ snmp_varlist_add_variable(¬ification_vars,
+ quorum_oid, quorum_oid_len,
+ ASN_UNSIGNED,
+ (u_char *)&quorum,
+ sizeof(quorum));
+ }
+ snmp_varlist_add_variable(¬ification_vars,
+ realup_oid, realup_oid_len,
+ ASN_UNSIGNED,
+ (u_char *)&realup,
+ sizeof(realup));
+ snmp_varlist_add_variable(¬ification_vars,
+ realtotal_oid, realtotal_oid_len,
+ ASN_UNSIGNED,
+ (u_char *)&realtotal,
+ sizeof(realtotal));
+
+ /* routerId */
+ snmp_varlist_add_variable(¬ification_vars,
+ routerId_oid, routerId_oid_len,
+ ASN_OCTET_STR,
+ (u_char *)global_data->router_id,
+ strlen(global_data->router_id));
+
+ send_v2trap(notification_vars);
+ snmp_free_varbind(notification_vars);
+}
+
+void
+check_snmp_quorum_trap(virtual_server *vs)
+{
+ check_snmp_rs_trap(NULL, vs);
+}
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/check/check_ssl.c
^
|
@@ -20,7 +20,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include <openssl/err.h>
@@ -36,7 +36,7 @@
/* SSL primitives */
/* Free an SSL context */
void
-clear_ssl(SSL_DATA * ssl)
+clear_ssl(ssl_data_t *ssl)
{
if (ssl)
if (ssl->ctx)
@@ -47,7 +47,7 @@
static int
password_cb(char *buf, int num, int rwflag, void *userdata)
{
- SSL_DATA *ssl = (SSL_DATA *) userdata;
+ ssl_data_t *ssl = (ssl_data_t *) userdata;
unsigned int plen = strlen(ssl->password);
if (num < plen + 1)
@@ -62,7 +62,7 @@
static int
build_ssl_ctx(void)
{
- SSL_DATA *ssl;
+ ssl_data_t *ssl;
/* Library initialization */
SSL_library_init();
@@ -71,12 +71,12 @@
bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
if (!check_data->ssl)
- ssl = (SSL_DATA *) MALLOC(sizeof (ssl_data));
+ ssl = (ssl_data_t *) MALLOC(sizeof(ssl_data_t));
else
ssl = check_data->ssl;
/* Initialize SSL context for SSL v2/3 */
- ssl->meth = SSLv23_method();
+ ssl->meth = (SSL_METHOD *) SSLv23_method();
ssl->ctx = SSL_CTX_new(ssl->meth);
/* return for autogen context */
@@ -134,14 +134,14 @@
int
init_ssl_ctx(void)
{
- SSL_DATA *ssl = check_data->ssl;
+ ssl_data_t *ssl = check_data->ssl;
if (!build_ssl_ctx()) {
log_message(LOG_INFO, "Error Initialize SSL, ctx Instance");
log_message(LOG_INFO, " SSL keyfile:%s", ssl->keyfile);
log_message(LOG_INFO, " SSL password:%s", ssl->password);
log_message(LOG_INFO, " SSL cafile:%s", ssl->cafile);
- log_message(LOG_INFO, "Terminate...\n");
+ log_message(LOG_INFO, "Terminate...");
clear_ssl(ssl);
return 0;
}
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/check/check_tcp.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include "check_tcp.h"
@@ -55,7 +55,7 @@
}
void
-tcp_check_handler(vector strvec)
+tcp_check_handler(vector_t *strvec)
{
tcp_checker_t *tcp_chk = (tcp_checker_t *) MALLOC(sizeof (tcp_checker_t));
@@ -65,7 +65,7 @@
}
void
-connect_port_handler(vector strvec)
+connect_port_handler(vector_t *strvec)
{
tcp_checker_t *tcp_chk = CHECKER_GET();
@@ -73,14 +73,14 @@
}
void
-bind_handler(vector strvec)
+bind_handler(vector_t *strvec)
{
tcp_checker_t *tcp_chk = CHECKER_GET();
- inet_stosockaddr(VECTOR_SLOT(strvec, 1), 0, &tcp_chk->bindto);
+ inet_stosockaddr(vector_slot(strvec, 1), 0, &tcp_chk->bindto);
}
void
-connect_timeout_handler(vector strvec)
+connect_timeout_handler(vector_t *strvec)
{
tcp_checker_t *tcp_chk = CHECKER_GET();
tcp_chk->connection_to = CHECKER_VALUE_INT(strvec) * TIMER_HZ;
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/check/ipvswrapper.c
^
|
@@ -18,7 +18,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include "ipvswrapper.h"
@@ -677,6 +677,226 @@
return IPVS_SUCCESS;
}
+#ifdef _WITH_SNMP_
+/* Update statistics for a given virtual server. This includes
+ statistics of real servers. The update is only done if we need
+ refreshing. */
+void
+ipvs_update_stats(virtual_server *vs)
+{
+ element e, ge = NULL;
+ real_server *rs;
+ virtual_server_group *vsg = NULL;
+ virtual_server_group_entry *vsg_entry = NULL;
+ uint32_t addr_ip = 0;
+ union nf_inet_addr nfaddr;
+ ipvs_service_entry_t * serv = NULL;
+ struct ip_vs_get_dests * dests = NULL;
+ int i;
+#define UPDATE_STATS_INIT 1
+#define UPDATE_STATS_VSG_IP 2
+#define UPDATE_STATS_VSG_FWMARK 4
+#define UPDATE_STATS_VSG_RANGE 6
+#define UPDATE_STATS_VSG_RANGE_IP 7
+#define UPDATE_STATS_END 99
+ int state = UPDATE_STATS_INIT;
+
+ if (time(NULL) - vs->lastupdated < STATS_REFRESH)
+ return;
+ vs->lastupdated = time(NULL);
+ /* Reset stats */
+ memset(&vs->stats, 0, sizeof(vs->stats));
+ if (vs->s_svr) {
+ memset(&vs->s_svr->stats, 0, sizeof(vs->s_svr->stats));
+ vs->s_svr->activeconns =
+ vs->s_svr->inactconns = vs->s_svr->persistconns = 0;
+ }
+ if (!LIST_ISEMPTY(vs->rs)) {
+ for (e = LIST_HEAD(vs->rs); e; ELEMENT_NEXT(e)) {
+ rs = ELEMENT_DATA(e);
+ memset(&rs->stats, 0, sizeof(rs->stats));
+ rs->activeconns = rs->inactconns = rs->persistconns = 0;
+ }
+ }
+ /* FSM: at each transition, we process "serv" if it is not NULL */
+ while (state != UPDATE_STATS_END) {
+ serv = NULL;
+ switch (state) {
+ case UPDATE_STATS_INIT:
+ /* We need to know the next state to reach */
+ if (vs->vsgname) {
+ if (!LIST_ISEMPTY(check_data->vs_group))
+ vsg = ipvs_get_group_by_name(vs->vsgname,
+ check_data->vs_group);
+ else
+ vsg = NULL;
+ if (!vsg)
+ state = UPDATE_STATS_END;
+ else {
+ state = UPDATE_STATS_VSG_IP;
+ ge = NULL;
+ }
+ continue;
+ }
+ state = UPDATE_STATS_END;
+ if (vs->vfwmark) {
+ memset(&nfaddr, 0, sizeof(nfaddr));
+ serv = ipvs_get_service(vs->vfwmark,
+ AF_INET,
+ vs->service_type,
+ nfaddr, 0);
+ break;
+ }
+ memcpy(&nfaddr, (vs->addr.ss_family == AF_INET6)?
+ (void*)(&((struct sockaddr_in6 *)&vs->addr)->sin6_addr):
+ (void*)(&((struct sockaddr_in *)&vs->addr)->sin_addr),
+ sizeof(nfaddr));
+ serv = ipvs_get_service(0,
+ vs->addr.ss_family,
+ vs->service_type,
+ nfaddr,
+ inet_sockaddrport(&vs->addr));
+ break;
+ case UPDATE_STATS_VSG_IP:
+ if (!ge)
+ ge = LIST_HEAD(vsg->addr_ip);
+ else
+ ELEMENT_NEXT(ge);
+ if (!ge) {
+ state = UPDATE_STATS_VSG_FWMARK;
+ continue;
+ }
+ vsg_entry = ELEMENT_DATA(ge);
+ memcpy(&nfaddr, (vsg_entry->addr.ss_family == AF_INET6)?
+ (void*)(&((struct sockaddr_in6 *)&vsg_entry->addr)->sin6_addr):
+ (void*)(&((struct sockaddr_in *)&vsg_entry->addr)->sin_addr),
+ sizeof(nfaddr));
+ serv = ipvs_get_service(0,
+ vsg_entry->addr.ss_family,
+ vs->service_type,
+ nfaddr,
+ inet_sockaddrport(&vsg_entry->addr));
+ break;
+ case UPDATE_STATS_VSG_FWMARK:
+ if (!ge)
+ ge = LIST_HEAD(vsg->vfwmark);
+ else
+ ELEMENT_NEXT(ge);
+ if (!ge) {
+ state = UPDATE_STATS_VSG_RANGE;
+ continue;
+ }
+ vsg_entry = ELEMENT_DATA(ge);
+ memset(&nfaddr, 0, sizeof(nfaddr));
+ serv = ipvs_get_service(vsg_entry->vfwmark,
+ AF_INET,
+ vs->service_type,
+ nfaddr, 0);
+ break;
+ case UPDATE_STATS_VSG_RANGE:
+ if (!ge)
+ ge = LIST_HEAD(vsg->range);
+ else
+ ELEMENT_NEXT(ge);
+ if (!ge) {
+ state = UPDATE_STATS_END;
+ continue;
+ }
+ vsg_entry = ELEMENT_DATA(ge);
+ addr_ip = (vsg_entry->addr.ss_family == AF_INET6) ?
+ ((struct sockaddr_in6 *)&vsg_entry->addr)->sin6_addr.s6_addr32[3]:
+ ((struct sockaddr_in *)&vsg_entry->addr)->sin_addr.s_addr;
+ state = UPDATE_STATS_VSG_RANGE_IP;
+ continue;
+ case UPDATE_STATS_VSG_RANGE_IP:
+ if (((addr_ip >> 24) & 0xFF) > vsg_entry->range) {
+ state = UPDATE_STATS_VSG_RANGE;
+ continue;
+ }
+ if (vsg_entry->addr.ss_family == AF_INET6) {
+ inet_sockaddrip6(&vsg_entry->addr, &nfaddr.in6);
+ nfaddr.in6.s6_addr32[3] = addr_ip;
+ } else {
+ nfaddr.in.s_addr = addr_ip;
+ }
+ serv = ipvs_get_service(0,
+ vsg_entry->addr.ss_family,
+ vs->service_type,
+ nfaddr,
+ inet_sockaddrport(&vsg_entry->addr));
+ addr_ip += 0x01000000;
+ break;
+ }
+ if (!serv)
+ continue;
+
+ /* Update virtual server stats */
+#define ADD_TO_VSSTATS(X) vs->stats.X += serv->stats.X;
+ ADD_TO_VSSTATS(conns);
+ ADD_TO_VSSTATS(inpkts);
+ ADD_TO_VSSTATS(outpkts);
+ ADD_TO_VSSTATS(inbytes);
+ ADD_TO_VSSTATS(outbytes);
+ ADD_TO_VSSTATS(cps);
+ ADD_TO_VSSTATS(inpps);
+ ADD_TO_VSSTATS(outpps);
+ ADD_TO_VSSTATS(inbps);
+ ADD_TO_VSSTATS(outbps);
+
+ /* Get real servers */
+ dests = ipvs_get_dests(serv);
+ if (!dests) {
+ FREE(serv);
+ return;
+ }
+ for (i = 0; i < dests->num_dests; i++) {
+ rs = NULL;
+
+#define VSD_EQUAL(entity) (((entity)->addr.ss_family == AF_INET && \
+ dests->entrytable[i].af == AF_INET && \
+ inaddr_equal(AF_INET, \
+ &dests->entrytable[i].addr, \
+ &((struct sockaddr_in *)&(entity)->addr)->sin_addr) && \
+ dests->entrytable[i].port == ((struct sockaddr_in *)&(entity)->addr)->sin_port) || \
+ ((entity)->addr.ss_family == AF_INET6 && \
+ dests->entrytable[i].af == AF_INET6 && \
+ inaddr_equal(AF_INET6, \
+ &dests->entrytable[i].addr, \
+ &((struct sockaddr_in6 *)&(entity)->addr)->sin6_addr) && \
+ dests->entrytable[i].port == ((struct sockaddr_in6 *)&(entity)->addr)->sin6_port))
+ /* Is it the sorry server? */
+ if (vs->s_svr && VSD_EQUAL(vs->s_svr))
+ rs = vs->s_svr;
+ else if (!LIST_ISEMPTY(vs->rs))
+ /* Search for a match in the list of real servers */
+ for (e = LIST_HEAD(vs->rs); e; ELEMENT_NEXT(e)) {
+ rs = ELEMENT_DATA(e);
+ if (VSD_EQUAL(rs))
+ break;
+ }
+ if (rs) {
+#define ADD_TO_RSSTATS(X) rs->X += dests->entrytable[i].X
+ ADD_TO_RSSTATS(activeconns);
+ ADD_TO_RSSTATS(inactconns);
+ ADD_TO_RSSTATS(persistconns);
+ ADD_TO_RSSTATS(stats.conns);
+ ADD_TO_RSSTATS(stats.inpkts);
+ ADD_TO_RSSTATS(stats.outpkts);
+ ADD_TO_RSSTATS(stats.inbytes);
+ ADD_TO_RSSTATS(stats.outbytes);
+ ADD_TO_RSSTATS(stats.cps);
+ ADD_TO_RSSTATS(stats.inpps);
+ ADD_TO_RSSTATS(stats.outpps);
+ ADD_TO_RSSTATS(stats.inbps);
+ ADD_TO_RSSTATS(stats.outbps);
+ }
+ }
+ FREE(dests);
+ FREE(serv);
+ }
+}
+#endif /* _WITH_SNMP_ */
+
#endif
/*
@@ -751,6 +971,10 @@
}
rc = waitpid(child, &status, 0);
+ if (rc < 0) {
+ log_message(LOG_INFO, "IPVS: waitpid error (%s)"
+ , strerror(errno));
+ }
if (!WIFEXITED(status) || WEXITSTATUS(status)) {
return 1;
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/check/ipwrapper.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include "ipwrapper.h"
@@ -27,6 +27,9 @@
#include "utils.h"
#include "notify.h"
#include "main.h"
+#ifdef _WITH_SNMP_
+ #include "check_snmp.h"
+#endif
/* Returns the sum of all RS weight in a virtual server. */
long unsigned
@@ -73,19 +76,27 @@
, ntohs(inet_sockaddrport(&vs->addr)));
notify_exec(rs->notify_down);
}
+#ifdef _WITH_SNMP_
+ check_snmp_rs_trap(rs, vs);
+#endif
/* Sooner or later VS will lose the quorum (if any). However,
* we don't push in a sorry server then, hence the regression
* is intended.
*/
- if (vs->quorum_state == UP && vs->quorum_down &&
+ if (vs->quorum_state == UP &&
weigh_live_realservers(vs) < vs->quorum - vs->hysteresis) {
vs->quorum_state = DOWN;
- log_message(LOG_INFO, "Executing [%s] for VS [%s]:%d"
- , vs->quorum_down
- , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
- , ntohs(inet_sockaddrport(&vs->addr)));
- notify_exec(vs->quorum_down);
+ if (vs->quorum_down) {
+ log_message(LOG_INFO, "Executing [%s] for VS [%s]:%d"
+ , vs->quorum_down
+ , (vs->vsgname) ? vs->vsgname : inet_sockaddrtos(&vs->addr)
+ , ntohs(inet_sockaddrport(&vs->addr)));
+ notify_exec(vs->quorum_down);
+ }
+#ifdef _WITH_SNMP_
+ check_snmp_quorum_trap(vs);
+#endif
}
}
}
@@ -122,11 +133,9 @@
element e;
list l = check_data->vs;
virtual_server *vs;
- real_server *rs;
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
vs = ELEMENT_DATA(e);
- rs = ELEMENT_DATA(LIST_HEAD(vs->rs));
if (!clear_service_vs(check_data->vs_group, vs))
return 0;
}
@@ -266,6 +275,9 @@
, ntohs(inet_sockaddrport(&vs->addr)));
notify_exec(vs->quorum_up);
}
+#ifdef _WITH_SNMP_
+ check_snmp_quorum_trap(vs);
+#endif
return;
}
@@ -303,6 +315,9 @@
/* Remove remaining alive real servers */
perform_quorum_state(vs, 0);
}
+#ifdef _WITH_SNMP_
+ check_snmp_quorum_trap(vs);
+#endif
return;
}
}
@@ -341,6 +356,9 @@
, ntohs(inet_sockaddrport(&vs->addr)));
notify_exec(rs->notify_up);
}
+#ifdef _WITH_SNMP_
+ check_snmp_rs_trap(rs, vs);
+#endif
/* We may have gained quorum */
update_quorum_state(vs);
@@ -370,6 +388,9 @@
, ntohs(inet_sockaddrport(&vs->addr)));
notify_exec(rs->notify_down);
}
+#ifdef _WITH_SNMP_
+ check_snmp_rs_trap(rs, vs);
+#endif
/* We may have lost quorum */
update_quorum_state(vs);
@@ -497,7 +518,7 @@
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\n"
+ log_message(LOG_INFO, "VS [[%s]:%d:%d:%d] in group %s no longer exist"
, inet_sockaddrtos(&vsge->addr)
, ntohs(inet_sockaddrport(&vsge->addr))
, vsge->range
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/core/Makefile.in
^
|
@@ -2,17 +2,21 @@
#
# Keepalived OpenSource project.
#
-# Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+# Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
CC = @CC@
+SNMP_FLAG = @SNMP_SUPPORT@
INCLUDES = -I../include -I../../lib
CFLAGS = @CFLAGS@ @CPPFLAGS@ $(INCLUDES) \
-Wall -Wunused -Wstrict-prototypes
-DEFS = -D@KERN@ -D@IPVS_SUPPORT@ -D@VRRP_SUPPORT@ @DFLAGS@
+DEFS = -D@KERN@ -D@IPVS_SUPPORT@ -D@VRRP_SUPPORT@ -D@SNMP_SUPPORT@ @DFLAGS@
COMPILE = $(CC) $(CFLAGS) $(DEFS)
OBJS = main.o daemon.o pidfile.o layer4.o smtp.o \
global_data.o global_parser.o
+ifeq ($(SNMP_FLAG),_WITH_SNMP_)
+ OBJS += snmp.o
+endif
HEADERS = $(OBJS:.o=.h)
.c.o:
@@ -38,3 +42,5 @@
global_parser.o: global_parser.c ../include/global_parser.h \
../include/global_data.h ../../lib/parser.h ../../lib/memory.h \
../../lib/utils.h
+snmp.o: snmp.c ../include/snmp.h ../../lib/logger.h ../../lib/list.h \
+ ../include/config.h ../include/global_data.h
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/core/daemon.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include <syslog.h>
@@ -55,8 +55,12 @@
}
/* Change directory to root. */
- if (!nochdir)
+ if (!nochdir) {
ret = chdir("/");
+ if (ret < 0) {
+ log_message(LOG_INFO, "xdaemon: chdir error");
+ }
+ }
/* File descriptor close. */
if (!noclose) {
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/core/global_data.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include <syslog.h>
@@ -31,11 +31,11 @@
#include "utils.h"
/* global vars */
-conf_data_t *data = NULL;
+conf_data_t *global_data = NULL;
/* Default settings */
static void
-set_default_router_id(conf_data_t * conf_data)
+set_default_router_id(conf_data_t * data)
{
char *new_id = NULL;
int len = 0;
@@ -45,15 +45,15 @@
return;
len = strlen(new_id);
- conf_data->router_id = MALLOC(len + 1);
- if (!conf_data->router_id)
+ data->router_id = MALLOC(len + 1);
+ if (!data->router_id)
return;
- memcpy(conf_data->router_id, new_id, len);
+ memcpy(data->router_id, new_id, len);
}
static void
-set_default_email_from(conf_data_t * conf_data)
+set_default_email_from(conf_data_t * data)
{
struct passwd *pwd = NULL;
char *hostname = NULL;
@@ -68,28 +68,28 @@
return;
len = strlen(hostname) + strlen(pwd->pw_name) + 2;
- conf_data->email_from = MALLOC(len);
- if (!conf_data->email_from)
+ data->email_from = MALLOC(len);
+ if (!data->email_from)
return;
- snprintf(conf_data->email_from, len, "%s@%s", pwd->pw_name, hostname);
+ snprintf(data->email_from, len, "%s@%s", pwd->pw_name, hostname);
}
static void
-set_default_smtp_connection_timeout(conf_data_t * conf_data)
+set_default_smtp_connection_timeout(conf_data_t * data)
{
- conf_data->smtp_connection_to = DEFAULT_SMTP_CONNECTION_TIMEOUT;
+ data->smtp_connection_to = DEFAULT_SMTP_CONNECTION_TIMEOUT;
}
static void
-set_default_values(conf_data_t * conf_data)
+set_default_values(conf_data_t * data)
{
/* No global data so don't default */
- if (!conf_data)
+ if (!data)
return;
- set_default_router_id(conf_data);
- set_default_smtp_connection_timeout(conf_data);
- set_default_email_from(conf_data);
+ set_default_router_id(data);
+ set_default_smtp_connection_timeout(data);
+ set_default_email_from(data);
}
/* email facility functions */
@@ -114,7 +114,7 @@
new = (char *) MALLOC(size + 1);
memcpy(new, addr, size + 1);
- list_add(data->email, new);
+ list_add(global_data->email, new);
}
/* data facility functions */
@@ -131,7 +131,7 @@
}
void
-free_global_data(conf_data_t * global_data)
+free_global_data(conf_data_t * data)
{
free_list(data->email);
FREE_PTR(data->router_id);
@@ -141,7 +141,7 @@
}
void
-dump_global_data(conf_data_t * global_data)
+dump_global_data(conf_data_t * data)
{
if (!data)
return;
@@ -164,4 +164,10 @@
data->email_from);
dump_list(data->email);
}
+#ifdef _WITH_SNMP_
+ if (data->enable_traps)
+ log_message(LOG_INFO, " SNMP Trap enabled");
+ else
+ log_message(LOG_INFO, " SNMP Trap disabled");
+#endif
}
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/core/global_parser.c
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include <netdb.h>
@@ -34,51 +34,58 @@
/* data handlers */
/* Global def handlers */
static void
-use_polling_handler(vector strvec)
+use_polling_handler(vector_t *strvec)
{
- data->linkbeat_use_polling = 1;
+ global_data->linkbeat_use_polling = 1;
}
static void
-routerid_handler(vector strvec)
+routerid_handler(vector_t *strvec)
{
- FREE_PTR(data->router_id);
- data->router_id = set_value(strvec);
+ FREE_PTR(global_data->router_id);
+ global_data->router_id = set_value(strvec);
}
static void
-plugin_handler(vector strvec)
+plugin_handler(vector_t *strvec)
{
- data->plugin_dir = set_value(strvec);
+ global_data->plugin_dir = set_value(strvec);
}
static void
-emailfrom_handler(vector strvec)
+emailfrom_handler(vector_t *strvec)
{
- FREE_PTR(data->email_from);
- data->email_from = set_value(strvec);
+ FREE_PTR(global_data->email_from);
+ global_data->email_from = set_value(strvec);
}
static void
-smtpto_handler(vector strvec)
+smtpto_handler(vector_t *strvec)
{
- data->smtp_connection_to = atoi(VECTOR_SLOT(strvec, 1)) * TIMER_HZ;
+ global_data->smtp_connection_to = atoi(vector_slot(strvec, 1)) * TIMER_HZ;
}
static void
-smtpip_handler(vector strvec)
+smtpip_handler(vector_t *strvec)
{
- inet_stosockaddr(VECTOR_SLOT(strvec, 1), SMTP_PORT_STR, &data->smtp_server);
+ inet_stosockaddr(vector_slot(strvec, 1), SMTP_PORT_STR, &global_data->smtp_server);
}
static void
-email_handler(vector strvec)
+email_handler(vector_t *strvec)
{
- vector email_vec = read_value_block();
+ vector_t *email_vec = read_value_block();
int i;
char *str;
- for (i = 0; i < VECTOR_SIZE(email_vec); i++) {
- str = VECTOR_SLOT(email_vec, i);
+ for (i = 0; i < vector_size(email_vec); i++) {
+ str = vector_slot(email_vec, i);
alloc_email(str);
}
free_strvec(email_vec);
}
+#ifdef _WITH_SNMP_
+static void
+trap_handler(vector_t *strvec)
+{
+ global_data->enable_traps = 1;
+}
+#endif
void
global_init_keywords(void)
@@ -92,4 +99,7 @@
install_keyword("smtp_server", &smtpip_handler);
install_keyword("smtp_connect_timeout", &smtpto_handler);
install_keyword("notification_email", &email_handler);
+#ifdef _WITH_SNMP_
+ install_keyword("enable_traps", &trap_handler);
+#endif
}
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/core/layer4.c
^
|
@@ -18,7 +18,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include "layer4.h"
@@ -82,7 +82,7 @@
int status;
socklen_t addrlen;
int ret = 0;
- TIMEVAL timer_min;
+ timeval_t timer_min;
/* Handle connection timeout */
if (thread->type == THREAD_WRITE_TIMEOUT) {
@@ -109,7 +109,7 @@
if (status == EINPROGRESS) {
timer_min = timer_sub_now(thread->sands);
thread_add_write(thread->master, func, THREAD_ARG(thread),
- thread->u.fd, TIMER_LONG(timer_min));
+ thread->u.fd, timer_long(timer_min));
return connect_in_progress;
} else if (status != 0) {
close(thread->u.fd);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/core/main.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include "main.h"
@@ -36,6 +36,9 @@
char *main_pidfile = KEEPALIVED_PID_FILE; /* overrule default pidfile */
char *checkers_pidfile = CHECKERS_PID_FILE; /* overrule default pidfile */
char *vrrp_pidfile = VRRP_PID_FILE; /* overrule default pidfile */
+#ifdef _WITH_SNMP_
+int snmp = 0; /* Enable SNMP support */
+#endif
/* Log facility table */
static struct {
@@ -101,7 +104,6 @@
int status;
/* register the terminate thread */
- log_message(LOG_INFO, "Terminating on signal");
thread_add_terminate_event(master);
if (vrrp_child > 0) {
@@ -151,12 +153,18 @@
" %s --log-console -l Log message to local console.\n"
" %s --log-detail -D Detailed log messages.\n"
" %s --log-facility -S 0-7 Set syslog facility to LOG_LOCAL[0-7]. (default=LOG_DAEMON)\n"
+#ifdef _WITH_SNMP_
+ " %s --snmp -x Enable SNMP subsystem\n"
+#endif
" %s --help -h Display this short inlined help screen.\n"
" %s --version -v Display the version number\n"
" %s --pid -p pidfile\n"
" %s --checkers_pid -c checkers pidfile\n"
" %s --vrrp_pid -r vrrp pidfile\n",
prog, prog, prog, prog, prog, prog, prog, prog,
+#ifdef _WITH_SNMP_
+ prog,
+#endif
prog, prog, prog, prog, prog, prog, prog);
}
@@ -184,6 +192,9 @@
{"pid", 'p', POPT_ARG_STRING, &option_arg, 'p'},
{"checkers_pid", 'c', POPT_ARG_STRING, &option_arg, 'c'},
{"vrrp_pid", 'r', POPT_ARG_STRING, &option_arg, 'r'},
+#ifdef _WITH_SNMP_
+ {"snmp", 'x', POPT_ARG_NONE, NULL, 'x'},
+#endif
{NULL, 0, 0, NULL, 0}
};
@@ -242,6 +253,11 @@
case 'r':
vrrp_pidfile = option_arg;
break;
+#ifdef _WITH_SNMP_
+ case 'x':
+ snmp = 1;
+ break;
+#endif
}
/* the others */
@@ -287,6 +303,11 @@
case 'r':
vrrp_pidfile = option_arg;
break;
+#ifdef _WITH_SNMP_
+ case 'x':
+ snmp = 1;
+ break;
+#endif
}
}
@@ -314,7 +335,7 @@
*/
parse_cmdline(argc, argv);
- openlog(PROG, LOG_PID | (debug & 1) ? LOG_CONS : 0, log_facility);
+ openlog(PROG, LOG_PID | ((debug & 1) ? LOG_CONS : 0), log_facility);
log_message(LOG_INFO, "Starting " VERSION_STRING);
/* Check if keepalived is already running */
@@ -323,6 +344,9 @@
goto end;
}
+ if (debug & 1)
+ enable_console_log();
+
/* daemonize process */
if (!(debug & 2))
xdaemon(0, 0, 0);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/core/pidfile.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include <sys/types.h>
@@ -67,6 +67,9 @@
return 0;
ret = fscanf(pidfile, "%d", &pid);
+ if (ret == EOF && ferror(pidfile) != 0) {
+ log_message(LOG_INFO, "Error opening pid file %s", pid_file);
+ }
fclose(pidfile);
/* If no process is attached to pidfile, remove it */
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/core/smtp.c
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include <time.h>
@@ -86,7 +86,7 @@
static char *
fetch_next_email(smtp_thread_arg * smtp_arg)
{
- return list_element(data->email, smtp_arg->email_it);
+ return list_element(global_data->email, smtp_arg->email_it);
}
/* layer4 connection handlers */
@@ -96,7 +96,7 @@
smtp_thread_arg *smtp_arg = THREAD_ARG(thread);
log_message(LOG_INFO, "SMTP connection ERROR to [%s]:%d."
- , inet_sockaddrtos(&data->smtp_server), SMTP_PORT);
+ , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
free_smtp_all(smtp_arg);
return 0;
}
@@ -106,7 +106,7 @@
smtp_thread_arg *smtp_arg = THREAD_ARG(thread);
log_message(LOG_INFO, "Timeout connecting SMTP server [%s]:%d."
- , inet_sockaddrtos(&data->smtp_server), SMTP_PORT);
+ , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
free_smtp_all(smtp_arg);
return 0;
}
@@ -116,7 +116,7 @@
int status;
DBG("SMTP connection to [%s]:%d now IN_PROGRESS.",
- inet_sockaddrtos(&data->smtp_server), SMTP_PORT);
+ inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
/*
* Here we use the propriety of a union structure,
@@ -135,11 +135,11 @@
smtp_thread_arg *smtp_arg = THREAD_ARG(thread);
log_message(LOG_INFO, "Remote SMTP server [%s]:%d connected."
- , inet_sockaddrtos(&data->smtp_server), SMTP_PORT);
+ , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
smtp_arg->stage = connect_success;
thread_add_read(thread->master, smtp_read_thread, smtp_arg,
- smtp_arg->fd, data->smtp_connection_to);
+ smtp_arg->fd, global_data->smtp_connection_to);
return 0;
}
@@ -157,7 +157,7 @@
if (thread->type == THREAD_READ_TIMEOUT) {
log_message(LOG_INFO, "Timeout reading data to remote SMTP server [%s]:%d."
- , inet_sockaddrtos(&data->smtp_server), SMTP_PORT);
+ , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
SMTP_FSM_READ(QUIT, thread, 0);
return -1;
}
@@ -171,7 +171,7 @@
if (errno == EAGAIN)
goto end;
log_message(LOG_INFO, "Error reading data from remote SMTP server [%s]:%d."
- , inet_sockaddrtos(&data->smtp_server), SMTP_PORT);
+ , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
SMTP_FSM_READ(QUIT, thread, 0);
return 0;
}
@@ -180,7 +180,7 @@
if (smtp_arg->buflen >= SMTP_BUFFER_MAX) {
log_message(LOG_INFO, "Received buffer from remote SMTP server [%s]:%d"
" overflow our get read buffer length."
- , inet_sockaddrtos(&data->smtp_server), SMTP_PORT);
+ , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
SMTP_FSM_READ(QUIT, thread, 0);
return 0;
} else {
@@ -204,7 +204,7 @@
thread_add_read(thread->master, smtp_read_thread,
smtp_arg, thread->u.fd,
- data->smtp_connection_to);
+ global_data->smtp_connection_to);
return 0;
}
@@ -226,7 +226,7 @@
if (status == -1) {
thread_add_read(thread->master, smtp_read_thread, smtp_arg,
- thread->u.fd, data->smtp_connection_to);
+ thread->u.fd, global_data->smtp_connection_to);
return 0;
}
@@ -235,10 +235,10 @@
/* Registering next smtp command processing thread */
if (smtp_arg->stage != ERROR) {
thread_add_write(thread->master, smtp_send_thread, smtp_arg,
- smtp_arg->fd, data->smtp_connection_to);
+ smtp_arg->fd, global_data->smtp_connection_to);
} else {
log_message(LOG_INFO, "Can not read data from remote SMTP server [%s]:%d."
- , inet_sockaddrtos(&data->smtp_server), SMTP_PORT);
+ , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
SMTP_FSM_READ(QUIT, thread, 0);
}
@@ -252,7 +252,7 @@
if (thread->type == THREAD_WRITE_TIMEOUT) {
log_message(LOG_INFO, "Timeout sending data to remote SMTP server [%s]:%d."
- , inet_sockaddrtos(&data->smtp_server), SMTP_PORT);
+ , inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
SMTP_FSM_READ(QUIT, thread, 0);
return 0;
}
@@ -268,11 +268,11 @@
/* Registering next smtp command processing thread */
if (smtp_arg->stage != ERROR) {
thread_add_read(thread->master, smtp_read_thread, smtp_arg,
- thread->u.fd, data->smtp_connection_to);
+ 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(&data->smtp_server), SMTP_PORT);
+ inet_sockaddrtos(&global_data->smtp_server), SMTP_PORT);
SMTP_FSM_READ(QUIT, thread, 0);
}
@@ -288,7 +288,7 @@
smtp_arg->stage++;
} else {
log_message(LOG_INFO, "Error connecting SMTP server[%s]:%d."
- " SMTP status code = %d", inet_sockaddrtos(&data->smtp_server),
+ " SMTP status code = %d", inet_sockaddrtos(&global_data->smtp_server),
SMTP_PORT, status);
smtp_arg->stage = ERROR;
}
@@ -321,7 +321,7 @@
} else {
log_message(LOG_INFO,
"Error processing HELO cmd on SMTP server [%s]:%d."
- " SMTP status code = %d", inet_sockaddrtos(&data->smtp_server),
+ " SMTP status code = %d", inet_sockaddrtos(&global_data->smtp_server),
SMTP_PORT, status);
smtp_arg->stage = ERROR;
}
@@ -337,7 +337,7 @@
char *buffer;
buffer = (char *) MALLOC(SMTP_BUFFER_MAX);
- snprintf(buffer, SMTP_BUFFER_MAX, SMTP_MAIL_CMD, data->email_from);
+ snprintf(buffer, SMTP_BUFFER_MAX, SMTP_MAIL_CMD, global_data->email_from);
if (send(thread->u.fd, buffer, strlen(buffer), 0) == -1)
smtp_arg->stage = ERROR;
FREE(buffer);
@@ -354,7 +354,7 @@
} else {
log_message(LOG_INFO,
"Error processing MAIL cmd on SMTP server [%s]:%d."
- " SMTP status code = %d", inet_sockaddrtos(&data->smtp_server),
+ " SMTP status code = %d", inet_sockaddrtos(&global_data->smtp_server),
SMTP_PORT, status);
smtp_arg->stage = ERROR;
}
@@ -399,7 +399,7 @@
} else {
log_message(LOG_INFO,
"Error processing RCPT cmd on SMTP server [%s]:%d."
- " SMTP status code = %d", inet_sockaddrtos(&data->smtp_server),
+ " SMTP status code = %d", inet_sockaddrtos(&global_data->smtp_server),
SMTP_PORT, status);
smtp_arg->stage = ERROR;
}
@@ -427,7 +427,7 @@
} else {
log_message(LOG_INFO,
"Error processing DATA cmd on SMTP server [%s]:%d."
- " SMTP status code = %d", inet_sockaddrtos(&data->smtp_server),
+ " SMTP status code = %d", inet_sockaddrtos(&global_data->smtp_server),
SMTP_PORT, status);
smtp_arg->stage = ERROR;
}
@@ -453,7 +453,7 @@
strftime(rfc822, sizeof(rfc822), "%a, %d %b %Y %H:%M:%S %z", gmtime(&tm));
snprintf(buffer, SMTP_BUFFER_MAX, SMTP_HEADERS_CMD,
- rfc822, data->email_from, smtp_arg->subject);
+ rfc822, global_data->email_from, smtp_arg->subject);
/* send the subject field */
if (send(thread->u.fd, buffer, strlen(buffer), 0) == -1)
@@ -485,7 +485,7 @@
} else {
log_message(LOG_INFO,
"Error processing DOT cmd on SMTP server [%s]:%d."
- " SMTP status code = %d", inet_sockaddrtos(&data->smtp_server),
+ " SMTP status code = %d", inet_sockaddrtos(&global_data->smtp_server),
SMTP_PORT, status);
smtp_arg->stage = ERROR;
}
@@ -522,13 +522,13 @@
{
enum connect_result status;
- if ((smtp_arg->fd = socket(data->smtp_server.ss_family, SOCK_STREAM, IPPROTO_TCP)) == -1) {
+ if ((smtp_arg->fd = socket(global_data->smtp_server.ss_family, SOCK_STREAM, IPPROTO_TCP)) == -1) {
DBG("SMTP connect fail to create socket.");
free_smtp_all(smtp_arg);
return;
}
- status = tcp_connect(smtp_arg->fd, &data->smtp_server);
+ status = tcp_connect(smtp_arg->fd, &global_data->smtp_server);
/* Handle connection status code */
thread_add_event(master, SMTP_FSM[status].send, smtp_arg, smtp_arg->fd);
@@ -542,7 +542,7 @@
smtp_thread_arg *smtp_arg;
/* Only send mail if email specified */
- if (!LIST_ISEMPTY(data->email) && data->smtp_server.ss_family != 0) {
+ if (!LIST_ISEMPTY(global_data->email) && global_data->smtp_server.ss_family != 0) {
/* allocate & initialize smtp argument data structure */
smtp_arg = (smtp_thread_arg *) MALLOC(sizeof (smtp_thread_arg));
smtp_arg->subject = (char *) MALLOC(MAX_HEADERS_LENGTH);
@@ -552,20 +552,20 @@
/* format subject if rserver is specified */
if (rs) {
snprintf(smtp_arg->subject, MAX_HEADERS_LENGTH, "[%s] Realserver [%s]:%d - %s"
- , data->router_id, inet_sockaddrtos(&rs->addr)
+ , global_data->router_id, inet_sockaddrtos(&rs->addr)
, ntohs(inet_sockaddrport(&rs->addr))
, subject);
} else if (vrrp)
snprintf(smtp_arg->subject, MAX_HEADERS_LENGTH,
"[%s] VRRP Instance %s - %s",
- data->router_id, vrrp->iname, subject);
+ global_data->router_id, vrrp->iname, subject);
else if (vgroup)
snprintf(smtp_arg->subject, MAX_HEADERS_LENGTH,
"[%s] VRRP Group %s - %s",
- data->router_id, vgroup->gname, subject);
- else if (data->router_id)
+ global_data->router_id, vgroup->gname, subject);
+ else if (global_data->router_id)
snprintf(smtp_arg->subject, MAX_HEADERS_LENGTH,
- "[%s] %s", data->router_id, subject);
+ "[%s] %s", global_data->router_id, subject);
else
snprintf(smtp_arg->subject, MAX_HEADERS_LENGTH, "%s",
subject);
|
[-]
[+]
|
Added |
keepalived-1.2.7.tar.bz2/keepalived/core/snmp.c
^
|
@@ -0,0 +1,250 @@
+/*
+ * Soft: Keepalived is a failover program for the LVS project
+ * <www.linuxvirtualserver.org>. It monitor & manipulate
+ * a loadbalanced server pool using multi-layer checks.
+ *
+ * Part: SNMP framework
+ *
+ * Authors: Vincent Bernat <bernat@luffy.cx>
+ *
+ * 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>
+ */
+
+#include "snmp.h"
+#include "logger.h"
+#include "config.h"
+#include "global_data.h"
+
+static int
+snmp_keepalived_log(int major, int minor, void *serverarg, void *clientarg)
+{
+ struct snmp_log_message *slm = (struct snmp_log_message*)serverarg;
+ log_message(slm->priority, "%s", slm->msg);
+ return 0;
+}
+
+/* Convert linux scope to InetScopeType */
+unsigned long
+snmp_scope(int scope)
+{
+ switch (scope) {
+ case 0: return 14; /* global */
+ case 255: return 0; /* nowhere */
+ case 254: return 1; /* host */
+ case 253: return 2; /* link */
+ case 200: return 5; /* site */
+ default: return 0;
+ }
+ return 0;
+}
+
+void*
+snmp_header_list_table(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method, list dlist)
+{
+ element e;
+ void *scr;
+ unsigned int target, current;
+
+ if (header_simple_table(vp, name, length, exact, var_len, write_method, -1))
+ return NULL;
+
+ if (LIST_ISEMPTY(dlist))
+ return NULL;
+
+ target = name[*length - 1];
+ current = 0;
+
+ for (e = LIST_HEAD(dlist); e; ELEMENT_NEXT(e)) {
+ scr = ELEMENT_DATA(e);
+ current++;
+ if (current == target)
+ /* Exact match */
+ return scr;
+ if (current < target)
+ /* No match found yet */
+ continue;
+ if (exact)
+ /* No exact match found */
+ return NULL;
+ /* current is the best match */
+ name[*length - 1] = current;
+ return scr;
+ }
+ /* No macth found at end */
+ return NULL;
+}
+
+#define SNMP_KEEPALIVEDVERSION 1
+#define SNMP_ROUTERID 2
+#define SNMP_MAIL_SMTPSERVERADDRESSTYPE 3
+#define SNMP_MAIL_SMTPSERVERADDRESS 4
+#define SNMP_MAIL_SMTPSERVERTIMEOUT 5
+#define SNMP_MAIL_EMAILFROM 6
+#define SNMP_MAIL_EMAILADDRESS 7
+#define SNMP_TRAPS 8
+#define SNMP_LINKBEAT 9
+
+static u_char*
+snmp_scalar(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method)
+{
+ static unsigned long long_ret;
+ static char version[] = VERSION_STRING;
+
+ if (header_generic(vp, name, length, exact, var_len, write_method))
+ return NULL;
+
+ switch (vp->magic) {
+ case SNMP_KEEPALIVEDVERSION:
+ *var_len = sizeof(version) - 2;
+ return (u_char *)version;
+ case SNMP_ROUTERID:
+ if (!global_data->router_id) return NULL;
+ *var_len = strlen(global_data->router_id);
+ return (u_char *)global_data->router_id;
+ case SNMP_MAIL_SMTPSERVERADDRESSTYPE:
+ long_ret = (global_data->smtp_server.ss_family == AF_INET6)?2:1;
+ return (u_char *)&long_ret;
+ case SNMP_MAIL_SMTPSERVERADDRESS:
+ if (global_data->smtp_server.ss_family == AF_INET6) {
+ struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&global_data->smtp_server;
+ *var_len = 16;
+ return (u_char *)&addr6->sin6_addr;
+ } else {
+ struct sockaddr_in *addr4 = (struct sockaddr_in *)&global_data->smtp_server;
+ *var_len = 4;
+ return (u_char *)&addr4->sin_addr;
+ }
+ return NULL;
+ case SNMP_MAIL_SMTPSERVERTIMEOUT:
+ long_ret = global_data->smtp_connection_to / TIMER_HZ;
+ return (u_char *)&long_ret;
+ case SNMP_MAIL_EMAILFROM:
+ if (!global_data->email_from) return NULL;
+ *var_len = strlen(global_data->email_from);
+ return (u_char *)global_data->email_from;
+ case SNMP_TRAPS:
+ long_ret = global_data->enable_traps?1:2;
+ return (u_char *)&long_ret;
+ case SNMP_LINKBEAT:
+ long_ret = global_data->linkbeat_use_polling?2:1;
+ return (u_char *)&long_ret;
+ default:
+ break;
+ }
+ return NULL;
+}
+
+static u_char*
+snmp_mail(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method)
+{
+ char *m;
+ if ((m = (char *)snmp_header_list_table(vp, name, length, exact,
+ var_len, write_method,
+ global_data->email)) == NULL)
+ return NULL;
+
+ switch (vp->magic) {
+ case SNMP_MAIL_EMAILADDRESS:
+ *var_len = strlen(m);
+ return (u_char *)m;
+ default:
+ break;
+ }
+ return NULL;
+}
+
+static oid global_oid[] = GLOBAL_OID;
+static struct variable8 global_vars[] = {
+ /* version */
+ {SNMP_KEEPALIVEDVERSION, ASN_OCTET_STR, RONLY, snmp_scalar, 1, {1}},
+ /* routerId */
+ {SNMP_ROUTERID, ASN_OCTET_STR, RONLY, snmp_scalar, 1, {2}},
+ /* mail */
+ {SNMP_MAIL_SMTPSERVERADDRESSTYPE, ASN_INTEGER, RONLY, snmp_scalar, 2, {3, 1}},
+ {SNMP_MAIL_SMTPSERVERADDRESS, ASN_OCTET_STR, RONLY, snmp_scalar, 2, {3, 2}},
+ {SNMP_MAIL_SMTPSERVERTIMEOUT, ASN_UNSIGNED, RONLY, snmp_scalar, 2, {3, 3}},
+ {SNMP_MAIL_EMAILFROM, ASN_OCTET_STR, RONLY, snmp_scalar, 2, {3, 4}},
+ /* emailTable */
+ {SNMP_MAIL_EMAILADDRESS, ASN_OCTET_STR, RONLY, snmp_mail, 4, {3, 5, 1, 2}},
+ /* trapEnable */
+ {SNMP_TRAPS, ASN_INTEGER, RONLY, snmp_scalar, 1, {4}},
+ /* linkBeat */
+ {SNMP_LINKBEAT, ASN_INTEGER, RONLY, snmp_scalar, 1, {5}},
+};
+
+static int
+snmp_setup_session_cb(int majorID, int minorID,
+ void *serverarg, void *clientarg)
+{
+ netsnmp_session *sess = serverarg;
+ if (serverarg == NULL)
+ return 0;
+ /* Because ping are done synchronously, we do everything to
+ avoid to block too long. Better disconnect from the master
+ agent than waiting for him... */
+ sess->timeout = ONE_SEC / 3;
+ sess->retries = 0;
+ return 0;
+}
+
+void
+snmp_agent_init(oid *myoid, int len, char *name, struct variable *variables,
+ int varsize, int varlen)
+{
+ log_message(LOG_INFO, "Starting SNMP subagent");
+ netsnmp_enable_subagent();
+ snmp_disable_log();
+ snmp_enable_calllog();
+ snmp_register_callback(SNMP_CALLBACK_LIBRARY,
+ SNMP_CALLBACK_LOGGING,
+ snmp_keepalived_log,
+ NULL);
+
+ /* Do not handle persistent states */
+ netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
+ NETSNMP_DS_LIB_DONT_PERSIST_STATE, TRUE);
+ /* Do not load any MIB */
+ setenv("MIBS", "", 1);
+ /* Ping AgentX less often than every 15 seconds: pinging can
+ block keepalived. We check every 2 minutes. */
+ netsnmp_ds_set_int(NETSNMP_DS_APPLICATION_ID,
+ NETSNMP_DS_AGENT_AGENTX_PING_INTERVAL, 120);
+ /* We also register a callback to modify default timeout and
+ retries value. */
+ snmp_register_callback(SNMP_CALLBACK_LIBRARY,
+ SNMP_CALLBACK_SESSION_INIT,
+ snmp_setup_session_cb, NULL);
+
+ init_agent(name);
+ if (register_mib(name, (struct variable *) variables, varsize,
+ varlen, myoid, len) != MIB_REGISTERED_OK)
+ log_message(LOG_WARNING, "Unable to register MIB");
+ register_mib("Keepalived", (struct variable *) global_vars,
+ sizeof(struct variable8),
+ sizeof(global_vars)/sizeof(struct variable8),
+ global_oid, OID_LENGTH(global_oid));
+ init_snmp(name);
+
+ register_sysORTable(global_oid, OID_LENGTH(global_oid) - 1,
+ "The MIB module for Keepalived");
+}
+
+void
+snmp_agent_close(oid *myoid, int len, char *name)
+{
+ unregister_sysORTable(myoid, len);
+ snmp_shutdown(name);
+}
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/check_api.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _CHECK_API_H
@@ -47,7 +47,7 @@
#define CHECKER_ARG(X) ((X)->data)
#define CHECKER_DATA(X) (((checker_t *)X)->data)
#define CHECKER_GET() (CHECKER_DATA(LIST_TAIL_DATA(checkers_queue)))
-#define CHECKER_VALUE_INT(X) (atoi(VECTOR_SLOT(X,1)))
+#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))
#define CHECKER_ENABLED(C) ((C)->enabled)
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/check_daemon.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _CHECK_DAEMON_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/check_data.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _CHECK_DATA_H
@@ -55,8 +55,7 @@
#define KEEPALIVED_DEFAULT_DELAY (60 * TIMER_HZ)
/* SSL specific data */
-typedef struct _ssl_data SSL_DATA;
-typedef struct _ssl_data {
+typedef struct ssl_data {
int enable;
int strong_check;
SSL_CTX *ctx;
@@ -65,7 +64,7 @@
char *cafile;
char *certfile;
char *keyfile;
-} ssl_data;
+} ssl_data_t;
/* Real Server definition */
typedef struct _real_server {
@@ -84,6 +83,13 @@
int alive;
list failed_checkers; /* List of failed checkers */
int set; /* in the IPVS table */
+#if defined(_WITH_SNMP_) && defined(_KRNL_2_6_) && defined(_WITH_LVS_)
+ /* Statistics */
+ uint32_t activeconns; /* active connections */
+ uint32_t inactconns; /* inactive connections */
+ uint32_t persistconns; /* persistent connections */
+ struct ip_vs_stats_user stats;
+#endif
} real_server;
/* Virtual Server group definition */
@@ -126,11 +132,16 @@
long unsigned hysteresis; /* up/down events "lag" WRT quorum. */
unsigned quorum_state; /* Reflects result of the last transition done. */
+#if defined(_WITH_SNMP_) && defined(_KRNL_2_6_) && defined(_WITH_LVS_)
+ /* Statistics */
+ time_t lastupdated;
+ struct ip_vs_stats_user stats;
+#endif
} virtual_server;
/* Configuration data root */
typedef struct _check_conf_data {
- SSL_DATA *ssl;
+ ssl_data_t *ssl;
list vs_group;
list vs;
} check_conf_data;
@@ -166,7 +177,8 @@
if ((a1->sin_addr.s_addr == a2->sin_addr.s_addr) &&
(a1->sin_port == a2->sin_port))
return 1;
- }
+ } else if (s1->ss_family == AF_UNSPEC)
+ return 1;
return 0;
}
@@ -220,10 +232,10 @@
extern check_conf_data *old_check_data;
/* prototypes */
-extern SSL_DATA *alloc_ssl(void);
+extern ssl_data_t *alloc_ssl(void);
extern void free_ssl(void);
extern void alloc_vsg(char *);
-extern void alloc_vsg_entry(vector);
+extern void alloc_vsg_entry(vector_t *);
extern void alloc_vs(char *, char *);
extern void alloc_rs(char *, char *);
extern void alloc_ssvr(char *, char *);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/check_http.h
^
|
@@ -18,7 +18,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _CHECK_HTTP_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/check_misc.h
^
|
@@ -18,7 +18,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _CHECK_MISC_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/check_parser.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _CHECK_PARSER_H
@@ -27,6 +27,6 @@
#include "vector.h"
/* Prototypes */
-extern vector check_init_keywords(void);
+extern vector_t *check_init_keywords(void);
#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/check_smtp.h
^
|
@@ -18,7 +18,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _CHECK_SMTP_H
|
[-]
[+]
|
Added |
keepalived-1.2.7.tar.bz2/keepalived/include/check_snmp.h
^
|
@@ -0,0 +1,132 @@
+/*
+ * Soft: Vrrpd is an implementation of VRRPv2 as specified in rfc2338.
+ * VRRP is a protocol which elect a master server on a LAN. If the
+ * master fails, a backup server takes over.
+ * The original implementation has been made by jerome etienne.
+ *
+ * Part: check_snmp.c program include file.
+ *
+ * Author: Vincent Bernat <bernat@luffy.cx>
+ *
+ * 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 _CHECK_SNMP_H
+#define _CHECK_SNMP_H
+
+#include "snmp.h"
+
+/* CHECK SNMP defines */
+#define CHECK_OID KEEPALIVED_OID, 3
+
+#define CHECK_SNMP_VSGROUPNAME 1
+#define CHECK_SNMP_VSGROUPMEMBERTYPE 3
+#define CHECK_SNMP_VSGROUPMEMBERFWMARK 4
+#define CHECK_SNMP_VSGROUPMEMBERADDRTYPE 5
+#define CHECK_SNMP_VSGROUPMEMBERADDRESS 6
+#define CHECK_SNMP_VSGROUPMEMBERADDR1 7
+#define CHECK_SNMP_VSGROUPMEMBERADDR2 8
+#define CHECK_SNMP_VSGROUPMEMBERPORT 9
+#define CHECK_SNMP_VSTYPE 10
+#define CHECK_SNMP_VSNAMEGROUP 14
+#define CHECK_SNMP_VSFWMARK 11
+#define CHECK_SNMP_VSADDRTYPE 12
+#define CHECK_SNMP_VSADDRESS 13
+#define CHECK_SNMP_VSPORT 16
+#define CHECK_SNMP_VSPROTOCOL 17
+#define CHECK_SNMP_VSLOADBALANCINGALGO 18
+#define CHECK_SNMP_VSLOADBALANCINGKIND 19
+#define CHECK_SNMP_VSSTATUS 20
+#define CHECK_SNMP_VSVIRTUALHOST 21
+#define CHECK_SNMP_VSPERSIST 22
+#define CHECK_SNMP_VSPERSISTTIMEOUT 23
+#define CHECK_SNMP_VSPERSISTGRANULARITY 24
+#define CHECK_SNMP_VSDELAYLOOP 25
+#define CHECK_SNMP_VSHASUSPEND 26
+#define CHECK_SNMP_VSALPHA 27
+#define CHECK_SNMP_VSOMEGA 28
+#define CHECK_SNMP_VSQUORUM 29
+#define CHECK_SNMP_VSQUORUMSTATUS 30
+#define CHECK_SNMP_VSQUORUMUP 31
+#define CHECK_SNMP_VSQUORUMDOWN 32
+#define CHECK_SNMP_VSHYSTERESIS 33
+#define CHECK_SNMP_VSREALTOTAL 34
+#define CHECK_SNMP_VSREALUP 35
+#define CHECK_SNMP_VSSTATSCONNS 61
+#define CHECK_SNMP_VSSTATSINPKTS 62
+#define CHECK_SNMP_VSSTATSOUTPKTS 63
+#define CHECK_SNMP_VSSTATSINBYTES 64
+#define CHECK_SNMP_VSSTATSOUTBYTES 65
+#define CHECK_SNMP_VSRATECPS 66
+#define CHECK_SNMP_VSRATEINPPS 67
+#define CHECK_SNMP_VSRATEOUTPPS 68
+#define CHECK_SNMP_VSRATEINBPS 69
+#define CHECK_SNMP_VSRATEOUTBPS 70
+#define CHECK_SNMP_RSTYPE 36
+#define CHECK_SNMP_RSADDRTYPE 37
+#define CHECK_SNMP_RSADDRESS 38
+#define CHECK_SNMP_RSPORT 39
+#define CHECK_SNMP_RSSTATUS 40
+#define CHECK_SNMP_RSWEIGHT 41
+#define CHECK_SNMP_RSUPPERCONNECTIONLIMIT 42
+#define CHECK_SNMP_RSLOWERCONNECTIONLIMIT 43
+#define CHECK_SNMP_RSACTIONWHENDOWN 44
+#define CHECK_SNMP_RSNOTIFYUP 45
+#define CHECK_SNMP_RSNOTIFYDOWN 46
+#define CHECK_SNMP_RSFAILEDCHECKS 47
+#define CHECK_SNMP_RSSTATSCONNS 48
+#define CHECK_SNMP_RSSTATSACTIVECONNS 49
+#define CHECK_SNMP_RSSTATSINACTIVECONNS 50
+#define CHECK_SNMP_RSSTATSPERSISTENTCONNS 51
+#define CHECK_SNMP_RSSTATSINPKTS 52
+#define CHECK_SNMP_RSSTATSOUTPKTS 53
+#define CHECK_SNMP_RSSTATSINBYTES 54
+#define CHECK_SNMP_RSSTATSOUTBYTES 55
+#define CHECK_SNMP_RSRATECPS 56
+#define CHECK_SNMP_RSRATEINPPS 57
+#define CHECK_SNMP_RSRATEOUTPPS 58
+#define CHECK_SNMP_RSRATEINBPS 59
+#define CHECK_SNMP_RSRATEOUTBPS 60
+
+#define STATE_VSGM_FWMARK 1
+#define STATE_VSGM_ADDRESS 2
+#define STATE_VSGM_RANGE 3
+#define STATE_VSGM_END 4
+
+#define STATE_RS_SORRY 1
+#define STATE_RS_REGULAR_FIRST 2
+#define STATE_RS_REGULAR_NEXT 3
+#define STATE_RS_END 4
+
+/* Macro */
+#define RETURN_IP46ADDRESS(entity) \
+do { \
+ if (entity->addr.ss_family == AF_INET6) { \
+ struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&entity->addr; \
+ *var_len = 16; \
+ return (u_char *)&addr6->sin6_addr; \
+ } else { \
+ struct sockaddr_in *addr4 = (struct sockaddr_in *)&entity->addr; \
+ *var_len = 4; \
+ return (u_char *)&addr4->sin_addr; \
+ } \
+} while(0)
+
+
+/* Prototypes */
+extern void check_snmp_agent_init(void);
+extern void check_snmp_agent_close(void);
+extern void check_snmp_rs_trap(real_server *, virtual_server *);
+extern void check_snmp_quorum_trap(virtual_server *);
+
+#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/check_ssl.h
^
|
@@ -18,7 +18,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _CHECK_SSL_H
@@ -30,7 +30,7 @@
/* Prototypes */
extern void install_ssl_check_keyword(void);
extern int init_ssl_ctx(void);
-extern void clear_ssl(SSL_DATA *);
+extern void clear_ssl(ssl_data_t *);
extern int ssl_connect(thread_t *, int);
extern int ssl_printerr(int);
extern int ssl_send_request(SSL *, char *, int);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/check_tcp.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _CHECK_TCP_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/config.h.in
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _CONFIG_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/daemon.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _DAEMON_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/global_data.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _GLOBAL_DATA_H
@@ -51,10 +51,13 @@
struct sockaddr_storage smtp_server;
long smtp_connection_to;
list email;
+#ifdef _WITH_SNMP_
+ int enable_traps;
+#endif
} conf_data_t;
/* Global vars exported */
-extern conf_data_t *data; /* Global configuration data */
+extern conf_data_t *global_data; /* Global configuration data */
/* Prototypes */
extern void alloc_email(char *);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/global_parser.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _GLOBAL_PARSER_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/ipvswrapper.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _IPVSWRAPPER_H
@@ -98,4 +98,10 @@
extern void ipvs_syncd_master(char *, int);
extern void ipvs_syncd_backup(char *, int);
+#ifdef _KRNL_2_6_
+/* Refresh statistics at most every 5 seconds */
+#define STATS_REFRESH 5
+extern void ipvs_update_stats(virtual_server * vs);
+#endif
+
#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/ipwrapper.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _IPWRAPPER_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/layer4.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _LAYER4_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/main.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _MAIN_H
@@ -46,5 +46,8 @@
extern pid_t checkers_child; /* Healthcheckers child process ID */
extern int daemon_mode; /* VRRP/CHECK subsystem selection */
extern int linkwatch; /* Use linkwatch kernel netlink reflection */
+#ifdef _WITH_SNMP_
+extern int snmp; /* Enable SNMP support */
+#endif
#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/pidfile.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _PIDFILE_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/smtp.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _SMTP_H
|
[-]
[+]
|
Added |
keepalived-1.2.7.tar.bz2/keepalived/include/snmp.h
^
|
@@ -0,0 +1,64 @@
+/*
+ * Soft: Keepalived is a failover program for the LVS project
+ * <www.linuxvirtualserver.org>. It monitor & manipulate
+ * a loadbalanced server pool using multi-layer checks.
+ *
+ * Part: snmp.c include file.
+ *
+ * Authors: Vincent Bernat <bernat@luffy.cx>
+ *
+ * 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 _SNMP_H
+#define _SNMP_H
+
+#define USING_AGENTX_SUBAGENT_MODULE
+
+#include <net-snmp/net-snmp-config.h>
+#include <net-snmp/net-snmp-includes.h>
+#include <net-snmp/agent/net-snmp-agent-includes.h>
+#include <net-snmp/agent/snmp_vars.h>
+#if HAVE_NET_SNMP_AGENT_UTIL_FUNCS_H
+#include <net-snmp/agent/util_funcs.h>
+#else
+/* The above header may be buggy. We just need those two functions. */
+int header_simple_table(struct variable *, oid *, size_t *,
+ int, size_t *,
+ WriteMethod ** write_method, int);
+int header_generic(struct variable *, oid *, size_t *, int,
+ size_t *, WriteMethod **);
+#endif
+#undef FREE
+
+#include "list.h"
+#include "utils.h"
+
+#define KEEPALIVED_OID 1, 3, 6, 1, 4, 1, 9586, 100, 5
+#define SNMPTRAP_OID 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0
+#define GLOBAL_OID {KEEPALIVED_OID, 1}
+
+/* For net-snmp */
+extern int register_sysORTable(oid *, size_t, const char *);
+extern int unregister_sysORTable(oid *, size_t);
+
+extern unsigned long snmp_scope(int scope);
+extern void* snmp_header_list_table(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method,
+ list dlist);
+extern void snmp_agent_init(oid *myoid, int len,
+ char *name, struct variable *variables,
+ int varsize, int varlen);
+extern void snmp_agent_close(oid *myoid, int len, char *name);
+
+#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp.h
^
|
@@ -18,7 +18,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_H
@@ -71,9 +71,12 @@
*/
typedef struct _vrrp_sgroup {
char *gname; /* Group name */
- vector iname; /* Set of VRRP instances in this group */
+ vector_t *iname; /* Set of VRRP instances in this group */
list index_list; /* List of VRRP instances */
int state; /* current stable state */
+ int global_tracking; /* Use floating priority and scripts
+ * All VRRP must share same tracking conf
+ */
/* State transition notification */
int notify_exec;
@@ -91,6 +94,9 @@
vrrp_sgroup *sync; /* Sync group we belong to */
interface *ifp; /* Interface we belong to */
int dont_track_primary; /* If set ignores ifp faults */
+ int vmac; /* If set try to set VRRP VMAC */
+ char vmac_ifname[IFNAMSIZ]; /* Name of VRRP VMAC interface */
+ unsigned int vmac_ifindex; /* ifindex of vmac interface */
list track_ifp; /* Interface state we monitor */
list track_script; /* Script state we monitor */
uint32_t mcast_saddr; /* Src IP address to use in VRRP IP header */
@@ -115,7 +121,7 @@
* preemption based on higher prio over lower
* prio is allowed. 0 means no delay.
*/
- TIMEVAL preempt_time; /* Time after which preemption can happen */
+ timeval_t preempt_time; /* Time after which preemption can happen */
int state; /* internal state (init/backup/master) */
int init_state; /* the initial state of the instance */
int wantstate; /* user explicitly wants a state (back/mast) */
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_arp.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_ARP_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_daemon.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_DAEMON_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_data.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_DATA_H
@@ -65,16 +65,16 @@
extern char *vrrp_buffer;
/* prototypes */
-extern void alloc_saddress(vector);
-extern void alloc_sroute(vector);
+extern void alloc_saddress(vector_t *);
+extern void alloc_sroute(vector_t *);
extern void alloc_vrrp_sync_group(char *);
extern void alloc_vrrp(char *);
-extern void alloc_vrrp_track(vector);
+extern void alloc_vrrp_track(vector_t *);
extern void alloc_vrrp_script(char *);
-extern void alloc_vrrp_track_script(vector);
-extern void alloc_vrrp_vip(vector);
-extern void alloc_vrrp_evip(vector);
-extern void alloc_vrrp_vroute(vector);
+extern void alloc_vrrp_track_script(vector_t *);
+extern void alloc_vrrp_vip(vector_t *);
+extern void alloc_vrrp_evip(vector_t *);
+extern void alloc_vrrp_vroute(vector_t *);
extern void alloc_vrrp_buffer(void);
extern void free_vrrp_buffer(void);
extern vrrp_conf_data *alloc_vrrp_data(void);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_if.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_IF_H
@@ -123,5 +123,6 @@
extern int if_setsockopt_mcast_loop(sa_family_t, int *);
extern int if_setsockopt_mcast_hops(sa_family_t, int *);
extern int if_setsockopt_mcast_if(sa_family_t, int *, interface *);
+extern int if_setsockopt_priority(int *);
#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_index.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_INDEX_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_ipaddress.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_IPADDR_H
@@ -79,7 +79,7 @@
extern void netlink_iplist(list, int);
extern void free_ipaddress(void *);
extern void dump_ipaddress(void *);
-extern void alloc_ipaddress(list, vector, interface *);
+extern void alloc_ipaddress(list, vector_t *, interface *);
extern void clear_diff_address(list, list);
extern void clear_diff_saddresses(void);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_iproute.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_IPROUTE_H
@@ -64,7 +64,7 @@
extern void netlink_rtlist_ipv4(list, int);
extern void free_iproute(void *);
extern void dump_iproute(void *);
-extern void alloc_route(list, vector);
+extern void alloc_route(list, vector_t *);
extern void clear_diff_routes(list, list);
extern void clear_diff_sroutes(void);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_ipsecah.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_IPSEC_AH_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_ndisc.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_NDISC_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_netlink.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_NETLINK_H
@@ -45,6 +45,7 @@
/* Define types */
#define NETLINK_TIMER (30 * TIMER_HZ)
+#define NLMSG_TAIL(nmsg) ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
/* Global vars exported */
extern struct nl_handle nl_kernel; /* Kernel reflection channel */
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_notify.h
^
|
@@ -18,7 +18,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_NOTIFY_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_parser.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_PARSER_H
@@ -27,6 +27,6 @@
#include "vector.h"
/* Prototypes */
-extern vector vrrp_init_keywords(void);
+extern vector_t *vrrp_init_keywords(void);
#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_scheduler.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_SCHEDULER_H
|
[-]
[+]
|
Added |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_snmp.h
^
|
@@ -0,0 +1,116 @@
+/*
+ * Soft: Vrrpd is an implementation of VRRPv2 as specified in rfc2338.
+ * VRRP is a protocol which elect a master server on a LAN. If the
+ * master fails, a backup server takes over.
+ * The original implementation has been made by jerome etienne.
+ *
+ * Part: vrrp_snmp.c program include file.
+ *
+ * Author: Vincent Bernat <bernat@luffy.cx>
+ *
+ * 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 _VRRP_SNMP_H
+#define _VRRP_SNMP_H
+
+#include "snmp.h"
+
+/* VRRP SNMP defines */
+#define VRRP_OID KEEPALIVED_OID, 2
+
+#define VRRP_SNMP_SCRIPT_NAME 3
+#define VRRP_SNMP_SCRIPT_COMMAND 4
+#define VRRP_SNMP_SCRIPT_INTERVAL 5
+#define VRRP_SNMP_SCRIPT_WEIGHT 6
+#define VRRP_SNMP_SCRIPT_RESULT 7
+#define VRRP_SNMP_SCRIPT_RISE 8
+#define VRRP_SNMP_SCRIPT_FALL 9
+#define VRRP_SNMP_ADDRESS_ADDRESSTYPE 9
+#define VRRP_SNMP_ADDRESS_VALUE 10
+#define VRRP_SNMP_ADDRESS_BROADCAST 11
+#define VRRP_SNMP_ADDRESS_MASK 12
+#define VRRP_SNMP_ADDRESS_SCOPE 13
+#define VRRP_SNMP_ADDRESS_IFINDEX 14
+#define VRRP_SNMP_ADDRESS_IFNAME 15
+#define VRRP_SNMP_ADDRESS_IFALIAS 16
+#define VRRP_SNMP_ADDRESS_ISSET 17
+#define VRRP_SNMP_ADDRESS_ISADVERTISED 18
+#define VRRP_SNMP_ROUTE_ADDRESSTYPE 19
+#define VRRP_SNMP_ROUTE_DESTINATION 20
+#define VRRP_SNMP_ROUTE_DESTINATIONMASK 21
+#define VRRP_SNMP_ROUTE_GATEWAY 22
+#define VRRP_SNMP_ROUTE_SECONDARYGATEWAY 23
+#define VRRP_SNMP_ROUTE_SOURCE 24
+#define VRRP_SNMP_ROUTE_METRIC 25
+#define VRRP_SNMP_ROUTE_SCOPE 26
+#define VRRP_SNMP_ROUTE_TYPE 27
+#define VRRP_SNMP_ROUTE_IFINDEX 28
+#define VRRP_SNMP_ROUTE_IFNAME 29
+#define VRRP_SNMP_ROUTE_ROUTINGTABLE 30
+#define VRRP_SNMP_ROUTE_ISSET 31
+#define VRRP_SNMP_SYNCGROUP_NAME 33
+#define VRRP_SNMP_SYNCGROUP_STATE 34
+#define VRRP_SNMP_SYNCGROUP_SMTPALERT 35
+#define VRRP_SNMP_SYNCGROUP_NOTIFYEXEC 36
+#define VRRP_SNMP_SYNCGROUP_SCRIPTMASTER 37
+#define VRRP_SNMP_SYNCGROUP_SCRIPTBACKUP 38
+#define VRRP_SNMP_SYNCGROUP_SCRIPTFAULT 39
+#define VRRP_SNMP_SYNCGROUP_SCRIPT 40
+#define VRRP_SNMP_SYNCGROUPMEMBER_INSTANCE 42
+#define VRRP_SNMP_SYNCGROUPMEMBER_NAME 43
+#define VRRP_SNMP_INSTANCE_NAME 45
+#define VRRP_SNMP_INSTANCE_VIRTUALROUTERID 46
+#define VRRP_SNMP_INSTANCE_STATE 47
+#define VRRP_SNMP_INSTANCE_INITIALSTATE 48
+#define VRRP_SNMP_INSTANCE_WANTEDSTATE 49
+#define VRRP_SNMP_INSTANCE_BASEPRIORITY 50
+#define VRRP_SNMP_INSTANCE_EFFECTIVEPRIORITY 51
+#define VRRP_SNMP_INSTANCE_VIPSENABLED 52
+#define VRRP_SNMP_INSTANCE_PRIMARYINTERFACE 53
+#define VRRP_SNMP_INSTANCE_TRACKPRIMARYIF 54
+#define VRRP_SNMP_INSTANCE_ADVERTISEMENTSINT 55
+#define VRRP_SNMP_INSTANCE_PREEMPT 56
+#define VRRP_SNMP_INSTANCE_PREEMPTDELAY 57
+#define VRRP_SNMP_INSTANCE_AUTHTYPE 58
+#define VRRP_SNMP_INSTANCE_USELVSSYNCDAEMON 59
+#define VRRP_SNMP_INSTANCE_LVSSYNCINTERFACE 60
+#define VRRP_SNMP_INSTANCE_SYNCGROUP 61
+#define VRRP_SNMP_INSTANCE_GARPDELAY 62
+#define VRRP_SNMP_INSTANCE_SMTPALERT 63
+#define VRRP_SNMP_INSTANCE_NOTIFYEXEC 64
+#define VRRP_SNMP_INSTANCE_SCRIPTMASTER 65
+#define VRRP_SNMP_INSTANCE_SCRIPTBACKUP 66
+#define VRRP_SNMP_INSTANCE_SCRIPTFAULT 67
+#define VRRP_SNMP_INSTANCE_SCRIPTSTOP 68
+#define VRRP_SNMP_INSTANCE_SCRIPT 69
+#define VRRP_SNMP_TRACKEDINTERFACE_NAME 70
+#define VRRP_SNMP_TRACKEDINTERFACE_WEIGHT 71
+#define VRRP_SNMP_TRACKEDSCRIPT_NAME 73
+#define VRRP_SNMP_TRACKEDSCRIPT_WEIGHT 74
+
+#define HEADER_STATE_STATIC_ADDRESS 1
+#define HEADER_STATE_VIRTUAL_ADDRESS 2
+#define HEADER_STATE_EXCLUDED_VIRTUAL_ADDRESS 3
+#define HEADER_STATE_STATIC_ROUTE 4
+#define HEADER_STATE_VIRTUAL_ROUTE 5
+#define HEADER_STATE_END 10
+
+
+/* Prototypes */
+extern void vrrp_snmp_agent_init(void);
+extern void vrrp_snmp_agent_close(void);
+extern void vrrp_snmp_instance_trap(vrrp_rt *);
+extern void vrrp_snmp_group_trap(vrrp_sgroup *);
+
+#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_sync.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_SYNC_H
@@ -46,6 +46,7 @@
extern void vrrp_sync_set_group(vrrp_sgroup *);
extern int vrrp_sync_group_up(vrrp_sgroup *);
extern int vrrp_sync_leave_fault(vrrp_rt *);
+extern int vrrp_sync_goto_master(vrrp_rt *);
extern void vrrp_sync_backup(vrrp_rt *);
extern void vrrp_sync_master(vrrp_rt *);
extern void vrrp_sync_master_election(vrrp_rt *);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_track.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#ifndef _VRRP_TRACK_H
@@ -39,8 +39,9 @@
#define SCRIPT_ISUP(L) (vrrp_script_up((L)))
/* VRRP script tracking defaults */
-#define VRRP_SCRIPT_DI 1 /* external script track interval (in sec) */
-#define VRRP_SCRIPT_DW 0 /* external script default weight */
+#define VRRP_SCRIPT_DI 1 /* external script track interval (in sec) */
+#define VRRP_SCRIPT_DT 0 /* external script track timeout (in sec) */
+#define VRRP_SCRIPT_DW 0 /* external script default weight */
/* VRRP script tracking results.
* The result is an integer between 0 and rise-1 to indicate a DOWN state,
@@ -57,7 +58,8 @@
typedef struct _vrrp_script {
char *sname; /* instance name */
char *script; /* the command to be called */
- int interval; /* interval between script calls */
+ long interval; /* interval between script calls */
+ long timeout; /* seconds before script timeout */
int weight; /* weight associated to this script */
int result; /* result of last call to this script: 0..R-1 = KO, R..R+F-1 = OK */
int inuse; /* how many users have weight>0 ? */
@@ -73,9 +75,9 @@
/* prototypes */
extern void dump_track(void *);
-extern void alloc_track(list, vector);
+extern void alloc_track(list, vector_t *);
extern void dump_track_script(void *);
-extern void alloc_track_script(list, vector);
+extern void alloc_track_script(list, vector_t *);
extern int vrrp_tracked_up(list);
extern void vrrp_log_tracked_down(list);
extern int vrrp_tracked_weight(list);
|
[-]
[+]
|
Added |
keepalived-1.2.7.tar.bz2/keepalived/include/vrrp_vmac.h
^
|
@@ -0,0 +1,42 @@
+/*
+ * Soft: Keepalived is a failover program for the LVS project
+ * <www.linuxvirtualserver.org>. It monitor & manipulate
+ * a loadbalanced server pool using multi-layer checks.
+ *
+ * Part: vrrp_vmac.c include file.
+ *
+ * Author: Alexandre Cassen, <acassen@linux-vs.org>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
+ */
+
+#ifndef _VRRP_VMAC_H
+#define _VRRP_VMAC_H
+
+/* global includes */
+#include <stdio.h>
+#include <stdlib.h>
+#include <arpa/inet.h>
+#include <string.h>
+#include <syslog.h>
+#include <net/ethernet.h>
+
+/* local includes */
+#include "vrrp.h"
+#include "vrrp_if.h"
+
+/* prototypes */
+extern int netlink_link_add_vmac(vrrp_rt *);
+extern int netlink_link_del_vmac(vrrp_rt *);
+
+#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/libipvs-2.4/libipvs.c
^
|
@@ -118,7 +118,7 @@
}
struct ip_vs_service_user *
-ipvs_get_service(__u32 fwmark, __u16 protocol, __u32 vaddr, __u16 vport)
+ipvs_get_service(u_int32_t fwmark, u_int16_t protocol, u_int32_t vaddr, u_int16_t vport)
{
struct ip_vs_service_user *svc;
socklen_t len;
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/libipvs-2.4/libipvs.h
^
|
@@ -47,7 +47,7 @@
/* get ipvs service */
extern struct ip_vs_service_user *
-ipvs_get_service(__u32 fwmark, __u16 protocol, __u32 vaddr, __u16 vport);
+ipvs_get_service(u_int32_t fwmark, u_int16_t protocol, u_int32_t vaddr, u_int16_t vport);
/* get ipvs timeout */
extern struct ip_vs_timeout_user *ipvs_get_timeouts(void);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/libipvs-2.6/Makefile.in
^
|
@@ -20,3 +20,4 @@
rm -f *.[ao] *~ *.orig *.rej core
distclean: clean
+ rm -f Makefile
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/libipvs-2.6/libipvs.c
^
|
@@ -879,7 +879,8 @@
ipvs_service_entry_t *
-ipvs_get_service(__u32 fwmark, __u16 af, __u16 protocol, union nf_inet_addr addr, __u16 port)
+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_service_entry_t *svc;
socklen_t len;
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/libipvs-2.6/libipvs.h
^
|
@@ -95,6 +95,10 @@
extern void ipvs_sort_services(struct ip_vs_get_services *s,
ipvs_service_cmp_t f);
+/* get one IPVS service */
+extern ipvs_service_entry_t *ipvs_get_service(u_int32_t, u_int16_t, u_int16_t,
+ union nf_inet_addr, u_int16_t);
+
/* get the destination array of the specified service */
extern struct ip_vs_get_dests *ipvs_get_dests(ipvs_service_entry_t *svc);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/Makefile.in
^
|
@@ -2,19 +2,23 @@
#
# Keepalived OpenSource project.
#
-# Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+# Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
CC = @CC@
+SNMP_FLAG = @SNMP_SUPPORT@
INCLUDES = -I../include -I../../lib
CFLAGS = @CFLAGS@ @CPPFLAGS@ $(INCLUDES) \
-Wall -Wunused -Wstrict-prototypes
-DEFS = -D@KERN@ -D@IPVS_SUPPORT@ -D@IPVS_SYNCD@ @DFLAGS@
+DEFS = -D@KERN@ -D@IPVS_SUPPORT@ -D@IPVS_SYNCD@ -D@VRRP_VMAC@ -D@SNMP_SUPPORT@ @DFLAGS@
COMPILE = $(CC) $(CFLAGS) $(DEFS)
OBJS = vrrp_daemon.o vrrp_data.o vrrp_parser.o \
vrrp.o vrrp_notify.o vrrp_scheduler.o vrrp_sync.o vrrp_index.o \
vrrp_netlink.o vrrp_arp.o vrrp_if.o vrrp_track.o vrrp_ipaddress.o \
- vrrp_iproute.o vrrp_ipsecah.o vrrp_ndisc.o
+ vrrp_iproute.o vrrp_ipsecah.o vrrp_ndisc.o vrrp_vmac.o
+ifeq ($(SNMP_FLAG),_WITH_SNMP_)
+ OBJS += vrrp_snmp.o
+endif
HEADERS = $(OBJS:.o=.h)
.c.o:
@@ -33,7 +37,7 @@
../include/vrrp_iproute.h ../include/vrrp_parser.h ../include/vrrp_data.h \
../include/vrrp.h ../include/global_data.h ../include/pidfile.h ../include/daemon.h \
../include/ipvswrapper.h ../../lib/list.h ../../lib/memory.h ../../lib/parser.h \
- ../../lib/signals.h
+ ../../lib/signals.h ../include/snmp.h ../include/vrrp_snmp.h
vrrp_data.o: vrrp_data.c ../include/vrrp_data.h \
../include/vrrp_sync.h ../include/vrrp_if.h ../include/vrrp_index.h \
../include/vrrp.h ../../lib/memory.h ../../lib/utils.h ../../lib/notify.h
@@ -44,14 +48,15 @@
vrrp.o: vrrp.c ../include/vrrp.h ../include/vrrp_scheduler.h \
../include/vrrp_notify.h ../include/ipvswrapper.h ../../lib/memory.h \
../../lib/list.h ../include/vrrp_data.h ../include/vrrp_sync.h ../include/vrrp_index.h \
- ../include/vrrp_arp.h ../../lib/utils.h
+ ../include/vrrp_arp.h ../../lib/utils.h ../include/vrrp_vmac.h ../include/snmp.h \
+ ../include/vrrp_snmp.h
vrrp_notify.o: vrrp_notify.c ../include/vrrp_notify.h ../../lib/memory.h \
../../lib/notify.h
vrrp_scheduler.o: vrrp_scheduler.c ../include/vrrp_scheduler.h \
../include/vrrp_ipsecah.h ../include/vrrp_if.h ../include/vrrp.h \
../include/vrrp_sync.h ../include/vrrp_notify.h ../include/ipvswrapper.h \
../../lib/memory.h ../../lib/list.h ../include/vrrp_data.h ../include/vrrp_index.h \
- ../include/smtp.h ../../lib/notify.h
+ ../include/smtp.h ../../lib/notify.h ../include/snmp.h ../include/vrrp_snmp.h
vrrp_sync.o: vrrp_sync.c ../include/vrrp_sync.h ../include/vrrp_if.h \
../include/vrrp_notify.h ../include/vrrp_data.h
vrrp_index.o: vrrp_index.c ../include/vrrp_index.h ../include/vrrp.h \
@@ -72,3 +77,9 @@
vrrp_ipsecah.o: vrrp_ipsecah.c ../include/vrrp_ipsecah.h
vrrp_ndisc.o: vrrp_ndisc.c ../include/vrrp_ndisc.h ../include/vrrp_ipaddress.h \
../../lib/utils.h ../../lib/memory.h
+vrrp_vmac.o: vrrp_vmac.c ../include/vrrp_vmac.h ../include/vrrp_netlink.h \
+ ../include/vrrp_data.h ../../lib/logger.h ../../lib/memory.h ../../lib/utils.h
+vrrp_snmp.o: vrrp_snmp.c ../include/vrrp_snmp.h ../include/vrrp_track.h \
+ ../include/vrrp_data.h ../include/vrrp_ipaddress.h ../include/vrrp_iproute.h \
+ ../include/vrrp.h ../../lib/vector.h ../../lib/list.h ../include/snmp.h \
+ ../include/global_data.h ../../lib/logger.h
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp.c
^
|
@@ -20,7 +20,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
/* local include */
@@ -35,6 +35,10 @@
#include "vrrp_data.h"
#include "vrrp_sync.h"
#include "vrrp_index.h"
+#include "vrrp_vmac.h"
+#ifdef _WITH_SNMP_
+#include "vrrp_snmp.h"
+#endif
#include "memory.h"
#include "list.h"
#include "logger.h"
@@ -233,8 +237,8 @@
ihl = ip->ihl << 2;
if (vrrp->auth_type == VRRP_AUTH_AH) {
- ah = (ipsec_ah *) (buffer + sizeof (struct iphdr));
- hd = (vrrp_pkt *) (buffer + ihl + vrrp_ipsecah_len());
+ ah = (ipsec_ah *) (buffer + ihl);
+ hd = (vrrp_pkt *) (ah + vrrp_ipsecah_len());
} else {
hd = (vrrp_pkt *) (buffer + ihl);
}
@@ -369,7 +373,8 @@
ip->ihl = 5;
ip->version = 4;
- ip->tos = 0;
+ /* set tos to internet network control */
+ ip->tos = 0xc0;
ip->tot_len = ip->ihl * 4 + vrrp_hd_len(vrrp);
ip->tot_len = htons(ip->tot_len);
ip->id = htons(++vrrp->ip_id);
@@ -726,6 +731,10 @@
/* Check if notify is needed */
notify_instance_exec(vrrp, VRRP_STATE_MAST);
+#ifdef _WITH_SNMP_
+ vrrp_snmp_instance_trap(vrrp);
+#endif
+
#ifdef _HAVE_IPVS_SYNCD_
/* Check if sync daemon handling is needed */
if (vrrp->lvs_syncd_if)
@@ -740,6 +749,8 @@
* Send an advertisement. To force a new master
* election.
*/
+ if (vrrp->sync && !vrrp_sync_goto_master(vrrp))
+ return;
vrrp_send_adv(vrrp, vrrp->effective_priority);
vrrp->state = VRRP_STATE_MAST;
@@ -751,6 +762,13 @@
void
vrrp_restore_interface(vrrp_rt * vrrp, int advF)
{
+ /* if we stop vrrp, warn the other routers to speed up the recovery */
+ if (advF) {
+ syslog(LOG_INFO, "VRRP_Instance(%s) sending 0 priority",
+ vrrp->iname);
+ vrrp_send_adv(vrrp, VRRP_PRIO_STOP);
+ }
+
/* remove virtual routes */
if (!LIST_ISEMPTY(vrrp->vroutes))
vrrp_handle_iproutes(vrrp, IPROUTE_DEL);
@@ -771,10 +789,6 @@
vrrp->vipset = 0;
}
-
- /* if we stop vrrp, warn the other routers to speed up the recovery */
- if (advF)
- vrrp_send_adv(vrrp, VRRP_PRIO_STOP);
}
void
@@ -795,12 +809,18 @@
vrrp_restore_interface(vrrp, 0);
vrrp->state = vrrp->wantstate;
notify_instance_exec(vrrp, VRRP_STATE_BACK);
+#ifdef _WITH_SNMP_
+ vrrp_snmp_instance_trap(vrrp);
+#endif
break;
case VRRP_STATE_GOTO_FAULT:
log_message(LOG_INFO, "VRRP_Instance(%s) Entering FAULT STATE", vrrp->iname);
vrrp_restore_interface(vrrp, 0);
vrrp->state = VRRP_STATE_FAULT;
notify_instance_exec(vrrp, VRRP_STATE_FAULT);
+#ifdef _WITH_SNMP_
+ vrrp_snmp_instance_trap(vrrp);
+#endif
break;
}
@@ -998,6 +1018,7 @@
if_setsockopt_hdrincl(&fd);
if_setsockopt_bindtodevice(&fd, ifp);
if_setsockopt_mcast_loop(family, &fd);
+ if_setsockopt_priority(&fd);
if (fd < 0)
return -1;
} else if (family == AF_INET6) {
@@ -1005,6 +1026,7 @@
if_setsockopt_mcast_hops(family, &fd);
if_setsockopt_mcast_if(family, &fd, ifp);
if_setsockopt_mcast_loop(family, &fd);
+ if_setsockopt_priority(&fd);
if (fd < 0)
return -1;
} else {
@@ -1086,10 +1108,14 @@
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
vrrp = ELEMENT_DATA(e);
- /* remove VIPs */
+ /* Remove VIPs/VROUTEs */
if (vrrp->state == VRRP_STATE_MAST)
vrrp_restore_interface(vrrp, 1);
+ /* Remove VMAC */
+ if (vrrp->vmac)
+ netlink_link_del_vmac(vrrp);
+
/* Run stop script */
if (vrrp->script_stop)
notify_exec(vrrp->script_stop);
@@ -1238,13 +1264,19 @@
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
vrrp = ELEMENT_DATA(e);
+ vrrp_rt *new_vrrp;
/*
* Try to find this vrrp into the new conf data
* reloaded.
*/
- if (!vrrp_exist(vrrp)) {
- vrrp_restore_interface(vrrp, 0);
+ new_vrrp = vrrp_exist(vrrp);
+ if (!new_vrrp) {
+ vrrp_restore_interface(vrrp, 1);
+
+ /* Remove VMAC if one was created */
+ if (vrrp->vmac)
+ netlink_link_del_vmac(vrrp);
} else {
/*
* If this vrrp instance exist in new
@@ -1256,6 +1288,14 @@
/* virtual routes diff */
clear_diff_vrrp_vroutes(vrrp);
+ /*
+ * Remove VMAC if it existed in old vrrp instance,
+ * but not the new one.
+ */
+ if (vrrp->vmac && !new_vrrp->vmac) {
+ netlink_link_del_vmac(vrrp);
+ }
+
/* reset the state */
reset_vrrp_state(vrrp);
}
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_arp.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
/* system includes */
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_daemon.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include "vrrp_daemon.h"
@@ -39,6 +39,9 @@
#ifdef _WITH_LVS_
#include "ipvswrapper.h"
#endif
+#ifdef _WITH_SNMP_
+ #include "vrrp_snmp.h"
+#endif
#include "list.h"
#include "main.h"
#include "memory.h"
@@ -54,21 +57,26 @@
signal_handler_destroy();
thread_destroy_master(master);
+ if (!(debug & 8))
+ shutdown_vrrp_instances();
+
/* Clear static entries */
netlink_rtlist_ipv4(vrrp_data->static_routes, IPROUTE_DEL);
netlink_iplist(vrrp_data->static_addresses, IPADDRESS_DEL);
- if (!(debug & 8))
- shutdown_vrrp_instances();
free_interface_queue();
gratuitous_arp_close();
ndisc_close();
+#ifdef _WITH_SNMP_
+ if (snmp)
+ vrrp_snmp_agent_close();
+#endif
/* Stop daemon */
pidfile_rm(vrrp_pidfile);
/* Clean data */
- free_global_data(data);
+ free_global_data(global_data);
free_vrrp_sockpool(vrrp_data);
free_vrrp_data(vrrp_data);
free_vrrp_buffer();
@@ -99,13 +107,17 @@
kernel_netlink_init();
gratuitous_arp_init();
ndisc_init();
+#ifdef _WITH_SNMP_
+ if (!reload && snmp)
+ vrrp_snmp_agent_init();
+#endif
#ifdef _WITH_LVS_
/* Initialize ipvs related */
ipvs_start();
#endif
/* Parse configuration file */
- data = alloc_global_data();
+ global_data = alloc_global_data();
vrrp_data = alloc_vrrp_data();
alloc_vrrp_buffer();
init_data(conf_file, vrrp_init_keywords);
@@ -136,7 +148,7 @@
/* Dump configuration */
if (debug & 4) {
- dump_global_data(data);
+ dump_global_data(global_data);
dump_vrrp_data(vrrp_data);
}
@@ -153,8 +165,6 @@
void
sighup_vrrp(void *v, int sig)
{
- log_message(LOG_INFO, "Reloading VRRP child process(%d) on signal",
- getpid());
thread_add_event(master, reload_vrrp_thread, NULL, 0);
}
@@ -162,7 +172,6 @@
void
sigend_vrrp(void *v, int sig)
{
- log_message(LOG_INFO, "Terminating VRRP child process on signal");
if (master)
thread_add_terminate_event(master);
}
@@ -185,9 +194,6 @@
/* set the reloading flag */
SET_RELOAD;
- /* Close sockpool */
- free_vrrp_sockpool(vrrp_data);
-
/* Signal handling */
signal_reset();
signal_handler_destroy();
@@ -195,7 +201,7 @@
/* Destroy master thread */
thread_destroy_master(master);
master = thread_make_master();
- free_global_data(data);
+ free_global_data(global_data);
free_interface_queue();
free_vrrp_buffer();
gratuitous_arp_close();
@@ -216,6 +222,9 @@
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;
@@ -272,7 +281,7 @@
}
/* Opening local VRRP syslog channel */
- openlog(PROG_VRRP, LOG_PID | (debug & 1) ? LOG_CONS : 0,
+ openlog(PROG_VRRP, LOG_PID | ((debug & 1) ? LOG_CONS : 0),
(log_facility==LOG_DAEMON) ? LOG_LOCAL1 : log_facility);
/* Child process part, write pidfile */
@@ -289,6 +298,9 @@
/* change to / dir */
ret = chdir("/");
+ if (ret < 0) {
+ log_message(LOG_INFO, "VRRP child process: error chdir");
+ }
/* Set mask */
umask(0);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_data.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include "vrrp_data.h"
@@ -36,7 +36,7 @@
/* Static addresses facility function */
void
-alloc_saddress(vector strvec)
+alloc_saddress(vector_t *strvec)
{
if (LIST_ISEMPTY(vrrp_data->static_addresses))
vrrp_data->static_addresses = alloc_list(free_ipaddress, dump_ipaddress);
@@ -45,7 +45,7 @@
/* Static routes facility function */
void
-alloc_sroute(vector strvec)
+alloc_sroute(vector_t *strvec)
{
if (LIST_ISEMPTY(vrrp_data->static_routes))
vrrp_data->static_routes = alloc_list(free_iproute, dump_iproute);
@@ -76,10 +76,12 @@
log_message(LOG_INFO, " VRRP Sync Group = %s, %s", vgroup->gname,
(vgroup->state == VRRP_STATE_MAST) ? "MASTER" : "BACKUP");
- for (i = 0; i < VECTOR_SIZE(vgroup->iname); i++) {
- str = VECTOR_SLOT(vgroup->iname, i);
+ for (i = 0; i < vector_size(vgroup->iname); i++) {
+ str = vector_slot(vgroup->iname, i);
log_message(LOG_INFO, " monitor = %s", str);
}
+ if (vgroup->global_tracking)
+ log_message(LOG_INFO, " Same tracking for all VRRP instances");
if (vgroup->script_backup)
log_message(LOG_INFO, " Backup state transition script = %s",
vgroup->script_backup);
@@ -114,9 +116,10 @@
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, " Weight = %d", vscript->weight);
log_message(LOG_INFO, " Rise = %d", vscript->rise);
- log_message(LOG_INFO, " Full = %d", vscript->fall);
+ log_message(LOG_INFO, " Fall = %d", vscript->fall);
switch (vscript->result) {
case VRRP_SCRIPT_STATUS_INIT:
@@ -282,6 +285,7 @@
new->gname = (char *) MALLOC(size + 1);
new->state = VRRP_STATE_INIT;
memcpy(new->gname, gname, size);
+ new->global_tracking = 0;
list_add(vrrp_data->vrrp_sync_group, new);
}
@@ -312,7 +316,7 @@
}
void
-alloc_vrrp_track(vector strvec)
+alloc_vrrp_track(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
@@ -322,7 +326,7 @@
}
void
-alloc_vrrp_track_script(vector strvec)
+alloc_vrrp_track_script(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
@@ -332,7 +336,7 @@
}
void
-alloc_vrrp_vip(vector strvec)
+alloc_vrrp_vip(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
if (vrrp->ifp == NULL) {
@@ -344,7 +348,7 @@
alloc_ipaddress(vrrp->vip, strvec, vrrp->ifp);
}
void
-alloc_vrrp_evip(vector strvec)
+alloc_vrrp_evip(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
@@ -354,7 +358,7 @@
}
void
-alloc_vrrp_vroute(vector strvec)
+alloc_vrrp_vroute(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
@@ -374,6 +378,7 @@
new->sname = (char *) MALLOC(size + 1);
memcpy(new->sname, sname, size + 1);
new->interval = VRRP_SCRIPT_DI * TIMER_HZ;
+ new->timeout = VRRP_SCRIPT_DT * TIMER_HZ;
new->weight = VRRP_SCRIPT_DW;
new->result = VRRP_SCRIPT_STATUS_INIT;
new->inuse = 0;
@@ -412,46 +417,46 @@
}
void
-free_vrrp_data(vrrp_conf_data * vrrp_data)
+free_vrrp_data(vrrp_conf_data * data)
{
- free_list(vrrp_data->static_addresses);
- free_list(vrrp_data->static_routes);
- free_mlist(vrrp_data->vrrp_index, 255+1);
- free_mlist(vrrp_data->vrrp_index_fd, 1024+1);
- free_list(vrrp_data->vrrp);
- free_list(vrrp_data->vrrp_sync_group);
- free_list(vrrp_data->vrrp_script);
-// free_list(vrrp_data->vrrp_socket_pool);
- FREE(vrrp_data);
+ free_list(data->static_addresses);
+ free_list(data->static_routes);
+ free_mlist(data->vrrp_index, 255+1);
+ free_mlist(data->vrrp_index_fd, 1024+1);
+ 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_conf_data * vrrp_data)
+free_vrrp_sockpool(vrrp_conf_data * data)
{
- free_list(vrrp_data->vrrp_socket_pool);
+ free_list(data->vrrp_socket_pool);
}
void
-dump_vrrp_data(vrrp_conf_data * vrrp_data)
+dump_vrrp_data(vrrp_conf_data * data)
{
- if (!LIST_ISEMPTY(vrrp_data->static_addresses)) {
+ if (!LIST_ISEMPTY(data->static_addresses)) {
log_message(LOG_INFO, "------< Static Addresses >------");
- dump_list(vrrp_data->static_addresses);
+ dump_list(data->static_addresses);
}
- if (!LIST_ISEMPTY(vrrp_data->static_routes)) {
+ if (!LIST_ISEMPTY(data->static_routes)) {
log_message(LOG_INFO, "------< Static Routes >------");
- dump_list(vrrp_data->static_routes);
+ dump_list(data->static_routes);
}
- if (!LIST_ISEMPTY(vrrp_data->vrrp)) {
+ if (!LIST_ISEMPTY(data->vrrp)) {
log_message(LOG_INFO, "------< VRRP Topology >------");
- dump_list(vrrp_data->vrrp);
+ dump_list(data->vrrp);
}
- if (!LIST_ISEMPTY(vrrp_data->vrrp_sync_group)) {
+ if (!LIST_ISEMPTY(data->vrrp_sync_group)) {
log_message(LOG_INFO, "------< VRRP Sync groups >------");
- dump_list(vrrp_data->vrrp_sync_group);
+ dump_list(data->vrrp_sync_group);
}
- if (!LIST_ISEMPTY(vrrp_data->vrrp_script)) {
+ if (!LIST_ISEMPTY(data->vrrp_script)) {
log_message(LOG_INFO, "------< VRRP Scripts >------");
- dump_list(vrrp_data->vrrp_script);
+ dump_list(data->vrrp_script);
}
}
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_if.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
/* global include */
@@ -95,6 +95,7 @@
if (!strcmp(ifp->ifname, ifname))
return ifp;
}
+
log_message(LOG_ERR, "No such interface, %s", ifname);
return NULL;
}
@@ -261,9 +262,9 @@
}
void
-dump_if(void *if_data)
+dump_if(void *data)
{
- interface *ifp = if_data;
+ interface *ifp = data;
char addr_str[41];
log_message(LOG_INFO, "------< NIC >------");
@@ -376,7 +377,7 @@
int
if_linkbeat(const interface * ifp)
{
- if (!data->linkbeat_use_polling)
+ if (!global_data->linkbeat_use_polling)
return 1;
if (IF_MII_SUPPORTED(ifp) || IF_ETHTOOL_SUPPORTED(ifp))
@@ -406,7 +407,7 @@
void
init_interface_linkbeat(void)
{
- if (data->linkbeat_use_polling) {
+ if (global_data->linkbeat_use_polling) {
log_message(LOG_INFO, "Using MII-BMSR NIC polling thread...");
init_if_linkbeat();
} else {
@@ -617,6 +618,24 @@
close(*sd);
*sd = -1;
}
+
+ return *sd;
+}
+
+int if_setsockopt_priority(int *sd) {
+ int ret;
+ int priority = 6;
+
+ if (*sd < 0)
+ return -1;
+
+ /* Set SO_PRIORITY for VRRP traffic */
+ ret = setsockopt(*sd, SOL_SOCKET, SO_PRIORITY, &priority, sizeof(priority));
+ if (ret < 0) {
+ log_message(LOG_INFO, "cant set SO_PRIORITY IP option. errno=%d (%m)", errno);
+ close(*sd);
+ *sd = -1;
+ }
return *sd;
}
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_index.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
/* local include */
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_ipaddress.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
/* local include */
@@ -131,7 +131,7 @@
FREE(addr_str);
}
void
-alloc_ipaddress(list ip_list, vector strvec, interface *ifp)
+alloc_ipaddress(list ip_list, vector_t *strvec, interface *ifp)
{
ip_address *new;
interface *ifp_local;
@@ -157,39 +157,39 @@
}
/* FMT parse */
- while (i < VECTOR_SIZE(strvec)) {
- str = VECTOR_SLOT(strvec, i);
+ while (i < vector_size(strvec)) {
+ str = vector_slot(strvec, i);
/* cmd parsing */
if (!strcmp(str, "dev")) {
- ifp_local = if_get_by_ifname(VECTOR_SLOT(strvec, ++i));
+ ifp_local = if_get_by_ifname(vector_slot(strvec, ++i));
if (!ifp_local) {
log_message(LOG_INFO, "VRRP is trying to assign VIP to unknown %s"
" interface !!! go out and fixe your conf !!!",
- (char *)VECTOR_SLOT(strvec, i));
+ (char *)vector_slot(strvec, i));
FREE(new);
return;
}
new->ifa.ifa_index = IF_INDEX(ifp_local);
new->ifp = ifp_local;
} else if (!strcmp(str, "scope")) {
- new->ifa.ifa_scope = netlink_scope_a2n(VECTOR_SLOT(strvec, ++i));
+ new->ifa.ifa_scope = netlink_scope_a2n(vector_slot(strvec, ++i));
} else if (!strcmp(str, "broadcast") || !strcmp(str, "brd")) {
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));
+ , vector_slot(strvec, i), vector_slot(strvec, addr_idx));
FREE(new);
return;
- } else if (!inet_pton(AF_INET, VECTOR_SLOT(strvec, ++i), &new->u.sin.sin_brd)) {
+ } 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...", vector_slot(strvec, i));
FREE(new);
return;
}
} else if (!strcmp(str, "label")) {
new->label = MALLOC(IFNAMSIZ);
- strncpy(new->label, VECTOR_SLOT(strvec, ++i), IFNAMSIZ);
+ strncpy(new->label, vector_slot(strvec, ++i), IFNAMSIZ);
} else {
p = strchr(str, '/');
if (p) {
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_iproute.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
/* local include */
@@ -174,7 +174,7 @@
FREE(log_msg);
}
void
-alloc_route(list rt_list, vector strvec)
+alloc_route(list rt_list, vector_t *strvec)
{
ip_route *new;
uint32_t ipaddr = 0;
@@ -185,41 +185,41 @@
new = (ip_route *) MALLOC(sizeof(ip_route));
/* FMT parse */
- while (i < VECTOR_SIZE(strvec)) {
- str = VECTOR_SLOT(strvec, i);
+ while (i < vector_size(strvec)) {
+ str = vector_slot(strvec, i);
/* cmd parsing */
if (!strcmp(str, "blackhole")) {
new->blackhole = 1;
- inet_ston(VECTOR_SLOT(strvec, ++i), &new->dst);
- new->dmask = inet_stom(VECTOR_SLOT(strvec, i));
+ inet_ston(vector_slot(strvec, ++i), &new->dst);
+ new->dmask = inet_stom(vector_slot(strvec, i));
} else if (!strcmp(str, "via") || !strcmp(str, "gw")) {
- inet_ston(VECTOR_SLOT(strvec, ++i), &new->gw);
+ inet_ston(vector_slot(strvec, ++i), &new->gw);
} else if (!strcmp(str, "or")) {
- inet_ston(VECTOR_SLOT(strvec, ++i), &new->gw2);
+ inet_ston(vector_slot(strvec, ++i), &new->gw2);
} else if (!strcmp(str, "src")) {
- inet_ston(VECTOR_SLOT(strvec, ++i), &new->src);
+ inet_ston(vector_slot(strvec, ++i), &new->src);
} else if (!strcmp(str, "dev") || !strcmp(str, "oif")) {
- ifp = if_get_by_ifname(VECTOR_SLOT(strvec, ++i));
+ ifp = if_get_by_ifname(vector_slot(strvec, ++i));
if (!ifp) {
log_message(LOG_INFO, "VRRP is trying to assign VROUTE to unknown "
"%s interface !!! go out and fixe your conf !!!",
- (char *)VECTOR_SLOT(strvec, i));
+ (char *)vector_slot(strvec, i));
FREE(new);
return;
}
new->index = IF_INDEX(ifp);
} else if (!strcmp(str, "table")) {
- new->table = atoi(VECTOR_SLOT(strvec, ++i));
+ new->table = atoi(vector_slot(strvec, ++i));
} else if (!strcmp(str, "metric")) {
- new->metric = atoi(VECTOR_SLOT(strvec, ++i));
+ new->metric = atoi(vector_slot(strvec, ++i));
} else if (!strcmp(str, "scope")) {
- new->scope = netlink_scope_a2n(VECTOR_SLOT(strvec, ++i));
+ new->scope = netlink_scope_a2n(vector_slot(strvec, ++i));
} else {
if (!strcmp(str, "to")) i++;
- if (inet_ston(VECTOR_SLOT(strvec, i), &ipaddr)) {
- inet_ston(VECTOR_SLOT(strvec, i), &new->dst);
- new->dmask = inet_stom(VECTOR_SLOT(strvec, i));
+ if (inet_ston(vector_slot(strvec, i), &ipaddr)) {
+ inet_ston(vector_slot(strvec, i), &new->dst);
+ new->dmask = inet_stom(vector_slot(strvec, i));
}
}
i++;
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_ipsecah.c
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include "vrrp_ipsecah.h"
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_ndisc.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
/* system includes */
@@ -127,8 +127,13 @@
char *lladdr = (char *) IF_HWADDR(ipaddress->ifp);
int len;
- /* Ethernet header */
- memset(eth->ether_dhost, 0xFF, ETH_ALEN);
+ /* Ethernet header:
+ * Destination ethernet address MUST use specific address Mapping
+ * as specified in rfc2464.7 Address Mapping for
+ */
+ memset(eth->ether_dhost, 0, ETH_ALEN);
+ eth->ether_dhost[0] = eth->ether_dhost[1] = 0x33;
+ eth->ether_dhost[5] = 1;
memcpy(eth->ether_shost, lladdr, ETH_ALEN);
eth->ether_type = htons(ETHERTYPE_IPV6);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_netlink.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
/* global include */
@@ -454,6 +454,11 @@
if (ifi->ifi_type == ARPHRD_LOOPBACK)
return 0;
+ /* Skip it if already exist */
+ ifp = if_get_by_ifname(name);
+ if (ifp)
+ return 0;
+
/* Fill the interface structure */
ifp = (interface *) MALLOC(sizeof (interface));
memcpy(ifp->ifname, name, strlen(name));
@@ -677,10 +682,8 @@
int
kernel_netlink(thread_t * thread)
{
- int status = 0;
-
if (thread->type != THREAD_READ_TIMEOUT)
- status = netlink_parse_info(netlink_broadcast_filter, &nl_kernel, NULL);
+ netlink_parse_info(netlink_broadcast_filter, &nl_kernel, NULL);
thread_add_read(master, kernel_netlink, NULL, nl_kernel.fd,
NETLINK_TIMER);
return 0;
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_notify.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
/* system include */
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_parser.c
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include "vrrp_parser.h"
@@ -27,6 +27,7 @@
#include "vrrp_sync.h"
#include "vrrp_index.h"
#include "vrrp_if.h"
+#include "vrrp_vmac.h"
#include "vrrp.h"
#include "global_data.h"
#include "global_parser.h"
@@ -36,71 +37,99 @@
/* Static addresses handler */
static void
-static_addresses_handler(vector strvec)
+static_addresses_handler(vector_t *strvec)
{
alloc_value_block(strvec, alloc_saddress);
}
/* Static routes handler */
static void
-static_routes_handler(vector strvec)
+static_routes_handler(vector_t *strvec)
{
alloc_value_block(strvec, alloc_sroute);
}
/* VRRP handlers */
static void
-vrrp_sync_group_handler(vector strvec)
+vrrp_sync_group_handler(vector_t *strvec)
{
- alloc_vrrp_sync_group(VECTOR_SLOT(strvec, 1));
+ alloc_vrrp_sync_group(vector_slot(strvec, 1));
}
static void
-vrrp_group_handler(vector strvec)
+vrrp_group_handler(vector_t *strvec)
{
vrrp_sgroup *vgroup = LIST_TAIL_DATA(vrrp_data->vrrp_sync_group);
vgroup->iname = read_value_block();
}
static void
-vrrp_gnotify_backup_handler(vector strvec)
+vrrp_gnotify_backup_handler(vector_t *strvec)
{
vrrp_sgroup *vgroup = LIST_TAIL_DATA(vrrp_data->vrrp_sync_group);
vgroup->script_backup = set_value(strvec);
vgroup->notify_exec = 1;
}
static void
-vrrp_gnotify_master_handler(vector strvec)
+vrrp_gnotify_master_handler(vector_t *strvec)
{
vrrp_sgroup *vgroup = LIST_TAIL_DATA(vrrp_data->vrrp_sync_group);
vgroup->script_master = set_value(strvec);
vgroup->notify_exec = 1;
}
static void
-vrrp_gnotify_fault_handler(vector strvec)
+vrrp_gnotify_fault_handler(vector_t *strvec)
{
vrrp_sgroup *vgroup = LIST_TAIL_DATA(vrrp_data->vrrp_sync_group);
vgroup->script_fault = set_value(strvec);
vgroup->notify_exec = 1;
}
static void
-vrrp_gnotify_handler(vector strvec)
+vrrp_gnotify_handler(vector_t *strvec)
{
vrrp_sgroup *vgroup = LIST_TAIL_DATA(vrrp_data->vrrp_sync_group);
vgroup->script = set_value(strvec);
vgroup->notify_exec = 1;
}
static void
-vrrp_gsmtp_handler(vector strvec)
+vrrp_gsmtp_handler(vector_t *strvec)
{
vrrp_sgroup *vgroup = LIST_TAIL_DATA(vrrp_data->vrrp_sync_group);
vgroup->smtp_alert = 1;
}
static void
-vrrp_handler(vector strvec)
+vrrp_gglobal_tracking_handler(vector_t *strvec)
{
- alloc_vrrp(VECTOR_SLOT(strvec, 1));
+ vrrp_sgroup *vgroup = LIST_TAIL_DATA(vrrp_data->vrrp_sync_group);
+ vgroup->global_tracking = 1;
}
static void
-vrrp_native_ipv6_handler(vector strvec)
+vrrp_handler(vector_t *strvec)
+{
+ alloc_vrrp(vector_slot(strvec, 1));
+}
+static void
+vrrp_vmac_handler(vector_t *strvec)
+{
+ vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
+ vrrp->vmac = 1;
+ if (!vrrp->mcast_saddr)
+ vrrp->mcast_saddr = IF_ADDR(vrrp->ifp);
+ if (vector_size(strvec) == 2) {
+ strncpy(vrrp->vmac_ifname, vector_slot(strvec, 1),
+ IFNAMSIZ - 1);
+ } else if (vrrp->vrid) {
+ snprintf(vrrp->vmac_ifname, IFNAMSIZ, "vrrp.%d", vrrp->vrid);
+ }
+
+ if (strlen(vrrp->vmac_ifname)) {
+ log_message(LOG_INFO, "vmac_ifname=%s for vrrp_instace %s"
+ , vrrp->vmac_ifname
+ , vrrp->iname);
+ }
+ if (vrrp->ifp && !(vrrp->vmac & 2))
+ netlink_link_add_vmac(vrrp);
+}
+static void
+vrrp_native_ipv6_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
vrrp->family = AF_INET6;
@@ -109,9 +138,9 @@
vrrp->auth_type = VRRP_AUTH_NONE;
}
static void
-vrrp_state_handler(vector strvec)
+vrrp_state_handler(vector_t *strvec)
{
- char *str = VECTOR_SLOT(strvec, 1);
+ char *str = vector_slot(strvec, 1);
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
vrrp_sgroup *vgroup = vrrp->sync;
@@ -125,110 +154,120 @@
vgroup->state = vrrp->wantstate;
}
static void
-vrrp_int_handler(vector strvec)
+vrrp_int_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
- char *name = VECTOR_SLOT(strvec, 1);
+ char *name = vector_slot(strvec, 1);
vrrp->ifp = if_get_by_ifname(name);
+ if (vrrp->vmac && !(vrrp->vmac & 2))
+ netlink_link_add_vmac(vrrp);
}
static void
-vrrp_track_int_handler(vector strvec)
+vrrp_track_int_handler(vector_t *strvec)
{
alloc_value_block(strvec, alloc_vrrp_track);
}
static void
-vrrp_track_scr_handler(vector strvec)
+vrrp_track_scr_handler(vector_t *strvec)
{
alloc_value_block(strvec, alloc_vrrp_track_script);
}
static void
-vrrp_dont_track_handler(vector strvec)
+vrrp_dont_track_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
vrrp->dont_track_primary = 1;
}
static void
-vrrp_mcastip_handler(vector strvec)
+vrrp_mcastip_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
- inet_ston(VECTOR_SLOT(strvec, 1), &vrrp->mcast_saddr);
+ inet_ston(vector_slot(strvec, 1), &vrrp->mcast_saddr);
}
static void
-vrrp_vrid_handler(vector strvec)
+vrrp_vrid_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
- vrrp->vrid = atoi(VECTOR_SLOT(strvec, 1));
+ vrrp->vrid = atoi(vector_slot(strvec, 1));
if (VRRP_IS_BAD_VID(vrrp->vrid)) {
- log_message(LOG_INFO, "VRRP Error : VRID not valid !\n");
+ log_message(LOG_INFO, "VRRP Error : VRID not valid !");
log_message(LOG_INFO,
- " must be between 1 & 255. reconfigure !\n");
- } else
+ " must be between 1 & 255. reconfigure !");
+ } else {
alloc_vrrp_bucket(vrrp);
+ if (vrrp->vmac && strlen(vrrp->vmac_ifname) == 0) {
+ snprintf(vrrp->vmac_ifname, IFNAMSIZ, "vrrp.%d"
+ , vrrp->vrid);
+ log_message(LOG_INFO, "vmac_ifname=%s for vrrp_instace %s"
+ , vrrp->vmac_ifname
+ , vrrp->iname);
+ }
+ }
}
static void
-vrrp_prio_handler(vector strvec)
+vrrp_prio_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
- vrrp->effective_priority = vrrp->base_priority = atoi(VECTOR_SLOT(strvec, 1));
+ vrrp->effective_priority = vrrp->base_priority = atoi(vector_slot(strvec, 1));
if (VRRP_IS_BAD_PRIORITY(vrrp->base_priority)) {
- log_message(LOG_INFO, "VRRP Error : Priority not valid !\n");
+ log_message(LOG_INFO, "VRRP Error : Priority not valid !");
log_message(LOG_INFO,
- " must be between 1 & 255. reconfigure !\n");
+ " must be between 1 & 255. reconfigure !");
log_message(LOG_INFO,
" Using default value : %d\n", VRRP_PRIO_DFL);
vrrp->effective_priority = vrrp->base_priority = VRRP_PRIO_DFL;
}
}
static void
-vrrp_adv_handler(vector strvec)
+vrrp_adv_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
- vrrp->adver_int = atoi(VECTOR_SLOT(strvec, 1));
+ vrrp->adver_int = atoi(vector_slot(strvec, 1));
if (VRRP_IS_BAD_ADVERT_INT(vrrp->adver_int)) {
- log_message(LOG_INFO, "VRRP Error : Advert interval not valid !\n");
+ log_message(LOG_INFO, "VRRP Error : Advert interval not valid !");
log_message(LOG_INFO,
- " must be between less than 1sec.\n");
- log_message(LOG_INFO, " Using default value : 1sec\n");
+ " must be between less than 1sec.");
+ log_message(LOG_INFO, " Using default value : 1sec");
vrrp->adver_int = 1;
}
vrrp->adver_int *= TIMER_HZ;
}
static void
-vrrp_debug_handler(vector strvec)
+vrrp_debug_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
- vrrp->debug = atoi(VECTOR_SLOT(strvec, 1));
+ vrrp->debug = atoi(vector_slot(strvec, 1));
if (VRRP_IS_BAD_DEBUG_INT(vrrp->debug)) {
- log_message(LOG_INFO, "VRRP Error : Debug interval not valid !\n");
- log_message(LOG_INFO, " must be between 0-4\n");
+ log_message(LOG_INFO, "VRRP Error : Debug interval not valid !");
+ log_message(LOG_INFO, " must be between 0-4");
vrrp->debug = 0;
}
}
static void
-vrrp_nopreempt_handler(vector strvec)
+vrrp_nopreempt_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
vrrp->nopreempt = 1;
}
static void /* backwards compatibility */
-vrrp_preempt_handler(vector strvec)
+vrrp_preempt_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
vrrp->nopreempt = 0;
}
static void
-vrrp_preempt_delay_handler(vector strvec)
+vrrp_preempt_delay_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
- vrrp->preempt_delay = atoi(VECTOR_SLOT(strvec, 1));
+ vrrp->preempt_delay = atoi(vector_slot(strvec, 1));
if (VRRP_IS_BAD_PREEMPT_DELAY(vrrp->preempt_delay)) {
- log_message(LOG_INFO, "VRRP Error : Preempt_delay not valid !\n");
- log_message(LOG_INFO, " must be between 0-%d\n",
+ log_message(LOG_INFO, "VRRP Error : Preempt_delay not valid !");
+ log_message(LOG_INFO, " must be between 0-%d",
TIMER_MAX_SEC);
vrrp->preempt_delay = 0;
}
@@ -236,65 +275,65 @@
vrrp->preempt_time = timer_add_long(timer_now(), vrrp->preempt_delay);
}
static void
-vrrp_notify_backup_handler(vector strvec)
+vrrp_notify_backup_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
vrrp->script_backup = set_value(strvec);
vrrp->notify_exec = 1;
}
static void
-vrrp_notify_master_handler(vector strvec)
+vrrp_notify_master_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
vrrp->script_master = set_value(strvec);
vrrp->notify_exec = 1;
}
static void
-vrrp_notify_fault_handler(vector strvec)
+vrrp_notify_fault_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
vrrp->script_fault = set_value(strvec);
vrrp->notify_exec = 1;
}
static void
-vrrp_notify_stop_handler(vector strvec)
+vrrp_notify_stop_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
vrrp->script_stop = set_value(strvec);
vrrp->notify_exec = 1;
}
static void
-vrrp_notify_handler(vector strvec)
+vrrp_notify_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
vrrp->script = set_value(strvec);
vrrp->notify_exec = 1;
}
static void
-vrrp_smtp_handler(vector strvec)
+vrrp_smtp_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
vrrp->smtp_alert = 1;
}
static void
-vrrp_lvs_syncd_handler(vector strvec)
+vrrp_lvs_syncd_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
vrrp->lvs_syncd_if = set_value(strvec);
}
static void
-vrrp_garp_delay_handler(vector strvec)
+vrrp_garp_delay_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
- vrrp->garp_delay = atoi(VECTOR_SLOT(strvec, 1)) * TIMER_HZ;
+ vrrp->garp_delay = atoi(vector_slot(strvec, 1)) * TIMER_HZ;
if (vrrp->garp_delay < TIMER_HZ)
vrrp->garp_delay = TIMER_HZ;
}
static void
-vrrp_auth_type_handler(vector strvec)
+vrrp_auth_type_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
- char *str = VECTOR_SLOT(strvec, 1);
+ char *str = vector_slot(strvec, 1);
if (!strcmp(str, "AH") && vrrp->family == AF_INET)
vrrp->auth_type = VRRP_AUTH_AH;
@@ -302,42 +341,42 @@
vrrp->auth_type = VRRP_AUTH_PASS;
}
static void
-vrrp_auth_pass_handler(vector strvec)
+vrrp_auth_pass_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
- char *str = VECTOR_SLOT(strvec, 1);
+ char *str = vector_slot(strvec, 1);
int max_size = sizeof (vrrp->auth_data);
int str_len = strlen(str);
if (str_len > max_size) {
str_len = max_size;
log_message(LOG_INFO,
- "Truncating auth_pass to %d characters", max_size);
+ "Truncating auth_pass to %d characters", max_size);
}
memset(vrrp->auth_data, 0, max_size);
memcpy(vrrp->auth_data, str, str_len);
}
static void
-vrrp_vip_handler(vector strvec)
+vrrp_vip_handler(vector_t *strvec)
{
vrrp_rt *vrrp = LIST_TAIL_DATA(vrrp_data->vrrp);
char *buf;
char *str = NULL;
- vector vec = NULL;
+ vector_t *vec = NULL;
int nbvip = 0;
buf = (char *) MALLOC(MAXBUF);
while (read_line(buf, MAXBUF)) {
vec = alloc_strvec(buf);
if (vec) {
- str = VECTOR_SLOT(vec, 0);
+ str = vector_slot(vec, 0);
if (!strcmp(str, EOB)) {
free_strvec(vec);
break;
}
- if (VECTOR_SIZE(vec)) {
+ if (vector_size(vec)) {
nbvip++;
if (nbvip > VRRP_MAX_VIP) {
log_message(LOG_INFO,
@@ -358,58 +397,66 @@
FREE(buf);
}
static void
-vrrp_evip_handler(vector strvec)
+vrrp_evip_handler(vector_t *strvec)
{
alloc_value_block(strvec, alloc_vrrp_evip);
}
static void
-vrrp_vroutes_handler(vector strvec)
+vrrp_vroutes_handler(vector_t *strvec)
{
alloc_value_block(strvec, alloc_vrrp_vroute);
}
static void
-vrrp_script_handler(vector strvec)
+vrrp_script_handler(vector_t *strvec)
{
- alloc_vrrp_script(VECTOR_SLOT(strvec, 1));
+ alloc_vrrp_script(vector_slot(strvec, 1));
}
static void
-vrrp_vscript_script_handler(vector strvec)
+vrrp_vscript_script_handler(vector_t *strvec)
{
vrrp_script *vscript = LIST_TAIL_DATA(vrrp_data->vrrp_script);
vscript->script = set_value(strvec);
}
static void
-vrrp_vscript_interval_handler(vector strvec)
+vrrp_vscript_interval_handler(vector_t *strvec)
{
vrrp_script *vscript = LIST_TAIL_DATA(vrrp_data->vrrp_script);
- vscript->interval = atoi(VECTOR_SLOT(strvec, 1)) * TIMER_HZ;
+ vscript->interval = atoi(vector_slot(strvec, 1)) * TIMER_HZ;
if (vscript->interval < TIMER_HZ)
vscript->interval = TIMER_HZ;
}
static void
-vrrp_vscript_weight_handler(vector strvec)
+vrrp_vscript_timeout_handler(vector_t *strvec)
+{
+ vrrp_script *vscript = LIST_TAIL_DATA(vrrp_data->vrrp_script);
+ vscript->timeout = atoi(vector_slot(strvec, 1)) * TIMER_HZ;
+ if (vscript->timeout < TIMER_HZ)
+ vscript->timeout = TIMER_HZ;
+}
+static void
+vrrp_vscript_weight_handler(vector_t *strvec)
{
vrrp_script *vscript = LIST_TAIL_DATA(vrrp_data->vrrp_script);
- vscript->weight = atoi(VECTOR_SLOT(strvec, 1));
+ vscript->weight = atoi(vector_slot(strvec, 1));
}
static void
-vrrp_vscript_rise_handler(vector strvec)
+vrrp_vscript_rise_handler(vector_t *strvec)
{
vrrp_script *vscript = LIST_TAIL_DATA(vrrp_data->vrrp_script);
- vscript->rise = atoi(VECTOR_SLOT(strvec, 1));
+ vscript->rise = atoi(vector_slot(strvec, 1));
if (vscript->rise < 1)
vscript->rise = 1;
}
static void
-vrrp_vscript_fall_handler(vector strvec)
+vrrp_vscript_fall_handler(vector_t *strvec)
{
vrrp_script *vscript = LIST_TAIL_DATA(vrrp_data->vrrp_script);
- vscript->fall = atoi(VECTOR_SLOT(strvec, 1));
+ vscript->fall = atoi(vector_slot(strvec, 1));
if (vscript->fall < 1)
vscript->fall = 1;
}
-vector
+vector_t *
vrrp_init_keywords(void)
{
/* global definitions mapping */
@@ -427,7 +474,9 @@
install_keyword("notify_fault", &vrrp_gnotify_fault_handler);
install_keyword("notify", &vrrp_gnotify_handler);
install_keyword("smtp_alert", &vrrp_gsmtp_handler);
+ install_keyword("global_tracking", &vrrp_gglobal_tracking_handler);
install_keyword_root("vrrp_instance", &vrrp_handler);
+ install_keyword("use_vmac", &vrrp_vmac_handler);
install_keyword("native_ipv6", &vrrp_native_ipv6_handler);
install_keyword("state", &vrrp_state_handler);
install_keyword("interface", &vrrp_int_handler);
@@ -461,6 +510,7 @@
install_keyword_root("vrrp_script", &vrrp_script_handler);
install_keyword("script", &vrrp_vscript_script_handler);
install_keyword("interval", &vrrp_vscript_interval_handler);
+ install_keyword("timeout", &vrrp_vscript_timeout_handler);
install_keyword("weight", &vrrp_vscript_weight_handler);
install_keyword("rise", &vrrp_vscript_rise_handler);
install_keyword("fall", &vrrp_vscript_fall_handler);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_scheduler.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include "vrrp_scheduler.h"
@@ -37,6 +37,9 @@
#include "main.h"
#include "smtp.h"
#include "signals.h"
+#ifdef _WITH_SNMP_
+#include "vrrp_snmp.h"
+#endif
/* VRRP FSM (Finite State Machine) design.
*
@@ -189,15 +192,15 @@
/* In case of VRRP SYNC, we have to carefully check that we are
* not running floating priorities on any VRRP instance.
*/
- if (vrrp->sync) {
- element e;
+ if (vrrp->sync && !vrrp->sync->global_tracking) {
+ element e2;
tracked_sc *sc;
tracked_if *tip;
int warning = 0;
if (!LIST_ISEMPTY(vrrp->track_ifp)) {
- for (e = LIST_HEAD(vrrp->track_ifp); e; ELEMENT_NEXT(e)) {
- tip = ELEMENT_DATA(e);
+ for (e2 = LIST_HEAD(vrrp->track_ifp); e2; ELEMENT_NEXT(e2)) {
+ tip = ELEMENT_DATA(e2);
if (tip->weight) {
tip->weight = 0;
warning++;
@@ -206,9 +209,8 @@
}
if (!LIST_ISEMPTY(vrrp->track_script)) {
- for (e = LIST_HEAD(vrrp->track_script); e;
- ELEMENT_NEXT(e)) {
- sc = ELEMENT_DATA(e);
+ for (e2 = LIST_HEAD(vrrp->track_script); e2; ELEMENT_NEXT(e2)) {
+ sc = ELEMENT_DATA(e2);
if (sc->weight) {
sc->scr->inuse--;
warning++;
@@ -255,6 +257,9 @@
vrrp->state = VRRP_STATE_BACK;
vrrp_smtp_notifier(vrrp);
notify_instance_exec(vrrp, VRRP_STATE_BACK);
+#ifdef _WITH_SNMP_
+ vrrp_snmp_instance_trap(vrrp);
+#endif
/* Init group if needed */
if ((vgroup = vrrp->sync)) {
@@ -262,6 +267,9 @@
vgroup->state = VRRP_STATE_BACK;
vrrp_sync_smtp_notifier(vgroup);
notify_group_exec(vgroup, VRRP_STATE_BACK);
+#ifdef _WITH_SNMP_
+ vrrp_snmp_group_trap(vgroup);
+#endif
}
}
}
@@ -305,20 +313,20 @@
}
/* Timer functions */
-static TIMEVAL
+static timeval_t
vrrp_compute_timer(const int fd)
{
vrrp_rt *vrrp;
element e;
list l = &vrrp_data->vrrp_index_fd[fd%1024 + 1];
- TIMEVAL timer;
+ timeval_t timer;
/* Multiple instances on the same interface */
- TIMER_RESET(timer);
+ timer_reset(timer);
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
vrrp = ELEMENT_DATA(e);
if (timer_cmp(vrrp->sands, timer) < 0 ||
- TIMER_ISNULL(timer))
+ timer_isnull(timer))
timer = timer_dup(vrrp->sands);
}
@@ -328,12 +336,12 @@
static long
vrrp_timer_fd(const int fd)
{
- TIMEVAL timer, vrrp_timer;
+ timeval_t timer, vrrp_timer;
long vrrp_long;
timer = vrrp_compute_timer(fd);
vrrp_timer = timer_sub(timer, time_now);
- vrrp_long = TIMER_LONG(vrrp_timer);
+ vrrp_long = timer_long(vrrp_timer);
return (vrrp_long < 0) ? TIMER_MAX_SEC : vrrp_long;
}
@@ -344,15 +352,15 @@
vrrp_rt *vrrp;
element e;
list l = &vrrp_data->vrrp_index_fd[fd%1024 + 1];
- TIMEVAL timer;
+ timeval_t timer;
int vrid = 0;
/* Multiple instances on the same interface */
- TIMER_RESET(timer);
+ timer_reset(timer);
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
vrrp = ELEMENT_DATA(e);
if (timer_cmp(vrrp->sands, timer) < 0 ||
- TIMER_ISNULL(timer)) {
+ timer_isnull(timer)) {
timer = timer_dup(vrrp->sands);
vrid = vrrp->vrid;
}
@@ -365,7 +373,7 @@
vrrp_register_workers(list l)
{
sock_t *sock;
- TIMEVAL timer;
+ timeval_t timer;
long vrrp_timer = 0;
element e;
@@ -641,6 +649,9 @@
vrrp->state = VRRP_STATE_BACK;
vrrp_smtp_notifier(vrrp);
notify_instance_exec(vrrp, VRRP_STATE_BACK);
+#ifdef _WITH_SNMP_
+ vrrp_snmp_instance_trap(vrrp);
+#endif
}
} else {
log_message(LOG_INFO, "VRRP_Instance(%s) Entering BACKUP STATE",
@@ -648,6 +659,9 @@
vrrp->state = VRRP_STATE_BACK;
vrrp_smtp_notifier(vrrp);
notify_instance_exec(vrrp, VRRP_STATE_BACK);
+#ifdef _WITH_SNMP_
+ vrrp_snmp_instance_trap(vrrp);
+#endif
}
}
}
@@ -664,6 +678,9 @@
vrrp->state = VRRP_STATE_FAULT;
vrrp->ms_down_timer = 3 * vrrp->adver_int + VRRP_TIMER_SKEW(vrrp);
notify_instance_exec(vrrp, VRRP_STATE_FAULT);
+#ifdef _WITH_SNMP_
+ vrrp_snmp_instance_trap(vrrp);
+#endif
} else {
/* If becoming MASTER in IPSEC AH AUTH, we reset the anti-replay */
if (vrrp->ipsecah_counter->cycle) {
@@ -702,11 +719,11 @@
prio_offset = 0;
/* Now we will sum the weights of all interfaces which are tracked. */
- if (!vrrp->sync && !LIST_ISEMPTY(vrrp->track_ifp))
+ if ((!vrrp->sync || vrrp->sync->global_tracking) && !LIST_ISEMPTY(vrrp->track_ifp))
prio_offset += vrrp_tracked_weight(vrrp->track_ifp);
/* Now we will sum the weights of all scripts which are tracked. */
- if (!vrrp->sync && !LIST_ISEMPTY(vrrp->track_script))
+ if ((!vrrp->sync || vrrp->sync->global_tracking) && !LIST_ISEMPTY(vrrp->track_script))
prio_offset += vrrp_script_weight(vrrp->track_script);
if (vrrp->base_priority == VRRP_PRIO_OWNER) {
@@ -802,6 +819,9 @@
if (vrrp->init_state == VRRP_STATE_BACK) {
vrrp->state = VRRP_STATE_BACK;
notify_instance_exec(vrrp, VRRP_STATE_BACK);
+#ifdef _WITH_SNMP_
+ vrrp_snmp_instance_trap(vrrp);
+#endif
} else {
vrrp_goto_master(vrrp);
}
@@ -936,10 +956,9 @@
/* In case of this is parent process */
if (pid) {
- long timeout;
- timeout = vscript->interval;
thread_add_child(thread->master, vrrp_script_child_thread,
- vscript, pid, timeout);
+ vscript, pid,
+ (vscript->timeout) ? vscript->timeout : vscript->interval);
return 0;
}
@@ -948,7 +967,14 @@
closeall(0);
open("/dev/null", O_RDWR);
ret = dup(0);
+ if (ret < 0) {
+ log_message(LOG_INFO, "dup(0) error");
+ }
+
ret = dup(0);
+ if (ret < 0) {
+ log_message(LOG_INFO, "dup(0) error");
+ }
status = system_call(vscript->script);
|
[-]
[+]
|
Added |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_snmp.c
^
|
@@ -0,0 +1,1181 @@
+/*
+ * Soft: Keepalived is a failover program for the LVS project
+ * <www.linuxvirtualserver.org>. It monitor & manipulate
+ * a loadbalanced server pool using multi-layer checks.
+ *
+ * Part: SNMP agent
+ *
+ * Author: Vincent Bernat <bernat@luffy.cx>
+ *
+ * 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>
+ */
+
+#include "vrrp.h"
+#include "vrrp_snmp.h"
+#include "vrrp_data.h"
+#include "vrrp_track.h"
+#include "vrrp_ipaddress.h"
+#include "vrrp_iproute.h"
+#include "config.h"
+#include "vector.h"
+#include "list.h"
+#include "logger.h"
+#include "global_data.h"
+
+
+/* Convert VRRP state to SNMP state */
+static unsigned long
+vrrp_snmp_state(int state)
+{
+ return (state<VRRP_STATE_GOTO_MASTER)?state:4;
+}
+
+static u_char*
+vrrp_snmp_script(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method)
+{
+ static unsigned long long_ret;
+ vrrp_script *scr;
+
+ if ((scr = (vrrp_script *)snmp_header_list_table(vp, name, length, exact,
+ var_len, write_method,
+ vrrp_data->vrrp_script)) == NULL)
+ return NULL;
+
+ switch (vp->magic) {
+ case VRRP_SNMP_SCRIPT_NAME:
+ *var_len = strlen(scr->sname);
+ return (u_char *)scr->sname;
+ case VRRP_SNMP_SCRIPT_COMMAND:
+ *var_len = strlen(scr->script);
+ return (u_char *)scr->script;
+ case VRRP_SNMP_SCRIPT_INTERVAL:
+ long_ret = scr->interval / TIMER_HZ;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_SCRIPT_WEIGHT:
+ long_ret = scr->weight;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_SCRIPT_RESULT:
+ switch (scr->result) {
+ case VRRP_SCRIPT_STATUS_INIT:
+ long_ret = 1; break;
+ case VRRP_SCRIPT_STATUS_INIT_GOOD:
+ long_ret = 4; break;
+ case VRRP_SCRIPT_STATUS_DISABLED:
+ long_ret = 0; break;
+ default:
+ long_ret = (scr->result >= scr->rise) ? 3 : 2;
+ }
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_SCRIPT_RISE:
+ long_ret = scr->rise;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_SCRIPT_FALL:
+ long_ret = scr->fall;
+ return (u_char *)&long_ret;
+ default:
+ break;
+ }
+ return NULL;
+}
+
+/* Header function using a FSM. `state' is the initial state, either
+ HEADER_STATE_STATIC_ADDRESS or HEADER_STATE_STATIC_ROUTE. We return
+ the matching address or route. */
+static void*
+vrrp_header_ar_table(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method,
+ int *state)
+{
+ oid *target, current[2], best[2];
+ int result, target_len;
+ element e1 = NULL, e2;
+ void *el, *bel = NULL;
+ list l2;
+ int curinstance = 0;
+ int curstate, nextstate;
+
+ if ((result = snmp_oid_compare(name, *length, vp->name, vp->namelen)) < 0) {
+ memcpy(name, vp->name, sizeof(oid) * vp->namelen);
+ *length = vp->namelen;
+ }
+
+ *write_method = 0;
+ *var_len = sizeof(long);
+
+ /* We search the best match: equal if exact, the lower OID in
+ the set of the OID strictly superior to the target
+ otherwise. */
+ best[0] = best[1] = MAX_SUBID; /* Our best match */
+ target = &name[vp->namelen]; /* Our target match */
+ target_len = *length - vp->namelen;
+
+ nextstate = *state;
+ while (nextstate != HEADER_STATE_END) {
+ curstate = nextstate;
+ switch (curstate) {
+ case HEADER_STATE_STATIC_ADDRESS:
+ /* Try static addresses */
+ l2 = vrrp_data->static_addresses;
+ current[1] = 0;
+ nextstate = HEADER_STATE_VIRTUAL_ADDRESS;
+ break;
+ case HEADER_STATE_VIRTUAL_ADDRESS:
+ /* Try virtual addresses */
+ if (LIST_ISEMPTY(vrrp_data->vrrp)) {
+ nextstate = HEADER_STATE_END;
+ continue;
+ }
+ curinstance++;
+ if (e1 == NULL)
+ e1 = LIST_HEAD(vrrp_data->vrrp);
+ else {
+ ELEMENT_NEXT(e1);
+ if (!e1) {
+ nextstate = HEADER_STATE_END;
+ continue;
+ }
+ }
+ l2 = ((vrrp_rt*)ELEMENT_DATA(e1))->vip;
+ current[1] = 0;
+ nextstate = HEADER_STATE_EXCLUDED_VIRTUAL_ADDRESS;
+ break;
+ case HEADER_STATE_EXCLUDED_VIRTUAL_ADDRESS:
+ /* Try excluded virtual addresses */
+ l2 = ((vrrp_rt*)ELEMENT_DATA(e1))->evip;
+ nextstate = HEADER_STATE_VIRTUAL_ADDRESS;
+ break;
+ case HEADER_STATE_STATIC_ROUTE:
+ /* Try static routes */
+ l2 = vrrp_data->static_routes;
+ current[1] = 0;
+ nextstate = HEADER_STATE_VIRTUAL_ROUTE;
+ break;
+ case HEADER_STATE_VIRTUAL_ROUTE:
+ /* Try virtual routes */
+ if (LIST_ISEMPTY(vrrp_data->vrrp) ||
+ ((e1 != NULL) && (ELEMENT_NEXT(e1), !e1))) {
+ nextstate = HEADER_STATE_END;
+ continue;
+ }
+ curinstance++;
+ if (e1 == NULL)
+ e1 = LIST_HEAD(vrrp_data->vrrp);
+ l2 = ((vrrp_rt*)ELEMENT_DATA(e1))->vroutes;
+ current[1] = 0;
+ nextstate = HEADER_STATE_VIRTUAL_ROUTE;
+ break;
+ default:
+ return NULL; /* Big problem! */
+ }
+ if (target_len && (curinstance < target[0]))
+ continue; /* Optimization: cannot be part of our set */
+ if (LIST_ISEMPTY(l2)) continue;
+ for (e2 = LIST_HEAD(l2); e2; ELEMENT_NEXT(e2)) {
+ el = ELEMENT_DATA(e2);
+ current[0] = curinstance;
+ current[1]++;
+ if ((result = snmp_oid_compare(current, 2, target,
+ target_len)) < 0)
+ continue;
+ if ((result == 0) && !exact)
+ continue;
+ if (result == 0) {
+ return el;
+ }
+ if (snmp_oid_compare(current, 2, best, 2) < 0) {
+ /* This is our best match */
+ memcpy(best, current, sizeof(oid) * 2);
+ bel = el;
+ *state = curstate;
+ /* Optimization: (e1,e2) is strictly
+ increasing, this is the lower
+ element of our target set. */
+ nextstate = HEADER_STATE_END;
+ break;
+ }
+ }
+ }
+
+ if (bel == NULL)
+ /* No best match */
+ return NULL;
+ if (exact)
+ /* No exact match */
+ return NULL;
+ /* Let's use our best match */
+ memcpy(target, best, sizeof(oid) * 2);
+ *length = vp->namelen + 2;
+ return bel;
+}
+
+static u_char*
+vrrp_snmp_address(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method)
+{
+ static unsigned long long_ret;
+ ip_address *addr;
+ int state = HEADER_STATE_STATIC_ADDRESS;
+
+ if ((addr = (ip_address *)
+ vrrp_header_ar_table(vp, name, length, exact,
+ var_len, write_method,
+ &state)) == NULL)
+ return NULL;
+
+ switch (vp->magic) {
+ case VRRP_SNMP_ADDRESS_ADDRESSTYPE:
+ long_ret = (addr->ifa.ifa_family == AF_INET6)?2:1;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_ADDRESS_VALUE:
+ if (addr->ifa.ifa_family == AF_INET6) {
+ *var_len = 16;
+ return (u_char *)&addr->u.sin6_addr;
+ } else {
+ *var_len = 4;
+ return (u_char *)&addr->u.sin.sin_addr;
+ }
+ break;
+ case VRRP_SNMP_ADDRESS_BROADCAST:
+ if (addr->ifa.ifa_family == AF_INET6) break;
+ *var_len = 4;
+ return (u_char *)&addr->u.sin.sin_brd;
+ case VRRP_SNMP_ADDRESS_MASK:
+ long_ret = addr->ifa.ifa_prefixlen;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_ADDRESS_SCOPE:
+ long_ret = snmp_scope(addr->ifa.ifa_scope);
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_ADDRESS_IFINDEX:
+ long_ret = addr->ifa.ifa_index;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_ADDRESS_IFNAME:
+ *var_len = strlen(addr->ifp->ifname);
+ return (u_char *)addr->ifp->ifname;
+ case VRRP_SNMP_ADDRESS_IFALIAS:
+ if (addr->label) {
+ *var_len = strlen(addr->label);
+ return (u_char*)addr->label;
+ }
+ break;
+ case VRRP_SNMP_ADDRESS_ISSET:
+ long_ret = (addr->set)?1:2;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_ADDRESS_ISADVERTISED:
+ long_ret = (state == HEADER_STATE_VIRTUAL_ADDRESS)?1:2;
+ return (u_char *)&long_ret;
+ default:
+ return NULL;
+ }
+ /* If we are here, we asked for a non existent data. Try the
+ next one. */
+ if (!exact && (name[*length-1] < MAX_SUBID))
+ return vrrp_snmp_address(vp, name, length,
+ exact, var_len, write_method);
+ return NULL;
+}
+
+static u_char*
+vrrp_snmp_route(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method)
+{
+ static unsigned long long_ret;
+ ip_route *route;
+ int state = HEADER_STATE_STATIC_ROUTE;
+
+ if ((route = (ip_route *)
+ vrrp_header_ar_table(vp, name, length, exact,
+ var_len, write_method,
+ &state)) == NULL)
+ return NULL;
+
+ switch (vp->magic) {
+ case VRRP_SNMP_ROUTE_ADDRESSTYPE:
+ long_ret = 1; /* IPv4 only */
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_ROUTE_DESTINATION:
+ *var_len = 4;
+ return (u_char *)&route->dst;
+ case VRRP_SNMP_ROUTE_DESTINATIONMASK:
+ long_ret = route->dmask;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_ROUTE_GATEWAY:
+ *var_len = 4;
+ return (u_char *)&route->gw;
+ case VRRP_SNMP_ROUTE_SECONDARYGATEWAY:
+ if (route->gw2) {
+ *var_len = 4;
+ return (u_char *)&route->gw2;
+ }
+ break;
+ case VRRP_SNMP_ROUTE_SOURCE:
+ *var_len = 4;
+ return (u_char *)&route->src;
+ case VRRP_SNMP_ROUTE_METRIC:
+ long_ret = route->metric;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_ROUTE_SCOPE:
+ long_ret = snmp_scope(route->scope);
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_ROUTE_TYPE:
+ if (route->blackhole)
+ long_ret = 3;
+ else if (route->gw2)
+ long_ret = 2;
+ else long_ret = 1;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_ROUTE_IFINDEX:
+ long_ret = route->index;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_ROUTE_IFNAME:
+ if (route->index) {
+ *var_len = strlen(IF_NAME(if_get_by_ifindex(route->index)));
+ return (u_char *)&IF_NAME(if_get_by_ifindex(route->index));
+ }
+ break;
+ case VRRP_SNMP_ROUTE_ROUTINGTABLE:
+ long_ret = route->table;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_ROUTE_ISSET:
+ long_ret = (route->set)?1:2;
+ return (u_char *)&long_ret;
+ default:
+ return NULL;
+ }
+ /* If we are here, we asked for a non existent data. Try the
+ next one. */
+ if (!exact && (name[*length-1] < MAX_SUBID))
+ return vrrp_snmp_route(vp, name, length,
+ exact, var_len, write_method);
+ return NULL;
+}
+
+static u_char*
+vrrp_snmp_syncgroup(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method)
+{
+ static unsigned long long_ret;
+ vrrp_sgroup *group;
+
+ if ((group = (vrrp_sgroup *)
+ snmp_header_list_table(vp, name, length, exact,
+ var_len, write_method,
+ vrrp_data->vrrp_sync_group)) == NULL)
+ return NULL;
+
+ switch (vp->magic) {
+ case VRRP_SNMP_SYNCGROUP_NAME:
+ *var_len = strlen(group->gname);
+ return (u_char *)group->gname;
+ case VRRP_SNMP_SYNCGROUP_STATE:
+ long_ret = vrrp_snmp_state(group->state);
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_SYNCGROUP_SMTPALERT:
+ long_ret = group->smtp_alert?1:2;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_SYNCGROUP_NOTIFYEXEC:
+ long_ret = group->notify_exec?1:2;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_SYNCGROUP_SCRIPTMASTER:
+ if (group->script_master) {
+ *var_len = strlen(group->script_master);
+ return (u_char *)group->script_master;
+ }
+ break;
+ case VRRP_SNMP_SYNCGROUP_SCRIPTBACKUP:
+ if (group->script_backup) {
+ *var_len = strlen(group->script_backup);
+ return (u_char *)group->script_backup;
+ }
+ break;
+ case VRRP_SNMP_SYNCGROUP_SCRIPTFAULT:
+ if (group->script_fault) {
+ *var_len = strlen(group->script_fault);
+ return (u_char *)group->script_fault;
+ }
+ break;
+ case VRRP_SNMP_SYNCGROUP_SCRIPT:
+ if (group->script) {
+ *var_len = strlen(group->script);
+ return (u_char *)group->script;
+ }
+ break;
+ default:
+ return NULL;
+ }
+ /* If we are here, we asked for a non existent data. Try the
+ next one. */
+ if (!exact && (name[*length-1] < MAX_SUBID))
+ return vrrp_snmp_syncgroup(vp, name, length,
+ exact, var_len, write_method);
+ return NULL;
+}
+
+static u_char*
+vrrp_snmp_syncgroupmember(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method)
+{
+ oid *target, current[2], best[2];
+ int result, target_len;
+ int curgroup, curinstance;
+ char *instance, *binstance = NULL;
+ element e;
+ vrrp_sgroup *group;
+
+ if ((result = snmp_oid_compare(name, *length, vp->name, vp->namelen)) < 0) {
+ memcpy(name, vp->name, sizeof(oid) * vp->namelen);
+ *length = vp->namelen;
+ }
+
+ *write_method = 0;
+ *var_len = sizeof(long);
+
+ if (LIST_ISEMPTY(vrrp_data->vrrp_sync_group))
+ return NULL;
+
+ /* We search the best match: equal if exact, the lower OID in
+ the set of the OID strictly superior to the target
+ otherwise. */
+ best[0] = best[1] = MAX_SUBID; /* Our best match */
+ target = &name[vp->namelen]; /* Our target match */
+ target_len = *length - vp->namelen;
+ curgroup = 0;
+ for (e = LIST_HEAD(vrrp_data->vrrp_sync_group); e; ELEMENT_NEXT(e)) {
+ group = ELEMENT_DATA(e);
+ curgroup++;
+ if (target_len && (curgroup < target[0]))
+ continue; /* Optimization: cannot be part of our set */
+ if (binstance)
+ break; /* Optimization: cannot be the lower
+ anymore, see break below */
+ vector_foreach_slot(group->iname, instance, curinstance) {
+ /* We build our current match */
+ current[0] = curgroup;
+ current[1] = curinstance + 1;
+ /* And compare it to our target match */
+ if ((result = snmp_oid_compare(current, 2, target,
+ target_len)) < 0)
+ continue;
+ if ((result == 0) && !exact)
+ continue;
+ if (result == 0) {
+ /* Got an exact match and asked for it */
+ *var_len = strlen(instance);
+ return (u_char *)instance;
+ }
+ if (snmp_oid_compare(current, 2, best, 2) < 0) {
+ /* This is our best match */
+ memcpy(best, current, sizeof(oid) * 2);
+ binstance = instance;
+ /* (current[0],current[1]) are
+ strictly increasing, this is our
+ lower element of our set */
+ break;
+ }
+ }
+ }
+ if (binstance == NULL)
+ /* No best match */
+ return NULL;
+ if (exact)
+ /* No exact match */
+ return NULL;
+ /* Let's use our best match */
+ memcpy(target, best, sizeof(oid) * 2);
+ *length = vp->namelen + 2;
+ *var_len = strlen(binstance);
+ return (u_char*)binstance;
+}
+
+static vrrp_rt*
+_get_instance(oid *name, size_t name_len)
+{
+ int instance;
+ element e;
+ vrrp_rt *vrrp = NULL;
+
+ if (name_len < 1) return NULL;
+ instance = name[name_len - 1];
+ if (LIST_ISEMPTY(vrrp_data->vrrp)) return NULL;
+ for (e = LIST_HEAD(vrrp_data->vrrp); e; ELEMENT_NEXT(e)) {
+ vrrp = ELEMENT_DATA(e);
+ if (--instance == 0) break;
+ }
+ return vrrp;
+}
+
+static int
+vrrp_snmp_instance_priority(int action,
+ u_char *var_val, u_char var_val_type, size_t var_val_len,
+ u_char *statP, oid *name, size_t name_len)
+{
+ vrrp_rt *vrrp = NULL;
+ switch (action) {
+ case RESERVE1:
+ /* Check that the proposed priority is acceptable */
+ if (var_val_type != ASN_INTEGER)
+ return SNMP_ERR_WRONGTYPE;
+ if (var_val_len > sizeof(long))
+ return SNMP_ERR_WRONGLENGTH;
+ if (VRRP_IS_BAD_PRIORITY((long)(*var_val)))
+ return SNMP_ERR_WRONGVALUE;
+ break;
+ case RESERVE2: /* Check that we can find the instance. We should. */
+ case COMMIT:
+ /* Find the instance */
+ vrrp = _get_instance(name, name_len);
+ if (!vrrp)
+ return SNMP_ERR_NOSUCHNAME;
+ if (action == RESERVE2)
+ break;
+ /* 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.",
+ 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
+ effective priority will be recomputed by some
+ thread. Otherwise, we should set it equal to the
+ base priority. */
+ if (vrrp->sync)
+ vrrp->effective_priority = vrrp->base_priority;
+ break;
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+static int
+vrrp_snmp_instance_preempt(int action,
+ u_char *var_val, u_char var_val_type, size_t var_val_len,
+ u_char *statP, oid *name, size_t name_len)
+{
+ vrrp_rt *vrrp = NULL;
+ switch (action) {
+ case RESERVE1:
+ /* Check that the proposed value is acceptable */
+ if (var_val_type != ASN_INTEGER)
+ return SNMP_ERR_WRONGTYPE;
+ if (var_val_len > sizeof(long))
+ return SNMP_ERR_WRONGLENGTH;
+ switch ((long)(*var_val)) {
+ case 1: /* enable preemption */
+ case 2: /* disable preemption */
+ break;
+ default:
+ return SNMP_ERR_WRONGVALUE;
+ }
+ break;
+ case RESERVE2: /* Check that we can find the instance. We should. */
+ case COMMIT:
+ /* Find the instance */
+ vrrp = _get_instance(name, name_len);
+ if (!vrrp) return SNMP_ERR_NOSUCHNAME;
+ if (action == RESERVE2)
+ break;
+ /* Commit: change values. There is no way to fail. */
+ switch ((long)(*var_val)) {
+ case 1:
+ log_message(LOG_INFO,
+ "VRRP_Instance(%s) preemption enabled with SNMP",
+ vrrp->iname);
+ vrrp->nopreempt = 0;
+ break;
+ case 2:
+ log_message(LOG_INFO,
+ "VRRP_Instance(%s) preemption disabled with SNMP",
+ vrrp->iname);
+ vrrp->nopreempt = 1;
+ break;
+ }
+ break;
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+static u_char*
+vrrp_snmp_instance(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method)
+{
+ static unsigned long long_ret;
+ vrrp_rt *rt;
+
+ if ((rt = (vrrp_rt *)snmp_header_list_table(vp, name, length, exact,
+ var_len, write_method,
+ vrrp_data->vrrp)) == NULL)
+ return NULL;
+
+ switch (vp->magic) {
+ case VRRP_SNMP_INSTANCE_NAME:
+ *var_len = strlen(rt->iname);
+ return (u_char *)rt->iname;
+ case VRRP_SNMP_INSTANCE_VIRTUALROUTERID:
+ long_ret = rt->vrid;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_STATE:
+ long_ret = vrrp_snmp_state(rt->state);
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_INITIALSTATE:
+ long_ret = vrrp_snmp_state(rt->init_state);
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_WANTEDSTATE:
+ long_ret = vrrp_snmp_state(rt->wantstate);
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_BASEPRIORITY:
+ long_ret = rt->base_priority;
+ *write_method = vrrp_snmp_instance_priority;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_EFFECTIVEPRIORITY:
+ long_ret = rt->effective_priority;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_VIPSENABLED:
+ long_ret = rt->vipset?1:2;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_PRIMARYINTERFACE:
+ *var_len = strlen(rt->ifp->ifname);
+ return (u_char *)&rt->ifp->ifname;
+ case VRRP_SNMP_INSTANCE_TRACKPRIMARYIF:
+ long_ret = rt->track_ifp?1:2;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_ADVERTISEMENTSINT:
+ long_ret = rt->adver_int / TIMER_HZ;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_PREEMPT:
+ long_ret = rt->nopreempt?2:1;
+ *write_method = vrrp_snmp_instance_preempt;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_PREEMPTDELAY:
+ long_ret = rt->preempt_delay / TIMER_HZ;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_AUTHTYPE:
+ long_ret = rt->auth_type;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_USELVSSYNCDAEMON:
+ long_ret = (rt->lvs_syncd_if)?1:2;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_LVSSYNCINTERFACE:
+ if (rt->lvs_syncd_if) {
+ *var_len = strlen(rt->lvs_syncd_if);
+ return (u_char *)rt->lvs_syncd_if;
+ }
+ break;
+ case VRRP_SNMP_INSTANCE_SYNCGROUP:
+ if (rt->sync) {
+ *var_len = strlen(rt->sync->gname);
+ return (u_char *)rt->sync->gname;
+ }
+ break;
+ case VRRP_SNMP_INSTANCE_GARPDELAY:
+ long_ret = rt->garp_delay / TIMER_HZ;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_SMTPALERT:
+ long_ret = rt->smtp_alert?1:2;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_NOTIFYEXEC:
+ long_ret = rt->notify_exec?1:2;
+ return (u_char *)&long_ret;
+ case VRRP_SNMP_INSTANCE_SCRIPTMASTER:
+ if (rt->script_master) {
+ *var_len = strlen(rt->script_master);
+ return (u_char *)rt->script_master;
+ }
+ break;
+ case VRRP_SNMP_INSTANCE_SCRIPTBACKUP:
+ if (rt->script_backup) {
+ *var_len = strlen(rt->script_backup);
+ return (u_char *)rt->script_backup;
+ }
+ break;
+ case VRRP_SNMP_INSTANCE_SCRIPTFAULT:
+ if (rt->script_fault) {
+ *var_len = strlen(rt->script_fault);
+ return (u_char *)rt->script_fault;
+ }
+ break;
+ case VRRP_SNMP_INSTANCE_SCRIPTSTOP:
+ if (rt->script_stop) {
+ *var_len = strlen(rt->script_stop);
+ return (u_char *)rt->script_stop;
+ }
+ break;
+ case VRRP_SNMP_INSTANCE_SCRIPT:
+ if (rt->script) {
+ *var_len = strlen(rt->script);
+ return (u_char *)rt->script;
+ }
+ break;
+ default:
+ return NULL;
+ }
+ /* If we are here, we asked for a non existent data. Try the
+ next one. */
+ if (!exact && (name[*length-1] < MAX_SUBID))
+ return vrrp_snmp_instance(vp, name, length,
+ exact, var_len, write_method);
+ return NULL;
+}
+
+static u_char*
+vrrp_snmp_trackedinterface(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method)
+{
+ static unsigned long long_ret;
+ oid *target, current[2], best[2];
+ int result, target_len;
+ int curinstance;
+ element e1, e2;
+ vrrp_rt *instance;
+ tracked_if *ifp, *bifp = NULL;
+
+ if ((result = snmp_oid_compare(name, *length, vp->name, vp->namelen)) < 0) {
+ memcpy(name, vp->name, sizeof(oid) * vp->namelen);
+ *length = vp->namelen;
+ }
+
+ *write_method = 0;
+ *var_len = sizeof(long);
+
+ if (LIST_ISEMPTY(vrrp_data->vrrp))
+ return NULL;
+
+ /* We search the best match: equal if exact, the lower OID in
+ the set of the OID strictly superior to the target
+ otherwise. */
+ best[0] = best[1] = MAX_SUBID; /* Our best match */
+ target = &name[vp->namelen]; /* Our target match */
+ target_len = *length - vp->namelen;
+ curinstance = 0;
+ for (e1 = LIST_HEAD(vrrp_data->vrrp); e1; ELEMENT_NEXT(e1)) {
+ instance = ELEMENT_DATA(e1);
+ curinstance++;
+ if (target_len && (curinstance < target[0]))
+ continue; /* Optimization: cannot be part of our set */
+ if (target_len && bifp && (curinstance > target[0] + 1))
+ break; /* Optimization: cannot be the lower anymore */
+ if (LIST_ISEMPTY(instance->track_ifp))
+ continue;
+ for (e2 = LIST_HEAD(instance->track_ifp); e2; ELEMENT_NEXT(e2)) {
+ ifp = ELEMENT_DATA(e2);
+ /* We build our current match */
+ current[0] = curinstance;
+ current[1] = ifp->ifp->ifindex;
+ /* And compare it to our target match */
+ if ((result = snmp_oid_compare(current, 2, target,
+ target_len)) < 0)
+ continue;
+ if ((result == 0) && !exact)
+ continue;
+ if (result == 0) {
+ /* Got an exact match and asked for it */
+ bifp = ifp;
+ goto trackedinterface_found;
+ }
+ if (snmp_oid_compare(current, 2, best, 2) < 0) {
+ /* This is our best match */
+ memcpy(best, current, sizeof(oid) * 2);
+ bifp = ifp;
+ }
+ }
+ }
+ if (bifp == NULL)
+ /* No best match */
+ return NULL;
+ if (exact)
+ /* No exact match */
+ return NULL;
+ /* Let's use our best match */
+ memcpy(target, best, sizeof(oid) * 2);
+ *length = vp->namelen + 2;
+ trackedinterface_found:
+ switch (vp->magic) {
+ case VRRP_SNMP_TRACKEDINTERFACE_NAME:
+ *var_len = strlen(bifp->ifp->ifname);
+ return (u_char *)bifp->ifp->ifname;
+ case VRRP_SNMP_TRACKEDINTERFACE_WEIGHT:
+ long_ret = bifp->weight;
+ return (u_char *)&long_ret;
+ }
+ return NULL;
+}
+
+static u_char*
+vrrp_snmp_trackedscript(struct variable *vp, oid *name, size_t *length,
+ int exact, size_t *var_len, WriteMethod **write_method)
+{
+ static unsigned long long_ret;
+ oid *target, current[2], best[2];
+ int result, target_len;
+ int curinstance, curscr;
+ element e1, e2;
+ vrrp_rt *instance;
+ tracked_sc *scr, *bscr = NULL;
+
+ if ((result = snmp_oid_compare(name, *length, vp->name, vp->namelen)) < 0) {
+ memcpy(name, vp->name, sizeof(oid) * vp->namelen);
+ *length = vp->namelen;
+ }
+
+ *write_method = 0;
+ *var_len = sizeof(long);
+
+ if (LIST_ISEMPTY(vrrp_data->vrrp))
+ return NULL;
+
+ /* We search the best match: equal if exact, the lower OID in
+ the set of the OID strictly superior to the target
+ otherwise. */
+ best[0] = best[1] = MAX_SUBID; /* Our best match */
+ target = &name[vp->namelen]; /* Our target match */
+ target_len = *length - vp->namelen;
+ curinstance = 0;
+ for (e1 = LIST_HEAD(vrrp_data->vrrp); e1; ELEMENT_NEXT(e1)) {
+ instance = ELEMENT_DATA(e1);
+ curinstance++;
+ if (target_len && (curinstance < target[0]))
+ continue; /* Optimization: cannot be part of our set */
+ if (bscr)
+ break; /* Optimization, see below */
+ if (LIST_ISEMPTY(instance->track_script))
+ continue;
+ curscr = 0;
+ for (e2 = LIST_HEAD(instance->track_script); e2; ELEMENT_NEXT(e2)) {
+ scr = ELEMENT_DATA(e2);
+ curscr++;
+ /* We build our current match */
+ current[0] = curinstance;
+ current[1] = curscr;
+ /* And compare it to our target match */
+ if ((result = snmp_oid_compare(current, 2, target,
+ target_len)) < 0)
+ continue;
+ if ((result == 0) && !exact)
+ continue;
+ if (result == 0) {
+ /* Got an exact match and asked for it */
+ bscr = scr;
+ goto trackedscript_found;
+ }
+ if (snmp_oid_compare(current, 2, best, 2) < 0) {
+ /* This is our best match */
+ memcpy(best, current, sizeof(oid) * 2);
+ bscr = scr;
+ /* (current[0],current[1]) are
+ strictly increasing, this is our
+ lower element of our set */
+ break;
+ }
+ }
+ }
+ if (bscr == NULL)
+ /* No best match */
+ return NULL;
+ if (exact)
+ /* No exact match */
+ return NULL;
+ /* Let's use our best match */
+ memcpy(target, best, sizeof(oid) * 2);
+ *length = vp->namelen + 2;
+ trackedscript_found:
+ switch (vp->magic) {
+ case VRRP_SNMP_TRACKEDSCRIPT_NAME:
+ *var_len = strlen(bscr->scr->sname);
+ return (u_char *)bscr->scr->sname;
+ case VRRP_SNMP_TRACKEDSCRIPT_WEIGHT:
+ long_ret = bscr->weight;
+ return (u_char *)&long_ret;
+ }
+ return NULL;
+}
+
+static oid vrrp_oid[] = {VRRP_OID};
+static struct variable8 vrrp_vars[] = {
+ /* vrrpSyncGroupTable */
+ {VRRP_SNMP_SYNCGROUP_NAME, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_syncgroup, 3, {1, 1, 2}},
+ {VRRP_SNMP_SYNCGROUP_STATE, ASN_INTEGER, RONLY,
+ vrrp_snmp_syncgroup, 3, {1, 1, 3}},
+ {VRRP_SNMP_SYNCGROUP_SMTPALERT, ASN_INTEGER, RONLY,
+ vrrp_snmp_syncgroup, 3, {1, 1, 4}},
+ {VRRP_SNMP_SYNCGROUP_NOTIFYEXEC, ASN_INTEGER, RONLY,
+ vrrp_snmp_syncgroup, 3, {1, 1, 5}},
+ {VRRP_SNMP_SYNCGROUP_SCRIPTMASTER, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_syncgroup, 3, {1, 1, 6}},
+ {VRRP_SNMP_SYNCGROUP_SCRIPTBACKUP, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_syncgroup, 3, {1, 1, 7}},
+ {VRRP_SNMP_SYNCGROUP_SCRIPTFAULT, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_syncgroup, 3, {1, 1, 8}},
+ {VRRP_SNMP_SYNCGROUP_SCRIPT, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_syncgroup, 3, {1, 1, 9}},
+ /* vrrpSyncGroupMemberTable */
+ {VRRP_SNMP_SYNCGROUPMEMBER_NAME, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_syncgroupmember, 3, {2, 1, 2}},
+ /* vrrpInstanceTable */
+ {VRRP_SNMP_INSTANCE_NAME, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 2}},
+ {VRRP_SNMP_INSTANCE_VIRTUALROUTERID, ASN_UNSIGNED, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 3}},
+ {VRRP_SNMP_INSTANCE_STATE, ASN_INTEGER, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 4}},
+ {VRRP_SNMP_INSTANCE_INITIALSTATE, ASN_INTEGER, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 5}},
+ {VRRP_SNMP_INSTANCE_WANTEDSTATE, ASN_INTEGER, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 6}},
+ {VRRP_SNMP_INSTANCE_BASEPRIORITY, ASN_INTEGER, RWRITE,
+ vrrp_snmp_instance, 3, {3, 1, 7}},
+ {VRRP_SNMP_INSTANCE_EFFECTIVEPRIORITY, ASN_INTEGER, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 8}},
+ {VRRP_SNMP_INSTANCE_VIPSENABLED, ASN_INTEGER, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 9}},
+ {VRRP_SNMP_INSTANCE_PRIMARYINTERFACE, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 10}},
+ {VRRP_SNMP_INSTANCE_TRACKPRIMARYIF, ASN_INTEGER, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 11}},
+ {VRRP_SNMP_INSTANCE_ADVERTISEMENTSINT, ASN_UNSIGNED, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 12}},
+ {VRRP_SNMP_INSTANCE_PREEMPT, ASN_INTEGER, RWRITE,
+ vrrp_snmp_instance, 3, {3, 1, 13}},
+ {VRRP_SNMP_INSTANCE_PREEMPTDELAY, ASN_UNSIGNED, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 14}},
+ {VRRP_SNMP_INSTANCE_AUTHTYPE, ASN_INTEGER, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 15}},
+ {VRRP_SNMP_INSTANCE_USELVSSYNCDAEMON, ASN_INTEGER, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 16}},
+ {VRRP_SNMP_INSTANCE_LVSSYNCINTERFACE, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 17}},
+ {VRRP_SNMP_INSTANCE_SYNCGROUP, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 18}},
+ {VRRP_SNMP_INSTANCE_GARPDELAY, ASN_UNSIGNED, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 19}},
+ {VRRP_SNMP_INSTANCE_SMTPALERT, ASN_INTEGER, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 20}},
+ {VRRP_SNMP_INSTANCE_NOTIFYEXEC, ASN_INTEGER, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 21}},
+ {VRRP_SNMP_INSTANCE_SCRIPTMASTER, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 22}},
+ {VRRP_SNMP_INSTANCE_SCRIPTBACKUP, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 23}},
+ {VRRP_SNMP_INSTANCE_SCRIPTFAULT, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 24}},
+ {VRRP_SNMP_INSTANCE_SCRIPTSTOP, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 25}},
+ {VRRP_SNMP_INSTANCE_SCRIPT, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_instance, 3, {3, 1, 26}},
+ /* vrrpTrackedInterfaceTable */
+ {VRRP_SNMP_TRACKEDINTERFACE_NAME, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_trackedinterface, 3, {4, 1, 1}},
+ {VRRP_SNMP_TRACKEDINTERFACE_WEIGHT, ASN_INTEGER, RONLY,
+ vrrp_snmp_trackedinterface, 3, {4, 1, 2}},
+ /* vrrpTrackedScriptTable */
+ {VRRP_SNMP_TRACKEDSCRIPT_NAME, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_trackedscript, 3, {5, 1, 2}},
+ {VRRP_SNMP_TRACKEDSCRIPT_WEIGHT, ASN_INTEGER, RONLY,
+ vrrp_snmp_trackedscript, 3, {5, 1, 3}},
+ /* vrrpAddressTable */
+ {VRRP_SNMP_ADDRESS_ADDRESSTYPE, ASN_INTEGER, RONLY,
+ vrrp_snmp_address, 3, {6, 1, 2}},
+ {VRRP_SNMP_ADDRESS_VALUE, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_address, 3, {6, 1, 3}},
+ {VRRP_SNMP_ADDRESS_BROADCAST, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_address, 3, {6, 1, 4}},
+ {VRRP_SNMP_ADDRESS_MASK, ASN_UNSIGNED, RONLY,
+ vrrp_snmp_address, 3, {6, 1, 5}},
+ {VRRP_SNMP_ADDRESS_SCOPE, ASN_INTEGER, RONLY,
+ vrrp_snmp_address, 3, {6, 1, 6}},
+ {VRRP_SNMP_ADDRESS_IFINDEX, ASN_INTEGER, RONLY,
+ vrrp_snmp_address, 3, {6, 1, 7}},
+ {VRRP_SNMP_ADDRESS_IFNAME, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_address, 3, {6, 1, 8}},
+ {VRRP_SNMP_ADDRESS_IFALIAS, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_address, 3, {6, 1, 9}},
+ {VRRP_SNMP_ADDRESS_ISSET, ASN_INTEGER, RONLY,
+ vrrp_snmp_address, 3, {6, 1, 10}},
+ {VRRP_SNMP_ADDRESS_ISADVERTISED, ASN_INTEGER, RONLY,
+ vrrp_snmp_address, 3, {6, 1, 11}},
+ /* vrrpRouteTable */
+ {VRRP_SNMP_ROUTE_ADDRESSTYPE, ASN_INTEGER, RONLY,
+ vrrp_snmp_route, 3, {7, 1, 2}},
+ {VRRP_SNMP_ROUTE_DESTINATION, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_route, 3, {7, 1, 3}},
+ {VRRP_SNMP_ROUTE_DESTINATIONMASK, ASN_UNSIGNED, RONLY,
+ vrrp_snmp_route, 3, {7, 1, 4}},
+ {VRRP_SNMP_ROUTE_GATEWAY, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_route, 3, {7, 1, 5}},
+ {VRRP_SNMP_ROUTE_SECONDARYGATEWAY, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_route, 3, {7, 1, 6}},
+ {VRRP_SNMP_ROUTE_SOURCE, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_route, 3, {7, 1, 7}},
+ {VRRP_SNMP_ROUTE_METRIC, ASN_UNSIGNED, RONLY,
+ vrrp_snmp_route, 3, {7, 1, 8}},
+ {VRRP_SNMP_ROUTE_SCOPE, ASN_INTEGER, RONLY,
+ vrrp_snmp_route, 3, {7, 1, 9}},
+ {VRRP_SNMP_ROUTE_TYPE, ASN_INTEGER, RONLY,
+ vrrp_snmp_route, 3, {7, 1, 10}},
+ {VRRP_SNMP_ROUTE_IFINDEX, ASN_INTEGER, RONLY,
+ vrrp_snmp_route, 3, {7, 1, 11}},
+ {VRRP_SNMP_ROUTE_IFNAME, ASN_OCTET_STR, RONLY,
+ vrrp_snmp_route, 3, {7, 1, 12}},
+ {VRRP_SNMP_ROUTE_ROUTINGTABLE, ASN_UNSIGNED, RONLY,
+ vrrp_snmp_route, 3, {7, 1, 13}},
+ {VRRP_SNMP_ROUTE_ISSET, ASN_INTEGER, RONLY,
+ vrrp_snmp_route, 3, {7, 1, 14}},
+ /* vrrpScriptTable */
+ {VRRP_SNMP_SCRIPT_NAME, ASN_OCTET_STR, RONLY, vrrp_snmp_script, 3, {8, 1, 2}},
+ {VRRP_SNMP_SCRIPT_COMMAND, ASN_OCTET_STR, RONLY, vrrp_snmp_script, 3, {8, 1, 3}},
+ {VRRP_SNMP_SCRIPT_INTERVAL, ASN_INTEGER, RONLY, vrrp_snmp_script, 3, {8, 1, 4}},
+ {VRRP_SNMP_SCRIPT_WEIGHT, ASN_INTEGER, RONLY, vrrp_snmp_script, 3, {8, 1, 5}},
+ {VRRP_SNMP_SCRIPT_RESULT, ASN_INTEGER, RONLY, vrrp_snmp_script, 3, {8, 1, 6}},
+ {VRRP_SNMP_SCRIPT_RISE, ASN_UNSIGNED, RONLY, vrrp_snmp_script, 3, {8, 1, 7}},
+ {VRRP_SNMP_SCRIPT_FALL, ASN_UNSIGNED, RONLY, vrrp_snmp_script, 3, {8, 1, 8}},
+};
+
+void
+vrrp_snmp_agent_init()
+{
+ snmp_agent_init(vrrp_oid, OID_LENGTH(vrrp_oid), "VRRP",
+ (struct variable *)vrrp_vars,
+ sizeof(struct variable8),
+ sizeof(vrrp_vars)/sizeof(struct variable8));
+}
+
+void
+vrrp_snmp_agent_close()
+{
+ snmp_agent_close(vrrp_oid, OID_LENGTH(vrrp_oid), "VRRP");
+}
+
+void
+vrrp_snmp_instance_trap(vrrp_rt *vrrp)
+{
+ /* OID of the notification */
+ oid notification_oid[] = { VRRP_OID, 9, 0, 2 };
+ size_t notification_oid_len = OID_LENGTH(notification_oid);
+ /* OID for snmpTrapOID.0 */
+ oid objid_snmptrap[] = { SNMPTRAP_OID };
+ size_t objid_snmptrap_len = OID_LENGTH(objid_snmptrap);
+
+ /* Other OID */
+ oid name_oid[] = { VRRP_OID, 3, 1, 2 };
+ size_t name_oid_len = OID_LENGTH(name_oid);
+ oid state_oid[] = { VRRP_OID, 3, 1, 4 };
+ size_t state_oid_len = OID_LENGTH(state_oid);
+ oid initialstate_oid[] = { VRRP_OID, 3, 1, 5};
+ size_t initialstate_oid_len = OID_LENGTH(initialstate_oid);
+ oid routerId_oid[] = { KEEPALIVED_OID, 1, 2, 0 };
+ size_t routerId_oid_len = OID_LENGTH(routerId_oid);
+
+ netsnmp_variable_list *notification_vars = NULL;
+
+ static unsigned long state;
+ static unsigned long istate;
+
+ if (!global_data->enable_traps) return;
+
+ /* snmpTrapOID */
+ snmp_varlist_add_variable(¬ification_vars,
+ objid_snmptrap, objid_snmptrap_len,
+ ASN_OBJECT_ID,
+ (u_char *) notification_oid,
+ notification_oid_len * sizeof(oid));
+ /* vrrpInstanceName */
+ snmp_varlist_add_variable(¬ification_vars,
+ name_oid, name_oid_len,
+ ASN_OCTET_STR,
+ (u_char *)vrrp->iname,
+ strlen(vrrp->iname));
+ /* vrrpInstanceState */
+ state = vrrp_snmp_state(vrrp->state);
+ snmp_varlist_add_variable(¬ification_vars,
+ state_oid, state_oid_len,
+ ASN_INTEGER,
+ (u_char *)&state,
+ sizeof(state));
+ /* vrrpInstanceInitialState */
+ istate = vrrp_snmp_state(vrrp->init_state);
+ snmp_varlist_add_variable(¬ification_vars,
+ initialstate_oid, initialstate_oid_len,
+ ASN_INTEGER,
+ (u_char *)&istate,
+ sizeof(istate));
+
+ /* routerId */
+ snmp_varlist_add_variable(¬ification_vars,
+ routerId_oid, routerId_oid_len,
+ ASN_OCTET_STR,
+ (u_char *)global_data->router_id,
+ strlen(global_data->router_id));
+
+ log_message(LOG_INFO,
+ "VRRP_Instance(%s): Sending SNMP notification",
+ vrrp->iname);
+ send_v2trap(notification_vars);
+ snmp_free_varbind(notification_vars);
+}
+
+void
+vrrp_snmp_group_trap(vrrp_sgroup *group)
+{
+ /* OID of the notification */
+ oid notification_oid[] = { VRRP_OID, 9, 0, 1 };
+ size_t notification_oid_len = OID_LENGTH(notification_oid);
+ /* OID for snmpTrapOID.0 */
+ oid objid_snmptrap[] = { SNMPTRAP_OID };
+ size_t objid_snmptrap_len = OID_LENGTH(objid_snmptrap);
+
+ /* Other OID */
+ oid name_oid[] = { VRRP_OID, 1, 1, 2 };
+ size_t name_oid_len = OID_LENGTH(name_oid);
+ oid state_oid[] = { VRRP_OID, 1, 1, 3 };
+ size_t state_oid_len = OID_LENGTH(state_oid);
+ oid routerId_oid[] = { KEEPALIVED_OID, 1, 2, 0 };
+ size_t routerId_oid_len = OID_LENGTH(routerId_oid);
+
+ netsnmp_variable_list *notification_vars = NULL;
+
+ static unsigned long state;
+
+ if (!global_data->enable_traps) return;
+
+ /* snmpTrapOID */
+ snmp_varlist_add_variable(¬ification_vars,
+ objid_snmptrap, objid_snmptrap_len,
+ ASN_OBJECT_ID,
+ (u_char *) notification_oid,
+ notification_oid_len * sizeof(oid));
+
+ /* vrrpSyncGroupName */
+ snmp_varlist_add_variable(¬ification_vars,
+ name_oid, name_oid_len,
+ ASN_OCTET_STR,
+ (u_char *)group->gname,
+ strlen(group->gname));
+ /* vrrpSyncGroupState */
+ state = vrrp_snmp_state(group->state);
+ snmp_varlist_add_variable(¬ification_vars,
+ state_oid, state_oid_len,
+ ASN_INTEGER,
+ (u_char *)&state,
+ sizeof(state));
+
+ /* routerId */
+ snmp_varlist_add_variable(¬ification_vars,
+ routerId_oid, routerId_oid_len,
+ ASN_OCTET_STR,
+ (u_char *)global_data->router_id,
+ strlen(global_data->router_id));
+
+ log_message(LOG_INFO,
+ "VRRP_Group(%s): Sending SNMP notification",
+ group->gname);
+ send_v2trap(notification_vars);
+ snmp_free_varbind(notification_vars);
+}
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_sync.c
^
|
@@ -17,13 +17,16 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
#include "vrrp_sync.h"
#include "vrrp_if.h"
#include "vrrp_notify.h"
#include "vrrp_data.h"
+#ifdef _WITH_SNMP_
+ #include "vrrp_snmp.h"
+#endif
#include "logger.h"
#include "smtp.h"
@@ -70,8 +73,8 @@
char *str;
int i;
- for (i = 0; i < VECTOR_SIZE(vgroup->iname); i++) {
- str = VECTOR_SLOT(vgroup->iname, i);
+ for (i = 0; i < vector_size(vgroup->iname); i++) {
+ str = vector_slot(vgroup->iname, i);
vrrp = vrrp_get_instance(str);
if (vrrp) {
if (LIST_ISEMPTY(vgroup->index_list))
@@ -135,6 +138,32 @@
return 0;
}
+/* Check transition to master state */
+int
+vrrp_sync_goto_master(vrrp_rt * vrrp)
+{
+ vrrp_rt *isync;
+ vrrp_sgroup *vgroup = vrrp->sync;
+ list l = vgroup->index_list;
+ element e;
+
+ if (GROUP_STATE(vgroup) == VRRP_STATE_MAST)
+ return 1;
+ if (GROUP_STATE(vgroup) == VRRP_STATE_GOTO_MASTER)
+ return 1;
+
+ /* Only sync to master if everyone wants to
+ * i.e. prefer backup state to avoid thrashing */
+ for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
+ isync = ELEMENT_DATA(e);
+ if (isync != vrrp && (isync->wantstate != VRRP_STATE_GOTO_MASTER &&
+ isync->wantstate != VRRP_STATE_MAST)) {
+ return 0;
+ }
+ }
+ return 1;
+}
+
void
vrrp_sync_master_election(vrrp_rt * vrrp)
{
@@ -191,6 +220,9 @@
vgroup->state = VRRP_STATE_BACK;
vrrp_sync_smtp_notifier(vgroup);
notify_group_exec(vgroup, VRRP_STATE_BACK);
+#ifdef _WITH_SNMP_
+ vrrp_snmp_group_trap(vgroup);
+#endif
}
void
@@ -203,6 +235,8 @@
if (GROUP_STATE(vgroup) == VRRP_STATE_MAST)
return;
+ if (!vrrp_sync_goto_master(vrrp))
+ return;
log_message(LOG_INFO, "VRRP_Group(%s) Syncing instances to MASTER state",
GROUP_NAME(vgroup));
@@ -221,6 +255,9 @@
vgroup->state = VRRP_STATE_MAST;
vrrp_sync_smtp_notifier(vgroup);
notify_group_exec(vgroup, VRRP_STATE_MAST);
+#ifdef _WITH_SNMP_
+ vrrp_snmp_group_trap(vgroup);
+#endif
}
void
@@ -256,4 +293,7 @@
}
vgroup->state = VRRP_STATE_FAULT;
notify_group_exec(vgroup, VRRP_STATE_FAULT);
+#ifdef _WITH_SNMP_
+ vrrp_snmp_group_trap(vgroup);
+#endif
}
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_track.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
*/
/* local include */
@@ -35,12 +35,12 @@
log_message(LOG_INFO, " %s weight %d", IF_NAME(tip->ifp), tip->weight);
}
void
-alloc_track(list track_list, vector strvec)
+alloc_track(list track_list, vector_t *strvec)
{
interface *ifp = NULL;
tracked_if *tip = NULL;
int weight = 0;
- char *tracked = VECTOR_SLOT(strvec, 0);
+ char *tracked = vector_slot(strvec, 0);
ifp = if_get_by_ifname(tracked);
@@ -50,9 +50,9 @@
return;
}
- if (VECTOR_SIZE(strvec) >= 3 &&
- !strcmp(VECTOR_SLOT(strvec, 1), "weight")) {
- weight = atoi(VECTOR_SLOT(strvec, 2));
+ if (vector_size(strvec) >= 3 &&
+ !strcmp(vector_slot(strvec, 1), "weight")) {
+ weight = atoi(vector_slot(strvec, 2));
if (weight < -254 || weight > 254) {
log_message(LOG_INFO, " %s: weight must be between "
"[-254..254] inclusive. Ignoring...", tracked);
@@ -92,12 +92,12 @@
log_message(LOG_INFO, " %s weight %d", tsc->scr->sname, tsc->weight);
}
void
-alloc_track_script(list track_list, vector strvec)
+alloc_track_script(list track_list, vector_t *strvec)
{
vrrp_script *vsc = NULL;
tracked_sc *tsc = NULL;
int weight = 0;
- char *tracked = VECTOR_SLOT(strvec, 0);
+ char *tracked = vector_slot(strvec, 0);
vsc = find_script_by_name(tracked);
@@ -110,9 +110,9 @@
/* default weight */
weight = vsc->weight;
- if (VECTOR_SIZE(strvec) >= 3 &&
- !strcmp(VECTOR_SLOT(strvec, 1), "weight")) {
- weight = atoi(VECTOR_SLOT(strvec, 2));
+ if (vector_size(strvec) >= 3 &&
+ !strcmp(vector_slot(strvec, 1), "weight")) {
+ weight = atoi(vector_slot(strvec, 2));
if (weight < -254 || weight > 254) {
weight = vsc->weight;
log_message(LOG_INFO, " %s: weight must be between [-254..254]"
|
[-]
[+]
|
Added |
keepalived-1.2.7.tar.bz2/keepalived/vrrp/vrrp_vmac.c
^
|
@@ -0,0 +1,238 @@
+/*
+ * Soft: Keepalived is a failover program for the LVS project
+ * <www.linuxvirtualserver.org>. It monitor & manipulate
+ * a loadbalanced server pool using multi-layer checks.
+ *
+ * Part: NETLINK VMAC address manipulation.
+ *
+ * Author: Alexandre Cassen, <acassen@linux-vs.org>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@gmail.com>
+ */
+
+/* local include */
+#include "vrrp_vmac.h"
+#include "vrrp_netlink.h"
+#include "vrrp_data.h"
+#include "logger.h"
+#include "memory.h"
+#include "utils.h"
+#include "parser.h"
+
+/* private matter */
+static const char *ll_kind = "macvlan";
+
+#ifdef _HAVE_VRRP_VMAC_
+/* Link layer handling */
+static int
+netlink_link_setlladdr(vrrp_rt *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_rt *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_rt *vrrp)
+{
+ int status = 1;
+ 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_UNSPEC;
+ req.ifi.ifi_index = IF_INDEX(vrrp->ifp);
+ req.ifi.ifi_change |= IFF_UP;
+ req.ifi.ifi_flags |= IFF_UP;
+
+ if (netlink_talk(&nl_cmd, &req.n) < 0)
+ status = -1;
+
+ return status;
+}
+#endif
+
+int
+netlink_link_add_vmac(vrrp_rt *vrrp)
+{
+#ifdef _HAVE_VRRP_VMAC_
+ struct rtattr *linkinfo;
+ interface *ifp;
+ char ifname[IFNAMSIZ];
+ struct {
+ struct nlmsghdr n;
+ struct ifinfomsg ifi;
+ char buf[256];
+ } req;
+
+ if (!vrrp->ifp)
+ return -1;
+
+ memset(&req, 0, sizeof (req));
+ memset(ifname, 0, IFNAMSIZ);
+ strncpy(ifname, vrrp->vmac_ifname, IFNAMSIZ - 1);
+
+ /*
+ * Check to see if this vmac interface was created
+ * by a previous instance.
+ */
+ if (reload && (ifp = if_get_by_ifname(ifname))) {
+ vrrp->ifp = ifp;
+ /* Save ifindex for use on delete */
+ vrrp->vmac_ifindex = IF_INDEX(vrrp->ifp);
+ vrrp->vmac |= 2;
+ return 1;
+ }
+
+ req.n.nlmsg_len = NLMSG_LENGTH(sizeof (struct ifinfomsg));
+ req.n.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_EXCL;
+ req.n.nlmsg_type = RTM_NEWLINK;
+ req.ifi.ifi_family = AF_INET;
+
+ /* macvlan settings */
+ 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));
+ 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));
+
+ if (netlink_talk(&nl_cmd, &req.n) < 0)
+ return -1;
+
+ /*
+ * Update interface queue and vrrp instance interface binding.
+ * bring it UP !
+ */
+ netlink_interface_lookup();
+ ifp = if_get_by_ifname(ifname);
+ if (!ifp)
+ return -1;
+ vrrp->ifp = ifp;
+ vrrp->vmac_ifindex = IF_INDEX(vrrp->ifp); /* For use on delete */
+ vrrp->vmac |= 2;
+ 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;
+}
+
+int
+netlink_link_del_vmac(vrrp_rt *vrrp)
+{
+ int status = 1;
+
+#ifdef _HAVE_VRRP_VMAC_
+ struct {
+ struct nlmsghdr n;
+ struct ifinfomsg ifi;
+ char buf[256];
+ } req;
+
+ if (!vrrp->ifp)
+ return -1;
+
+ 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_DELLINK;
+ req.ifi.ifi_family = AF_INET;
+ req.ifi.ifi_index = vrrp->vmac_ifindex;
+
+ if (netlink_talk(&nl_cmd, &req.n) < 0)
+ status = -1;
+#endif
+
+ return status;
+}
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/Makefile.in
^
|
@@ -8,11 +8,12 @@
INCLUDES = -I.
CFLAGS = @CFLAGS@ $(INCLUDES) \
-Wall -Wunused -Wstrict-prototypes
-DEFS = @DFLAGS@
+DEFS = @DFLAGS@ -D@SNMP_SUPPORT@
COMPILE = $(CC) $(CFLAGS) $(DEFS)
OBJS = memory.o utils.o notify.o timer.o scheduler.o \
- vector.o list.o html.o parser.o signals.o logger.o
+ vector.o list.o html.o parser.o signals.o logger.o \
+ list_head.o
HEADERS = $(OBJS:.o=.h)
.c.o:
@@ -37,3 +38,4 @@
parser.o: parser.c parser.h memory.h
signals.o: signals.c signals.h
logger.o: logger.c logger.h
+list_head.o: list_head.c list_head.h
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/html.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#include <string.h>
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/html.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#ifndef _HTML_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/list.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#include "list.h"
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/list.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#ifndef _LIST_H
|
[-]
[+]
|
Added |
keepalived-1.2.7.tar.bz2/lib/list_head.c
^
|
@@ -0,0 +1,101 @@
+/*
+ * Soft: Keepalived is a failover program for the LVS project
+ * <www.linuxvirtualserver.org>. It monitor & manipulate
+ * a loadbalanced server pool using multi-layer checks.
+ *
+ * Part: list_head. This code is comming from Linux Kernel.
+ *
+ * Author: Alexandre Cassen, <acassen@linux-vs.org>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
+ */
+
+#include "list_head.h"
+
+void list_sort(struct list_head *head,
+ int (*cmp)(struct list_head *a, struct list_head *b))
+{
+ struct list_head *p, *q, *e, *list, *tail, *oldhead;
+ int insize, nmerges, psize, qsize, i;
+
+ list = head->next;
+ list_head_del(head);
+ insize = 1;
+
+ while (1) {
+ p = oldhead = list;
+ list = tail = NULL;
+ nmerges = 0;
+
+ while (p) {
+ nmerges++;
+ q = p;
+ psize = 0;
+ for (i = 0; i < insize; i++) {
+ psize++;
+ q = q->next == oldhead ? NULL : q->next;
+ if (!q)
+ break;
+ }
+
+ qsize = insize;
+ while (psize > 0 || (qsize > 0 && q)) {
+ if (!psize) {
+ e = q;
+ q = q->next;
+ qsize--;
+ if (q == oldhead)
+ q = NULL;
+ } else if (!qsize || !q) {
+ e = p;
+ p = p->next;
+ psize--;
+ if (p == oldhead)
+ p = NULL;
+ } else if (cmp(p, q) <= 0) {
+ e = p;
+ p = p->next;
+ psize--;
+ if (p == oldhead)
+ p = NULL;
+ } else {
+ e = q;
+ q = q->next;
+ qsize--;
+ if (q == oldhead)
+ q = NULL;
+ }
+ if (tail)
+ tail->next = e;
+ else
+ list = e;
+ e->prev = tail;
+ tail = e;
+ }
+ p = q;
+ }
+
+ tail->next = list;
+ list->prev = tail;
+
+ if (nmerges <= 1)
+ break;
+
+ insize *= 2;
+ }
+
+ head->next = list;
+ head->prev = list->prev;
+ list->prev->next = head;
+ list->prev = head;
+}
|
[-]
[+]
|
Added |
keepalived-1.2.7.tar.bz2/lib/list_head.h
^
|
@@ -0,0 +1,571 @@
+/*
+ * Soft: Keepalived is a failover program for the LVS project
+ * <www.linuxvirtualserver.org>. It monitor & manipulate
+ * a loadbalanced server pool using multi-layer checks.
+ *
+ * Part: list_head. This code is comming from Linux Kernel.
+ *
+ * Author: Alexandre Cassen, <acassen@linux-vs.org>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
+ */
+
+#ifndef _LIST_HEAD_H
+#define _LIST_HEAD_H
+
+#include <stdlib.h>
+#include <stddef.h>
+
+/*
+ * container_of - cast a member of a structure out to the containing structure
+ *
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ */
+#ifndef container_of
+# define container_of(ptr, type, member) ({ \
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \
+ (type *)( (char *)__mptr - offsetof(type,member) );})
+#endif
+
+/*
+ * These are non-NULL pointers that will result in page faults
+ * under normal circumstances, used to verify that nobody uses
+ * non-initialized list entries.
+ */
+#define LIST_POISON1 ((void *) 0x00100100)
+#define LIST_POISON2 ((void *) 0x00200200)
+
+/*
+ * Simple doubly linked list implementation.
+ *
+ * Some of the internal functions ("__xxx") are useful when
+ * manipulating whole lists rather than single entries, as
+ * sometimes we already know the next/prev entries and we can
+ * generate better code by using them directly rather than
+ * using the generic single-entry routines.
+ */
+
+typedef struct list_head {
+ struct list_head *next, *prev;
+} list_head_t;
+
+#define LIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define LIST_HEAD(name) \
+ struct list_head name = LIST_HEAD_INIT(name)
+
+#define INIT_LIST_HEAD(ptr) do { \
+ (ptr)->next = (ptr); (ptr)->prev = (ptr); \
+} while (0)
+
+/*
+ * Insert a new entry between two known consecutive entries.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_add(struct list_head *new,
+ struct list_head *prev,
+ struct list_head *next)
+{
+ next->prev = new;
+ new->next = next;
+ new->prev = prev;
+ prev->next = new;
+}
+
+/**
+ * list_head_add - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it after
+ *
+ * Insert a new entry after the specified head.
+ * This is good for implementing stacks.
+ */
+static inline void list_head_add(struct list_head *new, struct list_head *head)
+{
+ __list_add(new, head, head->next);
+}
+
+/**
+ * list_add_tail - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it before
+ *
+ * Insert a new entry before the specified head.
+ * This is useful for implementing queues.
+ */
+static inline void list_add_tail(struct list_head *new, struct list_head *head)
+{
+ __list_add(new, head->prev, head);
+}
+
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_del(struct list_head * prev, struct list_head * next)
+{
+ next->prev = prev;
+ prev->next = next;
+}
+
+/**
+ * list_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: list_empty on entry does not return true after this, the entry is
+ * in an undefined state.
+ */
+static inline void list_head_del(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+ entry->next = LIST_POISON1;
+ entry->prev = LIST_POISON2;
+}
+
+/**
+ * list_del_init - deletes entry from list and reinitialize it.
+ * @entry: the element to delete from the list.
+ */
+static inline void list_del_init(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+ INIT_LIST_HEAD(entry);
+}
+
+/**
+ * list_move - delete from one list and add as another's head
+ * @list: the entry to move
+ * @head: the head that will precede our entry
+ */
+static inline void list_move(struct list_head *list, struct list_head *head)
+{
+ __list_del(list->prev, list->next);
+ list_head_add(list, head);
+}
+
+/**
+ * list_move_tail - delete from one list and add as another's tail
+ * @list: the entry to move
+ * @head: the head that will follow our entry
+ */
+static inline void list_move_tail(struct list_head *list,
+ struct list_head *head)
+{
+ __list_del(list->prev, list->next);
+ list_add_tail(list, head);
+}
+
+/**
+ * list_is_first - tests whether @list is the first entry in list @head
+ * @list: the entry to test
+ * @head: the head of the list
+ */
+static inline int list_is_first(const struct list_head *list,
+ const struct list_head *head)
+{
+ return list->prev == head;
+}
+
+/**
+ * list_is_last - tests whether @list is the last entry in list @head
+ * @list: the entry to test
+ * @head: the head of the list
+ */
+static inline int list_is_last(const struct list_head *list,
+ const struct list_head *head)
+{
+ return list->next == head;
+}
+
+/**
+ * list_empty - tests whether a list is empty
+ * @head: the list to test.
+ */
+static inline int list_empty(const struct list_head *head)
+{
+ return head->next == head;
+}
+
+static inline void __list_splice(struct list_head *list,
+ struct list_head *head)
+{
+ struct list_head *first = list->next;
+ struct list_head *last = list->prev;
+ struct list_head *at = head->next;
+
+ first->prev = head;
+ head->next = first;
+
+ last->next = at;
+ at->prev = last;
+}
+
+/**
+ * list_splice - join two lists
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
+ */
+static inline void list_splice(struct list_head *list, struct list_head *head)
+{
+ if (!list_empty(list))
+ __list_splice(list, head);
+}
+
+/**
+ * list_splice_init - join two lists and reinitialise the emptied list.
+ * @list: the new list to add.
+ * @head: the place to add it in the first list.
+ *
+ * The list at @list is reinitialised
+ */
+static inline void list_splice_init(struct list_head *list,
+ struct list_head *head)
+{
+ if (!list_empty(list)) {
+ __list_splice(list, head);
+ INIT_LIST_HEAD(list);
+ }
+}
+
+/**
+ * list_sort - merge sort elements of a list.
+ * @head: the head of the list.
+ * @cmp: the function used to compare to list nodes.
+ */
+void list_sort(struct list_head *head,
+ int (*cmp)(struct list_head *a, struct list_head *b));
+
+/**
+ * list_entry - get the struct for this entry
+ * @ptr: the &struct list_head pointer.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_entry(ptr, type, member) \
+ container_of(ptr, type, member)
+
+/**
+ * list_first_entry - get the first element from a list
+ * @ptr: the list head to take the element from.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Note, that list is expected to be not empty.
+ */
+#define list_first_entry(ptr, type, member) \
+ list_entry((ptr)->next, type, member)
+
+/**
+ * list_last_entry - get the last element from a list
+ * @ptr: the list head to take the element from.
+ * @type: the type of the struct this is embedded in.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Note, that list is expected to be not empty.
+ */
+#define list_last_entry(ptr, type, member) \
+ list_entry((ptr)->prev, type, member)
+
+
+/**
+ * list_for_each - iterate over a list
+ * @pos: the &struct list_head to use as a loop counter.
+ * @head: the head for your list.
+ */
+#define list_for_each(pos, head) \
+ for (pos = (head)->next; pos != (head); \
+ pos = pos->next)
+
+/**
+ * __list_for_each - iterate over a list
+ * @pos: the &struct list_head to use as a loop counter.
+ * @head: the head for your list.
+ *
+ * This variant differs from list_for_each() in that it's the
+ * simplest possible list iteration code, no prefetching is done.
+ * Use this for code that knows the list to be very short (empty
+ * or 1 entry) most of the time.
+ */
+#define __list_for_each(pos, head) \
+ for (pos = (head)->next; pos != (head); pos = pos->next)
+
+/**
+ * list_for_each_prev - iterate over a list backwards
+ * @pos: the &struct list_head to use as a loop counter.
+ * @head: the head for your list.
+ */
+#define list_for_each_prev(pos, head) \
+ for (pos = (head)->prev; pos != (head); \
+ pos = pos->prev)
+
+/**
+ * list_for_each_safe - iterate over a list safe against removal of list entry
+ * @pos: the &struct list_head to use as a loop counter.
+ * @n: another &struct list_head to use as temporary storage
+ * @head: the head for your list.
+ */
+#define list_for_each_safe(pos, n, head) \
+ for (pos = (head)->next, n = pos->next; pos != (head); \
+ pos = n, n = pos->next)
+
+/**
+ * list_for_each_entry - iterate over list of given type
+ * @pos: the type * to use as a loop counter.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry(pos, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_reverse - iterate backwards over list of given type.
+ * @pos: the type * to use as a loop counter.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_reverse(pos, head, member) \
+ for (pos = list_entry((head)->prev, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.prev, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_continue - iterate over list of given type
+ * continuing after existing point
+ * @pos: the type * to use as a loop counter.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_continue(pos, head, member) \
+ for (pos = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_continue_reverse - iterate backwards from the given point
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Start to iterate over list of given type backwards, continuing after
+ * the current position.
+ */
+#define list_for_each_entry_continue_reverse(pos, head, member) \
+ for (pos = list_entry(pos->member.prev, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = list_entry(pos->member.prev, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_from - iterate over list of given type from the current point
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Iterate over list of given type, continuing from current position.
+ */
+#define list_for_each_entry_from(pos, head, member) \
+ for (; &pos->member != (head); \
+ pos = list_entry(pos->member.next, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_from - iterate over list of given type from the current point
+ * @pos: the type * to use as a loop cursor.
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ *
+ * Iterate over list of given type, continuing from current position.
+ */
+#define list_for_each_entry_from_reverse(pos, head, member) \
+ for (; &pos->member != (head); \
+ pos = list_entry(pos->member.prev, typeof(*pos), member))
+
+/**
+ * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @pos: the type * to use as a loop counter.
+ * @n: another type * to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_safe(pos, n, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member), \
+ n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+
+/*
+ * Double linked lists with a single pointer list head.
+ * Mostly useful for hash tables where the two pointer list head is
+ * too wasteful.
+ * You lose the ability to access the tail in O(1).
+ */
+
+struct hlist_head {
+ struct hlist_node *first;
+};
+
+struct hlist_node {
+ struct hlist_node *next, **pprev;
+};
+
+#define HLIST_HEAD_INIT { .first = NULL }
+#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
+#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
+#define INIT_HLIST_NODE(ptr) ((ptr)->next = NULL, (ptr)->pprev = NULL)
+
+static __inline__ int hlist_unhashed(const struct hlist_node *h)
+{
+ return !h->pprev;
+}
+
+static __inline__ int hlist_empty(const struct hlist_head *h)
+{
+ return !h->first;
+}
+
+static __inline__ void __hlist_del(struct hlist_node *n)
+{
+ struct hlist_node *next = n->next;
+ struct hlist_node **pprev = n->pprev;
+ *pprev = next;
+ if (next)
+ next->pprev = pprev;
+}
+
+static __inline__ void hlist_del(struct hlist_node *n)
+{
+ __hlist_del(n);
+ n->next = LIST_POISON1;
+ n->pprev = LIST_POISON2;
+}
+
+static __inline__ void hlist_del_init(struct hlist_node *n)
+{
+ if (n->pprev) {
+ __hlist_del(n);
+ INIT_HLIST_NODE(n);
+ }
+}
+
+static __inline__ void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
+{
+ struct hlist_node *first = h->first;
+ n->next = first;
+ if (first)
+ first->pprev = &n->next;
+ h->first = n;
+ n->pprev = &h->first;
+}
+
+static __inline__ void hlist_add_before(struct hlist_node *n, struct hlist_node *next)
+{
+ n->pprev = next->pprev;
+ n->next = next;
+ next->pprev = &n->next;
+ *(n->pprev) = n;
+}
+
+static __inline__ void hlist_add_after(struct hlist_node *n,
+ struct hlist_node *next)
+{
+ next->next = n->next;
+ n->next = next;
+ next->pprev = &n->next;
+ if (next->next)
+ next->next->pprev = &next->next;
+}
+
+#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
+
+#define hlist_for_each(pos, head) \
+ for (pos = (head)->first; pos; pos = pos->next)
+
+#define hlist_for_each_safe(pos, n, head) \
+ for (pos = (head)->first; n = pos ? pos->next : 0, pos; \
+ pos = n)
+
+/**
+ * hlist_for_each_entry - iterate over list of given type
+ * @tpos: the type * to use as a loop counter.
+ * @pos: the &struct hlist_node to use as a loop counter.
+ * @head: the head for your list.
+ * @member: the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry(tpos, pos, head, member) \
+ for (pos = (head)->first; \
+ pos && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = pos->next)
+
+/**
+ * hlist_for_each_entry_continue - iterate over a hlist continuing after existing point
+ * @tpos: the type * to use as a loop counter.
+ * @pos: the &struct hlist_node to use as a loop counter.
+ * @member: the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry_continue(tpos, pos, member) \
+ for (pos = (pos)->next; \
+ pos && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = pos->next)
+
+/**
+ * hlist_for_each_entry_from - iterate over a hlist continuing from existing point
+ * @tpos: the type * to use as a loop counter.
+ * @pos: the &struct hlist_node to use as a loop counter.
+ * @member: the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry_from(tpos, pos, member) \
+ for (; pos && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = pos->next)
+
+/**
+ * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @tpos: the type * to use as a loop counter.
+ * @pos: the &struct hlist_node to use as a loop counter.
+ * @n: another &struct hlist_node to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the hlist_node within the struct.
+ */
+#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \
+ for (pos = (head)->first; \
+ pos && ({ n = pos->next; 1; }) && \
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
+ pos = n)
+
+#define hlist_insert_sorted(tpos, ntpos, pos, head, smember, hmember, res) \
+ res = 0; \
+ tpos = NULL; \
+ hlist_for_each_entry(tpos, pos, (head), hmember) \
+ if (ntpos->smember <= tpos->smember) \
+ break; \
+ if (tpos) { \
+ if (ntpos->smember < tpos->smember) \
+ hlist_add_before(&ntpos->hmember, &tpos->hmember); \
+ else if (ntpos->smember > tpos->smember) \
+ hlist_add_after(&tpos->hmember, &ntpos->hmember); \
+ else \
+ res = 1; \
+ } else \
+ hlist_add_head(&ntpos->hmember, (head));
+
+#endif /* ! _LIST_HEAD_H */
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/logger.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#include <syslog.h>
@@ -36,13 +36,15 @@
log_message(const int facility, const char *format, ...)
{
va_list args;
+ char buf[256];
- va_start(args,format);
+ va_start(args, format);
+ vsnprintf(buf, sizeof(buf), format, args);
+ va_end(args);
if (log_console) {
- vfprintf(stderr, format, args);
- fprintf(stderr,"\n");
+ fprintf(stderr, "%s\n", buf);
}
- vsyslog(facility, format, args);
+ syslog(facility, "%s", buf);
}
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/logger.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#ifndef _LOGGER_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/memory.c
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#include "memory.h"
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/memory.h
^
|
@@ -18,7 +18,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#ifndef _MEMORY_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/notify.c
^
|
@@ -17,13 +17,14 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#include <unistd.h>
#include <stdlib.h>
#include <syslog.h>
#include <fcntl.h>
+#include <errno.h>
#include "notify.h"
#include "signals.h"
#include "logger.h"
@@ -79,8 +80,16 @@
closeall(0);
open("/dev/null", O_RDWR);
+
ret = dup(0);
+ if (ret < 0) {
+ log_message(LOG_INFO, "dup(0) error");
+ }
+
ret = dup(0);
+ if (ret < 0) {
+ log_message(LOG_INFO, "dup(0) error");
+ }
system_call(cmd);
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/notify.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#ifndef _NOTIFY_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/parser.c
^
|
@@ -19,7 +19,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#include <glob.h>
@@ -31,8 +31,8 @@
#include "logger.h"
/* global vars */
-vector keywords;
-vector current_keywords;
+vector_t *keywords;
+vector_t *current_keywords;
FILE *current_stream;
char *current_conf_file;
int reload = 0;
@@ -41,13 +41,13 @@
static int sublevel = 0;
void
-keyword_alloc(vector keywords_vec, char *string, void (*handler) (vector))
+keyword_alloc(vector_t *keywords_vec, char *string, void (*handler) (vector_t *))
{
- struct keyword *keyword;
+ keyword_t *keyword;
vector_alloc_slot(keywords_vec);
- keyword = (struct keyword *) MALLOC(sizeof (struct keyword));
+ keyword = (keyword_t *) MALLOC(sizeof(keyword_t));
keyword->string = string;
keyword->handler = handler;
@@ -55,18 +55,18 @@
}
void
-keyword_alloc_sub(vector keywords_vec, char *string, void (*handler) (vector))
+keyword_alloc_sub(vector_t *keywords_vec, char *string, void (*handler) (vector_t *))
{
int i = 0;
- struct keyword *keyword;
+ keyword_t *keyword;
/* fetch last keyword */
- keyword = VECTOR_SLOT(keywords_vec, VECTOR_SIZE(keywords_vec) - 1);
+ keyword = vector_slot(keywords_vec, vector_size(keywords_vec) - 1);
/* position to last sub level */
for (i = 0; i < sublevel; i++)
keyword =
- VECTOR_SLOT(keyword->sub, VECTOR_SIZE(keyword->sub) - 1);
+ vector_slot(keyword->sub, vector_size(keyword->sub) - 1);
/* First sub level allocation */
if (!keyword->sub)
@@ -90,25 +90,25 @@
}
void
-install_keyword_root(char *string, void (*handler) (vector))
+install_keyword_root(char *string, void (*handler) (vector_t *))
{
keyword_alloc(keywords, string, handler);
}
void
-install_keyword(char *string, void (*handler) (vector))
+install_keyword(char *string, void (*handler) (vector_t *))
{
keyword_alloc_sub(keywords, string, handler);
}
void
-dump_keywords(vector keydump, int level)
+dump_keywords(vector_t *keydump, int level)
{
int i, j;
- struct keyword *keyword_vec;
+ keyword_t *keyword_vec;
- for (i = 0; i < VECTOR_SIZE(keydump); i++) {
- keyword_vec = VECTOR_SLOT(keydump, i);
+ for (i = 0; i < vector_size(keydump); i++) {
+ keyword_vec = vector_slot(keydump, i);
for (j = 0; j < level; j++)
printf(" ");
printf("Keyword : %s\n", keyword_vec->string);
@@ -118,13 +118,13 @@
}
void
-free_keywords(vector keywords_vec)
+free_keywords(vector_t *keywords_vec)
{
- struct keyword *keyword_vec;
+ keyword_t *keyword_vec;
int i;
- for (i = 0; i < VECTOR_SIZE(keywords_vec); i++) {
- keyword_vec = VECTOR_SLOT(keywords_vec, i);
+ for (i = 0; i < vector_size(keywords_vec); i++) {
+ keyword_vec = vector_slot(keywords_vec, i);
if (keyword_vec->sub)
free_keywords(keyword_vec->sub);
FREE(keyword_vec);
@@ -132,12 +132,12 @@
vector_free(keywords_vec);
}
-vector
+vector_t *
alloc_strvec(char *string)
{
char *cp, *start, *token;
int str_len;
- vector strvec;
+ vector_t *strvec;
if (!string)
return NULL;
@@ -199,10 +199,10 @@
int i;
for(i = 0; i < globbuf.gl_pathc; i++){
- log_message(LOG_INFO, "Opening file '%s'.\n",globbuf.gl_pathv[i]);
+ log_message(LOG_INFO, "Opening file '%s'.", globbuf.gl_pathv[i]);
stream = fopen(globbuf.gl_pathv[i], "r");
if (!stream) {
- log_message(LOG_INFO, "Configuration file '%s' open problem (%s)...\n"
+ log_message(LOG_INFO, "Configuration file '%s' open problem (%s)..."
, globbuf.gl_pathv[i], strerror(errno));
return;
}
@@ -211,14 +211,26 @@
char prev_path[MAXBUF];
path = getcwd(prev_path, MAXBUF);
+ if (!path) {
+ log_message(LOG_INFO, "getcwd(%s) error (%s)"
+ , prev_path, strerror(errno));
+ }
char *confpath = strdup(globbuf.gl_pathv[i]);
dirname(confpath);
ret = chdir(confpath);
+ if (ret < 0) {
+ log_message(LOG_INFO, "chdir(%s) error (%s)"
+ , confpath, strerror(errno));
+ }
process_stream(current_keywords);
fclose(stream);
ret = chdir(prev_path);
+ if (ret < 0) {
+ log_message(LOG_INFO, "chdir(%s) error (%s)"
+ , prev_path, strerror(errno));
+ }
}
globfree(&globbuf);
@@ -228,7 +240,7 @@
check_include(char *buf)
{
char *str;
- vector strvec;
+ vector_t *strvec;
char *path;
int ret;
@@ -237,24 +249,33 @@
if (!strvec){
return 0;
}
- str = VECTOR_SLOT(strvec, 0);
+ str = vector_slot(strvec, 0);
if (!strcmp(str, EOB)) {
free_strvec(strvec);
return 0;
}
- if(!strcmp("include", str) && VECTOR_SIZE(strvec) == 2){
- char *conf_file = VECTOR_SLOT(strvec, 1);
+ if(!strcmp("include", str) && vector_size(strvec) == 2){
+ char *conf_file = vector_slot(strvec, 1);
FILE *prev_stream = current_stream;
char *prev_conf_file = current_conf_file;
char prev_path[MAXBUF];
path = getcwd(prev_path, MAXBUF);
+ if (!path) {
+ log_message(LOG_INFO, "getcwd(%s) error (%s)\n"
+ , prev_path, strerror(errno));
+ }
+
read_conf_file(conf_file);
current_stream = prev_stream;
current_conf_file = prev_conf_file;
ret = chdir(prev_path);
+ if (ret < 0) {
+ log_message(LOG_INFO, "chdir(%s) error (%s)\n"
+ , prev_path, strerror(errno));
+ }
return 1;
}
free_strvec(strvec);
@@ -281,29 +302,29 @@
return (ch == EOF) ? 0 : 1;
}
-vector
+vector_t *
read_value_block(void)
{
char *buf;
int i;
char *str = NULL;
char *dup;
- vector vec = NULL;
- vector elements = vector_alloc();
+ vector_t *vec = NULL;
+ vector_t *elements = vector_alloc();
buf = (char *) MALLOC(MAXBUF);
while (read_line(buf, MAXBUF)) {
vec = alloc_strvec(buf);
if (vec) {
- str = VECTOR_SLOT(vec, 0);
+ str = vector_slot(vec, 0);
if (!strcmp(str, EOB)) {
free_strvec(vec);
break;
}
- if (VECTOR_SIZE(vec))
- for (i = 0; i < VECTOR_SIZE(vec); i++) {
- str = VECTOR_SLOT(vec, i);
+ if (vector_size(vec))
+ for (i = 0; i < vector_size(vec); i++) {
+ str = vector_slot(vec, i);
dup = (char *) MALLOC(strlen(str) + 1);
memcpy(dup, str, strlen(str));
vector_alloc_slot(elements);
@@ -319,23 +340,23 @@
}
void
-alloc_value_block(vector strvec, void (*alloc_func) (vector))
+alloc_value_block(vector_t *strvec, void (*alloc_func) (vector_t *))
{
char *buf;
char *str = NULL;
- vector vec = NULL;
+ vector_t *vec = NULL;
buf = (char *) MALLOC(MAXBUF);
while (read_line(buf, MAXBUF)) {
vec = alloc_strvec(buf);
if (vec) {
- str = VECTOR_SLOT(vec, 0);
+ str = vector_slot(vec, 0);
if (!strcmp(str, EOB)) {
free_strvec(vec);
break;
}
- if (VECTOR_SIZE(vec))
+ if (vector_size(vec))
(*alloc_func) (vec);
free_strvec(vec);
@@ -347,9 +368,9 @@
void *
-set_value(vector strvec)
+set_value(vector_t *strvec)
{
- char *str = VECTOR_SLOT(strvec, 1);
+ char *str = vector_slot(strvec, 1);
int size = strlen(str);
int i = 0;
int len = 0;
@@ -357,8 +378,8 @@
char *tmp;
if (*str == '"') {
- for (i = 2; i < VECTOR_SIZE(strvec); i++) {
- str = VECTOR_SLOT(strvec, i);
+ for (i = 2; i < vector_size(strvec); i++) {
+ str = vector_slot(strvec, i);
len += strlen(str);
if (!alloc)
alloc =
@@ -367,12 +388,12 @@
else {
alloc =
REALLOC(alloc, sizeof (char *) * (len + 1));
- tmp = VECTOR_SLOT(strvec, i-1);
+ tmp = vector_slot(strvec, i-1);
if (*str != '"' && *tmp != '"')
strncat(alloc, " ", 1);
}
- if (i != VECTOR_SIZE(strvec)-1)
+ if (i != vector_size(strvec)-1)
strncat(alloc, str, strlen(str));
}
} else {
@@ -385,14 +406,14 @@
/* recursive configuration stream handler */
static int kw_level = 0;
void
-process_stream(vector keywords_vec)
+process_stream(vector_t *keywords_vec)
{
int i;
- struct keyword *keyword_vec;
+ keyword_t *keyword_vec;
char *str;
char *buf;
- vector strvec;
- vector prev_keywords = current_keywords;
+ vector_t *strvec;
+ vector_t *prev_keywords = current_keywords;
current_keywords = keywords_vec;
buf = zalloc(MAXBUF);
@@ -403,15 +424,15 @@
if (!strvec)
continue;
- str = VECTOR_SLOT(strvec, 0);
+ str = vector_slot(strvec, 0);
if (!strcmp(str, EOB) && kw_level > 0) {
free_strvec(strvec);
break;
}
- for (i = 0; i < VECTOR_SIZE(keywords_vec); i++) {
- keyword_vec = VECTOR_SLOT(keywords_vec, i);
+ for (i = 0; i < vector_size(keywords_vec); i++) {
+ keyword_vec = vector_slot(keywords_vec, i);
if (!strcmp(keyword_vec->string, str)) {
if (keyword_vec->handler)
@@ -436,7 +457,7 @@
/* Data initialization */
void
-init_data(char *conf_file, vector (*init_keywords) (void))
+init_data(char *conf_file, vector_t * (*init_keywords) (void))
{
/* Init Keywords structure */
keywords = vector_alloc();
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/parser.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#ifndef _PARSER_H
@@ -40,11 +40,11 @@
#define MAXBUF 1024
/* ketword definition */
-struct keyword {
+typedef struct _keyword {
char *string;
- void (*handler) (vector);
- vector sub;
-};
+ void (*handler) (vector_t *);
+ vector_t *sub;
+} keyword_t;
/* Reloading helpers */
#define SET_RELOAD (reload = 1)
@@ -52,25 +52,25 @@
#define RELOAD_DELAY 5
/* global vars exported */
-extern vector keywords;
+extern vector_t *keywords;
extern FILE *current_stream;
extern int reload;
/* Prototypes */
-extern void keyword_alloc(vector keywords_vec, char *string, void (*handler) (vector));
-extern void keyword_alloc_sub(vector keywords_vec, char *string, void (*handler) (vector));
-extern void install_keyword_root(char *string, void (*handler) (vector));
+extern void keyword_alloc(vector_t *, char *, void (*handler) (vector_t *));
+extern void keyword_alloc_sub(vector_t *, char *, void (*handler) (vector_t *));
+extern void install_keyword_root(char *, void (*handler) (vector_t *));
extern void install_sublevel(void);
extern void install_sublevel_end(void);
-extern void install_keyword(char *string, void (*handler) (vector));
-extern void dump_keywords(vector keydump, int level);
-extern void free_keywords(vector keywords_vec);
-extern vector alloc_strvec(char *string);
-extern int read_line(char *buf, int size);
-extern vector read_value_block(void);
-extern void alloc_value_block(vector strvec, void (*alloc_func) (vector));
-extern void *set_value(vector strvec);
-extern void process_stream(vector keywords_vec);
-extern void init_data(char *conf_file, vector (*init_keywords) (void));
+extern void install_keyword(char *, void (*handler) (vector_t *));
+extern void dump_keywords(vector_t *, int);
+extern void free_keywords(vector_t *);
+extern vector_t *alloc_strvec(char *);
+extern int read_line(char *, int);
+extern vector_t *read_value_block(void);
+extern void alloc_value_block(vector_t *, void (*alloc_func) (vector_t *));
+extern void *set_value(vector_t *);
+extern void process_stream(vector_t *);
+extern void init_data(char *, vector_t * (*init_keywords) (void));
#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/scheduler.c
^
|
@@ -19,9 +19,18 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
+/* SNMP should be included first: it redefines "FREE" */
+#ifdef _WITH_SNMP_
+#include <net-snmp/net-snmp-config.h>
+#include <net-snmp/net-snmp-includes.h>
+#include <net-snmp/agent/net-snmp-agent-includes.h>
+#include <net-snmp/agent/snmp_vars.h>
+#undef FREE
+#endif
+
#include <signal.h>
#include <sys/wait.h>
#include <sys/select.h>
@@ -445,10 +454,10 @@
/* Update timer value */
static void
-thread_update_timer(thread_list_t *list, TIMEVAL *timer_min)
+thread_update_timer(thread_list_t *list, timeval_t *timer_min)
{
if (list->head) {
- if (!TIMER_ISNULL(*timer_min)) {
+ if (!timer_isnull(*timer_min)) {
if (timer_cmp(list->head->sands, *timer_min) <= 0) {
*timer_min = list->head->sands;
}
@@ -460,19 +469,19 @@
/* Compute the wait timer. Take care of timeouted fd */
static void
-thread_compute_timer(thread_master_t * m, TIMEVAL * timer_wait)
+thread_compute_timer(thread_master_t * m, timeval_t * timer_wait)
{
- TIMEVAL timer_min;
+ timeval_t timer_min;
/* Prepare timer */
- TIMER_RESET(timer_min);
+ timer_reset(timer_min);
thread_update_timer(&m->timer, &timer_min);
thread_update_timer(&m->write, &timer_min);
thread_update_timer(&m->read, &timer_min);
thread_update_timer(&m->child, &timer_min);
/* Take care about monothonic clock */
- if (!TIMER_ISNULL(timer_min)) {
+ if (!timer_isnull(timer_min)) {
timer_min = timer_sub(timer_min, time_now);
if (timer_min.tv_sec < 0) {
timer_min.tv_sec = timer_min.tv_usec = 0;
@@ -498,13 +507,18 @@
fd_set readfd;
fd_set writefd;
fd_set exceptfd;
- TIMEVAL timer_wait;
+ timeval_t timer_wait;
int signal_fd;
+#ifdef _WITH_SNMP_
+ timeval_t snmp_timer_wait;
+ int snmpblock = 0;
+ int fdsetsize;
+#endif
assert(m != NULL);
/* Timer initialization */
- memset(&timer_wait, 0, sizeof (TIMEVAL));
+ memset(&timer_wait, 0, sizeof (timeval_t));
retry: /* When thread can't fetch try to find next thread again. */
@@ -546,11 +560,33 @@
signal_fd = signal_rfd();
FD_SET(signal_fd, &readfd);
+#ifdef _WITH_SNMP_
+ /* When SNMP is enabled, we may have to select() on additional
+ * FD. snmp_select_info() will add them to `readfd'. The trick
+ * with this function is its last argument. We need to set it
+ * to 0 and we need to use the provided new timer only if it
+ * is still set to 0. */
+ fdsetsize = FD_SETSIZE;
+ snmpblock = 0;
+ memcpy(&snmp_timer_wait, &timer_wait, sizeof(timeval_t));
+ snmp_select_info(&fdsetsize, &readfd, &snmp_timer_wait, &snmpblock);
+ if (snmpblock == 0)
+ memcpy(&timer_wait, &snmp_timer_wait, sizeof(timeval_t));
+#endif
+
ret = select(FD_SETSIZE, &readfd, &writefd, &exceptfd, &timer_wait);
/* we have to save errno here because the next syscalls will set it */
old_errno = errno;
+ /* Handle SNMP stuff */
+#ifdef _WITH_SNMP_
+ if (ret > 0)
+ snmp_read(&readfd);
+ else if (ret == 0)
+ snmp_timeout();
+#endif
+
/* handle signals synchronously, including child reaping */
if (FD_ISSET(signal_fd, &readfd))
signal_run_callback();
@@ -649,6 +685,11 @@
/* Return one event. */
thread = thread_trim_head(&m->ready);
+#ifdef _WITH_SNMP_
+ run_alarms();
+ netsnmp_check_outstanding_agent_requests();
+#endif
+
/* There is no ready thread. */
if (!thread)
goto retry;
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/scheduler.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#ifndef _SCHEDULER_H
@@ -42,7 +42,7 @@
struct _thread_master *master; /* pointer to the struct thread_master. */
int (*func) (struct _thread *); /* event function */
void *arg; /* event argument */
- TIMEVAL sands; /* rest of time sands value. */
+ timeval_t sands; /* rest of time sands value. */
union {
int val; /* second argument of the event. */
int fd; /* file descriptor in case of read/write. */
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/signals.c
^
|
@@ -18,7 +18,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#include <signal.h>
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/signals.h
^
|
@@ -18,7 +18,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#ifndef _SIGNALS_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/timer.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#include <stdio.h>
@@ -26,15 +26,15 @@
#include "timer.h"
/* time_now holds current time */
-TIMEVAL time_now = { tv_sec: 0, tv_usec: 0 };
+timeval_t time_now = { tv_sec: 0, tv_usec: 0 };
/* set a timer to a specific value */
-TIMEVAL
-timer_dup(TIMEVAL b)
+timeval_t
+timer_dup(timeval_t b)
{
- TIMEVAL a;
+ timeval_t a;
- TIMER_RESET(a);
+ timer_reset(a);
a.tv_sec = b.tv_sec;
a.tv_usec = b.tv_usec;
return a;
@@ -42,7 +42,7 @@
/* timer compare */
int
-timer_cmp(TIMEVAL a, TIMEVAL b)
+timer_cmp(timeval_t a, timeval_t b)
{
if (a.tv_sec > b.tv_sec)
return 1;
@@ -56,12 +56,12 @@
}
/* timer sub */
-TIMEVAL
-timer_sub(TIMEVAL a, TIMEVAL b)
+timeval_t
+timer_sub(timeval_t a, timeval_t b)
{
- TIMEVAL ret;
+ timeval_t ret;
- TIMER_RESET(ret);
+ timer_reset(ret);
ret.tv_usec = a.tv_usec - b.tv_usec;
ret.tv_sec = a.tv_sec - b.tv_sec;
@@ -74,12 +74,12 @@
}
/* timer add */
-TIMEVAL
-timer_add_long(TIMEVAL a, long b)
+timeval_t
+timer_add_long(timeval_t a, long b)
{
- TIMEVAL ret;
+ timeval_t ret;
- TIMER_RESET(ret);
+ timer_reset(ret);
ret.tv_usec = a.tv_usec + b % TIMER_HZ;
ret.tv_sec = a.tv_sec + b / TIMER_HZ;
@@ -100,11 +100,11 @@
* normally return 0, unless <now> is NULL, in which case it will return -1 and
* set errno to EFAULT.
*/
-int monotonic_gettimeofday(TIMEVAL *now)
+int monotonic_gettimeofday(timeval_t *now)
{
- static TIMEVAL mono_date;
- static TIMEVAL drift; /* warning: signed seconds! */
- TIMEVAL sys_date, adjusted, deadline;
+ static timeval_t mono_date;
+ static timeval_t drift; /* warning: signed seconds! */
+ timeval_t sys_date, adjusted, deadline;
if (!now) {
errno = EFAULT;
@@ -174,14 +174,14 @@
}
/* current time */
-TIMEVAL
+timeval_t
timer_now(void)
{
- TIMEVAL curr_time;
+ timeval_t curr_time;
int old_errno = errno;
/* init timer */
- TIMER_RESET(curr_time);
+ timer_reset(curr_time);
monotonic_gettimeofday(&curr_time);
errno = old_errno;
@@ -189,13 +189,13 @@
}
/* sets and returns current time from system time */
-TIMEVAL
+timeval_t
set_time_now(void)
{
int old_errno = errno;
/* init timer */
- TIMER_RESET(time_now);
+ timer_reset(time_now);
monotonic_gettimeofday(&time_now);
errno = old_errno;
@@ -203,15 +203,15 @@
}
/* timer sub from current time */
-TIMEVAL
-timer_sub_now(TIMEVAL a)
+timeval_t
+timer_sub_now(timeval_t a)
{
return timer_sub(time_now, a);
}
/* print timer value */
void
-timer_dump(TIMEVAL a)
+timer_dump(timeval_t a)
{
unsigned long timer;
timer = a.tv_sec * TIMER_HZ + a.tv_usec;
@@ -219,7 +219,7 @@
}
unsigned long
-timer_tol(TIMEVAL a)
+timer_tol(timeval_t a)
{
unsigned long timer;
timer = a.tv_sec * TIMER_HZ + a.tv_usec;
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/timer.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#ifndef _TIMER_H
@@ -25,29 +25,31 @@
#include <sys/time.h>
-typedef struct timeval TIMEVAL;
+typedef struct timeval timeval_t;
/* Global vars */
-extern TIMEVAL time_now;
+extern timeval_t time_now;
-/* macro utilities */
-#define TIME_MAX_FORWARD_US 2000000
-#define TIMER_HZ 1000000
-#define TIMER_MAX_SEC 1000
-#define TIMER_SEC(T) ((T).tv_sec)
-#define TIMER_LONG(T) ((T).tv_sec * TIMER_HZ + (T).tv_usec)
-#define TIMER_ISNULL(T) ((T).tv_sec == 0 && (T).tv_usec == 0)
-#define TIMER_RESET(T) (memset(&(T), 0, sizeof(struct timeval)))
+/* Some defines */
+#define TIME_MAX_FORWARD_US 2000000
+#define TIMER_HZ 1000000
+#define TIMER_MAX_SEC 1000
+
+/* Some usefull macros */
+#define timer_sec(T) ((T).tv_sec)
+#define timer_long(T) ((T).tv_sec * TIMER_HZ + (T).tv_usec)
+#define timer_isnull(T) ((T).tv_sec == 0 && (T).tv_usec == 0)
+#define timer_reset(T) (memset(&(T), 0, sizeof(timeval_t)))
/* prototypes */
-extern TIMEVAL timer_now(void);
-extern TIMEVAL set_time_now(void);
-extern TIMEVAL timer_dup(TIMEVAL b);
-extern int timer_cmp(TIMEVAL a, TIMEVAL b);
-extern TIMEVAL timer_sub(TIMEVAL a, TIMEVAL b);
-extern TIMEVAL timer_add_long(TIMEVAL a, long b);
-extern TIMEVAL timer_sub_now(TIMEVAL a);
-extern void timer_dump(TIMEVAL a);
-extern unsigned long timer_tol(TIMEVAL a);
+extern timeval_t timer_now(void);
+extern timeval_t set_time_now(void);
+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_long(timeval_t, long);
+extern timeval_t timer_sub_now(timeval_t);
+extern void timer_dump(timeval_t);
+extern unsigned long timer_tol(timeval_t);
#endif
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/utils.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#include "utils.h"
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/utils.h
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#ifndef _UTILS_H
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/vector.c
^
|
@@ -17,7 +17,7 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#include "vector.h"
@@ -27,16 +27,31 @@
* Initialize vector struct.
* allocalted 'size' slot elements then return vector.
*/
-vector
+vector_t *
vector_alloc(void)
{
- vector v = (vector) MALLOC(sizeof (struct _vector));
+ vector_t *v = (vector_t *) MALLOC(sizeof(vector_t));
+ return v;
+}
+
+vector_t *
+vector_init(unsigned int size)
+{
+ vector_t *v = vector_alloc();
+
+ /* allocate at least one slot */
+ if (size == 0)
+ size = 1;
+
+ v->allocated = size;
+ v->active = 0;
+ v->slot = (void *) MALLOC(sizeof(void *) * size);
return v;
}
/* allocated one slot */
void
-vector_alloc_slot(vector v)
+vector_alloc_slot(vector_t *v)
{
v->allocated += VECTOR_DEFAULT_SIZE;
if (v->slot)
@@ -47,64 +62,220 @@
/* Insert a value into a specific slot */
void
-vector_insert_slot(vector v, int slot, void *value)
+vector_insert_slot(vector_t *v, int index, void *value)
{
int i;
vector_alloc_slot(v);
- for (i = (v->allocated / VECTOR_DEFAULT_SIZE) - 2; i >= slot; i--)
+ for (i = (v->allocated / VECTOR_DEFAULT_SIZE) - 2; i >= index; i--)
v->slot[i + 1] = v->slot[i];
- v->slot[slot] = value;
+ v->slot[index] = value;
}
-/* Free memory vector allocation */
-void
-vector_free(vector v)
+/* Copy / dup a vector */
+vector_t *
+vector_copy(vector_t *v)
{
- FREE(v->slot);
- FREE(v);
+ unsigned int size;
+ vector_t *new = vector_alloc();
+
+ new->active = v->active;
+ new->allocated = v->allocated;
+
+ size = sizeof(void *) * (v->allocated);
+ new->slot = (void *) MALLOC(size);
+ memcpy(new->slot, v->slot, size);
+
+ return new;
}
+/* Check assigned index, and if it runs short double index pointer */
void
-free_strvec(vector strvec)
+vector_ensure(vector_t *v, unsigned int num)
{
- int i;
- char *str;
-
- if (!strvec)
+ if (v->allocated > num)
return;
- for (i = 0; i < VECTOR_SIZE(strvec); i++)
- if ((str = VECTOR_SLOT(strvec, i)) != NULL)
- FREE(str);
+ v->slot = REALLOC(v->slot, sizeof(void *) * (v->allocated * 2));
+ memset(&v->slot[v->allocated], 0, sizeof (void *) * v->allocated);
+ v->allocated *= 2;
- vector_free(strvec);
+ if (v->allocated <= num)
+ vector_ensure(v, num);
+}
+
+/* This function only returns next empty slot index. It dose not mean
+ * the slot's index memory is assigned, please call vector_ensure()
+ * after calling this function.
+ */
+int
+vector_empty_slot(vector_t *v)
+{
+ unsigned int i;
+
+ if (v->active == 0)
+ return 0;
+
+ for (i = 0; i < v->active; i++) {
+ if (v->slot[i] == 0) {
+ return i;
+ }
+ }
+
+ return i;
+}
+
+/* Set value to the smallest empty slot. */
+int
+vector_set(vector_t *v, void *val)
+{
+ unsigned int i;
+
+ i = vector_empty_slot(v);
+ vector_ensure(v, i);
+
+ v->slot[i] = val;
+
+ if (v->active <= i)
+ v->active = i + 1;
+
+ return i;
}
/* Set a vector slot value */
void
-vector_set_slot(vector v, void *value)
+vector_set_slot(vector_t *v, void *value)
{
unsigned int i = v->allocated - 1;
v->slot[i] = value;
}
+/* Set value to specified index slot. */
+int
+vector_set_index(vector_t *v, unsigned int i, void *val)
+{
+ vector_ensure(v, i);
+
+ v->slot[i] = val;
+
+ if (v->active <= i)
+ v->active = i + 1;
+
+ return i;
+}
+
+/* Look up vector. */
+void *
+vector_lookup(vector_t *v, unsigned int i)
+{
+ if (i >= v->active)
+ return NULL;
+ return v->slot[i];
+}
+
+/* Lookup vector, ensure it. */
+void *
+vector_lookup_ensure(vector_t *v, unsigned int i)
+{
+ vector_ensure(v, i);
+ return v->slot[i];
+}
+
+/* Unset value at specified index slot. */
+void
+vector_unset(vector_t *v, unsigned int i)
+{
+ if (i >= v->allocated)
+ return;
+
+ v->slot[i] = NULL;
+
+ if (i + 1 == v->active) {
+ v->active--;
+ while (i && v->slot[--i] == NULL && v->active--)
+ ; /* Is this ugly ? */
+ }
+}
+
+/* Count the number of not emplty slot. */
+unsigned int
+vector_count(vector_t *v)
+{
+ unsigned int i;
+ unsigned count = 0;
+
+ for (i = 0; i < v->active; i++) {
+ if (v->slot[i] != NULL) {
+ count++;
+ }
+ }
+
+ return count;
+}
+
+/* Free memory vector allocation */
+void
+vector_only_wrapper_free(vector_t *v)
+{
+ FREE(v);
+}
+
+void
+vector_only_slot_free(void *slot)
+{
+ FREE(slot);
+}
+
+void
+vector_only_index_free(void *slot)
+{
+ vector_only_slot_free(slot);
+}
+
+void
+vector_free(vector_t *v)
+{
+ FREE(v->slot);
+ FREE(v);
+}
+
/* dump vector slots */
void
-vector_dump(vector v)
+vector_dump(vector_t *v)
{
int i;
printf("Vector Size : %d\n", v->allocated);
- for (i = 0; i < v->allocated; i++)
- if (v->slot[i] != NULL)
- printf(" Slot [%d]: %p\n", i, VECTOR_SLOT(v, i));
+ for (i = 0; i < v->allocated; i++) {
+ if (v->slot[i] != NULL) {
+ printf(" Slot [%d]: %p\n", i, vector_slot(v, i));
+ }
+ }
+}
+
+/* String vector related */
+void
+free_strvec(vector_t *strvec)
+{
+ int i;
+ char *str;
+
+ if (!strvec)
+ return;
+
+ for (i = 0; i < vector_size(strvec); i++) {
+ if ((str = vector_slot(strvec, i)) != NULL) {
+ FREE(str);
+ }
+ }
+
+ vector_free(strvec);
}
void
-dump_strvec(vector strvec)
+dump_strvec(vector_t *strvec)
{
int i;
char *str;
@@ -114,8 +285,8 @@
printf("String Vector : ");
- for (i = 0; i < VECTOR_SIZE(strvec); i++) {
- str = VECTOR_SLOT(strvec, i);
+ for (i = 0; i < vector_size(strvec); i++) {
+ str = vector_slot(strvec, i);
printf("[%i]=%s ", i, str);
}
printf("\n");
|
[-]
[+]
|
Changed |
keepalived-1.2.7.tar.bz2/lib/vector.h
^
|
@@ -17,34 +17,50 @@
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2001-2011 Alexandre Cassen, <acassen@linux-vs.org>
+ * Copyright (C) 2001-2012 Alexandre Cassen, <acassen@linux-vs.org>
*/
#ifndef _VECTOR_H
#define _VECTOR_H
/* vector definition */
-struct _vector {
- unsigned int allocated;
- void **slot;
-};
-typedef struct _vector *vector;
+typedef struct _vector {
+ unsigned int active;
+ unsigned int allocated;
+ void **slot;
+} vector_t;
+/* Some defines */
#define VECTOR_DEFAULT_SIZE 1
-#define VECTOR_SLOT(V,E) ((V)->slot[(E)])
-#define VECTOR_SIZE(V) ((V)->allocated)
+/* Some usefull macros */
+#define vector_slot(V,E) ((V)->slot[(E)])
+#define vector_size(V) ((V)->allocated)
+#define vector_active(V) ((V)->active)
#define vector_foreach_slot(v,p,i) \
for (i = 0; i < (v)->allocated && ((p) = (v)->slot[i]); i++)
/* Prototypes */
-extern vector vector_alloc(void);
-extern void vector_alloc_slot(vector v);
-extern void vector_free(vector v);
-extern void free_strvec(vector strvec);
-extern void vector_set_slot(vector v, void *value);
-extern void vector_insert_slot(vector v, int slot, void *value);
-extern void vector_dump(vector v);
-extern void dump_strvec(vector strvec);
+extern vector_t *vector_alloc(void);
+extern vector_t *vector_init(unsigned int);
+extern void vector_alloc_slot(vector_t *);
+extern void vector_insert_slot(vector_t *, int, void *);
+extern vector_t *vector_copy(vector_t *);
+extern void vector_ensure(vector_t *, unsigned int);
+extern int vector_empty_slot(vector_t *);
+extern int vector_set(vector_t *, void *);
+extern void vector_set_slot(vector_t *, void *);
+extern int vector_set_index(vector_t *, unsigned int, void *);
+extern void *vector_lookup(vector_t *, unsigned int);
+extern void *vector_lookup_ensure(vector_t *, unsigned int);
+extern void vector_unset(vector_t *, unsigned int);
+extern unsigned int vector_count(vector_t *);
+extern void vector_only_wrapper_free(vector_t *);
+extern void vector_only_index_free(void *);
+extern void vector_only_slot_free(void *);
+extern void vector_free(vector_t *);
+extern void vector_dump(vector_t *);
+extern void free_strvec(vector_t *);
+extern void dump_strvec(vector_t *);
#endif
|