diff options
author | Daniil Baturin <daniil@baturin.org> | 2018-10-21 22:06:29 +0200 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2018-10-21 22:06:29 +0200 |
commit | 569a97fc0e9fd4a729cca5a36cc2bdba066d7356 (patch) | |
tree | c1cacf8facf01071a279c5fe965fc6e0bd6d2907 /scripts | |
parent | c912b1a542304dd2adec87bf225bf241ef9cdf7a (diff) | |
download | vyatta-cfg-quagga-569a97fc0e9fd4a729cca5a36cc2bdba066d7356.tar.gz vyatta-cfg-quagga-569a97fc0e9fd4a729cca5a36cc2bdba066d7356.zip |
T64: fix and revamp the broken extcommunity-list commands.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/policy/vyatta-policy.pl | 54 |
1 files changed, 17 insertions, 37 deletions
diff --git a/scripts/policy/vyatta-policy.pl b/scripts/policy/vyatta-policy.pl index 9ca97036..c5e781ba 100755 --- a/scripts/policy/vyatta-policy.pl +++ b/scripts/policy/vyatta-policy.pl @@ -27,7 +27,7 @@ update_access_list($accesslist) if ($accesslist); update_access_list6($accesslist6) if ($accesslist6); update_as_path($aspathlist) if ($aspathlist); update_community_list($communitylist) if ($communitylist); -update_ext_community_list($extcommunitylist) if ($extcommunitylist); +update_ext_community_list($extcommunitylist) if ($extcommunitylist); check_peer_syntax($peer) if ($peer); check_routemap_action($routemap) if ($routemap); check_delete_routemap_action($deleteroutemap) if ($deleteroutemap); @@ -72,59 +72,40 @@ sub is_extcommunity_list { sub update_ext_community_list { - my $variant= shift; my $name = shift; my $config = new Vyatta::Config; my @rules = (); - if($variant !~ /^standard|expanded$/ ) { - die -"set policy route extcommunity-list [ standard | expanded ] list-name rule rule-num action { deny | permit } - ^^^^^^^^^^^^^^^^^^^^^^^\n"; - }; - - # remove the old rule - if ( is_extcommunity_list($num) ) { - my $clist = `$VTYSH -c \"show ip extcommunity-list $num\" | grep -v \"access list $num\"`; + # remove the old rules + if ( is_extcommunity_list($name) ) { + my $clist = `$VTYSH -c \"show ip extcommunity-list $name\" | grep -v \"expanded list $name\"`; my @oldrules = split(/\n/, $clist); foreach my $oldrule (@oldrules) { - print "$oldrule\n"; - system("$VTYSH -c \"conf t\" -c \"no ip extcommunity-list $num $oldrule\""); + system("$VTYSH -c \"conf t\" -c \"no ip extcommunity-list expanded $name $oldrule\""); } - } + } - $config->setLevel("policy route extcommunity-list $variant $name "); + $config->setLevel("policy extcommunity-list $name rule"); @rules = $config->listNodes(); foreach my $rule ( sort numerically @rules ) { - # set the action my $action = $config->returnValue("$rule action"); die - "policy route extcommunity-list $variant $name rule $rule: You must specify an action\n" + "extcommunity-list $name rule $rule: You must specify an action\n" unless $action; # grab the regex my $regex = $config->returnValue("$rule regex"); - die "policy route extcommunity-list $variant $name rule $rule: You must specify a regex\n" - unless $regex; - if($variant eq 'standard') { - unless (($regex =~ /(.*):(.*)/) and (isIpAddress($1)or($1=~/^\d+$/) ) and ($2=~/^\d+$/)) { - die "for standard extcommunity-list regex should be either: - -AS:VAL - - This is a format to define AS based Extended Community value. AS part is 2 octets Global Administrator subfield in Extended Community value. VAL part is 4 octets Local Administrator subfield. 7675:100 represents AS 7675 policy value 100. - -IP-Address:VAL + if(!defined($regex)) { + die "extcommunity-list $name rule $rule: You must specify a regex\n"; + } + if (!($regex =~ /(.*):(.*)/) and (isIpAddress($1)or($1=~/^\d+$/) ) and ($2=~/^\d+$/)) { + die "extcommunity-list $name rule $rule: Malformed extcommunity-list regex"; + } + system("$VTYSH -c \"conf t\" -c \"ip extcommunity-list expanded $name $action $regex\""); + } - This is a format to define IP address based Extended Community value. IP-Address part is 4 octets Global Administrator subfield. VAL part is 2 octets Local Administrator subfield. 10.0.0.1:100 represents IP 10.0.0.1 policy value 100. -"; - - }; - }; - $cmdline.="-c \"ip extcommunity-list $name $action $regex\" "; - }; - exit system($cmdline); + exit(0); } @@ -138,7 +119,6 @@ sub update_community_list { my $clist = `$VTYSH -c \"show ip community-list $num\" | grep -v \"access list $num\"`; my @oldrules = split(/\n/, $clist); foreach my $oldrule (@oldrules) { - print "$oldrule\n"; system("$VTYSH -c \"conf t\" -c \"no ip community-list $num $oldrule\""); } } |