summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2025-10-06 20:54:32 +0200
committerGitHub <noreply@github.com>2025-10-06 20:54:32 +0200
commitd21b01246a6ef01e407f62cb908e625462fbdc40 (patch)
treeb3a1d3e2cf39530af6a9e79149c7ceb75b309b18 /src/conf_mode
parent7bffb45f931f91416000a483c77e6749ced71206 (diff)
parentbc73a4f7452434f25119267129f337640d8a959c (diff)
downloadvyos-1x-d21b01246a6ef01e407f62cb908e625462fbdc40.tar.gz
vyos-1x-d21b01246a6ef01e407f62cb908e625462fbdc40.zip
Merge pull request #4778 from jestabro/revert-bgp-remove-per-vrf-system-as
Revert "bgp: T7760: remove per vrf instance system-as node"
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/protocols_bgp.py30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py
index 696981012..fe5740a18 100755
--- a/src/conf_mode/protocols_bgp.py
+++ b/src/conf_mode/protocols_bgp.py
@@ -200,7 +200,7 @@ def verify(config_dict):
if 'dependent_vrfs' in bgp:
for vrf, vrf_options in bgp['dependent_vrfs'].items():
if vrf != 'default':
- if 'protocols' in vrf_options and 'bgp' in vrf_options['protocols']:
+ if dict_search('protocols.bgp', vrf_options):
dependent_vrfs = ', '.join(bgp['dependent_vrfs'].keys())
raise ConfigError(f'Cannot delete default BGP instance, ' \
f'dependent VRF instance(s): {dependent_vrfs}')
@@ -210,20 +210,8 @@ def verify(config_dict):
return None
- ERR_MSG_GLOBAL_VRF_AS_MISSING = 'BGP "system-as" number must be defined! Use "set protocols ' \
- 'bgp system-as <asn>" to define a global BGP instance AS number.'
- system_as = None
- if vrf:
- system_as = dict_search('dependent_vrfs.default.protocols.bgp.system_as', bgp)
- if not system_as:
- raise ConfigError(ERR_MSG_GLOBAL_VRF_AS_MISSING)
-
- elif 'system_as' not in bgp:
- raise ConfigError(ERR_MSG_GLOBAL_VRF_AS_MISSING)
-
- # Cache global defined system AS number used in further checks
- if not system_as:
- system_as = bgp['system_as']
+ if 'system_as' not in bgp:
+ raise ConfigError('BGP system-as number must be defined!')
# Verify BMP
if 'bmp' in bgp:
@@ -269,7 +257,7 @@ def verify(config_dict):
if 'remote_as' in peer_config:
is_ibgp = True
if peer_config['remote_as'] != 'internal' and \
- peer_config['remote_as'] != system_as:
+ peer_config['remote_as'] != bgp['system_as']:
is_ibgp = False
if peer_group not in peer_groups_context:
@@ -290,7 +278,7 @@ def verify(config_dict):
# Neighbor local-as override can not be the same as the local-as
# we use for this BGP instane!
asn = list(peer_config['local_as'].keys())[0]
- if asn == system_as:
+ if asn == bgp['system_as']:
raise ConfigError('Cannot have local-as same as system-as number')
# Neighbor AS specified for local-as and remote-as can not be the same
@@ -343,7 +331,7 @@ 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']:
@@ -381,6 +369,12 @@ def verify(config_dict):
if 'source_interface' in peer_config['interface']:
raise ConfigError(f'"source-interface" option not allowed for neighbor "{peer}"')
+ # Local-AS allowed only for EBGP peers
+ if 'local_as' in peer_config:
+ remote_as = verify_remote_as(peer_config, bgp)
+ if remote_as == bgp['system_as']:
+ raise ConfigError(f'local-as configured for "{peer}", allowed only for eBGP peers!')
+
for afi in ['ipv4_unicast', 'ipv4_multicast', 'ipv4_labeled_unicast', 'ipv4_flowspec',
'ipv6_unicast', 'ipv6_multicast', 'ipv6_labeled_unicast', 'ipv6_flowspec',
'l2vpn_evpn']: