From c3aaf658b16abd2fd7313bbe31d86e013b4d0546 Mon Sep 17 00:00:00 2001 From: Marco Sinhoreli Date: Sun, 3 May 2026 12:21:27 +0200 Subject: [PATCH] NE: persist OVN broadcast/isolation URI on NIC for vif.binding=lswitch Delta 1 already overrides nic.setBroadcastType(Lswitch) on the NicProfile during prepare() so the KVM agent picks the OVS Lswitch path. But the underlying nics row still carried the cosmetic ``vlan://`` URI allocated by GuestNetworkGuru at design-time, which is misleading on listNics / DB queries: a NIC sitting on an OVN logical switch should not advertise a VLAN URI. Override broadcast_uri and isolation_uri on the NicProfile to ``ovn://cs-net-`` (the convention used by the legacy ovn-plugin) and persist the same on the nics row via nicDao.update. The VLAN that the guru allocated stays as a ghost in op_dc_vnet_alloc -- it is never used on the wire because the VIF attaches to br-int and traffic flows through OVN's logical pipeline over geneve. Releasing the VLAN back to the pool would require intercepting the design phase, which is out of scope for this hook. Verified end-to-end: i-2-24-VM on network 214 now lists broadcast_uri = ovn://cs-net-214 isolation_uri = ovn://cs-net-214 and the OVN NB LSP / OVS iface-id / OVN SB Port_Binding remain correctly bound to the chassis, as before. --- .../network/NetworkExtensionElement.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/network/NetworkExtensionElement.java b/framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/network/NetworkExtensionElement.java index 84bea25f73e..d10c6b74cb1 100644 --- a/framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/network/NetworkExtensionElement.java +++ b/framework/extensions/src/main/java/org/apache/cloudstack/framework/extensions/network/NetworkExtensionElement.java @@ -518,8 +518,33 @@ public class NetworkExtensionElement extends AdapterBase implements // libvirt sets external_ids:iface-id atomically with tap creation. // No agent patch is required for this binding mode. if (isLswitchVifBinding(network)) { + // Override broadcast type + URI on the NicProfile (in-memory), + // and persist the same to the underlying nics row so listNics + // / DB queries report consistent OVN identifiers instead of + // the stale VLAN URI the GuestNetworkGuru allocated at + // design-time. + java.net.URI ovnUri = null; + try { + ovnUri = java.net.URI.create("ovn://cs-net-" + network.getId()); + } catch (Exception e) { + logger.warn("Failed to build OVN URI for NIC {}: {}", nic.getId(), e.getMessage()); + } nic.setBroadcastType(Networks.BroadcastDomainType.Lswitch); - logger.debug("prepare: applied Lswitch broadcast type to NIC {} (uuid={}) on network {} per extension vif.binding hint", + if (ovnUri != null) { + nic.setBroadcastUri(ovnUri); + nic.setIsolationUri(ovnUri); + try { + com.cloud.vm.NicVO nicVo = nicDao.findById(nic.getId()); + if (nicVo != null) { + nicVo.setBroadcastUri(ovnUri); + nicVo.setIsolationUri(ovnUri); + nicDao.update(nicVo.getId(), nicVo); + } + } catch (Exception e) { + logger.warn("Failed to persist OVN URI on nics row {}: {}", nic.getId(), e.getMessage()); + } + } + logger.debug("prepare: applied Lswitch broadcast type and ovn:// URI to NIC {} (uuid={}) on network {} per extension vif.binding hint", nic.getId(), nic.getUuid(), network.getId()); }