diff options
author | Stig Thormodsrud <stig@vyatta.com> | 2011-01-24 20:03:02 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2011-01-25 17:00:01 -0800 |
commit | 47a2452f92a33aadc26ba5b591c96cfe81482a9b (patch) | |
tree | 8bb32f891ec8ddf5f401aeb89d8cee9a5e37ae60 | |
parent | 05680da28fa9f94f1b3e3897c8c8e13d13580264 (diff) | |
download | vyatta-cfg-quagga-47a2452f92a33aadc26ba5b591c96cfe81482a9b.tar.gz vyatta-cfg-quagga-47a2452f92a33aadc26ba5b591c96cfe81482a9b.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); |