diff options
author | Daniil Baturin <daniil@baturin.org> | 2018-10-28 19:31:54 +0100 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2018-10-28 19:31:54 +0100 |
commit | 8c49870a5bb7fb87c5aa1fd138d3531c7f75dfc8 (patch) | |
tree | e28dcd9fbcebc48ab52ea563abf2b3dc2116307b /scripts | |
parent | 75a15fc61c2266c3c6cb6895106b2662fb3443c9 (diff) | |
parent | f5aaf437d83022b6f6f707cb542dbcbc05aadb15 (diff) | |
download | vyatta-cfg-quagga-8c49870a5bb7fb87c5aa1fd138d3531c7f75dfc8.tar.gz vyatta-cfg-quagga-8c49870a5bb7fb87c5aa1fd138d3531c7f75dfc8.zip |
Merge branch 'current' into crux
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/bgp/vyatta-bgp.pl | 13 | ||||
-rwxr-xr-x | scripts/policy/vyatta-policy.pl | 62 |
2 files changed, 37 insertions, 38 deletions
diff --git a/scripts/bgp/vyatta-bgp.pl b/scripts/bgp/vyatta-bgp.pl index 97a0b861..856d3dcd 100755 --- a/scripts/bgp/vyatta-bgp.pl +++ b/scripts/bgp/vyatta-bgp.pl @@ -1596,7 +1596,18 @@ sub main ## deletes with priority # delete everything in neighbor, ordered nodes last - my @ordered = ('remote-as', 'peer-group', 'shutdown', 'route-map', 'prefix-list', 'filter-list', 'distribute-list', 'unsuppress-map'); + my @ordered = ('remote-as', 'peer-group', 'shutdown', + 'address-family ipv4-unicast route-map', + 'address-family ipv4-unicast prefix-list', + 'address-family ipv4-unicast filter-list', + 'address-family ipv4-unicast distribute-list', + 'address-family ipv4-unicast unsuppress-map', + 'address-family ipv6-unicast route-map', + 'address-family ipv6-unicast prefix-list', + 'address-family ipv6-unicast filter-list', + 'address-family ipv6-unicast distribute-list', + 'address-family ipv6-unicast unsuppress-map'); + # notice the extra space in the level string. keeps the parent from being deleted. $qconfig->deleteConfigTreeRecursive('protocols bgp var neighbor var ', undef, \@ordered) || die "exiting $?\n"; $qconfig->deleteConfigTreeRecursive('protocols bgp var peer-group var ', undef, \@ordered) || die "exiting $?\n"; diff --git a/scripts/policy/vyatta-policy.pl b/scripts/policy/vyatta-policy.pl index 4acd1881..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,54 +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"; - }; - my $cmdline="$VTYSH -c \"configure terminal\" "; - # remove the old rule + # remove the old rules if ( is_extcommunity_list($name) ) { - $cmdline.= " -c \"no ip 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) { + 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); } @@ -130,10 +116,12 @@ sub update_community_list { # remove the old rule if ( is_community_list($num) ) { - system( - "$VTYSH -c \"configure terminal\" -c \"no ip community-list $num\" " - ); - } + my $clist = `$VTYSH -c \"show ip community-list $num\" | grep -v \"access list $num\"`; + my @oldrules = split(/\n/, $clist); + foreach my $oldrule (@oldrules) { + system("$VTYSH -c \"conf t\" -c \"no ip community-list $num $oldrule\""); + } + } $config->setLevel("policy community-list $num rule"); @rules = $config->listNodes(); |