netutils/dhcpc : do not send decline message to same dhcp server
authorJin-Seong Kim <jseong82.kim@samsung.com>
Thu, 25 May 2017 08:30:55 +0000 (17:30 +0900)
committerEunBong Song <eunb.song@samsung.com>
Tue, 11 Jul 2017 01:26:56 +0000 (10:26 +0900)
This commit is bug fix to prevent send decline message
 - dhcp declient message is used to announce duplicated
   assigned IP address in a network
 - dhcp client doesn't have routine to check duplicate IP
   via ARP, so no need to send decline message to same server

Change-Id: Iae6036e064d767159fa6d1b6a10f95fcaa3c317f
Signed-off-by: Jin-Seong Kim <jseong82.kim@samsung.com>
apps/netutils/dhcpc/dhcpc.c

index 354a0f1..6b8cac0 100644 (file)
@@ -592,10 +592,15 @@ int dhcpc_request(void *handle, struct dhcpc_state *presult)
                 */
 
                else if (msgtype == DHCPOFFER) {
-                       ndbg("Received another OFFER, send DECLINE\n");
-                       result = dhcpc_sendmsg(pdhcpc, presult, DHCPDECLINE);
-                       if (result <= 0) {
-                               ndbg("recv request error(%d)(%d)\n", result, errno);
+                       /* If we get OFFERs from same dhcp server, do not send DECLINE */
+                       if (pdhcpc->serverid.s_addr == presult->serverid.s_addr) {
+                               ndbg("Received duplicated OFFER from %08x\n", ntohl(presult->serverid.s_addr));
+                       } else {
+                               ndbg("Received another OFFER from %08x, send DECLINE\n", ntohl(presult->serverid.s_addr));
+                               result = dhcpc_sendmsg(pdhcpc, presult, DHCPDECLINE);
+                               if (result <= 0) {
+                                       ndbg("recv request error(%d)(%d)\n", result, errno);
+                               }
                        }
                }