Source IP to be set to Relay Agent IP in DHCP packet from client
Change-Id: I5e5e0afca20d2eda7f6631a27d1be429412884c2
diff --git a/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/Dhcp4HandlerImpl.java b/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/Dhcp4HandlerImpl.java
index 14ee700..59310b5 100644
--- a/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/Dhcp4HandlerImpl.java
+++ b/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/Dhcp4HandlerImpl.java
@@ -884,7 +884,11 @@
// Sets relay agent IP
int effectiveRelayAgentIp = relayAgentIp != null ?
relayAgentIp.toInt() : clientInterfaceIp.toInt();
+ Ip4Address effectiveRealRealyAgentIP = relayAgentIp != null ?
+ relayAgentIp : clientInterfaceIp;
dhcpPacket.setGatewayIPAddress(effectiveRelayAgentIp);
+ ipv4Packet.setSourceAddress(effectiveRealRealyAgentIP.toInt());
+ log.debug("Source IP address set as relay agent IP with value: {}", effectiveRealRealyAgentIP);
}
}
diff --git a/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerUtil.java b/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerUtil.java
index 9b3097e..5d07993 100644
--- a/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerUtil.java
+++ b/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerUtil.java
@@ -568,12 +568,15 @@
ipv6Packet.setDestinationAddress(serverInfo.getDhcpServerIp6().get().toOctets());
}
if (isRelayAgentIpFromCfgEmpty(serverInfo, receivedFromDevice)) {
- dhcp6Relay.setLinkAddress(relayAgentIp.toOctets());
log.debug("indirect connection: relayAgentIp NOT availale from config file! Use dynamic. {}",
HexString.toHexString(relayAgentIp.toOctets(), ":"));
+ serverIpFacing = relayAgentIp;
} else {
- dhcp6Relay.setLinkAddress(serverInfo.getRelayAgentIp6(receivedFromDevice).get().toOctets());
+ serverIpFacing = serverInfo.getRelayAgentIp6(receivedFromDevice).get();
}
+ log.debug("Source IP address set as relay agent IP with value: {}", serverIpFacing);
+ dhcp6Relay.setLinkAddress(serverIpFacing.toOctets());
+ ipv6Packet.setSourceAddress(serverIpFacing.toOctets());
}
// peer address: address of the client or relay agent from which the message to be relayed was received.
dhcp6Relay.setPeerAddress(peerAddress);