From 513b28967f698ff0954fb1d6083e2ad64cf26e10 Mon Sep 17 00:00:00 2001 From: Divakar Date: Mon, 3 Aug 2015 10:07:05 +0530 Subject: [PATCH] Check size of MAC vector before reading the element While clearing the neutron router, Agent some times receives NULL object without any properties. As this is not a delete operation ServiceInstance attempts to calcualte the properties of the instance by traversing the node grpah. When VMI is seen, it attempts to read the mac address which as such is not preset leading to crash. As a fix, the mac address is read only if the Mac vector has some element in it. Change-Id: Idd2afde67f56728408e5c553d772f30d00a246af closes-bug: #1474272 --- src/vnsw/agent/oper/service_instance.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/vnsw/agent/oper/service_instance.cc b/src/vnsw/agent/oper/service_instance.cc index 55994384560..ec894c4e9b0 100644 --- a/src/vnsw/agent/oper/service_instance.cc +++ b/src/vnsw/agent/oper/service_instance.cc @@ -218,17 +218,23 @@ static void FindAndSetInterfaces( properties->interface_count++; if(vmi_props.service_interface_type == "left") { properties->vmi_inside = IdPermsGetUuid(vmi->id_perms()); - properties->mac_addr_inside = vmi->mac_addresses().at(0); + if (vmi->mac_addresses().size()) { + properties->mac_addr_inside = vmi->mac_addresses().at(0); + } properties->ip_addr_inside = FindInterfaceIp(graph, adj); } else if(vmi_props.service_interface_type == "right") { properties->vmi_outside = IdPermsGetUuid(vmi->id_perms()); - properties->mac_addr_outside = vmi->mac_addresses().at(0); + if (vmi->mac_addresses().size()) { + properties->mac_addr_outside = vmi->mac_addresses().at(0); + } properties->ip_addr_outside = FindInterfaceIp(graph, adj); } else if(vmi_props.service_interface_type == "management") { properties->vmi_management = IdPermsGetUuid(vmi->id_perms()); - properties->mac_addr_management = vmi->mac_addresses().at(0); + if (vmi->mac_addresses().size()) { + properties->mac_addr_management = vmi->mac_addresses().at(0); + } properties->ip_addr_management = FindInterfaceIp(graph, adj); }