diff options
author | Stig Thormodsrud <stig@vyatta.com> | 2008-08-04 16:50:59 -0700 |
---|---|---|
committer | Stig Thormodsrud <stig@vyatta.com> | 2008-08-04 16:50:59 -0700 |
commit | d4f59395af97f25c80045c616065d58ee831d962 (patch) | |
tree | fb0e0213ec825fe08de0e7e35e72726418aaf3c2 | |
parent | c82e59744a3c5500305d5c4938b012ee7c1b0800 (diff) | |
download | vyatta-cfg-quagga-d4f59395af97f25c80045c616065d58ee831d962.tar.gz vyatta-cfg-quagga-d4f59395af97f25c80045c616065d58ee831d962.zip |
Add IPv6 support to bgp cli.
8 files changed, 124 insertions, 36 deletions
diff --git a/scripts/bgp/vyatta-bgp.pl b/scripts/bgp/vyatta-bgp.pl index 319f980b..6f72a5c5 100755 --- a/scripts/bgp/vyatta-bgp.pl +++ b/scripts/bgp/vyatta-bgp.pl @@ -7,6 +7,7 @@ use Getopt::Long; GetOptions("check-peer-name=s" => \$peername, "check-as" => \$checkas, "check-peer-groups" => \$checkpeergroups, + "check-if-peer-group" => \$checkifpeergroup, "peergroup=s" => \$pg, "as=s" => \$as, "neighbor=s" => \$neighbor, @@ -23,23 +24,35 @@ elsif (defined $neighbor && elsif (defined $neighbor && defined $as && defined $checkas) { check_as(-1, $neighbor, $as); } +elsif (defined $pg && + defined $checkifpeergroup) { check_if_peer_group($pg); } exit 0; +sub check_if_peer_group { + my $neighbor = shift; + + my $version = is_ip_v4_or_v6($neighbor); + exit 1 if defined $version; + exit 0; +} + + # Make sure the neighbor is a proper IP or name sub check_peer_name() { my $neighbor = shift; $_ = $neighbor; - if ((! isIpAddress("$neighbor")) && (/[\s\W]/g)) { + my $version = is_ip_v4_or_v6($neighbor); + if ((!defined($version)) && (/[\s\W]/g)) { print "malformed neighbor address $neighbor\n"; exit 1; } # Quagga treats the first byte as a potential IPv6 address # so we can't use it as a peer group name. So let's check for it. - if (/^[A-Fa-f]{1,4}$/) { + if ($version == 6 && /^[A-Fa-f]{1,4}$/) { print "malformed neighbor address $neighbor\n"; exit 1; } @@ -55,8 +68,8 @@ sub check_for_peer_groups() { my @peers, @neighbors; # short circuit if the neighbor is an IP rather than name - $node =~ s/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}//; - if ($node eq "") { return; } + my $version = is_ip_v4_or_v6($node); + return if defined $version; # get the list of neighbors and see if they have a peer-group set $config->setLevel("protocols bgp $as neighbor"); @@ -91,8 +104,8 @@ sub check_as() { my $pgtest = $neighbor; # if this is peer-group then short circuit this - $pgtest =~ s/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}//; - if ($pgtest ne "") { return; } + my $version = is_ip_v4_or_v6($node); + return if ! defined $version; $config->setLevel("protocols bgp $as neighbor $neighbor"); $remoteas = $config->returnValue("remote-as"); diff --git a/templates/protocols/bgp/node.tag/ipv6/aggregate-address/node.def b/templates/protocols/bgp/node.tag/ipv6/aggregate-address/node.def new file mode 100644 index 00000000..cb260727 --- /dev/null +++ b/templates/protocols/bgp/node.tag/ipv6/aggregate-address/node.def @@ -0,0 +1,23 @@ +tag: +type: ipv6net +help: Set a BGP IPv6 aggregate network +comp_help: + <h:h:h:h:h:h:h:h/x> IPv6 aggregate network + +syntax:expression: exec "${vyatta_sbindir}/check_prefix_boundary $VAR(@)" + +delete: touch /tmp/`echo $VAR(@) | sed 's!/!!'`.$PPID + +end: vyatta-vtysh -n -c "configure terminal" \ + -c "router bgp $VAR(../../@)" \ + -c "no ipv6 bgp aggregate-address $VAR(@)"; + if [ -f "/tmp/`echo $VAR(@) | sed 's!/!!'`.$PPID" ]; then + rm -rf /tmp/`echo $VAR(@) | sed 's!/!!'`.$PPID; + else + if [ -n "$VAR(./summary-only)" ]; then + cond="$cond summary-only"; + fi; + vyatta-vtysh -c "configure terminal" \ + -c "router bgp $VAR(../../@)" \ + -c "ipv6 bgp aggregate-address $VAR(@) $cond"; + fi; diff --git a/templates/protocols/bgp/node.tag/ipv6/aggregate-address/node.tag/summary-only/node.def b/templates/protocols/bgp/node.tag/ipv6/aggregate-address/node.tag/summary-only/node.def new file mode 100644 index 00000000..7aaf0620 --- /dev/null +++ b/templates/protocols/bgp/node.tag/ipv6/aggregate-address/node.tag/summary-only/node.def @@ -0,0 +1 @@ +help: Set to announce the aggregate summary network only diff --git a/templates/protocols/bgp/node.tag/ipv6/network/node.def b/templates/protocols/bgp/node.tag/ipv6/network/node.def new file mode 100644 index 00000000..cfe2d8a7 --- /dev/null +++ b/templates/protocols/bgp/node.tag/ipv6/network/node.def @@ -0,0 +1,15 @@ +multi: +type: ipv6net +help: Set a BGP IPv6 network +comp_help: + <h:h:h:h:h:h:h:h/x> IPv6 network + +syntax:expression: exec "${vyatta_sbindir}/check_prefix_boundary $VAR(@)" + +create: vyatta-vtysh -c "configure terminal" \ + -c "router bgp $VAR(../../@)" \ + -c "ipv6 bgp network $VAR(@)"; + +delete: vyatta-vtysh -c "configure terminal" \ + -c "router bgp $VAR(../../@)" \ + -c "no ipv6 bgp network $VAR(@)"; diff --git a/templates/protocols/bgp/node.tag/ipv6/node.def b/templates/protocols/bgp/node.tag/ipv6/node.def new file mode 100644 index 00000000..1a8f732e --- /dev/null +++ b/templates/protocols/bgp/node.tag/ipv6/node.def @@ -0,0 +1 @@ +help: Set a BGP IPv6 settings diff --git a/templates/protocols/bgp/node.tag/neighbor/node.def b/templates/protocols/bgp/node.tag/neighbor/node.def index 4e2e2793..2699782b 100644 --- a/templates/protocols/bgp/node.tag/neighbor/node.def +++ b/templates/protocols/bgp/node.tag/neighbor/node.def @@ -1,10 +1,22 @@ tag: type: txt help: Set a BGP neighbor -comp_help: \1 <x.x.x.x>\tBGP neighbor IP address -syntax:expression: exec "/opt/vyatta/sbin/vyatta-bgp.pl --check-peer-name $VAR(@)" -update: if [ -n "`echo $VAR(@) | sed 's/[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}.[0-9]\{1,3\}//'`" ]; then - vyatta-vtysh -c "configure terminal" -c "router bgp $VAR(../@)" -c "neighbor $VAR(@) peer-group" ; - fi ; -delete: /opt/vyatta/sbin/vyatta-bgp.pl --check-peer-groups --peergroup $VAR(@) --as $VAR(../@); - vyatta-vtysh -c "configure terminal" -c "router bgp $VAR(../@)" -c "no neighbor $VAR(@)" +comp_help: + <x.x.x.x> BGP neighbor IP address + <h:h:h:h:h:h:h:h> BGP neighbor IPv6 address + +syntax:expression: exec "/opt/vyatta/sbin/vyatta-bgp.pl \ + --check-peer-name $VAR(@)" + +update: if /opt/vyatta/sbin/vyatta-bgp.pl --check-if-peer-group \ + --peergroup $VAR(@); then + vyatta-vtysh -c "configure terminal" \ + -c "router bgp $VAR(../@)" \ + -c "neighbor $VAR(@) peer-group"; + fi; + +delete: /opt/vyatta/sbin/vyatta-bgp.pl --check-peer-groups \ + --peergroup $VAR(@) --as $VAR(../@); + vyatta-vtysh -c "configure terminal" \ + -c "router bgp $VAR(../@)" \ + -c "no neighbor $VAR(@)" diff --git a/templates/protocols/bgp/node.tag/neighbor/node.tag/remote-as/node.def b/templates/protocols/bgp/node.tag/neighbor/node.tag/remote-as/node.def index 10b33281..0381d22b 100644 --- a/templates/protocols/bgp/node.tag/neighbor/node.tag/remote-as/node.def +++ b/templates/protocols/bgp/node.tag/neighbor/node.tag/remote-as/node.def @@ -1,10 +1,33 @@ type: u32 +priority: 1 help: Set neighbor BGP AS number -comp_help: \1 <1-4294967294>\tAS number -syntax:expression: $VAR(@) >= 1 && $VAR(@) <= 4294967294; "remote-as must be between 1 and 4294967294" -update: vyatta-vtysh -c "configure terminal" -c "router bgp $VAR(../../@)" \ - -c "neighbor $VAR(../@) remote-as $VAR(@)" -# commented out because deleting anything after remote-as will cause a failure in Quagga -# this is a temporary fix until node ordering is enabled -#delete: vyatta-vtysh -c "configure terminal" -c "router bgp $VAR(../../@)" \ -# -c "no neighbor $VAR(../@) remote-as $VAR(@)" +comp_help: + <1-4294967294> AS number + +syntax:expression: $VAR(@) >= 1 && $VAR(@) <= 4294967294; \ + "remote-as must be between 1 and 4294967294" + +update: vyatta-vtysh -c "configure terminal" \ + -c "router bgp $VAR(../../@)" \ + -c "neighbor $VAR(../@) remote-as $VAR(@)"; + if /opt/vyatta/sbin/vyatta-validate-type.pl -q ipv6 $VAR(../@) + then + vyatta-vtysh -c "configure terminal" \ + -c "router bgp $VAR(../../@)" \ + -c "no neighbor $VAR(../@) activate" \ + -c "address-family ipv6" \ + -c "neighbor $VAR(../@) activate"; + fi + +#remote-as needs to be set 1st & deleted last - comment out for now +#delete: vyatta-vtysh -c "configure terminal" \ +# -c "router bgp $VAR(../../@)" \ +# -c "no neighbor $VAR(../@) remote-as $VAR(@)"; +delete: if /opt/vyatta/sbin/vyatta-validate-type.pl -q ipv6 $VAR(../@) + then + vyatta-vtysh -c "configure terminal" \ + -c "router bgp $VAR(../../@)" \ + -c "neighbor $VAR(../@) activate" \ + -c "address-family ipv6" \ + -c "no neighbor $VAR(../@) activate"; + fi diff --git a/templates/protocols/bgp/node.tag/network/node.def b/templates/protocols/bgp/node.tag/network/node.def index fe253baa..e263d4e3 100644 --- a/templates/protocols/bgp/node.tag/network/node.def +++ b/templates/protocols/bgp/node.tag/network/node.def @@ -2,27 +2,27 @@ tag: type: ipv4net help: Set a BGP network comp_help: \1 <x.x.x.x/x>\tnetwork + syntax:expression: exec "${vyatta_sbindir}/check_prefix_boundary $VAR(@)" + commit:expression: !($VAR(./backdoor/) != "" && $VAR(./route-map/) != ""); "protocols bgp $VAR(../@) network $VAR(@): May specify route-map or backdoor but not both" + delete: touch /tmp/`echo $VAR(@) | sed 's!/!!'`.$PPID -end: vyatta-vtysh --noerror -c "configure terminal" -c "router bgp $VAR(../@)" -c "no network $VAR(@)"; - if [ -f "/tmp/`echo $VAR(@) | sed 's!/!!'`.$PPID" ]; then +end: vyatta-vtysh -n -c "configure terminal" \ + -c "router bgp $VAR(../@)" \ + -c "no network $VAR(@)"; + if [ -f "/tmp/`echo $VAR(@) | sed 's!/!!'`.$PPID" ]; then rm -rf /tmp/`echo $VAR(@) | sed 's!/!!'`.$PPID; - else - # uncomment and replace the call to vyatta-check-typeless-node.pl pending bug 2525 - #if [ -n \"$VAR(./backdoor/)\" ]; then - # COND=\"backdoor\"; - #fi; - ${vyatta_sbindir}/vyatta-check-typeless-node.pl "protocols bgp $VAR(../@) network $VAR(@) backdoor"; - if [ $? -eq 0 ]; then - cond="backdoor "; - fi ; - + else + if [ -n "$VAR(./backdoor/)" ]; then + cond="backdoor"; + fi; if [ -n "$VAR(./route-map/@)" ]; then cond="route-map $VAR(./route-map/@)"; fi; - - vyatta-vtysh -c "configure terminal" -c "router bgp $VAR(../@)" -c "network $VAR(@) $cond"; - fi; + vyatta-vtysh -c "configure terminal" \ + -c "router bgp $VAR(../@)" \ + -c "network $VAR(@) $cond"; + fi; |