DHCP servers MAC remain unresolved for connectPoints until org.onosproject.dhcprelay app toggle
Change-Id: I8fc5104a80c9845710a3f5e7bae035f0a6762241
diff --git a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp4HandlerImpl.java b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp4HandlerImpl.java
index ece4323..886115b 100644
--- a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp4HandlerImpl.java
+++ b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp4HandlerImpl.java
@@ -1619,17 +1619,12 @@
}
private void hostUpdated(Host host, List<DhcpServerInfo> srverInfoList) {
- DhcpServerInfo serverInfo;
- Ip4Address targetIp;
- if (!srverInfoList.isEmpty()) {
- serverInfo = srverInfoList.get(0);
- targetIp = serverInfo.getDhcpGatewayIp4().orElse(null);
+ srverInfoList.stream().forEach(serverInfo -> {
+ Ip4Address targetIp = serverInfo.getDhcpGatewayIp4().orElse(null);
Ip4Address serverIp = serverInfo.getDhcpServerIp4().orElse(null);
-
if (targetIp == null) {
targetIp = serverIp;
}
-
if (targetIp != null) {
if (host.ipAddresses().contains(targetIp)) {
serverInfo.setDhcpConnectMac(host.mac());
@@ -1637,7 +1632,7 @@
requestDhcpPacket(serverIp);
}
}
- }
+ });
}
@@ -1653,13 +1648,9 @@
}
private void hostRemoved(Host host, List<DhcpServerInfo> serverInfoList) {
- DhcpServerInfo serverInfo;
- Ip4Address targetIp;
- if (!serverInfoList.isEmpty()) {
- serverInfo = serverInfoList.get(0);
+ serverInfoList.stream().forEach(serverInfo -> {
+ Ip4Address targetIp = serverInfo.getDhcpGatewayIp4().orElse(null);
Ip4Address serverIp = serverInfo.getDhcpServerIp4().orElse(null);
- targetIp = serverInfo.getDhcpGatewayIp4().orElse(null);
-
if (targetIp == null) {
targetIp = serverIp;
}
@@ -1671,7 +1662,7 @@
cancelDhcpPacket(serverIp);
}
}
- }
+ });
}
private void requestDhcpPacket(Ip4Address serverIp) {
diff --git a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java
index 38cfd1d..e36daf9 100644
--- a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java
+++ b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java
@@ -1431,12 +1431,9 @@
}
private void hostUpdated(Host host, List<DhcpServerInfo> serverInfoList) {
- DhcpServerInfo serverInfo;
- Ip6Address targetIp;
- if (!serverInfoList.isEmpty()) {
- serverInfo = serverInfoList.get(0);
+ serverInfoList.stream().forEach(serverInfo -> {
Ip6Address serverIp = serverInfo.getDhcpServerIp6().orElse(null);
- targetIp = serverInfo.getDhcpGatewayIp6().orElse(null);
+ Ip6Address targetIp = serverInfo.getDhcpGatewayIp6().orElse(null);
if (targetIp == null) {
targetIp = serverIp;
@@ -1448,7 +1445,7 @@
requestDhcpPacket(serverIp);
}
}
- }
+ });
}
/**
* Handle host removed.
@@ -1462,13 +1459,9 @@
}
private void hostRemoved(Host host, List<DhcpServerInfo> serverInfoList) {
- DhcpServerInfo serverInfo;
- Ip6Address targetIp;
-
- if (!serverInfoList.isEmpty()) {
- serverInfo = serverInfoList.get(0);
+ serverInfoList.stream().forEach(serverInfo -> {
Ip6Address serverIp = serverInfo.getDhcpServerIp6().orElse(null);
- targetIp = serverInfo.getDhcpGatewayIp6().orElse(null);
+ Ip6Address targetIp = serverInfo.getDhcpGatewayIp6().orElse(null);
if (targetIp == null) {
targetIp = serverIp;
@@ -1480,7 +1473,7 @@
cancelDhcpPacket(serverIp);
}
}
- }
+ });
}
/**