chiark / gitweb /
dhcp: Properly handle unsuccessful cases for DHCP Ack
authorPatrik Flykt <patrik.flykt@linux.intel.com>
Tue, 17 Dec 2013 15:24:16 +0000 (16:24 +0100)
committerTom Gundersen <teg@jklm.no>
Tue, 17 Dec 2013 15:24:16 +0000 (16:24 +0100)
Ignore DHCP Ack packets if they are found to be erroneous or have
an unexpected xid by setting the result to zero instead of propagating
an error. Also remember to report a DHCP Nak and stop the DHCP client.

src/libsystemd-dhcp/dhcp-client.c

index 01d406c..c0c348c 100644 (file)
@@ -897,6 +897,9 @@ static int client_receive_raw_message(sd_event_source *s, int fd,
                         client->receive_message =
                                 sd_event_source_unref(client->receive_message);
                 }
                         client->receive_message =
                                 sd_event_source_unref(client->receive_message);
                 }
+
+                r = 0;
+
                 break;
 
         case DHCP_STATE_INIT:
                 break;
 
         case DHCP_STATE_INIT:
@@ -910,7 +913,7 @@ static int client_receive_raw_message(sd_event_source *s, int fd,
         }
 
 error:
         }
 
 error:
-        if (r < 0)
+        if (r < 0 || r == DHCP_EVENT_NO_LEASE)
                 return client_stop(client, r);
 
         return 0;
                 return client_stop(client, r);
 
         return 0;