Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 18976 - net.eth0 doesn't bring down the interface
Summary: net.eth0 doesn't bring down the interface
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-08 11:08 UTC by Mark Aikens
Modified: 2004-06-14 08:00 UTC (History)
3 users (show)

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


Attachments
Patch to force interface down (net.eth1.patch,299 bytes, patch)
2003-08-04 05:57 UTC, Andrew Cowie
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Aikens 2003-04-08 11:08:20 UTC
When I stop net.eth0, the interface is still up with an IP, according to ifconfig. I have 
eth0 using DHCP and it acquires an infinite lease from the DHCP server, which is the 
root of the problem. 
 
On startup, dhcpcd queries the server and gets the infinite lease.  When dhcpcd sees 
that it is infinite, it reports that and exits immediatly (presumably because an infinite 
lease never needs to be renewed.) Now when I try to "net.eth0 stop", the script tries 
to send a signal to the non-running dhcpcd and thinks that it succeeds.  However the 
interface is still up. 

Reproducible: Always
Steps to Reproduce:
1. Acquire an infinite DHCP lease on an interface (eth0, for example) 
2. /etc/init.d/net.eth0 stop 
3. ifconfig eth0 
Actual Results:  
eth0      Protokoll:Ethernet  Hardware Adresse 00:50:2C:03:1C:52   
          inet Adresse:192.168.1.2  Bcast:192.168.1.255  Maske:255.255.255.0 
          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1 
... 

Expected Results:  
eth0      Protokoll:Ethernet  Hardware Adresse 00:50:2C:03:1C:52   
          inet Adresse:192.168.1.2  Bcast:192.168.1.255  Maske:255.255.255.0 
          BROADCAST NOTRAILERS MULTICAST  MTU:1500  Metric:1 
... 

Portage 2.0.47-r10 (default-x86-1.4, gcc-3.2.2, glibc-2.3.1-r4) 
================================================================= 
System uname: 2.4.20 i686 AMD Athlon(tm) XP 2000+ 
GENTOO_MIRRORS="http://gentoo.oregonstate.edu/ http://www.ibiblio.org/gentoo/" 
CONFIG_PROTECT="/etc /var/qmail/control /usr/share/config /usr/kde/2/share/config 
/usr/kde/3/share/config 
/usr/X11R6/lib/X11/xkb:/usr/kde/3.1/share/config:/usr/share/config" 
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d" 
PORTDIR="/usr/portage" 
DISTDIR="/usr/portage/distfiles" 
PKGDIR="/usr/portage/packages" 
PORTAGE_TMPDIR="/work" 
PORTDIR_OVERLAY="/usr/local/portage" 
USE="x86 oss 3dnow apm avi crypt cups encode gif jpeg kde gnome libg++ mikmod 
mmx mpeg ncurses nls pdflib png quicktime spell truetype xml2 xmms xv zlib alsa gdbm 
berkdb slang readline arts tetex aalib java X sdl gpm tcpd pam libwww ssl perl python 
imlib oggvorbis gtk qt motif opengl cdr mbox -svga -esd" 
COMPILER="gcc3" 
CHOST="i686-pc-linux-gnu" 
CFLAGS="-mcpu=athlon -O3 -pipe" 
CXXFLAGS="-mcpu=athlon -O3 -pipe" 
ACCEPT_KEYWORDS="x86" 
MAKEOPTS="-j2" 
AUTOCLEAN="yes" 
SYNC="rsync://rsync.gentoo.org/gentoo-portage" 
FEATURES="sandbox ccache"
Comment 1 Martin Schlemmer (RETIRED) gentoo-dev 2003-04-08 15:43:15 UTC
Wout, comments please ?  I do not know dhcpcd.
Comment 2 Wout Mertens (RETIRED) gentoo-dev 2003-05-06 08:50:25 UTC
Yup, that is correct. dhcpcd does do that, and that is indeed why the interface stays up. So the dhcpcd component needs to get a check to see if the interface is still up after running dhcpcd -k, and bring it down manually if it is.

Something like
ifconfig $INTERFACE | grep -q UP && ifconfig $INTERFACE down
or maybe just
ifconfig $INTERFACE down

:)
Comment 3 Andrew Cowie 2003-08-04 05:57:34 UTC
Created attachment 15471 [details, diff]
Patch to force interface down
Comment 4 Andrew Cowie 2003-08-04 05:58:18 UTC
Actually, it's simpler than this. I had this problem, and was able to isolate the problem (at least in my case), to this.

The stop() function of the net.eth1 script has a ladder of if statements, choosing the appropriate way to shut down. In the case of DHCP, it does this by calling dhcpcd -k. 

However, if, when the interface came up it got an "infinite lease" (don't ask me, I've never heard of an infinite lease either. But I put a ton of `set -x`s in, and that's what I found my firewall just gave me. dhcpcd's message on receipt of an "infinite lease" was to shutdown (which makes sense, I suppose). That's fine, but with no dhcp process running (I *had* been wondering about that) using dhcpcd -k doesn't do anything ... and among other things that don't get done, the interface doesn't get dropped.

Proposed patch to fix the situation attached. It's pretty simple. Right now if the interface *isn't* dhcp, then it runs ifconfig down. So, just run it anyway. Cover's both situations.

Note that this is not related to bug 9529 (which is suggesting that dhcpcd -k is a bad way to drop the interface; I agree) or bug 15579.

Cheers,

AfC
http://www.operationaldynamics.com/about/andrew/
Comment 5 Wout Mertens (RETIRED) gentoo-dev 2003-08-04 06:43:46 UTC
If you do force the shutdowning of the interface, I would like to point out that this is not a good idea for systems that have an nfs mounted root.

I think that there should be some way to prevent ifconfig down from being run in that case.

Note that in such a case you would be running dhcpcd with the -T option, so that dhcpcd would keep the dhcp-provided address alive, but would not change the ip address (nfs root would be down the same instant). So either an <iface>_NFSROOT parameter would enforce this behaviour, or a generic <iface>_NEVERDOWN would prevent the interface from being brought down or something along those lines...
Comment 6 Anders Rune Jensen (RETIRED) gentoo-dev 2004-02-28 05:16:43 UTC
I have a problem related to this, maybe it's already mentioned. But if I have a static IP and I change it to dynamic it doesn't work just restarted net.eth0. I have to run dhcpd eth0 manually afterwards.
Comment 7 Wout Mertens (RETIRED) gentoo-dev 2004-02-28 05:30:09 UTC
Anders, this is because the interface was still up probably. When the interface is up, dhcpcd will not get started. I don't like that behaviour, but it's a different bug. See bug #28362.
Comment 8 Aron Griffis (RETIRED) gentoo-dev 2004-06-14 08:00:31 UTC
This is fixed in the current baselayouts (for example baselayout-1.9.4-r2)

        # Stop DHCP (should be N/A for aliases)
        # Don't trust current configuration... investigate ourselves
        if /sbin/dhcpcd -z ${i} &>${devnull}; then
            ebegin "  Releasing DHCP lease for ${IFACE}"
            for ((count = 0; count < 9; count = count + 1)); do
                /sbin/dhcpcd -z ${i} &>${devnull} || break
                sleep 1
            done
            [[ ${count} -lt 9 ]]
            eend $? "Timed out"
        fi
        ebegin "  Stopping ${i}"
        ifconfig ${i} down &>${devnull}
        eend 0