diff options
| author | Christian Breunig <christian@breunig.cc> | 2026-06-26 20:16:50 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-06-26 20:16:50 +0200 |
| commit | fe27e9cedb1bc7a91095a19d1867cfda428e12fe (patch) | |
| tree | 627d07302494801dfb7b6c440e877d55b163d217 /src | |
| parent | 29d887a9cb2e32db7406442251437ce7f5794803 (diff) | |
| parent | 4e11adfb927c22e2f977c897d56a4d243860e877 (diff) | |
| download | vyos-1x-fe27e9cedb1bc7a91095a19d1867cfda428e12fe.tar.gz vyos-1x-fe27e9cedb1bc7a91095a19d1867cfda428e12fe.zip | |
Merge pull request #5297 from alexandr-san4ez/T8865-rolling
bgp: T8865: Reject `vni` sub-block in VRF l2vpn-evpn when `advertise-all-vni` is globally active
Diffstat (limited to 'src')
| -rwxr-xr-x | src/conf_mode/protocols_bgp.py | 23 | ||||
| -rw-r--r-- | src/migration-scripts/bgp/7-to-8 | 45 |
2 files changed, 68 insertions, 0 deletions
diff --git a/src/conf_mode/protocols_bgp.py b/src/conf_mode/protocols_bgp.py index 2ec631f4c..bde6fcdd0 100755 --- a/src/conf_mode/protocols_bgp.py +++ b/src/conf_mode/protocols_bgp.py @@ -647,6 +647,29 @@ def verify(config_dict): if 'route_target' in vni_config and 'advertise_all_vni' not in afi_config: raise ConfigError('BGP EVPN "route-target" requires "advertise-all-vni" to be set!') + # T8865: Detect conflict between VRF-level "vni" sub-block and global + # "advertise-all-vni". When advertise-all-vni is active in the default + # BGP instance, FRR already owns all VNIs discovered from the kernel. + # Attempting to create the same VNI again via a VRF BGP "vni" sub-block + # causes FRR to return "% Failed to create VNI" and perform an early exit + # from config processing. + if vrf and 'vni' in afi_config: + default_bgp_evpn = dict_search( + 'dependent_vrfs.default.protocols.bgp.address_family.l2vpn_evpn', + bgp, + ) + if ( + default_bgp_evpn is not None + and 'deleted' not in default_bgp_evpn + ): + if 'advertise_all_vni' in default_bgp_evpn: + raise ConfigError( + 'BGP EVPN "vni" sub-configuration conflicts with ' + '"advertise-all-vni" in the default BGP instance. ' + 'Remove "vni" from the VRF l2vpn-evpn configuration ' + 'or disable "advertise-all-vni" for the default BGP.' + ) + return None def generate(config_dict): diff --git a/src/migration-scripts/bgp/7-to-8 b/src/migration-scripts/bgp/7-to-8 new file mode 100644 index 000000000..4db4b3211 --- /dev/null +++ b/src/migration-scripts/bgp/7-to-8 @@ -0,0 +1,45 @@ +# Copyright (C) VyOS Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this library. If not, see <http://www.gnu.org/licenses/>. + +# T8865: When "address-family l2vpn-evpn advertise-all-vni" is +# configured remove the conflicting "vni" sub-node from each affected VRF +# because FRR returns "Failed to create VNI". + +from vyos.configtree import ConfigTree + +vrf_base = ['vrf', 'name'] +bgp_base = ['protocols', 'bgp'] +bgp_l2vpn_evpn = bgp_base + ['address-family', 'l2vpn-evpn'] + + +def migrate(config: ConfigTree) -> None: + if not config.exists(vrf_base): + return # Nothing to do + + # Only act when advertise-all-vni is set in the default BGP instance + if not config.exists(bgp_l2vpn_evpn + ['advertise-all-vni']): + return + + for vrf in config.list_nodes(vrf_base): + vni_path = vrf_base + [ + vrf, + 'protocols', + 'bgp', + 'address-family', + 'l2vpn-evpn', + 'vni', + ] + if config.exists(vni_path): + config.delete(vni_path) |
