Skip to content

Commit 1f21848

Browse files
committed
Merge pull request #1681 from murali-reddy/router_eth_device_index
CLOUDSTACK-9491: incorrect parsing of device list to find ethernet index of plugged NICIn VmwareResource, findRouterEthDeviceIndex() method find ethernet interface index given the mac address. This method is used, once a nic is plugged to determine ethernet interface. "/proc/sys/net/ipv4/conf" from the VR and looped through the devices to find the right ethernet interface. Howver current logic read it once, and loops through the device list. Its observerd device may not show up '/proc/sys/net/ipv4/conf' immediatly once NIC is plugged in the VM from vCenter. Fix ensured, while waiting for 15 sec in the loop, read the latest content from /proc/sys/net/ipv4/conf , so that right device list is processed. Manual tested VPC scenarios of adding new tiers which uses findRouterEthDeviceIndex, to find the guest/public network ethernet index. * pr/1681: CLOUDSTACK-9491: incorrect parsing of device list to find ethernet index of plugged NIC Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2 parents 55b9180 + b449351 commit 1f21848

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -833,18 +833,19 @@ private int findRouterEthDeviceIndex(String domrName, String routerIp, String ma
833833
VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
834834

835835
s_logger.info("findRouterEthDeviceIndex. mac: " + mac);
836-
837-
// TODO : this is a temporary very inefficient solution, will refactor it later
838-
Pair<Boolean, String> result = SshHelper.sshExecute(routerIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "ls /proc/sys/net/ipv4/conf");
836+
ArrayList<String> skipInterfaces = new ArrayList<String>(Arrays.asList("all", "default", "lo"));
839837

840838
// when we dynamically plug in a new NIC into virtual router, it may take time to show up in guest OS
841839
// we use a waiting loop here as a workaround to synchronize activities in systems
842840
long startTick = System.currentTimeMillis();
843841
while (System.currentTimeMillis() - startTick < 15000) {
842+
843+
// TODO : this is a temporary very inefficient solution, will refactor it later
844+
Pair<Boolean, String> result = SshHelper.sshExecute(routerIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "ls /proc/sys/net/ipv4/conf");
844845
if (result.first()) {
845846
String[] tokens = result.second().split("\\s+");
846847
for (String token : tokens) {
847-
if (!("all".equalsIgnoreCase(token) || "default".equalsIgnoreCase(token) || "lo".equalsIgnoreCase(token))) {
848+
if (!(skipInterfaces.contains(token))) {
848849
String cmd = String.format("ip address show %s | grep link/ether | sed -e 's/^[ \t]*//' | cut -d' ' -f2", token);
849850

850851
if (s_logger.isDebugEnabled())
@@ -855,8 +856,11 @@ private int findRouterEthDeviceIndex(String domrName, String routerIp, String ma
855856
if (s_logger.isDebugEnabled())
856857
s_logger.debug("result: " + result2.first() + ", output: " + result2.second());
857858

858-
if (result2.first() && result2.second().trim().equalsIgnoreCase(mac.trim()))
859+
if (result2.first() && result2.second().trim().equalsIgnoreCase(mac.trim())) {
859860
return Integer.parseInt(token.substring(3));
861+
} else {
862+
skipInterfaces.add(token);
863+
}
860864
}
861865
}
862866
}

0 commit comments

Comments
 (0)