Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 8626 - network script doesn cleanup dhcpcd if setting gateway fails
Summary: network script doesn cleanup dhcpcd if setting gateway fails
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: PPC Linux
: High normal (vote)
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-01 17:50 UTC by Jonathan Nall
Modified: 2002-10-23 06:21 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Nall 2002-10-01 17:50:07 UTC
this bug is against the default network script /etc/init.d/net.eth0.
if i have the following in my /etc/conf.d/net:
iface_eth1="dhcp"
gateway="eth1/192.168.0.1"

at home, i get a DHCP address and use router 192.168.0.1. however, if i'm at the
coffee shop, i get a DHCP address, but 192.168.0.1 doesn't exist. so
/sbin/dhcpcd is successful, but the "Setting default gateway" section in
/etc/init.d/net.eth0 fails (since the /sbin/route command fails (since there is
no 192.168.0.1)). it takes down the interface, but doesn't check to see if it
was a dhcp interface. if it _was_ a DHCP interface, it should kill dhcpcd and
remove the /var/run/dhcpcd...pid file.

the problem in it not killing dhcpcd is that when you try and bring up the
interface again, you get a "/var/run/dhcpcd...pid file is present"-type of error.
Comment 1 Martin Schlemmer (RETIRED) gentoo-dev 2002-10-03 12:45:22 UTC
Edit net.eth0, and change the following section:

------------------------------------------------------------------------
    if [ -n "${gateway}" ] && [ "${gateway%/*}" = "${IFACE}" ]
    then
        ebegin "  Setting default gateway"
        /sbin/route add default gw ${gateway#*/} dev ${gateway%/*} \
            netmask 0.0.0.0 metric 1 >/dev/null || {

            local error=$?
            ifconfig ${IFACE} down &>/dev/null
            eend ${error} "Failed to bring ${IFACE} up"
            return ${error}
        }
        eend 0
    fi
-------------------------------------------------------------------------

To:

-------------------------------------------------------------------------
    if [ -n "${gateway}" ] && [ "${gateway%/*}" = "${IFACE}" ]
    then
        ebegin "  Setting default gateway"
        /sbin/route add default gw ${gateway#*/} dev ${gateway%/*} \
            netmask 0.0.0.0 metric 1 >/dev/null || {

            local error=$?
            ifconfig ${IFACE} down &>/dev/null
            eend ${error} "Failed to bring ${IFACE} up"
            stop
            return ${error}
        }
        eend 0
    fi
-------------------------------------------------------------------------

Note the 'stop' before the 'return ${error}'.  See if this fixes it and
please reply.
Comment 2 Jonathan Nall 2002-10-04 15:57:37 UTC
this change works just fine.
Comment 3 Martin Schlemmer (RETIRED) gentoo-dev 2002-10-12 11:14:56 UTC
Fixed on CVS, thanks.
Comment 4 Jonathan Nall 2002-10-19 10:20:06 UTC
is it fine for me to close this now? (or is the developer supposed to close it?)

Comment 5 Martin Schlemmer (RETIRED) gentoo-dev 2002-10-19 22:48:32 UTC
You can close it if its fixed.
Comment 6 Jonathan Nall 2002-10-23 06:21:13 UTC
this works fine for me. closing.