Bug 68919

Summary: 'ping' command changed, lost features
Product: [Retired] Red Hat Linux Reporter: Joel Votaw <joel>
Component: iputilsAssignee: Phil Knirsch <pknirsch>
Status: CLOSED CURRENTRELEASE QA Contact: Mike McLean <mikem>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: giulioo, leszek.cieplinski, rvokal, steve
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-05-14 15:28:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Joel Votaw 2002-07-15 23:14:32 UTC
Description of Problem:

Two things (maybe more) have changed about the 'ping' command that break some 
shell scripts.

1. It's exit code seems to be the same regardless of whether or not it could 
ping the desired host.

2. When using the '-cN' option, ping will not exit after N packets have been 
sent and timed out.  I've been using the -w option instead, but it's really not 
the same.

In general it seems like quite a few command-line options have changed since we 
upgraded from RedHat 7.1.



Version-Release number of selected component (if applicable): iputils-ss020124



How Reproducible: 100%



Steps to Reproduce:
1. if ping -w5 somehost > /dev/null 2>&1; then echo true; fi
2. In my experience the above will always print "true" regardless of whether or 
not somehost is alive.
3. This makes it harder to write shell scripts which ping a host to see if it's 
alive before performing some action.

Actual Results:


Expected Results:


Additional Information: Please contact me if you need more info.

Comment 1 Mike McLean 2002-07-22 18:38:48 UTC
*** Bug 69282 has been marked as a duplicate of this bug. ***

Comment 2 giulioo 2002-11-12 11:29:57 UTC
Use
ping -c1 -w1 nonexistent_host
to have ping check for an host being up or down without hanging and with correct
exit status.


Comment 3 giulioo 2002-11-12 11:31:20 UTC
*** Bug 77685 has been marked as a duplicate of this bug. ***

Comment 4 Joel Votaw 2002-11-12 16:50:37 UTC
        ping -c1 -w1 nonexistenthost

does in fact do the job.  (Funny, I thought I tested that before and it didn't 
work ... I must be hallucinating).

It would still be nice for 

        ping -w1 nonexistenthost

to return the correct exit value, too.  ("success" should be determined by any 
packets coming back from the host, regardless of if you force the number of 
packets sent to a specific value.)

As a nitpick, I suggest adding this example to the manpage -- there seem to be 
several other people that have run into this problem too.

Also, how does the -c option work if -w is not also specified?  Does it ever 
time out, or does it just take a very long time?  Perhaps there should be an 
addition to the manpage under the -c descripttion that says "in practise this 
takes ages to time out so you probably want to specify -w also".

Thank you very much for your help with this.  I don't mean to complain too 
much, just offer constructive feedback so Linux can be even better.

Comment 5 Need Real Name 2002-12-03 16:05:17 UTC
If an ordinary user on our default RH8 install tries to ping a non existant 
address like 192.168.40.40 ping returns:

From 217.37.xx.xxx icmp_seq=1 Destination Port Unreachable

repeatedly,

Trouble is if I run that for one second I get:

--- 192.168.40.40 ping statistics ---
0 packets transmitted, 0 received, +6415 errors

CPU Usage and Load continue to grow as resources permit. I gave up when my load 
average went through 3 having no desire to see what would break.

I worry about the potential here for a local Denial of Service attack by anyone 
with a user account on the server.



Comment 6 Phil Knirsch 2003-05-14 15:28:22 UTC
This has been fixed in the current release. ping -c 1 will timeout again.

Read ya, Phil