From 7b0db5b8d3078457195bedfb3a54d3aa6d49ffd1 Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Sun, 6 Apr 2014 06:02:03 -0400 Subject: [PATCH] arp.c: If the safe_read that fetches arp responses encounters a return of -1 with errno == EAGAIN or EWOULDBLOCK, then report the error, as it should never happen given that the function is called only once after polling for ready-reads. Further, the old code was buggy; it would subtract from the arpreply_offset the return value of -1 in that case, which is just wrong. --- ndhc/arp.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ndhc/arp.c b/ndhc/arp.c index 3d15e10..ac866f1 100644 --- a/ndhc/arp.c +++ b/ndhc/arp.c @@ -712,15 +712,13 @@ void handle_arp_response(struct client_state_t *cs) int r = 0; if (arpreply_offset < sizeof arpreply) { r = safe_read(cs->arpFd, (char *)&arpreply + arpreply_offset, - sizeof arpreply - arpreply_offset); - if (r < 0 && errno != EWOULDBLOCK && errno != EAGAIN) { + sizeof arpreply - arpreply_offset); + if (r < 0) { log_error("arp: ARP response read failed: %s", strerror(errno)); switch (arpState) { - case AS_COLLISION_CHECK: arp_failed(cs); break; - case AS_GW_CHECK: arp_gw_failed(cs); break; - default: - arp_reopen_fd(cs); - break; + case AS_COLLISION_CHECK: arp_failed(cs); break; + case AS_GW_CHECK: arp_gw_failed(cs); break; + default: arp_reopen_fd(cs); break; } } else arpreply_offset += r;