Bug 17371 - Incorrect (reversed) test in add_default_route
Incorrect (reversed) test in add_default_route
Product: Red Hat Linux
Classification: Retired
Component: initscripts (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bill Nottingham
Depends On:
  Show dependency treegraph
Reported: 2000-09-08 19:20 EDT by Need Real Name
Modified: 2014-03-16 22:16 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-02-15 15:56:45 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Need Real Name 2000-09-08 19:20:13 EDT
In /etc/sysconfig/network-scripts/network-functions,  add_default _route
tests  check_device_down before restoriing the default route defined in
$GATEWAY and $GATEWAYDEV.  The test is reversed, since  check_device_down
returns zero if the tested interface is down, and the ! in the test  will
cause the route to be added if the interface is still up.

I found this when trying to setup a ppp connection in addition to my nornal
lan connection on eth0. Starting ppp replaces the default route by its own
default, and the original default should be reactivated when ppp goes down.
This did not work until I changed the code as shown below.

Here is the code as I have modified it:

add_default_route ()
    . /etc/sysconfig/network
    if [ "${GATEWAY}" != "" -a "${GATEWAY}" != "none" -a "${GATEWAYDEV}" !=
"" ] ; then
#        if ! check_device_down ; then  # direction of test reversed by BEB
6 sept 2000
        if  check_device_down ; then
            /sbin/route add default gw ${GATEWAY} ${GATEWAYDEV}
Comment 1 Need Real Name 2000-09-08 22:36:12 EDT
It occurs to me that there may be something else going on here. Perhaps the
original test is correct, but that the wrong interface is being checked. that
is, instead of "add default route (for eth0) if ppp0 has gone down", it should
be "add default route (for eth0) if eth0 is still up". In this case, when
check_device_down  checks $DEVICE, $DEVICE should be eth0, not ppp0.
Comment 2 Bill Nottingham 2005-02-15 15:56:45 EST
Closing out bugs on older, no longer supported, releases. Please open a new bug
if this persists on current releases.

Note You need to log in before you can comment on or make changes to this bug.