summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2025-08-28 14:46:48 +0200
committerChristian Breunig <christian@breunig.cc>2025-09-09 17:58:26 +0200
commitd871fe9c4c65de87232802ed54b263c9b2824391 (patch)
tree85d9e15d9fad7ddba7bde3eae357a7a051fa3ca2 /src/conf_mode
parenta4b72d3839f2ee05456b0677a8f2cc27c04a9423 (diff)
downloadvyos-1x-d871fe9c4c65de87232802ed54b263c9b2824391.tar.gz
vyos-1x-d871fe9c4c65de87232802ed54b263c9b2824391.zip
bgp: T7760: deprecate per bgp vrf instance system-as node
Originating from the bug in T7665. To avoid potential issues down the line - and given that there's no compelling technical reason to retain the system-as CLI node under per-VRF BGP configuration, which cannot be achieved through alternative means - the maintainers have collectively decided to deprecate the following command: set vrf name <name> protocols bgp system-as <asn> Starting with VyOS 1.4.4, this CLI command will be considered deprecated. While it will still be accepted, it will no longer have any operational effect. A deprecation warning will be displayed at commit time, indicating that the BGP ASN from the global BGP configuration is now used instead. A migration script will handle the transition and perform the following actions: * Ensure a global BGP configuration exists; if not, initialize one. * Iterate over all configured VRFs to determine whether a BGP instance exists * For any insance, update the configuration to use the global system-as and apply the local-as ASN no-prepend replace-as option on all affected neighbors to preserve existing behavior. * If a neighbor is already configured with a local-as directive, that neighbor will be excluded from the migration process, as it already follows a custom configuration. * Add allowas-in per neighbor option. Required to not deny prefix received updates due to as-path contains our own global ASN.
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/protocols_bgp.py34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py
index fe5740a18..ab0e7e44a 100755
--- a/src/conf_mode/protocols_bgp.py
+++ b/src/conf_mode/protocols_bgp.py
@@ -18,6 +18,7 @@ from sys import exit
from sys import argv
from vyos.base import Warning
+from vyos.base import DeprecationWarning
from vyos.config import Config
from vyos.configverify import has_frr_protocol_in_dict
from vyos.configverify import verify_prefix_list
@@ -210,8 +211,27 @@ 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)
+
+ if 'system_as' in bgp:
+ tmp_as = bgp['system_as']
+ DeprecationWarning(f'CLI command "vrf name {vrf} protocols bgp system-as ' \
+ f'{tmp_as}" is ignored and will be removed in VyOS 1.5! ' \
+ f'\n\nGlobal "protocols bgp system-as {system_as}" option ' \
+ 'applies, use per neighbor "local-as" option to override.')
+
+ 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 +277,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 +298,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 +389,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']: