DHCP relay bug fixes
- DHCP relay doesn't set destination MAC properly when forwarding the reply
- SR doesn't properly turn off the arp handler in dhcp relay
Change-Id: I7f7660bfe70fee14abcfdd3abb750e4a88b6ec42
diff --git a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/DhcpRelayManager.java b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/DhcpRelayManager.java
index 7a0aec8..26d0dfe 100644
--- a/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/DhcpRelayManager.java
+++ b/apps/dhcprelay/src/main/java/org/onosproject/dhcprelay/DhcpRelayManager.java
@@ -772,26 +772,30 @@
private void writeResponseDhcpRecord(Ethernet ethernet,
DHCP dhcpPayload) {
Optional<Interface> outInterface = getOutputInterface(ethernet, dhcpPayload);
- outInterface.ifPresent(outIface -> {
- ConnectPoint location = outIface.connectPoint();
- VlanId vlanId = outIface.vlan();
- MacAddress macAddress = MacAddress.valueOf(dhcpPayload.getClientHardwareAddress());
- HostId hostId = HostId.hostId(macAddress, vlanId);
- DhcpRecord record = dhcpRelayStore.getDhcpRecord(hostId).orElse(null);
- if (record == null) {
- record = new DhcpRecord(HostId.hostId(macAddress, vlanId));
- } else {
- record = record.clone();
- }
- record.addLocation(new HostLocation(location, System.currentTimeMillis()));
- if (dhcpPayload.getPacketType() == DHCP.MsgType.DHCPACK) {
- record.ip4Address(Ip4Address.valueOf(dhcpPayload.getYourIPAddress()));
- }
- record.ip4Status(dhcpPayload.getPacketType());
- record.setDirectlyConnected(directlyConnected(dhcpPayload));
- record.updateLastSeen();
- dhcpRelayStore.updateDhcpRecord(HostId.hostId(macAddress, vlanId), record);
- });
+ if (!outInterface.isPresent()) {
+ log.warn("Failed to determine where to send {}", dhcpPayload.getPacketType());
+ return;
+ }
+
+ Interface outIface = outInterface.get();
+ ConnectPoint location = outIface.connectPoint();
+ VlanId vlanId = outIface.vlan();
+ MacAddress macAddress = MacAddress.valueOf(dhcpPayload.getClientHardwareAddress());
+ HostId hostId = HostId.hostId(macAddress, vlanId);
+ DhcpRecord record = dhcpRelayStore.getDhcpRecord(hostId).orElse(null);
+ if (record == null) {
+ record = new DhcpRecord(HostId.hostId(macAddress, vlanId));
+ } else {
+ record = record.clone();
+ }
+ record.addLocation(new HostLocation(location, System.currentTimeMillis()));
+ if (dhcpPayload.getPacketType() == DHCP.MsgType.DHCPACK) {
+ record.ip4Address(Ip4Address.valueOf(dhcpPayload.getYourIPAddress()));
+ }
+ record.ip4Status(dhcpPayload.getPacketType());
+ record.setDirectlyConnected(directlyConnected(dhcpPayload));
+ record.updateLastSeen();
+ dhcpRelayStore.updateDhcpRecord(HostId.hostId(macAddress, vlanId), record);
}
//build the DHCP discover/request packet with gatewayip(unicast packet)
@@ -903,6 +907,7 @@
return null;
}
+ etherReply.setDestinationMACAddress(dhcpPayload.getClientHardwareAddress());
etherReply.setVlanID(outInterface.vlan().toShort());
// we leave the srcMac from the original packet
diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
index 5e50b83..ad3b6fc 100644
--- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
+++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
@@ -358,7 +358,7 @@
"requestInterceptsEnabled", "false");
compCfgService.preSetProperty("org.onosproject.incubator.net.neighbour.impl.NeighbourResolutionManager",
"requestInterceptsEnabled", "false");
- compCfgService.preSetProperty("org.onosproject.dhcprelay.DhcpRelay",
+ compCfgService.preSetProperty("org.onosproject.dhcprelay.DhcpRelayManager",
"arpEnabled", "false");
compCfgService.preSetProperty("org.onosproject.net.host.impl.HostManager",
"greedyLearningIpv6", "true");