diff options
author | Stig Thormodsrud <stig@vyatta.com> | 2011-01-24 20:03:02 -0800 |
---|---|---|
committer | Stig Thormodsrud <stig@vyatta.com> | 2011-01-25 11:14:13 -0800 |
commit | 836ce18ba2ecb403cb12b2ea2e1e83403994d833 (patch) | |
tree | 8bb32f891ec8ddf5f401aeb89d8cee9a5e37ae60 | |
parent | 1acb297337d1a011d2daad7c15bd0368b02fc083 (diff) | |
download | vyatta-cfg-quagga-836ce18ba2ecb403cb12b2ea2e1e83403994d833.tar.gz vyatta-cfg-quagga-836ce18ba2ecb403cb12b2ea2e1e83403994d833.zip |
Fix 6501: "clear vrrp master interface <interface> group <group>" doesnt work with sync groups.
(cherry picked from commit 34972b97e834d66147e91c071a1c1caabe18f76f)
-rwxr-xr-x | scripts/keepalived/vyatta-clear-vrrp.pl | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/scripts/keepalived/vyatta-clear-vrrp.pl b/scripts/keepalived/vyatta-clear-vrrp.pl index cdc74cf5..34c0327e 100755 --- a/scripts/keepalived/vyatta-clear-vrrp.pl +++ b/scripts/keepalived/vyatta-clear-vrrp.pl @@ -241,12 +241,31 @@ if ($action eq 'clear_master') { my $conf = <$f>; close $f; - my ($new_conf, $match_instance) = vrrp_extract_instance($conf, $instance); - if ($match_instance !~ /nopreempt/) { - print "Warning: $instance is in preempt mode"; - print " and may retake master\n"; + my $sync_group = list_vrrp_sync_group($intf, $group); + my @instances = (); + if (defined($sync_group)) { + print "vrrp group $vrrp_group on $vrrp_intf is in sync-group " + . "$sync_group\n"; + @instances = list_vrrp_sync_group_members($sync_group); + } else { + push @instances, $instance; + } + + my $new_conf = $conf; + my $clear_instances; + foreach my $inst (@instances) { + my $match_instance; + print "Forcing $inst to BACKUP...\n"; + Vyatta::Keepalived::vrrp_log("vrrp extract $inst"); + ($new_conf, $match_instance) = vrrp_extract_instance($new_conf, $inst); + if ($match_instance !~ /nopreempt/) { + print "Warning: $instance is in preempt mode"; + print " and may retake master\n"; + + } + $match_instance = set_instance_inital_state($match_instance, 'BACKUP'); + $clear_instances .= "$match_instance\n"; } - $match_instance = set_instance_inital_state($match_instance, 'BACKUP'); # # need to set the correct initial state for the remaining instances @@ -265,13 +284,12 @@ if ($action eq 'clear_master') { restart_daemon($conf_file); - print "Forcing $vrrp_intf-$group to BACKUP...\n"; sleep(3); # # add modified instance back and restart # - $new_conf .= "\n" . $match_instance . "\n"; + $new_conf .= "\n" . $clear_instances . "\n"; keepalived_write_file($conf_file, $new_conf); Vyatta::Keepalived::restart_daemon($conf_file); |