diff options
-rw-r--r-- | data/templates/frr/bgp.frr.tmpl | 27 | ||||
-rw-r--r-- | interface-definitions/include/bgp-afi-maximum-paths.xml.i | 51 | ||||
-rw-r--r-- | interface-definitions/protocols-bgp.xml.in | 31 | ||||
-rw-r--r-- | smoketest/configs/bgp-big-as-cloud | 4 | ||||
-rwxr-xr-x | smoketest/scripts/cli/test_protocols_bgp.py | 8 | ||||
-rwxr-xr-x | src/migration-scripts/quagga/8-to-9 | 61 |
6 files changed, 102 insertions, 80 deletions
diff --git a/data/templates/frr/bgp.frr.tmpl b/data/templates/frr/bgp.frr.tmpl index b7abbff5c..3101de7ea 100644 --- a/data/templates/frr/bgp.frr.tmpl +++ b/data/templates/frr/bgp.frr.tmpl @@ -208,11 +208,11 @@ router bgp {{ asn }} aggregate-address {{ ip }}{{ ' as-set' if afi_config.aggregate_address[ip].as_set is defined }}{{ ' summary-only' if afi_config.aggregate_address[ip].summary_only is defined }} {% endfor %} {% endif %} -{% if afi_config.maximum_paths is defined and afi_config.maximum_paths is not none %} - maximum-paths {{ afi_config.maximum_paths }} +{% if afi_config.maximum_paths is defined and afi_config.maximum_paths.ebgp is defined and afi_config.maximum_paths.ebgp is not none %} + maximum-paths {{ afi_config.maximum_paths.ebgp }} {% endif %} -{% if afi_config.maximum_paths_ibgp is defined and afi_config.maximum_paths_ibgp is not none %} - maximum-paths ibgp {{ afi_config.maximum_paths_ibgp }} +{% if afi_config.maximum_paths is defined and afi_config.maximum_paths.ibgp is defined and afi_config.maximum_paths.ibgp is not none %} + maximum-paths ibgp {{ afi_config.maximum_paths.ibgp }} {% endif %} {% if afi_config.redistribute is defined and afi_config.redistribute is not none %} {% for protocol in afi_config.redistribute %} @@ -287,25 +287,6 @@ router bgp {{ asn }} {% endfor %} {% endif %} ! -{# set protocols bgp xxxx maximum-paths ibgp x, Generated by default for afi_4 #} -{# We don't have this parameter in afi_6. But this is supported in FRR #} -{% if maximum_paths is defined and maximum_paths is not none %} -{% if maximum_paths.ebgp is defined and maximum_paths.ebgp is not none %} - ! - address-family ipv4 unicast - maximum-paths {{ maximum_paths.ebgp }} - exit-address-family - ! -{% endif %} -{% if maximum_paths.ibgp is defined and maximum_paths.ibgp is not none %} - ! - address-family ipv4 unicast - maximum-paths ibgp {{ maximum_paths.ibgp }} - exit-address-family - ! -{% endif %} -{% endif %} - ! {% if peer_group is defined and peer_group is not none %} {% for peer, config in peer_group.items() %} {{ bgp_neighbor(peer, config, true) }} diff --git a/interface-definitions/include/bgp-afi-maximum-paths.xml.i b/interface-definitions/include/bgp-afi-maximum-paths.xml.i index 5ee0d13a3..62133c375 100644 --- a/interface-definitions/include/bgp-afi-maximum-paths.xml.i +++ b/interface-definitions/include/bgp-afi-maximum-paths.xml.i @@ -1,26 +1,33 @@ <!-- included start from bgp-afi-maximum-paths.xml.i --> -<leafNode name="maximum-paths"> +<node name="maximum-paths"> <properties> - <help>Forward packets over multiple paths (eBGP)</help> - <valueHelp> - <format>u32:1-256</format> - <description>Number of paths to consider</description> - </valueHelp> - <constraint> - <validator name="numeric" argument="--range 1-256"/> - </constraint> + <help>Forward packets over multiple paths</help> </properties> -</leafNode> -<leafNode name="maximum-paths-ibgp"> - <properties> - <help>Forward packets over multiple paths (iBGP)</help> - <valueHelp> - <format>u32:1-256</format> - <description>Number of paths to consider</description> - </valueHelp> - <constraint> - <validator name="numeric" argument="--range 1-256"/> - </constraint> - </properties> -</leafNode> + <children> + <leafNode name="ebgp"> + <properties> + <help>eBGP maximum paths</help> + <valueHelp> + <format>u32:1-256</format> + <description>Number of paths to consider</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--range 1-256"/> + </constraint> + </properties> + </leafNode> + <leafNode name="ibgp"> + <properties> + <help>iBGP maximum paths</help> + <valueHelp> + <format>u32:1-256</format> + <description>Number of paths to consider</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--range 1-256"/> + </constraint> + </properties> + </leafNode> + </children> +</node> <!-- included end --> diff --git a/interface-definitions/protocols-bgp.xml.in b/interface-definitions/protocols-bgp.xml.in index c2a123313..96a0b1315 100644 --- a/interface-definitions/protocols-bgp.xml.in +++ b/interface-definitions/protocols-bgp.xml.in @@ -350,37 +350,6 @@ </node> </children> </node> - <node name="maximum-paths"> - <properties> - <help>BGP multipaths</help> - </properties> - <children> - <leafNode name="ebgp"> - <properties> - <help>Maximum ebgp multipaths</help> - <valueHelp> - <format>u32:1-255</format> - <description>EBGP multipaths</description> - </valueHelp> - <constraint> - <validator name="numeric" argument="--range 1-255"/> - </constraint> - </properties> - </leafNode> - <leafNode name="ibgp"> - <properties> - <help>Maximum ibgp multipaths</help> - <valueHelp> - <format>u32:1-255</format> - <description>EBGP multipaths</description> - </valueHelp> - <constraint> - <validator name="numeric" argument="--range 1-255"/> - </constraint> - </properties> - </leafNode> - </children> - </node> <node name="listen"> <properties> <help>Listen for and accept BGP dynamic neighbors from range</help> diff --git a/smoketest/configs/bgp-big-as-cloud b/smoketest/configs/bgp-big-as-cloud index df3ae015c..694243d1e 100644 --- a/smoketest/configs/bgp-big-as-cloud +++ b/smoketest/configs/bgp-big-as-cloud @@ -1186,6 +1186,10 @@ protocols { } } } + maximum-paths { + ebgp 8 + ibgp 16 + } neighbor 192.0.16.209 { address-family { ipv4-unicast { diff --git a/smoketest/scripts/cli/test_protocols_bgp.py b/smoketest/scripts/cli/test_protocols_bgp.py index f22b47551..9aa1541cf 100755 --- a/smoketest/scripts/cli/test_protocols_bgp.py +++ b/smoketest/scripts/cli/test_protocols_bgp.py @@ -237,10 +237,10 @@ class TestProtocolsBGP(unittest.TestCase): self.session.set(base_path + ['parameters', 'ebgp-requires-policy']) # AFI maximum path support - self.session.set(base_path + ['address-family', 'ipv4-unicast', 'maximum-paths', max_path_v4]) - self.session.set(base_path + ['address-family', 'ipv4-unicast', 'maximum-paths-ibgp', max_path_v4ibgp]) - self.session.set(base_path + ['address-family', 'ipv6-unicast', 'maximum-paths', max_path_v6]) - self.session.set(base_path + ['address-family', 'ipv6-unicast', 'maximum-paths-ibgp', max_path_v6ibgp]) + self.session.set(base_path + ['address-family', 'ipv4-unicast', 'maximum-paths', 'ebgp', max_path_v4]) + self.session.set(base_path + ['address-family', 'ipv4-unicast', 'maximum-paths', 'ibgp', max_path_v4ibgp]) + self.session.set(base_path + ['address-family', 'ipv6-unicast', 'maximum-paths', 'ebgp', max_path_v6]) + self.session.set(base_path + ['address-family', 'ipv6-unicast', 'maximum-paths', 'ibgp', max_path_v6ibgp]) # commit changes self.session.commit() diff --git a/src/migration-scripts/quagga/8-to-9 b/src/migration-scripts/quagga/8-to-9 new file mode 100755 index 000000000..15c44924f --- /dev/null +++ b/src/migration-scripts/quagga/8-to-9 @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2021 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# - T3391: Migrate "maximum-paths" setting from "protocols bgp asn maximum-paths" +# under the IPv4 address-family tree. Reason is we currently have no way in +# configuring this for IPv6 address-family. This mimics the FRR configuration. + +from sys import argv +from sys import exit +from vyos.configtree import ConfigTree + +if (len(argv) < 2): + print("Must specify file name!") + exit(1) + +file_name = argv[1] + +with open(file_name, 'r') as f: + config_file = f.read() + +base = ['protocols', 'bgp'] +config = ConfigTree(config_file) + +if not config.exists(base): + # Nothing to do + exit(0) + +# Check if BGP is actually configured and obtain the ASN +asn_list = config.list_nodes(base) +if asn_list: + # There's always just one BGP node, if any + bgp_base = base + [asn_list[0]] + + maximum_paths = bgp_base + ['maximum-paths'] + if config.exists(maximum_paths): + for bgp_type in ['ebgp', 'ibgp']: + if config.exists(maximum_paths + [bgp_type]): + new_base = bgp_base + ['address-family', 'ipv4-unicast', 'maximum-paths'] + config.set(new_base) + config.copy(maximum_paths + [bgp_type], new_base + [bgp_type]) + config.delete(maximum_paths) + +try: + with open(file_name, 'w') as f: + f.write(config.to_string()) +except OSError as e: + print("Failed to save the modified config: {}".format(e)) + exit(1) |