summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuslan Volodin <ntwman93@gmail.com>2026-06-16 14:17:37 +0300
committerRuslan Volodin <ntwman93@gmail.com>2026-06-16 14:17:37 +0300
commit43f4c41ded3fc9695e11c541069f89a137cd7a53 (patch)
tree907fa52c7bb1779b7f9a574f9f9f4391e972e649 /src
parent4fb32bc179127691f40c8e93c55877aa76f10416 (diff)
downloadvyos-1x-43f4c41ded3fc9695e11c541069f89a137cd7a53.tar.gz
vyos-1x-43f4c41ded3fc9695e11c541069f89a137cd7a53.zip
T8972: VPP: sync LCP interface VRF table binding
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/interfaces_ethernet.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/conf_mode/interfaces_ethernet.py b/src/conf_mode/interfaces_ethernet.py
index 10b778eea..3b8453780 100755
--- a/src/conf_mode/interfaces_ethernet.py
+++ b/src/conf_mode/interfaces_ethernet.py
@@ -45,6 +45,7 @@ from vyos.utils.dict import dict_search
from vyos.utils.dict import dict_to_paths_values
from vyos.utils.dict import dict_set
from vyos.utils.dict import dict_delete
+from vyos.utils.network import get_vrf_tableid
from vyos.utils.process import is_systemd_service_running
from vyos.vpp.config_verify import verify_vpp_remove_interface
from vyos.vpp.control_vpp import VPPControl
@@ -473,8 +474,36 @@ def apply(ethernet):
mtu = e.get_mtu()
vpp_api.set_iface_mtu(lcp_name, mtu)
+ sync_vpp_lcp_vrf_tables(ethernet, vpp_api)
+
return None
+
+def sync_vpp_lcp_vrf_tables(ethernet: dict, vpp_api: VPPControl) -> None:
+ """Synchronize VyOS VRF assignment to VPP IP FIB table binding."""
+
+ def iter_vpp_lcp_vrf_targets() -> list[tuple[str, int]]:
+ interfaces = [ethernet['ifname']]
+ for vif in ethernet.get('vif', {}).values():
+ interfaces.append(vif['ifname'])
+ for vif_s in ethernet.get('vif_s', {}).values():
+ interfaces.append(vif_s['ifname'])
+ for vif_c in vif_s.get('vif_c', {}).values():
+ interfaces.append(vif_c['ifname'])
+ return [(iface, get_vrf_tableid(iface) or 0) for iface in interfaces]
+
+ lcp_vpp_ifaces = {
+ pair.get('vpp_name_hw')
+ for pair in vpp_api.lcp_pairs_list()
+ if pair.get('vpp_name_hw')
+ }
+
+ for ifname, table_id in iter_vpp_lcp_vrf_targets():
+ if ifname not in lcp_vpp_ifaces:
+ continue
+
+ vpp_api.move_interface_to_ip_table_preserve_addresses(ifname, table_id)
+
if __name__ == '__main__':
try:
c = get_config()