summaryrefslogtreecommitdiff
path: root/src/migration-scripts
diff options
context:
space:
mode:
authorNataliia Solomko <natalirs1985@gmail.com>2026-05-26 18:27:56 +0300
committerNataliia Solomko <natalirs1985@gmail.com>2026-06-09 18:41:56 +0300
commitb49e8f00560bdbd69f85539396afb6391b281519 (patch)
tree57990da78f634de549947fd28f408a137061aaa7 /src/migration-scripts
parent6a5f1961cde6116457cb9e6b958bee7b66603c3b (diff)
downloadvyos-1x-b49e8f00560bdbd69f85539396afb6391b281519.tar.gz
vyos-1x-b49e8f00560bdbd69f85539396afb6391b281519.zip
bgp: T8223: Prevent `advertise-all-vni` in multiple BGP VRF instances simultaneously
FRR only allows one BGP instance to hold `advertise-all-vni` at a time (FRR issue #9405). When a default BGP instance is present it is always started before named VRF instances, so if a named VRF holds the flag FRR silently rejects it on every boot (regardless of default EVPN config), causing the running config to diverge from what is stored in VyOS. Enforce the following policy in verify(): - Default BGP instance may always hold `advertise-all-vni`. - A named VRF may hold it only when no default BGP instance exists. - Only one BGP instance (default or named VRF) may hold it at a time. The default BGP verify path additionally scans dependent VRFs so that adding or modifying the default BGP instance while a named VRF already holds the flag is caught even when the VRF node is not part of the current commit.
Diffstat (limited to 'src/migration-scripts')
-rw-r--r--src/migration-scripts/bgp/6-to-758
1 files changed, 58 insertions, 0 deletions
diff --git a/src/migration-scripts/bgp/6-to-7 b/src/migration-scripts/bgp/6-to-7
new file mode 100644
index 000000000..efba9678e
--- /dev/null
+++ b/src/migration-scripts/bgp/6-to-7
@@ -0,0 +1,58 @@
+# 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/>.
+
+# T8223: remove "advertise-all-vni" from named VRFs where it conflicts with
+# a default BGP instance or another named VRF
+
+from vyos.configtree import ConfigTree
+
+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(base):
+ # Nothing to do
+ return
+
+ def _cleanup_address_family(config: ConfigTree, vrf) -> None:
+ """Remove advertise-all-vni from the named VRF and clean up any
+ empty parent nodes left behind."""
+ config.delete(base + [vrf] + bgp_l2vpn_evpn + ['advertise-all-vni'])
+ if len(config.list_nodes(base + [vrf] + bgp_l2vpn_evpn)) == 0:
+ config.delete(base + [vrf] + bgp_l2vpn_evpn)
+ if len(config.list_nodes(base + [vrf] + ['protocols', 'bgp', 'address-family'])) == 0:
+ config.delete(base + [vrf] + ['protocols', 'bgp', 'address-family'])
+
+ # Collect named VRFs that have advertise-all-vni configured.
+ advertise_all_vni_vrfs = []
+
+ for vrf in config.list_nodes(base):
+ if config.exists(base + [vrf] + bgp_l2vpn_evpn + ['advertise-all-vni']):
+ if config.exists(bgp_base):
+ # A default BGP instance exists. FRR always starts it before
+ # named VRFs, so the named VRF's advertise-all-vni would be
+ # silently rejected on every boot. Remove it.
+ _cleanup_address_family(config, vrf)
+ else:
+ advertise_all_vni_vrfs.append(vrf)
+
+ # No default BGP instance, but multiple named VRFs hold advertise-all-vni.
+ # FRR only allows one instance to hold it at a time. Keep the first VRF
+ # and remove it from the rest.
+ if len(advertise_all_vni_vrfs) > 1:
+ for vrf in advertise_all_vni_vrfs[1:]:
+ _cleanup_address_family(config, vrf)