Bug 176439 - net/fping: Possible Fping incompatibility with FreeBSD
Summary: net/fping: Possible Fping incompatibility with FreeBSD
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Alex Kozlov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-26 13:20 UTC by Alexandre RAYNAUD
Modified: 2013-04-22 16:50 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandre RAYNAUD 2013-02-26 13:20:00 UTC
In precise circumstances, Fping 3.4 command gives inconsistent results on FreeBSD OS using either Fping 3.4 FreeBSD port or Fping 3.4 compilled from source.

From a FreeBSD box, using fping command to check an unreachable host_ip's availability located in the same subnet as the FreeBSD Host, fping get stuck at the second try returning many errors ("host_ip  error while sending ping: Host is down"). The first try will be ok.

If we wait few seconds (maybe 1 minute) between each test, the error doesn't occur.

The returned fping error message part "error while sending ping" is comming from fping source (fping.c) at line 1581
the second part of fping error message "Host is down" seems to come from /usr/src/sys/sys/errno.h line  133 (#define EHOSTDOWN       64              /* Host is down */).

As consequence of this issue, applications relying on Fping to check host availability cannot be fully trusted.

(ps : Using fping with ip located on external/routed network, fping always
works normally, without any error)

Fix: 

Don't know how to fix the problem but it seems to be related with a caching issue.
How-To-Repeat: To repeat the problem :  
-The  FreeBSD box from where we run fping command must have an interface configured with an ip address in the same subnet as the host_ip we want to check the availability.
The host_ip we want to check availability MUST BE DOWN. 
All the tests must be done with THE SAME HOST_IP.

Running {fping host_ip} for the first time return : {host_ip is unreachable} which is the expected output.
As soon as the firt command finish (important to not wait), running another {fping host_ip} return : 
{
host_ip error while sending ping: Host is down
host_ip error while sending ping: Host is down
host_ip error while sending ping: Host is down
host_ip error while sending ping: Host is down
host_ip error while sending ping: Host is down
host_ip error while sending ping: Host is down
host_ip error while sending ping: Host is down
..
}

Then pfing will get stuck and if you ctrl-c, it will stops and you will
get the normal fping output : {^Chost_ip is unreachable}

Remark : if you wait about 1 minute between 2 testS, no error occur.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2013-02-27 00:10:51 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-ports-bugs

ports PR.
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2013-02-27 00:11:25 UTC
Maintainer of net/fping,

Please note that PR ports/176439 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/176439

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 3 Edwin Groothuis freebsd_committer freebsd_triage 2013-02-27 00:11:26 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 4 jharris 2013-02-28 02:57:48 UTC
On Wed, Feb 27, 2013 at 12:11:25AM +0000, Edwin Groothuis wrote:

> The full text of the PR can be found at:
>     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/176439


Sorry, but I can only reproduce that output with ping(8), not fping(8),
which I just rebuilt from the latest port:

  %uname -a ; echo ; svn info . ; fping -v ; fping 192.168.1.99 ; fping 192.168.1.99 ; fping 192.168.1.99 ; echo ; ping -r 192.168.1.99 | & head -5
  FreeBSD laptop 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec  4 09:23:10 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64

  Path: .
  Working Copy Root Path: /usr/ports
  URL: svn://svn.freebsd.org/ports/head/net/fping
  Repository Root: svn://svn.freebsd.org/ports
  Repository UUID: 35697150-7ecd-e111-bb59-0022644237b5
  Revision: 313076
  Node Kind: directory
  Schedule: normal
  Last Changed Author: zeising
  Last Changed Rev: 304773
  Last Changed Date: 2012-09-24 05:15:59 -0400 (Mon, 24 Sep 2012)

  fping: Version 3.4
  fping: comments to david@schweikert.ch
  192.168.1.99 is unreachable
  192.168.1.99 is unreachable
  192.168.1.99 is unreachable

  ping: sendto: Network is unreachable
  ping: sendto: Network is unreachable
  ping: sendto: Network is unreachable
  ping: sendto: Network is unreachable
  ping: sendto: Network is unreachable

Is there something I'm missing?

Thanks.

-- 
Jason Harris           |  PGP:  This _is_ PGP-signed, isn't it?
jharris@widomaker.com _|_ Got photons? (TM), (C) 2004
Comment 5 Alexandre RAYNAUD 2013-03-02 09:37:30 UTC
Missed:  Unreachable IP address tested has to be in the same subnet as the FreeBSD host from where fping is executed to reproduce the issue.

 

MAIRIE DE SALLANCHES

Direction des Systèmes d'Information

Alexandre RAYNAUD

email: alexandre.raynaud@sallanches.fr

 
Comment 6 Alexandre RAYNAUD 2013-03-02 19:24:02 UTC
This issue has been declared as bug from fping maintainer 

 

https://github.com/schweikert/fping/issues/39

 

 

MAIRIE DE SALLANCHES

Direction des Systèmes d'Information

Alexandre RAYNAUD

email: alexandre.raynaud@sallanches.fr

 
Comment 7 jharris 2013-03-04 12:33:43 UTC
OK, using the CORRECT subnet, I can reproduce it:

  %fping 10.0.1.99 ; sudo arp -d 10.0.1.99 ; fping 10.0.1.99 ; fping 10.0.1.99

  %arp 10.0.1.99
  ? (10.0.1.99) at (incomplete) on rl0 expired [ethernet]

The difference is if the unreachable IP is in the arp cache when fping starts.

Note that ping does the same thing:

  %ping 10.0.1.99 ; sudo arp -d 10.0.1.99 ; ping 10.0.1.99 ; ping 10.0.1.99

(and you have to hit ^C to stop every ping process).

It looks like adding -c is a way to get fping to give up sooner:

  %fping 10.0.1.99 ; sudo arp -d 10.0.1.99 ; fping 10.0.1.99 ; fping -c 5 10.0.1.99
  10.0.1.99 is unreachable
  10.0.1.99 (10.0.1.99) deleted
  10.0.1.99 is unreachable

  10.0.1.99 : xmt/rcv/%loss = 5/0/100%

The OP (Raynaud Alexandre) says this causes problems for zabbix, but only on FreeBSD.

OP:  Is it one or both of ports/net-mgmt/zabbix{,2}-server?  [Note:  Reply directly
to this message, leaving the subject line and bug-followup@FreeBSD.org intact,
to update this PR.]

Thanks.

-- 
Jason Harris           |  PGP:  This _is_ PGP-signed, isn't it?
jharris@widomaker.com _|_ Got photons? (TM), (C) 2004
Comment 8 Alexandre RAYNAUD 2013-03-05 09:52:39 UTC
I have only tested ports/net-mgmt/zabbix2-server (actually our zabbix =
production server)

Zabbix works perfectly, nothing wrong in that port. The only issue is =
Zabbix icmpping simple check that relies on fping. And because fping =
gives inconsistant results (as you describe it has to do with arp =
cache), Zabbix icmpping simple check is not reliable to check host =
availability.



MAIRIE DE SALLANCHES
Direction des Syst=E8mes d'Information
Alexandre RAYNAUD
email: alexandre.raynaud@sallanches.fr
Comment 9 jharris 2013-03-05 13:36:54 UTC
On Mon, Mar 04, 2013 at 08:33:43AM -0400, Jason Harris wrote:

> The difference is if the unreachable IP is in the arp cache when fping starts.


> The OP (Raynaud Alexandre) says this causes problems for zabbix, but only on FreeBSD.

 
This [MAINTAINER-approved/written] patch solves the reported inconsistency based on
the state of the ARP cache:

  %fping 10.0.1.99 ; fping 10.0.1.99 ; fping 10.0.1.99 ; fping 10.0.1.99
  10.0.1.99 is unreachable
  10.0.1.99 is unreachable
  10.0.1.99 is unreachable
  10.0.1.99 is unreachable

Note that you need to "mkdir files && mv patch-fping.c files/" and then reinstall fping.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

diff -r 830ac78f8d7f Makefile
--- a/Makefile	Tue Mar 05 08:51:42 2013 -0400
+++ b/Makefile	Tue Mar 05 08:53:29 2013 -0400
@@ -8,6 +8,7 @@
 
 PORTNAME=	fping
 PORTVERSION=	3.4
+PORTREVISION=	1
 CATEGORIES=	net ipv6
 MASTER_SITES=   http://fping.org/dist/
 
diff -r 830ac78f8d7f files/patch-fping.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/files/patch-fping.c	Tue Mar 05 08:53:29 2013 -0400
@@ -0,0 +1,16 @@
+diff -r c564b3055165 src/fping.c
+--- src/fping.c	Tue Mar 05 08:13:11 2013 -0400
++++ src/fping.c	Tue Mar 05 08:45:33 2013 -0400
+@@ -1572,7 +1572,11 @@
+     n = sendto( s, buffer, ping_pkt_size, 0,
+         ( struct sockaddr* )&h->saddr, sizeof( FPING_SOCKADDR ) );
+ 
+-    if( n < 0 || n != ping_pkt_size )
++    if(( n < 0 || n != ping_pkt_size)
++#if defined( EHOSTDOWN )
++                                      && errno != EHOSTDOWN
++#endif
++                                                            )
+     {
+         if( verbose_flag || unreachable_flag )
+         {
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (FreeBSD)

iJ0EARECAF0FAlE16tJWGGh0dHA6Ly9rZXlzZXJ2ZXIua2pzbC5jb206MTEzNzEv
cGtzL2xvb2t1cD9vcD1nZXQmc2VhcmNoPTB4RDM5REEwRTMmd2VoYXZleW91bm93
PXRydWUACgkQSypIl9OdoOOpngCeM7o5Fiyz+tNd913oIw9eQgx3bFIAnjzizqhw
i0Ah52bnldvJGfXn/nwT
=R4KM
-----END PGP SIGNATURE-----

-- 
Jason Harris           |  PGP:  This _is_ PGP-signed, isn't it?
jharris@widomaker.com _|_ Got photons? (TM), (C) 2004
Comment 10 dfilter service freebsd_committer freebsd_triage 2013-04-22 16:44:49 UTC
Author: ak
Date: Mon Apr 22 15:44:41 2013
New Revision: 316242
URL: http://svnweb.freebsd.org/changeset/ports/316242

Log:
  - Add timestamps option (used by netperf-wrapper) [1]
  - Fix fping issue with the unreachable ip in the arp cache [2]
  - Convert Makefile headers to new style
  
  PR:	ports/177368 [1]
  PR:	ports/176439 [2]
  Submitted by:	Lars Eggert <lars@eggert.org> [1], Alexandre RAYNAUD <alexandre.raynaud@sallanches.fr> [2]
  Approved by:	Jason Harris <jharris@widomaker.com> (maintainer)

Added:
  head/net/fping/files/
  head/net/fping/files/patch-fping.c   (contents, props changed)
Modified:
  head/net/fping/Makefile   (contents, props changed)
  head/net/fping/distinfo   (contents, props changed)

Modified: head/net/fping/Makefile
==============================================================================
--- head/net/fping/Makefile	Mon Apr 22 15:37:34 2013	(r316241)
+++ head/net/fping/Makefile	Mon Apr 22 15:44:41 2013	(r316242)
@@ -1,22 +1,23 @@
-# ex:ts=8
-# Ports collection makefile for:  fping
-# Date created:			  Tue Mar 25, 1997
-# Whom:				  David O'Brien (obrien@NUXI.com)
-#
+# Created by: David O'Brien (obrien@NUXI.com)
 # $FreeBSD$
-#
 
 PORTNAME=	fping
 PORTVERSION=	3.4
+PORTREVISION=	1
 CATEGORIES=	net ipv6
-MASTER_SITES=   http://fping.org/dist/
+MASTER_SITES=	http://fping.org/dist/
+
+PATCH_SITES=	https://raw.github.com/tohojo/netperf-wrapper/master/misc/
+PATCH_DIST_STRIP=	-p1
 
 MAINTAINER=	jharris@widomaker.com
 COMMENT=	Quickly ping N hosts w/o flooding the network
 
+OPTIONS_DEFINE=		TIMESTAMPS
 OPTIONS_MULTI=		NET
 OPTIONS_MULTI_NET=	IPV4 IPV6
 OPTIONS_DEFAULT=	IPV4
+TIMESTAMPS_DESC=	Enable timestamps
 
 GNU_CONFIGURE=	yes
 CONFIGURE_ARGS=	--bindir="${PREFIX}/sbin"
@@ -39,6 +40,10 @@ MAN8+=	fping6.8
 CONFIGURE_ARGS+=--disable-ipv6
 .endif
 
+.if ${PORT_OPTIONS:MTIMESTAMPS}
+PATCHFILES+=	fping_timestamps.patch
+.endif
+
 post-install:
 .if ${PORT_OPTIONS:MIPV4}
 	@${STRIP_CMD} ${PREFIX}/sbin/fping

Modified: head/net/fping/distinfo
==============================================================================
--- head/net/fping/distinfo	Mon Apr 22 15:37:34 2013	(r316241)
+++ head/net/fping/distinfo	Mon Apr 22 15:44:41 2013	(r316242)
@@ -1,2 +1,4 @@
 SHA256 (fping-3.4.tar.gz) = d42528af4931f16a8e3438bd4a45cfdd72163ad8835a3c95351c336a26e56afe
 SIZE (fping-3.4.tar.gz) = 142986
+SHA256 (fping_timestamps.patch) = 5e07b36e2029a042de79536c30d852a7ee65d90216747ca68fe54eba94798f3a
+SIZE (fping_timestamps.patch) = 2211

Added: head/net/fping/files/patch-fping.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/net/fping/files/patch-fping.c	Mon Apr 22 15:44:41 2013	(r316242)
@@ -0,0 +1,16 @@
+diff -r c564b3055165 src/fping.c
+--- src/fping.c	Tue Mar 05 08:13:11 2013 -0400
++++ src/fping.c	Tue Mar 05 08:45:33 2013 -0400
+@@ -1572,7 +1572,11 @@
+     n = sendto( s, buffer, ping_pkt_size, 0,
+         ( struct sockaddr* )&h->saddr, sizeof( FPING_SOCKADDR ) );
+ 
+-    if( n < 0 || n != ping_pkt_size )
++    if(( n < 0 || n != ping_pkt_size)
++#if defined( EHOSTDOWN )
++                                      && errno != EHOSTDOWN
++#endif
++                                                            )
+     {
+         if( verbose_flag || unreachable_flag )
+         {
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 11 Alex Kozlov freebsd_committer freebsd_triage 2013-04-22 16:46:56 UTC
State Changed
From-To: feedback->closed

Committed. Thanks!
Comment 12 Alex Kozlov freebsd_committer freebsd_triage 2013-04-22 16:47:27 UTC
Responsible Changed
From-To: freebsd-ports-bugs->ak

I'll take it.