summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStig Thormodsrud <stig@io.vyatta.com>2009-03-01 09:44:30 -0800
committerStig Thormodsrud <stig@io.vyatta.com>2009-03-01 09:44:30 -0800
commit449ca5016fb6f42abfecdda7fc906ed81f4d439e (patch)
treed8fdfe1741e859347f659d5ac5a7472ee4430487
parentf6c3d454f99f430bfb538ba2008965a0eab97527 (diff)
downloadvyatta-cfg-quagga-449ca5016fb6f42abfecdda7fc906ed81f4d439e.tar.gz
vyatta-cfg-quagga-449ca5016fb6f42abfecdda7fc906ed81f4d439e.zip
Fix 4152: Add support for VRRP operation on unnumbered interfaces
-rwxr-xr-xlib/Vyatta/Keepalived.pm6
-rwxr-xr-xscripts/keepalived/vyatta-keepalived.pl37
-rwxr-xr-xscripts/keepalived/vyatta-show-vrrp.pl5
-rw-r--r--templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/node.def2
-rw-r--r--templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/hello-source-address/node.def6
-rw-r--r--templates/interfaces/ethernet/node.tag/vrrp/node.def2
-rw-r--r--templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/hello-source-address/node.def6
7 files changed, 58 insertions, 6 deletions
diff --git a/lib/Vyatta/Keepalived.pm b/lib/Vyatta/Keepalived.pm
index 5267d102..1f3c2592 100755
--- a/lib/Vyatta/Keepalived.pm
+++ b/lib/Vyatta/Keepalived.pm
@@ -157,12 +157,14 @@ sub vrrp_get_config {
if (!defined $primary_addr) {
$primary_addr = "0.0.0.0";
}
-
if ($primary_addr =~ m/(\d+\.\d+\.\d+\.\d+)\/\d+/) {
- $primary_addr = $1;
+ $primary_addr = $1; # strip /mask
}
$config->setLevel("$path vrrp vrrp-group $group");
+ my $source_addr = $config->returnOrigValue("hello-source-address");
+ $primary_addr = $source_addr if defined $source_addr;
+
my @vips = $config->returnOrigValues("virtual-address");
my $priority = $config->returnOrigValue("priority");
if (!defined $priority) {
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";
diff --git a/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/node.def b/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/node.def
index 26fdf457..f90c20db 100644
--- a/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/node.def
+++ b/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/node.def
@@ -1,3 +1,3 @@
help: Configure Virtual Router Redundancy Protocol (VRRP) parameters
-commit:expression: $VAR(../address/) != ""; "Must define a primary IP address on $VAR(../../@) vif $VAR(../@)"
+
end:expression: "sudo /opt/vyatta/sbin/vyatta-keepalived.pl --vrrp-action update --intf $VAR(../../@).$VAR(../@) "
diff --git a/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/hello-source-address/node.def b/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/hello-source-address/node.def
new file mode 100644
index 00000000..edb0d58a
--- /dev/null
+++ b/templates/interfaces/ethernet/node.tag/vif/node.tag/vrrp/vrrp-group/node.tag/hello-source-address/node.def
@@ -0,0 +1,6 @@
+type: ipv4
+
+help: Set hello-source-address
+
+comp_help: possible completions:
+ <x.x.x.x> Set source address for vrrp hello packets (optional)
diff --git a/templates/interfaces/ethernet/node.tag/vrrp/node.def b/templates/interfaces/ethernet/node.tag/vrrp/node.def
index d88c9745..fc9bd82e 100644
--- a/templates/interfaces/ethernet/node.tag/vrrp/node.def
+++ b/templates/interfaces/ethernet/node.tag/vrrp/node.def
@@ -1,3 +1,3 @@
help: Configure Virtual Router Redundancy Protocol (VRRP)
-commit:expression: $VAR(../address/) != ""; "Must define a primary IP address on $VAR(../@)"
+
end:expression: "sudo /opt/vyatta/sbin/vyatta-keepalived.pl --vrrp-action update --intf $VAR(../@) "
diff --git a/templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/hello-source-address/node.def b/templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/hello-source-address/node.def
new file mode 100644
index 00000000..edb0d58a
--- /dev/null
+++ b/templates/interfaces/ethernet/node.tag/vrrp/vrrp-group/node.tag/hello-source-address/node.def
@@ -0,0 +1,6 @@
+type: ipv4
+
+help: Set hello-source-address
+
+comp_help: possible completions:
+ <x.x.x.x> Set source address for vrrp hello packets (optional)