Adding d/p/13_check_icmp_improvements from upstream
This commit is contained in:
		
							parent
							
								
									00de3fe5ea
								
							
						
					
					
						commit
						953ee52d81
					
				
					 2 changed files with 201 additions and 0 deletions
				
			
		
							
								
								
									
										200
									
								
								debian/patches/13_check_icmp_improvements
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										200
									
								
								debian/patches/13_check_icmp_improvements
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,200 @@ | |||
| From 413af1955538b06803458c628099f1ba9da1966b Mon Sep 17 00:00:00 2001 | ||||
| From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | ||||
| Date: Fri, 4 Nov 2022 16:51:32 +0100 | ||||
| Subject: [PATCH 1/5] Remove trailing whitespaces | ||||
| 
 | ||||
| --- | ||||
|  plugins-root/check_icmp.c | 24 ++++++++++++------------ | ||||
|  1 file changed, 12 insertions(+), 12 deletions(-) | ||||
| 
 | ||||
| diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c | ||||
| index f8f153512..abd88c4e7 100644 | ||||
| --- a/plugins-root/check_icmp.c | ||||
| +++ b/plugins-root/check_icmp.c | ||||
| @@ -1,39 +1,39 @@ | ||||
|  /***************************************************************************** | ||||
| -*  | ||||
| +* | ||||
|  * Monitoring check_icmp plugin | ||||
| -*  | ||||
| +* | ||||
|  * License: GPL | ||||
|  * Copyright (c) 2005-2008 Monitoring Plugins Development Team | ||||
|  * Original Author : Andreas Ericsson <ae@op5.se> | ||||
| -*  | ||||
| +* | ||||
|  * Description: | ||||
| -*  | ||||
| +* | ||||
|  * This file contains the check_icmp plugin | ||||
| -*  | ||||
| +* | ||||
|  * Relevant RFC's: 792 (ICMP), 791 (IP) | ||||
| -*  | ||||
| +* | ||||
|  * This program was modeled somewhat after the check_icmp program, | ||||
|  * which was in turn a hack of fping (www.fping.org) but has been | ||||
|  * completely rewritten since to generate higher precision rta values, | ||||
|  * and support several different modes as well as setting ttl to control. | ||||
|  * redundant routes. The only remainders of fping is currently a few | ||||
|  * function names. | ||||
| -*  | ||||
| -*  | ||||
| +* | ||||
| +* | ||||
|  * This program is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
| -*  | ||||
| +* | ||||
|  * This program is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU General Public License for more details. | ||||
| -*  | ||||
| +* | ||||
|  * You should have received a copy of the GNU General Public License | ||||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
| -*  | ||||
| -*  | ||||
| +* | ||||
| +* | ||||
|  *****************************************************************************/ | ||||
|   | ||||
|  /* progname may change */ | ||||
| 
 | ||||
| From 7d074091dba8c1d4081971bf62e694d0b1a03d41 Mon Sep 17 00:00:00 2001 | ||||
| From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | ||||
| Date: Fri, 4 Nov 2022 16:53:57 +0100 | ||||
| Subject: [PATCH 2/5] Remove hardcoded DBL_MAX definition | ||||
| 
 | ||||
| --- | ||||
|  plugins-root/check_icmp.c | 4 ---- | ||||
|  1 file changed, 4 deletions(-) | ||||
| 
 | ||||
| diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c | ||||
| index abd88c4e7..0d10d22db 100644 | ||||
| --- a/plugins-root/check_icmp.c | ||||
| +++ b/plugins-root/check_icmp.c | ||||
| @@ -95,10 +95,6 @@ const char *email = "devel@monitoring-plugins.org"; | ||||
|  # define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 | ||||
|  #endif | ||||
|   | ||||
| -#ifndef DBL_MAX | ||||
| -# define DBL_MAX 9.9999999999e999 | ||||
| -#endif | ||||
| - | ||||
|  typedef unsigned short range_t;  /* type for get_range() -- unimplemented */ | ||||
|   | ||||
|  typedef struct rta_host { | ||||
| 
 | ||||
| From 9a73a94258689cd9337fe7a7937fe85e4670aaeb Mon Sep 17 00:00:00 2001 | ||||
| From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | ||||
| Date: Fri, 4 Nov 2022 17:08:36 +0100 | ||||
| Subject: [PATCH 3/5] Replace DBL_MAX with INFITY to check if value was set | ||||
| 
 | ||||
| --- | ||||
|  plugins-root/check_icmp.c | 5 +++-- | ||||
|  1 file changed, 3 insertions(+), 2 deletions(-) | ||||
| 
 | ||||
| diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c | ||||
| index 0d10d22db..7f3c4b5ba 100644 | ||||
| --- a/plugins-root/check_icmp.c | ||||
| +++ b/plugins-root/check_icmp.c | ||||
| @@ -55,6 +55,7 @@ const char *email = "devel@monitoring-plugins.org"; | ||||
|  #include <errno.h> | ||||
|  #include <signal.h> | ||||
|  #include <ctype.h> | ||||
| +#include <float.h> | ||||
|  #include <net/if.h> | ||||
|  #include <netinet/in_systm.h> | ||||
|  #include <netinet/in.h> | ||||
| @@ -1220,7 +1221,7 @@ finish(int sig) | ||||
|  			   host->rta / 1000, (float)warn.rta / 1000, (float)crit.rta / 1000, | ||||
|  			   (targets > 1) ? host->name : "", host->pl, warn.pl, crit.pl, | ||||
|  			   (targets > 1) ? host->name : "", (float)host->rtmax / 1000, | ||||
| -			   (targets > 1) ? host->name : "", (host->rtmin < DBL_MAX) ? (float)host->rtmin / 1000 : (float)0); | ||||
| +			   (targets > 1) ? host->name : "", (host->rtmin < INFINITY) ? (float)host->rtmin / 1000 : (float)0); | ||||
|   | ||||
|  		host = host->next; | ||||
|  	} | ||||
| @@ -1323,7 +1324,7 @@ add_target_ip(char *arg, struct sockaddr_storage *in) | ||||
|  		memcpy(host_sin6->sin6_addr.s6_addr, sin6->sin6_addr.s6_addr, sizeof host_sin6->sin6_addr.s6_addr); | ||||
|  	} | ||||
|   | ||||
| -	host->rtmin = DBL_MAX; | ||||
| +	host->rtmin = INFINITY; | ||||
|   | ||||
|  	if(!list) list = cursor = host; | ||||
|  	else cursor->next = host; | ||||
| 
 | ||||
| From d3a4bad51d72a3c5bcc06ceb5e0a823dcc24bf49 Mon Sep 17 00:00:00 2001 | ||||
| From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | ||||
| Date: Sun, 19 Feb 2023 14:31:21 +0100 | ||||
| Subject: [PATCH 4/5] check_icmp: Fix compiler warning | ||||
| 
 | ||||
| This fixes a compiler warning with no real world impact. | ||||
| The compiler complains about a missing return, which is correct, but | ||||
| in that scenario the program would crash anyways, so this has no impact. | ||||
| --- | ||||
|  plugins-root/check_icmp.c | 5 +++-- | ||||
|  1 file changed, 3 insertions(+), 2 deletions(-) | ||||
| 
 | ||||
| diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c | ||||
| index 7f3c4b5ba..317cd5357 100644 | ||||
| --- a/plugins-root/check_icmp.c | ||||
| +++ b/plugins-root/check_icmp.c | ||||
| @@ -1430,20 +1430,21 @@ set_source_ip(char *arg) | ||||
|  static in_addr_t | ||||
|  get_ip_address(const char *ifname) | ||||
|  { | ||||
| +  // TODO: Rewrite this so the function return an error and we exit somewhere else | ||||
| +	struct sockaddr_in ip; | ||||
|  #if defined(SIOCGIFADDR) | ||||
|  	struct ifreq ifr; | ||||
| -	struct sockaddr_in ip; | ||||
|   | ||||
|  	strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); | ||||
|  	ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0'; | ||||
|  	if(ioctl(icmp_sock, SIOCGIFADDR, &ifr) == -1) | ||||
|  		crash("Cannot determine IP address of interface %s", ifname); | ||||
|  	memcpy(&ip, &ifr.ifr_addr, sizeof(ip)); | ||||
| -	return ip.sin_addr.s_addr; | ||||
|  #else | ||||
|  	errno = 0; | ||||
|  	crash("Cannot get interface IP address on this platform."); | ||||
|  #endif | ||||
| +	return ip.sin_addr.s_addr; | ||||
|  } | ||||
|   | ||||
|  /* | ||||
| 
 | ||||
| From 423284edfa980fc3fdb51ab20af96685a988ba97 Mon Sep 17 00:00:00 2001 | ||||
| From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | ||||
| Date: Sun, 19 Feb 2023 14:34:29 +0100 | ||||
| Subject: [PATCH 5/5] check_icmp: Fix compiler warning | ||||
| 
 | ||||
| This fixes a compiler warning which complains about an uninitialized | ||||
| value for a variable which is then returned. | ||||
| This had no real world impact, since the program would crash in the | ||||
| branch where result is not set. | ||||
| The variable is initialized to "-1" which would be the error for | ||||
| inet_pton. | ||||
| --- | ||||
|  plugins-root/check_icmp.c | 2 +- | ||||
|  1 file changed, 1 insertion(+), 1 deletion(-) | ||||
| 
 | ||||
| diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c | ||||
| index 317cd5357..e59e92d33 100644 | ||||
| --- a/plugins-root/check_icmp.c | ||||
| +++ b/plugins-root/check_icmp.c | ||||
| @@ -1339,7 +1339,7 @@ add_target_ip(char *arg, struct sockaddr_storage *in) | ||||
|  static int | ||||
|  add_target(char *arg) | ||||
|  { | ||||
| -	int error, result; | ||||
| +	int error, result = -1; | ||||
|  	struct sockaddr_storage ip; | ||||
|  	struct addrinfo hints, *res, *p; | ||||
|  	struct sockaddr_in *sin; | ||||
							
								
								
									
										1
									
								
								debian/patches/series
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								debian/patches/series
									
										
									
									
										vendored
									
									
								
							|  | @ -4,3 +4,4 @@ | |||
| 10_check_http_chunked_wo_actual_content | ||||
| 11_fallback_for_gnutls | ||||
| 12_check_curl_improvements | ||||
| 13_check_icmp_improvements | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue