diff options
| author | Daniil Baturin <daniil@vyos.io> | 2025-09-23 16:01:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-23 16:01:35 +0100 |
| commit | bf1c29aa71980158a4e820d69351660e863cf219 (patch) | |
| tree | faec0ae12b342add260633086e6b3c51262a9504 /src/conf_mode | |
| parent | 9952d21aa35fd40fe583de1ac20287a6784e8052 (diff) | |
| parent | 85fe32f0e1a91a47fe4a6d4a5cdd6ac516dcc3b9 (diff) | |
| download | vyos-1x-bf1c29aa71980158a4e820d69351660e863cf219.tar.gz vyos-1x-bf1c29aa71980158a4e820d69351660e863cf219.zip | |
Merge pull request #4684 from c-po/bgp-vrf-system-as
bgp: T7760: remove per vrf instance system-as node
Diffstat (limited to 'src/conf_mode')
| -rwxr-xr-x | src/conf_mode/protocols_bgp.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py index fe5740a18..4e7f09d0e 100755 --- a/src/conf_mode/protocols_bgp.py +++ b/src/conf_mode/protocols_bgp.py @@ -210,8 +210,20 @@ def verify(config_dict): return None - if 'system_as' not in bgp: - raise ConfigError('BGP system-as number must be defined!') + 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'] # Verify BMP if 'bmp' in bgp: @@ -257,7 +269,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'] != bgp['system_as']: + peer_config['remote_as'] != system_as: is_ibgp = False if peer_group not in peer_groups_context: @@ -278,7 +290,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 == bgp['system_as']: + if asn == 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 @@ -369,12 +381,6 @@ 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']: |
