ONOS-2926 Remove IP instead of host when the IP mapping is released
Change-Id: Ifea3366ce8a18ea068e615636b3069e769221c0e
diff --git a/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java b/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java
index 345d5ad..153463a 100644
--- a/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java
+++ b/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java
@@ -481,7 +481,10 @@
}
}
} else if (incomingPacketType.getValue() == DHCPPacketType.DHCPRELEASE.getValue()) {
- dhcpStore.releaseIP(hostId);
+ Ip4Address ip4Address = dhcpStore.releaseIP(hostId);
+ if (ip4Address != null) {
+ hostProviderService.removeIpFromHost(hostId, ip4Address);
+ }
}
}
}
@@ -666,9 +669,10 @@
if ((ipAssignment.assignmentStatus() != IpAssignment.AssignmentStatus.Option_Expired) &&
(ipAssignment.leasePeriod() > 0) && (timeLapsed > (ipAssignment.leasePeriodMs()))) {
- dhcpStore.releaseIP(entry.getKey());
- // TODO remove only the IP from the host entry when the API is in place.
- hostProviderService.hostVanished(entry.getKey());
+ Ip4Address ip4Address = dhcpStore.releaseIP(entry.getKey());
+ if (ip4Address != null) {
+ hostProviderService.removeIpFromHost(entry.getKey(), ipAssignment.ipAddress());
+ }
}
}
timeout = Timer.getTimer().newTimeout(new PurgeListTask(), timerDelay, TimeUnit.MINUTES);