ONOS-2800 Preventing learning of IP 0.0.0.0
Change-Id: Ic16d4cf847edef671f1c62018afd0eb3f7585e2d
diff --git a/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java b/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java
index 8da6a99..fa331fa 100644
--- a/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java
+++ b/providers/host/src/main/java/org/onosproject/provider/host/impl/HostLocationProvider.java
@@ -72,8 +72,8 @@
import static org.slf4j.LoggerFactory.getLogger;
/**
- * Provider which uses an OpenFlow controller to detect network
- * end-station hosts.
+ * Provider which uses an OpenFlow controller to detect network end-station
+ * hosts.
*/
@Component(immediate = true)
public class HostLocationProvider extends AbstractProvider implements HostProvider {
@@ -289,7 +289,9 @@
private void updateLocationIP(HostId hid, MacAddress mac,
VlanId vlan, HostLocation hloc,
IpAddress ip) {
- HostDescription desc = new DefaultHostDescription(mac, vlan, hloc, ip);
+ HostDescription desc = ip.isZero() ?
+ new DefaultHostDescription(mac, vlan, hloc) :
+ new DefaultHostDescription(mac, vlan, hloc, ip);
try {
providerService.hostDetected(hid, desc);
} catch (IllegalStateException e) {
@@ -323,9 +325,7 @@
return;
}
- HostLocation hloc =
- new HostLocation(heardOn, System.currentTimeMillis());
-
+ HostLocation hloc = new HostLocation(heardOn, System.currentTimeMillis());
HostId hid = HostId.hostId(eth.getSourceMAC(), vlan);
// ARP: possible new hosts, update both location and IP