diff options
author | Stig Thormodsrud <stig@vyatta.com> | 2010-03-20 13:08:04 -0700 |
---|---|---|
committer | Stig Thormodsrud <stig@vyatta.com> | 2010-03-20 13:08:04 -0700 |
commit | 442fd359980919f018107849240b63ce73bcffc3 (patch) | |
tree | 97624a57cd4208651e25c1b75f9f3a087b723068 | |
parent | 369b7c567639d7230c945045c855c678fadfb887 (diff) | |
download | vyatta-cfg-quagga-442fd359980919f018107849240b63ce73bcffc3.tar.gz vyatta-cfg-quagga-442fd359980919f018107849240b63ce73bcffc3.zip |
Fix 4161: Bad config handling of "protocols ospf passive-interface"
-rwxr-xr-x | scripts/vyatta_quagga_utils.pl | 29 | ||||
-rw-r--r-- | templates/protocols/ospf/passive-interface/node.def | 46 |
2 files changed, 64 insertions, 11 deletions
diff --git a/scripts/vyatta_quagga_utils.pl b/scripts/vyatta_quagga_utils.pl index 0b9fb2ae..df263a08 100755 --- a/scripts/vyatta_quagga_utils.pl +++ b/scripts/vyatta_quagga_utils.pl @@ -6,7 +6,7 @@ use Vyatta::Misc; use NetAddr::IP; use Getopt::Long; -my ( $prefix, $exists, $not_exists, $area, $community ); +my ( $prefix, $exists, $not_exists, $area, $community, $passive ); # Allowed well-know community values (see set commuinity) my %communities = ( @@ -24,6 +24,7 @@ GetOptions( "exists=s" => \$exists, "check-ospf-area=s" => \$area, "check-community" => \$community, + "check-ospf-passive=s" => \$passive, ); check_community(@ARGV) if ($community); @@ -31,6 +32,7 @@ check_prefix_boundry($prefix) if ($prefix); check_not_exists($not_exists) if ($not_exists); check_exists($exists) if ($exists); check_ospf_area($area) if ($area); +check_ospf_passive($passive) if ($passive); exit 0; @@ -94,3 +96,28 @@ sub check_community { die "$arg unknown community value\n" } } + +sub check_ospf_passive { + my $passive = shift; + + my $config = new Vyatta::Config; + $config->setLevel('protocols ospf passive-interface'); + my @nodesO = $config->returnOrigValues(); + my @nodes = $config->returnValues(); + + my %nO_hash = map { $_ => 1 } @nodesO; + my %n_hash = map { $_ => 1 } @nodes; + + if ($nO_hash{'default'}) { + exit 0 if ! $n_hash{'default'}; + print "Error: can't add interface when using 'default'\n"; + exit 1; + } else { + if (scalar(@nodes) > 1 and $n_hash{'default'}) { + print "Error: delete other interfaces before using 'default'\n"; + exit 1; + } + } + + exit 0; +} diff --git a/templates/protocols/ospf/passive-interface/node.def b/templates/protocols/ospf/passive-interface/node.def index 2ee24c93..bd66993e 100644 --- a/templates/protocols/ospf/passive-interface/node.def +++ b/templates/protocols/ospf/passive-interface/node.def @@ -1,19 +1,45 @@ multi: type: txt help: Set to suppress routing updates on an interface + allowed: ${vyatta_sbindir}/vyatta-interfaces.pl --show all && echo default -create: if [ -z $VAR(@) ] - then vtysh -c "configure terminal" -c "router ospf" \ - -c "passive-interface default"; - else vtysh -c "configure terminal" -c "router ospf" \ - -c "passive-interface $VAR(@)" - fi + + + +create: sudo /opt/vyatta/sbin/vyatta_quagga_utils.pl \ + --check-ospf-passive="$VAR(@)" + if [ $? != 0 ] ; then + exit 1; + fi + if [ -z $VAR(@) ] || [ "$VAR(@)" == "default" ] ; then + vtysh -c "configure terminal" \ + -c "router ospf" \ + -c "passive-interface default"; + else + vtysh -c "configure terminal" \ + -c "router ospf" \ + -c "passive-interface $VAR(@)" + fi + delete: if [ -z $VAR(@) ] - then vtysh -c "configure terminal" -c "router ospf" \ - -c "no passive-interface default" - else vtysh -c "configure terminal" -c "router ospf" \ - -c "no passive-interface $VAR(@)" + then + vtysh -c "configure terminal" \ + -c "router ospf" \ + -c "no passive-interface default" + else + if [ "$VAR(@)" == "default" ] + then + if [ $VAR(../passive-interface-exclude/@) ] + then + echo "Error: delete passive-interface-exclude before deleting passive-interface default"; + exit 1; + fi + fi + vtysh -c "configure terminal" \ + -c "router ospf" \ + -c "no passive-interface $VAR(@)" fi + comp_help: possible completions: <interface> Set an interface to be passive (i.e. suppress routing updates) default Set default to suppress routing updates on all interfaces |