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.
This commit is contained in:
		
							
								
								
									
										12
									
								
								ndhc/arp.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								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;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user