summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorerik <stipmonster@gmail.com>2020-07-05 16:09:54 +0200
committerGitHub <noreply@github.com>2020-07-05 16:09:54 +0200
commit65f89e8637b81e9f40c9ab0543df6c6aad39ce3e (patch)
tree56e1ec9b63824ab3613a943eb9ecdbe79adbaf19 /scripts
parent7c719556bdee7c7e965c0b1eb4f182704ee1c6fd (diff)
downloadvyatta-cfg-quagga-65f89e8637b81e9f40c9ab0543df6c6aad39ce3e.tar.gz
vyatta-cfg-quagga-65f89e8637b81e9f40c9ab0543df6c6aad39ce3e.zip
frr: T2686: fixed large-community-list configuration generation
Co-authored-by: Erik Kooistra <me@erikkooistra.nl>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/policy/vyatta-policy.pl52
1 files changed, 51 insertions, 1 deletions
diff --git a/scripts/policy/vyatta-policy.pl b/scripts/policy/vyatta-policy.pl
index cbff3d4b..3e73a3bb 100755
--- a/scripts/policy/vyatta-policy.pl
+++ b/scripts/policy/vyatta-policy.pl
@@ -8,7 +8,7 @@ use Getopt::Long;
my $VTYSH = '/usr/bin/vtysh';
my $ACL_CONSUMERS_DIR = "/opt/vyatta/sbin/policy";
-my ( $accesslist, $accesslist6, $aspathlist, $communitylist, $extcommunitylist, $peer );
+my ( $accesslist, $accesslist6, $aspathlist, $communitylist, $extcommunitylist, $largecommunitylist, $peer );
my ( $routemap, $deleteroutemap, $listpolicy );
GetOptions(
@@ -17,6 +17,7 @@ GetOptions(
"update-aspath-list=s" => \$aspathlist,
"update-community-list=s" => \$communitylist,
"update-extcommunity-list=s" => \$extcommunitylist,
+ "update-large-community-list=s" => \$largecommunitylist,
"check-peer-syntax=s" => \$peer,
"check-routemap-action=s" => \$routemap,
"check-delete-routemap-action=s" => \$deleteroutemap,
@@ -28,6 +29,7 @@ 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_large_community_list($largecommunitylist) if ($largecommunitylist);
check_peer_syntax($peer) if ($peer);
check_routemap_action($routemap) if ($routemap);
check_delete_routemap_action($deleteroutemap) if ($deleteroutemap);
@@ -71,6 +73,54 @@ sub is_extcommunity_list {
}
}
+sub is_large_community_list {
+ my $list = shift;
+
+ my $count = `$VTYSH -c \"show bgp large-community-list $list detail\" | grep -c $list`;
+ if ( $count > 0 ) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
+sub update_large_community_list {
+ my $name = shift;
+ my $config = new Vyatta::Config;
+ my @rules = ();
+
+ # remove the old rules
+ if ( is_large_community_list($name) ) {
+ my $clist = `$VTYSH -c \"show bgp large-community-list $name detail\" | grep -v \"expanded list $name\"`;
+ my @oldrules = split(/\n/, $clist);
+ foreach my $oldrule (@oldrules) {
+ system("$VTYSH -c \"conf t\" -c \"no bgp large-community-list expanded $name $oldrule\"");
+ }
+ }
+
+ $config->setLevel("policy large-community-list $name rule");
+ @rules = $config->listNodes();
+ foreach my $rule ( sort numerically @rules ) {
+ # set the action
+ my $action = $config->returnValue("$rule action");
+ die
+ "large-community-list $name rule $rule: You must specify an action\n"
+ unless $action;
+
+ # grab the regex
+ my $regex = $config->returnValue("$rule regex");
+ if(!defined($regex)) {
+ die "large-community-list $name rule $rule: You must specify a regex\n";
+ }
+ if (!($regex =~ /(.*):(.*):(.*)/) and (isIpAddress($1)or($1=~/^\d+$/) ) and ($2=~/^\d+$/)) {
+ die "large-community-list $name rule $rule: Malformed large-community-list regex";
+ }
+ system("$VTYSH -c \"conf t\" -c \"bgp large-community-list expanded $name $action $regex\"");
+ }
+
+ exit(0);
+}
sub update_ext_community_list {
my $name = shift;