[VOL-4184] If the HW identifier is not specified the DHCP relay fails for all packets, even though we only use it in case we and to change src/dst mac.
Change-Id: I4a0258b6e8b1bc5067ac50146c0b395c9044d49b
diff --git a/app/src/main/java/org/opencord/dhcpl2relay/impl/DhcpL2Relay.java b/app/src/main/java/org/opencord/dhcpl2relay/impl/DhcpL2Relay.java
index 1980851..a426035 100755
--- a/app/src/main/java/org/opencord/dhcpl2relay/impl/DhcpL2Relay.java
+++ b/app/src/main/java/org/opencord/dhcpl2relay/impl/DhcpL2Relay.java
@@ -765,12 +765,6 @@
context.inPacket().receivedFrom(), ethernetPacket);
}
- MacAddress relayAgentMac = relayAgentMacAddress(context);
- if (relayAgentMac == null) {
- log.warn("RelayAgent MAC not found ");
- return null;
- }
-
Ethernet etherReply = (Ethernet) ethernetPacket.clone();
IPv4 ipv4Packet = (IPv4) etherReply.getPayload();
@@ -815,6 +809,13 @@
ipv4Packet.setPayload(udpPacket);
etherReply.setPayload(ipv4Packet);
if (modifyClientPktsSrcDstMac) {
+ MacAddress relayAgentMac = relayAgentMacAddress(context);
+ if (relayAgentMac == null) {
+ log.warn("Rewriting src MAC failed because OLT MAC not found for {} in sadis. " +
+ "Packet is dropped, can't act as RelayAgent",
+ context.inPacket().receivedFrom().deviceId());
+ return null;
+ }
etherReply.setSourceMACAddress(relayAgentMac);
etherReply.setDestinationMACAddress(dhcpConnectMac);
}
@@ -1287,7 +1288,7 @@
private MacAddress relayAgentMacAddress(PacketContext context) {
SubscriberAndDeviceInformation device = this.getDevice(context);
if (device == null) {
- log.warn("Device not found for {}", context.inPacket().receivedFrom());
+ log.warn("Information for Device {} not found in Sadis", context.inPacket().receivedFrom());
return null;
}
return device.hardwareIdentifier();