From 81a7898ae52e86bb02530dc284057b03499a294d Mon Sep 17 00:00:00 2001 From: Quentin Armitage Date: Tue, 10 Nov 2015 09:29:07 +0000 Subject: Allow specification of default VRRP version to use Rather than have to specify using VRRP version 3 on each VRRP instance, allow global configuration to set the default version. Signed-off-by: Quentin Armitage (cherry picked from commit 8c84409635ee1b40827638a5b5a93f0568a3c3c2) --- doc/keepalived.conf.SYNOPSIS | 2 ++ doc/man/man5/keepalived.conf.5 | 6 +++++- keepalived/core/global_data.c | 2 ++ keepalived/core/global_parser.c | 12 ++++++++++++ keepalived/include/global_data.h | 1 + keepalived/vrrp/vrrp_data.c | 2 +- 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/doc/keepalived.conf.SYNOPSIS b/doc/keepalived.conf.SYNOPSIS index 7f0d279..7a74bab 100644 --- a/doc/keepalived.conf.SYNOPSIS +++ b/doc/keepalived.conf.SYNOPSIS @@ -44,6 +44,7 @@ global_defs { # Block identification vrrp_garp_master_refresh_repeat # how many gratuitous ARP messages shoule be sent # at each periodic repeat # Default: once (per period) + vrrp_version # Default VRRP version (default 2) } linkbeat_use_polling # Use media link failure detection polling fashion @@ -159,6 +160,7 @@ Important: for a SYNC group to run reliably, it is vital that all instances in vrrp_instance { # VRRP instance declaration use_vmac # Use VRRP Virtual MAC + version # VRRP version to use vmac_xmit_base # Send/Recv VRRP messages from base # interface instead of VMAC interface native_ipv6 # Force instance to use IPv6 diff --git a/doc/man/man5/keepalived.conf.5 b/doc/man/man5/keepalived.conf.5 index 076fe04..8b51668 100644 --- a/doc/man/man5/keepalived.conf.5 +++ b/doc/man/man5/keepalived.conf.5 @@ -56,6 +56,9 @@ and # number of gratuitous ARP messages to send at a time while MASTER vrrp_garp_master_refresh_repeat 2 # default 1 + # Set the default VRRP version to use + vrrp_version <2 or 3> # default version 2 + enable_traps # enable SNMP traps plugin_dir # UNIMPLEMENTED } @@ -193,7 +196,8 @@ which will transition together on any state change. mcast_src_ip unicast_src_ip - version <2 or 3> # VRRP version to run on interface (default 2) + version <2 or 3> # VRRP version to run on interface + # default is global parameter vrrp_version. # Do not send VRRP adverts over VRRP multicast group. # Instead it sends adverts to the following list of diff --git a/keepalived/core/global_data.c b/keepalived/core/global_data.c index 1aa7af3..4053186 100644 --- a/keepalived/core/global_data.c +++ b/keepalived/core/global_data.c @@ -91,6 +91,7 @@ set_vrrp_defaults(data_t * data) data->vrrp_garp_rep = VRRP_GARP_REP; data->vrrp_garp_refresh_rep = VRRP_GARP_REFRESH_REP; data->vrrp_garp_delay = VRRP_GARP_DELAY; + data->vrrp_version = VRRP_VERSION_2; } /* email facility functions */ @@ -197,6 +198,7 @@ dump_global_data(data_t * data) data->vrrp_garp_refresh.tv_sec); log_message(LOG_INFO, " Gratuitous ARP repeat = %d", data->vrrp_garp_rep); log_message(LOG_INFO, " Gratuitous ARP refresh repeat = %d", data->vrrp_garp_refresh_rep); + log_message(LOG_INFO, " VRRP default protocol version = %d", data->vrrp_version); #ifdef _WITH_SNMP_ if (data->enable_traps) log_message(LOG_INFO, " SNMP Trap enabled"); diff --git a/keepalived/core/global_parser.c b/keepalived/core/global_parser.c index ba14d59..745bf2e 100644 --- a/keepalived/core/global_parser.c +++ b/keepalived/core/global_parser.c @@ -123,6 +123,17 @@ vrrp_garp_refresh_rep_handler(vector_t *strvec) if ( global_data->vrrp_garp_refresh_rep < 1 ) global_data->vrrp_garp_refresh_rep = 1; } +static void +vrrp_version_handler(vector_t *strvec) +{ + uint8_t version = atoi(vector_slot(strvec, 1)); + if (VRRP_IS_BAD_VERSION(version)) { + log_message(LOG_INFO, "VRRP Error : Version not valid !\n"); + log_message(LOG_INFO, " must be between either 2 or 3. reconfigure !\n"); + return; + } + global_data->vrrp_version = version; +} #ifdef _WITH_SNMP_ static void trap_handler(vector_t *strvec) @@ -148,6 +159,7 @@ global_init_keywords(void) install_keyword("vrrp_garp_master_repeat", &vrrp_garp_rep_handler); install_keyword("vrrp_garp_master_refresh", &vrrp_garp_refresh_handler); install_keyword("vrrp_garp_master_refresh_repeat", &vrrp_garp_refresh_rep_handler); + install_keyword("vrrp_version", &vrrp_version_handler); #ifdef _WITH_SNMP_ install_keyword("enable_traps", &trap_handler); #endif diff --git a/keepalived/include/global_data.h b/keepalived/include/global_data.h index 2a4e561..8aaa374 100644 --- a/keepalived/include/global_data.h +++ b/keepalived/include/global_data.h @@ -56,6 +56,7 @@ typedef struct _data { timeval_t vrrp_garp_refresh; int vrrp_garp_rep; int vrrp_garp_refresh_rep; + int vrrp_version; /* VRRP version (2 or 3) */ #ifdef _WITH_SNMP_ int enable_traps; #endif diff --git a/keepalived/vrrp/vrrp_data.c b/keepalived/vrrp/vrrp_data.c index 1235aac..a7fd50b 100644 --- a/keepalived/vrrp/vrrp_data.c +++ b/keepalived/vrrp/vrrp_data.c @@ -360,7 +360,7 @@ alloc_vrrp(char *iname) new->family = AF_INET; new->wantstate = VRRP_STATE_BACK; new->init_state = VRRP_STATE_BACK; - new->version = VRRP_VERSION_2; + new->version = global_data->vrrp_version; new->master_priority = 0; new->last_transition = timer_now(); new->adver_int = TIMER_HZ; -- 1.7.12.1