Copilot commented on code in PR #13758:
URL: https://github.com/apache/cloudstack/pull/13758#discussion_r3701423762


##########
server/src/main/java/com/cloud/network/security/SecurityGroupManagerImpl.java:
##########
@@ -1451,18 +1451,27 @@ public boolean securityGroupRulesForVmSecIp(long nicId, 
String secondaryIp, bool
         // Verify permissions
         _accountMgr.checkAccess(caller, null, false, vm);
 
+        Network network = _networkModel.getNetwork(nic.getNetworkId());
+
+        // On a Direct Routed network the host needs a route and a static 
neighbour entry for the
+        // secondary IP before it is reachable at all. That is independent of 
security groups,
+        // which are optional there and which the Instance may not be using, 
so the agent is told
+        // either way - otherwise the address would stay dark until the 
Instance was restarted.
+        boolean directRouted = 
Network.GuestType.L3.equals(network.getGuestType());
+

Review Comment:
   This dereferences `network.getGuestType()` without checking whether 
`_networkModel.getNetwork(...)` returned null, which would throw a 
NullPointerException. It’s safer to fail with a clear 
InvalidParameterValueException (and it also avoids passing a null network into 
`isSecurityGroupSupportedInNetwork`).



##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java:
##########
@@ -288,17 +315,92 @@ public LibvirtVMDef.InterfaceDef plug(NicTO nic, String 
guestOsType, String nicA
         }
         intf.setLinkStateUp(nic.isEnabled());
 
-        executeMacIpScript(intf.getBrName(), nic.getMac(), nic.getIp(), 
nic.getIp6Address(), nic.getNicSecIps());
+        // Host-wide property (EVPN use case) runs the MAC/IP script for every 
NIC; a Direct
+        // Routed NIC needs it regardless, since the host route and static 
neighbour entry are
+        // what deliver its traffic.
+        if (_macIpStaticEnabled || isDirectRoutedNic(nic)) {
+            executeMacIpScript(intf.getBrName(), nic.getMac(), nic.getIp(), 
nic.getIp6Address(), nic.getNicSecIps());
+        }

Review Comment:
   If modifymacip.sh is missing and vm.network.macip.static is disabled, Direct 
Routed (L3) NICs will silently skip installing the required host route + static 
neighbour entries (executeMacIpScript returns early when _macIpScriptPath is 
null). This can leave VMs starting successfully but with no connectivity and no 
warning. Consider failing the plug with a clear error when a Direct Routed NIC 
is detected and _macIpScriptPath is null.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to