Skip to content
Snippets Groups Projects
Commit e1ac2744 authored by abat's avatar abat
Browse files

Merge into master from pull request #205:

DeviceManager: handle null entity classes returned by classifyEntity (https://github.com/floodlight/floodlight/pull/205)
parents 188c03df 27329c63
No related branches found
No related tags found
No related merge requests found
......@@ -901,6 +901,9 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
// entity. Look up the entity in the returned class'
// class entity index.
entityClass = entityClassifier.classifyEntity(entity);
if (entityClass == null) {
return null;
}
ClassState classState = getClassState(entityClass);
if (classState.classIndex != null) {
......@@ -993,6 +996,10 @@ IFlowReconcileListener, IInfoProvider, IHAListener {
// entity. Look up the entity in the returned class'
// class entity index.
entityClass = entityClassifier.classifyEntity(entity);
if (entityClass == null) {
// could not classify entity. No device
return null;
}
ClassState classState = getClassState(entityClass);
if (classState.classIndex != null) {
......
......@@ -193,7 +193,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
.setTargetHardwareAddress(Ethernet.toMACAddress("00:11:22:33:44:55"))
.setTargetProtocolAddress(IPv4.toIPv4AddressBytes("192.168.1.2")));
this.testARPReplyPacket_3_Serialized = testARPReplyPacket_3.serialize();
// Build the PacketIn
this.packetIn_1 = ((OFPacketIn) mockFloodlightProvider.
getOFMessageFactory().getMessage(OFType.PACKET_IN))
......@@ -391,7 +391,19 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
assertEquals(4, deviceManager.getAllDevices().size());
verify(mockListener);
reset(mockListener);
replay(mockListener);
deviceManager.entityClassifier = new MockEntityClassifierMac();
deviceManager.startUp(null);
Entity entityNoClass = new Entity(5L, (short)1, 5, -1L, 1, new Date());
assertEquals(null, deviceManager.learnDeviceByEntity(entityNoClass));
verify(mockListener);
}
@Test
public void testAttachmentPointLearning() throws Exception {
......@@ -1177,6 +1189,7 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
Entity entity4 = new Entity(4L, (short)2, 4, 2L, 2, new Date());
Entity entity5 = new Entity(5L, (short)1, 5, 3L, 1, new Date());
IDevice d1 = deviceManager.learnDeviceByEntity(entity1);
IDevice d2 = deviceManager.learnDeviceByEntity(entity2);
......@@ -1259,6 +1272,11 @@ public class DeviceManagerImplTest extends FloodlightTestCase {
if (!exceptionCaught)
fail("findDevice() did not throw IllegalArgumentException");
Entity entityNoClass = new Entity(5L, (short)1, 5, -1L, 1, new Date());
assertEquals(null, deviceManager.findDeviceByEntity(entityNoClass));
// Now look up destination devices
assertEquals(d1, deviceManager.findDestDevice(d2,
entity1.getMacAddress(),
......
......@@ -44,6 +44,8 @@ public class MockEntityClassifierMac extends DefaultEntityClassifier {
return testECMac1;
} else if (entity.getSwitchDPID() == 2L) {
return testECMac2;
} else if (entity.getSwitchDPID() == -1L) {
return null;
}
return DefaultEntityClassifier.entityClass;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment