[monitoring-plugins] check_dhcp: Don't peek before reading response

Holger Weiss git at monitoring-plugins.org
Wed Sep 14 12:00:27 CEST 2016


 Module: monitoring-plugins
 Branch: master
 Commit: 99f5be29927de6863849441b8af4b794033cc8bd
 Author: Holger Weiss <holger at zedat.fu-berlin.de>
   Date: Wed Sep 14 11:57:31 2016 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=99f5be2

check_dhcp: Don't peek before reading response

Omit a recvfrom(3) call which has the MSG_PEEK flag set and should have
no effect at all.  According to a comment in the code, this call was
meant to be a workaround to an opaque issue.  If anyone runs into that
issue, we should fix it properly instead.

---

 plugins-root/check_dhcp.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/plugins-root/check_dhcp.c b/plugins-root/check_dhcp.c
index d8afb17..445ddbc 100644
--- a/plugins-root/check_dhcp.c
+++ b/plugins-root/check_dhcp.c
@@ -692,17 +692,11 @@ int receive_dhcp_packet(void *buffer, int buffer_size, int sock, int timeout, st
                 }
 
         else{
-
-		/* why do we need to peek first?  i don't know, its a hack.  without it, the source address of the first packet received was
-		   not being interpreted correctly.  sigh... */
 		bzero(&source_address,sizeof(source_address));
 		address_size=sizeof(source_address);
                 recv_result=recvfrom(sock,(char *)buffer,buffer_size,MSG_PEEK,(struct sockaddr *)&source_address,&address_size);
 		if(verbose)
-			printf("recv_result_1: %d\n",recv_result);
-                recv_result=recvfrom(sock,(char *)buffer,buffer_size,0,(struct sockaddr *)&source_address,&address_size);
-		if(verbose)
-			printf("recv_result_2: %d\n",recv_result);
+			printf("recv_result: %d\n",recv_result);
 
                 if(recv_result==-1){
 			if(verbose){



More information about the Commits mailing list