diff options
author | Stig Thormodsrud <stig@io.vyatta.com> | 2009-03-01 09:44:30 -0800 |
---|---|---|
committer | Stig Thormodsrud <stig@io.vyatta.com> | 2009-03-01 09:44:30 -0800 |
commit | 449ca5016fb6f42abfecdda7fc906ed81f4d439e (patch) | |
tree | d8fdfe1741e859347f659d5ac5a7472ee4430487 /scripts/keepalived | |
parent | f6c3d454f99f430bfb538ba2008965a0eab97527 (diff) | |
download | vyatta-cfg-quagga-449ca5016fb6f42abfecdda7fc906ed81f4d439e.tar.gz vyatta-cfg-quagga-449ca5016fb6f42abfecdda7fc906ed81f4d439e.zip |
Fix 4152: Add support for VRRP operation on unnumbered interfaces
Diffstat (limited to 'scripts/keepalived')
-rwxr-xr-x | scripts/keepalived/vyatta-keepalived.pl | 37 | ||||
-rwxr-xr-x | scripts/keepalived/vyatta-show-vrrp.pl | 5 |
2 files changed, 40 insertions, 2 deletions
diff --git a/scripts/keepalived/vyatta-keepalived.pl b/scripts/keepalived/vyatta-keepalived.pl index a553a1ce..d151b605 100755 --- a/scripts/keepalived/vyatta-keepalived.pl +++ b/scripts/keepalived/vyatta-keepalived.pl @@ -27,6 +27,8 @@ use lib "/opt/vyatta/share/perl5/"; use Vyatta::Config; use Vyatta::Keepalived; use Vyatta::TypeChecker; +use Vyatta::Interface; +use Vyatta::Misc; use Getopt::Long; use strict; @@ -37,6 +39,36 @@ my $conf_file = get_conf_file(); my %HoA_sync_groups; +sub validate_source_addr { + my ($ifname, $source_addr) = @_; + + my @ipaddrs; + if (defined $source_addr) { + my %config_ipaddrs; + my @ipaddrs = Vyatta::Misc::getInterfacesIPadresses('all'); + foreach my $ip (@ipaddrs) { + if ($ip =~ /^([\d.]+)\/([\d.]+)$/) { # strip /mask + $config_ipaddrs{$1} = 1; + } + } + if (!defined $config_ipaddrs{$source_addr}) { + print "hello-source-address [$source_addr] must be configured on" . + " some interface\n"; + exit 1; + } + return; + } + # if the hello-source-address wasn't configured, check that the + # interface has an IPv4 address configured on it. + my $intf = new Vyatta::Interface($ifname); + @ipaddrs = $intf->address(4); + if (scalar(@ipaddrs) < 1) { + print "must configure either a primary address on [$ifname] or" . + " a hello-source-address\n"; + exit 1; + } + return; +} sub keepalived_get_values { my ($intf, $path) = @_; @@ -87,6 +119,8 @@ sub keepalived_get_values { if (defined $sync_group && $sync_group ne "") { push @{ $HoA_sync_groups{$sync_group} }, $vrrp_instance; } + my $hello_source_addr = $config->returnValue("hello-source-address"); + validate_source_addr($intf, $hello_source_addr); $config->setLevel("$path vrrp vrrp-group $group authentication"); my $auth_type = $config->returnValue("type"); @@ -135,6 +169,9 @@ sub keepalived_get_values { $output .= "\t\tauth_type $auth_type\n"; $output .= "\t\tauth_pass $auth_pass\n\t}\n"; } + if (defined $hello_source_addr) { + $output .= "\tmcast_src_ip $hello_source_addr\n"; + } $output .= "\tvirtual_ipaddress \{\n"; foreach my $vip (@vips) { $output .= "\t\t$vip\n"; diff --git a/scripts/keepalived/vyatta-show-vrrp.pl b/scripts/keepalived/vyatta-show-vrrp.pl index 4b8d6fec..0e8e2909 100755 --- a/scripts/keepalived/vyatta-show-vrrp.pl +++ b/scripts/keepalived/vyatta-show-vrrp.pl @@ -178,7 +178,8 @@ sub vrrp_showsummary { my ($primary_addr, $priority, $preempt, $advert_int, $auth_type, @vips) = Vyatta::Keepalived::vrrp_get_config($intf, $group); my $format = "\n%-16s%-8s%-8s%-16s%-16s%-16s"; - printf($format, $intf, $group, 'int', $primary_addr, $link, $state); + my $vip = pop @vips; + printf($format, $intf, $group, 'vip', $vip, $link, $state); foreach my $vip (@vips){ printf("\n%-24s%-8s%-16s", ' ', 'vip', $vip); } @@ -198,7 +199,7 @@ sub vrrp_show { if ($state eq "master" || $state eq "backup" || $state eq "fault") { my ($primary_addr, $priority, $preempt, $advert_int, $auth_type, @vips) = Vyatta::Keepalived::vrrp_get_config($intf, $group); - print "Physical interface: $intf, Address $primary_addr\n"; + print "Physical interface: $intf, Source Address $primary_addr\n"; print " Interface state: $link, Group $group, State: $state\n"; print " Priority: $priority, Advertisement interval: $advert_int, "; print "Authentication type: $auth_type\n"; |