On 2019/01/09 17:01, Martijn van Duren wrote: > monitoring-plugins' check_dhcp has some weird in a counter: > $ doas /usr/local/libexec/nagios/check_dhcp -s 10.17.11.55 -u -i bnx0 > OK: Received 260350 DHCPOFFER(s), 1 of 1 requested servers responded, max > lease time = 21600 sec. > > This is caused by receive_dhcp_packet, which only does > recvfrom(MSG_PEEK), which causes the packet to be found as long as the > timer hasn't expired. The diff below removes the MSG_PEEK flag and > returns the correct value: > $ doas ./check_dhcp -s 10.17.11.55 -u -i trunk0 > OK: Received 1 DHCPOFFER(s), 1 of 1 requested servers responded, max lease > time = 21600 sec. > > OK?
Needs a REVISION-main bump, otherwise OK maintainer > > martijn@ > > Index: patches/patch-plugins-root_check_dhcp_c > =================================================================== > RCS file: > /cvs/ports/net/monitoring-plugins/patches/patch-plugins-root_check_dhcp_c,v > retrieving revision 1.1 > diff -u -p -r1.1 patch-plugins-root_check_dhcp_c > --- patches/patch-plugins-root_check_dhcp_c 19 Jul 2017 12:14:29 -0000 > 1.1 > +++ patches/patch-plugins-root_check_dhcp_c 9 Jan 2019 16:00:36 -0000 > @@ -3,8 +3,11 @@ Fix stack smashing. > > Upstream merge request: > https://github.com/monitoring-plugins/monitoring-plugins/pull/1500 > ---- plugins-root/check_dhcp.c.orig Wed Jul 19 12:53:55 2017 > -+++ plugins-root/check_dhcp.c Wed Jul 19 13:46:40 2017 > + > +MSG_PEEK causes the packet to be counted multiple times. > +Index: plugins-root/check_dhcp.c > +--- plugins-root/check_dhcp.c.orig > ++++ plugins-root/check_dhcp.c > @@ -323,7 +323,8 @@ int get_hardware_address(int sock,char *interface_name > #elif defined(__bsd__) > /* King 2004 see > ACKNOWLEDGEMENTS */ > @@ -15,3 +18,12 @@ https://github.com/monitoring-plugins/mo > char *buf; > unsigned char *ptr; > struct if_msghdr *ifm; > +@@ -693,7 +694,7 @@ int receive_dhcp_packet(void *buffer, int buffer_size, > + else{ > + 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); > ++ recv_result=recvfrom(sock,(char > *)buffer,buffer_size,0,(struct sockaddr *)&source_address,&address_size); > + if(verbose) > + printf("recv_result: %d\n",recv_result); > + >