diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-01-21 18:09:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-21 18:09:32 +0100 |
commit | a80cd3058cb8d9a9152c8c205d41175056c6fa52 (patch) | |
tree | 9f8b144dabf9bfcefaed16ee73627acbafb620f9 | |
parent | 0a6ca540da53d07e19e1186404d706757b2e5942 (diff) | |
parent | a0a88d2dea9710efd80b27b24b4f40b13c613768 (diff) | |
download | vyos-1x-a80cd3058cb8d9a9152c8c205d41175056c6fa52.tar.gz vyos-1x-a80cd3058cb8d9a9152c8c205d41175056c6fa52.zip |
Merge pull request #690 from Cheeze-It/current
bgp: T1875: Adding BGP listen range FRR feature
-rw-r--r-- | data/templates/frr/bgp.frr.tmpl | 10 | ||||
-rw-r--r-- | interface-definitions/protocols-bgp.xml.in | 34 | ||||
-rwxr-xr-x | src/conf_mode/protocols_bgp.py | 10 |
3 files changed, 52 insertions, 2 deletions
diff --git a/data/templates/frr/bgp.frr.tmpl b/data/templates/frr/bgp.frr.tmpl index db0de45da..68731abab 100644 --- a/data/templates/frr/bgp.frr.tmpl +++ b/data/templates/frr/bgp.frr.tmpl @@ -203,6 +203,16 @@ router bgp {{ asn }} {% endfor %} {% endif %} ! +{% if listen is defined %} +{% if listen.limit is defined and listen.limit is not none %} + bgp listen limit {{ listen.limit }} +{% endif %} +{% for prefix, options in listen.range.items() %} +{% if options.peer_group is defined and options.peer_group is not none %} + bgp listen range {{ prefix }} peer-group {{ options.peer_group }} +{% endif %} +{% endfor %} +{% endif %} {% if parameters is defined %} {% if parameters.always_compare_med is defined %} bgp always-compare-med diff --git a/interface-definitions/protocols-bgp.xml.in b/interface-definitions/protocols-bgp.xml.in index cec73a15b..12437128c 100644 --- a/interface-definitions/protocols-bgp.xml.in +++ b/interface-definitions/protocols-bgp.xml.in @@ -250,6 +250,40 @@ </leafNode> </children> </node> + <node name="listen"> + <properties> + <help>Listen for and accept BGP dynamic neighbors from range</help> + </properties> + <children> + <leafNode name="limit"> + <properties> + <help>Maximum number of dynamic neighbors that can be created</help> + <valueHelp> + <format>u32:1-5000</format> + <description>BGP neighbor limit</description> + </valueHelp> + <constraint> + <validator name="numeric" argument="--range 1-5000"/> + </constraint> + </properties> + </leafNode> + <tagNode name="range"> + <properties> + <help>IPv4/IPv6 prefix range</help> + <completionHelp> + <list><x.x.x.x/x> <h:h:h:h:h:h:h:h/h></list> + </completionHelp> + <constraint> + <validator name="ipv4-prefix"/> + <validator name="ipv6-prefix"/> + </constraint> + </properties> + <children> + #include <include/bgp-peer-group.xml.i> + </children> + </tagNode> + </children> + </node> <tagNode name="neighbor"> <properties> <help>BGP neighbor</help> diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py index cdae23d27..39d367b97 100755 --- a/src/conf_mode/protocols_bgp.py +++ b/src/conf_mode/protocols_bgp.py @@ -109,7 +109,7 @@ def verify(bgp): if tmp not in afi_config['prefix_list']: # bail out early continue - # get_config_dict() mangles all '-' characters to '_' this is legitim, thus all our + # get_config_dict() mangles all '-' characters to '_' this is legitimate, thus all our # compares will run on '_' as also '_' is a valid name for a prefix-list prefix_list = afi_config['prefix_list'][tmp].replace('-', '_') if afi == 'ipv4_unicast': @@ -127,7 +127,13 @@ def verify(bgp): route_map = afi_config['route_map'][tmp].replace('-', '_') if dict_search(f'policy.route_map.{route_map}', asn_config) == None: raise ConfigError(f'route-map "{route_map}" used for "{tmp}" does not exist!') - + + # Throw an error if a peer group is not configured for allow range + if 'listen' in asn_config: + if 'range' in asn_config['listen']: + for prefix in asn_config['listen']['range']: + if not 'peer_group' in asn_config['listen']['range'].get(prefix): + raise ConfigError(f'Listen range for prefix "{prefix}" has no peer group configured.') return None |