summaryrefslogtreecommitdiff
path: root/src/conf_mode/protocols_bgp.py
diff options
context:
space:
mode:
authorNicolas Vandamme <n.vandamme@firis-system.lu>2025-09-01 17:24:26 +0200
committerGitHub <noreply@github.com>2025-09-01 17:24:26 +0200
commita791cc3b7bb28081a6e79a988964f1fc51a47dae (patch)
treeef5e734bf580f1abfd7d3d4ea30240d8d9fb1278 /src/conf_mode/protocols_bgp.py
parentb9f60711392463af1892a30472fba6622a73390a (diff)
parentb1b4545cb7984cd3cdf42554ab2b28acd1ecb6cb (diff)
downloadvyos-1x-a791cc3b7bb28081a6e79a988964f1fc51a47dae.tar.gz
vyos-1x-a791cc3b7bb28081a6e79a988964f1fc51a47dae.zip
Merge branch 'vyos:current' into current
Diffstat (limited to 'src/conf_mode/protocols_bgp.py')
-rwxr-xr-xsrc/conf_mode/protocols_bgp.py49
1 files changed, 37 insertions, 12 deletions
diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py
index c4af717af..fe5740a18 100755
--- a/src/conf_mode/protocols_bgp.py
+++ b/src/conf_mode/protocols_bgp.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2020-2024 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# 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
@@ -316,6 +316,7 @@ def verify(config_dict):
Warning(f'BGP neighbor "{peer}" requires address-family!')
# Peer-group member cannot override remote-as of peer-group
+ peer_group = None
if 'peer_group' in peer_config:
peer_group = peer_config['peer_group']
if 'remote_as' in peer_config and 'remote_as' in bgp['peer_group'][peer_group]:
@@ -330,6 +331,27 @@ def verify(config_dict):
peer_group = peer_config['interface']['v6only']['peer_group']
if 'remote_as' in peer_config['interface']['v6only'] and 'remote_as' in bgp['peer_group'][peer_group]:
raise ConfigError(f'Peer-group member "{peer}" cannot override remote-as of peer-group "{peer_group}"!')
+
+ for afi in ['ipv4_unicast', 'ipv4_multicast', 'ipv4_labeled_unicast', 'ipv4_flowspec',
+ 'ipv6_unicast', 'ipv6_multicast', 'ipv6_labeled_unicast', 'ipv6_flowspec',
+ 'l2vpn_evpn']:
+ if dict_search(
+ f'address_family.{afi}.route_reflector_client',
+ peer_config,
+ ) == {} or (
+ peer_group
+ and dict_search(
+ f'peer_group.{peer_group}.address_family.{afi}.route_reflector_client',
+ bgp,
+ )
+ == {}
+ ):
+ peer_as = verify_remote_as(peer_config, bgp)
+ if peer_as != 'internal' and peer_as != bgp['system_as']:
+ raise ConfigError('route-reflector-client only supported for iBGP peers')
+ else:
+ # It doesn’t make sense to check the remote-as of a peer group.
+ pass
# Only checks for ipv4 and ipv6 neighbors
# Check if neighbor address is assigned as system interface address
@@ -412,16 +434,7 @@ def verify(config_dict):
if tmp in afi_config['route_map']:
verify_route_map(afi_config['route_map'][tmp], bgp)
- if 'route_reflector_client' in afi_config:
- peer_group_as = peer_config.get('remote_as')
-
- if peer_group_as is None or (peer_group_as != 'internal' and peer_group_as != bgp['system_as']):
- raise ConfigError('route-reflector-client only supported for iBGP peers')
- else:
- if 'peer_group' in peer_config:
- peer_group_as = dict_search(f'peer_group.{peer_group}.remote_as', bgp)
- if peer_group_as is None or (peer_group_as != 'internal' and peer_group_as != bgp['system_as']):
- raise ConfigError('route-reflector-client only supported for iBGP peers')
+ # route-reflector-client verification has been moved to neighbor-only part
# T5833 not all AFIs are supported for VRF
if 'vrf' in bgp and 'address_family' in peer_config:
@@ -523,12 +536,24 @@ def verify(config_dict):
raise ConfigError(
'Please unconfigure import vrf commands before using vpn commands in dependent VRFs!')
+ # Verify if the route-map exists
+ if dict_search('route_map.vrf.import', afi_config) is not None:
+ verify_route_map(afi_config['route_map']['vrf']['import'], bgp)
+
+ if (dict_search('route_map.vrf.import', afi_config) is not None
+ or dict_search('import.vrf', afi_config) is not None):
# FRR error: please unconfigure vpn to vrf commands before
# using import vrf commands
- if 'vpn' in afi_config['import'] or dict_search('export.vpn', afi_config) != None:
+ if (dict_search('import.vpn', afi_config) is not None
+ or dict_search('export.vpn', afi_config) is not None):
raise ConfigError('Please unconfigure VPN to VRF commands before '\
'using "import vrf" commands!')
+ if (dict_search('route_map.vpn.import', afi_config) is not None
+ or dict_search('route_map.vpn.export', afi_config) is not None) :
+ raise ConfigError('Please unconfigure route-map VPN to VRF commands before '\
+ 'using "import vrf" commands!')
+
# Verify that the export/import route-maps do exist
for export_import in ['export', 'import']:
tmp = dict_search(f'route_map.vpn.{export_import}', afi_config)