From 0294f753e1b788b115ec75e660ef10212a0128b2 Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Sat, 28 Feb 2009 13:36:44 -0800 Subject: Fix 3778: vrrp should allow prefix to be included with the virtual-address --- scripts/keepalived/vyatta-keepalived.pl | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/keepalived/vyatta-keepalived.pl b/scripts/keepalived/vyatta-keepalived.pl index b2f0ba3b..a553a1ce 100755 --- a/scripts/keepalived/vyatta-keepalived.pl +++ b/scripts/keepalived/vyatta-keepalived.pl @@ -26,6 +26,7 @@ use lib "/opt/vyatta/share/perl5/"; use Vyatta::Config; use Vyatta::Keepalived; +use Vyatta::TypeChecker; use Getopt::Long; use strict; @@ -351,11 +352,12 @@ sub keepalived_write_file { # # main # -my ($action, $vrrp_intf, $vrrp_group); +my ($action, $vrrp_intf, $vrrp_group, $vrrp_vip); GetOptions("vrrp-action=s" => \$action, "intf=s" => \$vrrp_intf, - "group=s" => \$vrrp_group); + "group=s" => \$vrrp_group, + "vip=s" => \$vrrp_vip); if (! defined $action) { print "no action\n"; @@ -396,6 +398,21 @@ if ($action eq "delete") { exit 0; } +if ($action eq "check-vip") { + if (! defined $vrrp_vip) { + print "must include the virtual-address to check"; + exit 1; + } + my $rc = 1; + if ($vrrp_vip =~ /\//) { + $rc = Vyatta::TypeChecker::validateType('ipv4net', $vrrp_vip, 1); + } else { + $rc = Vyatta::TypeChecker::validateType('ipv4', $vrrp_vip, 1); + } + exit 1 if ! $rc; + exit 0; +} + exit 0; # end of file -- cgit v1.2.3