From 8b97107b8dd06b15c19a5dab63409b581f9de40a Mon Sep 17 00:00:00 2001
From: "Nicholas J. Kain" <nicholas@kain.us>
Date: Sun, 26 Dec 2010 15:03:14 -0500
Subject: [PATCH] Allow receive of short dhcp packets over raw listen sockets.

---
 ndhc/dhcpmsg.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/ndhc/dhcpmsg.c b/ndhc/dhcpmsg.c
index 8643c33..d10962c 100644
--- a/ndhc/dhcpmsg.c
+++ b/ndhc/dhcpmsg.c
@@ -227,23 +227,12 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
 
     memset(&packet, 0, packet_size);
     int len = safe_read(fd, (char *)&packet, packet_size);
-    if (len == -1) {
+    if (len == -1 && errno != EAGAIN && errno != EWOULDBLOCK) {
         log_line("get_raw_packet: read error %s", strerror(errno));
         usleep(500000); /* possible down interface, looping condition */
         return -1;
     }
 
-    if (len < header_size) {
-        log_line("Message too short to contain IP + UDP headers, ignoring");
-        sleep(1);
-        return -2;
-    }
-
-    if (len < ntohs(packet.ip.tot_len)) {
-        log_line("Truncated packet");
-        return -2;
-    }
-
     /* ignore any extra garbage bytes */
     len = ntohs(packet.ip.tot_len);