Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 28130 - Shutdown with pcmcia ethernet card trys to stop net.eth* twice when using pcmcia-cs scripts
Summary: Shutdown with pcmcia ethernet card trys to stop net.eth* twice when using pcm...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Mobile Herd (OBSOLETE)
URL:
Whiteboard:
Keywords: Inclusion
Depends on:
Blocks: 68964
  Show dependency tree
 
Reported: 2003-09-07 14:50 UTC by Jason Andryuk
Modified: 2005-04-25 05:13 UTC (History)
3 users (show)

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


Attachments
Patch to /etc/pcmcia/network adding check support (network.patch,229 bytes, patch)
2003-09-07 14:56 UTC, Jason Andryuk
Details | Diff
patch too /etc/pcmcia/network adding --quiet option (network.diff,352 bytes, patch)
2003-09-10 13:03 UTC, Jason Andryuk
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Andryuk 2003-09-07 14:50:04 UTC
There is a known problem with the shutdown of pcmcia ethernet cards where the
system attempts to take down the interface twice.  First net.eth* is brought
down by the init system, and then cardmgr of the pcmcia-cs package tries to
bring down the same interface.  This give a nice error message.

Syslog shows:
cardmgr[3424]: executing: './network check eth0'
cardmgr[3424]: executing: './network stop eth0'
And then the error.

The problem is that the 'check' option of the network script is not implemented.
 All that needs to happen is for the check script to query the status of the the
net.eth* script.  cardmgr is smart enough not to stop a stopped interface.

So here is a patch for /etc/pcmcia/network:
--- network.orig        2003-09-07 17:17:15.000000000 -0400
+++ network     2003-09-07 17:17:21.000000000 -0400
@@ -31,5 +31,6 @@
                /etc/init.d/net.$DEVICE stop
                ;;
        "check")
+               exit `/etc/init.d/net.$DEVICE --quiet status`
                ;;
 esac

--------------------------

This works for me.

More elaborate versions of 'check' are implemented in other pcmcia scripts, and
these can be refered to if you want to implement those.

I also just noticed that there is a race between hotplug and cardmgr to setup
the interface, and to take it down:
-=Insert Card=-
Sep  7 17:37:46 beowulf cardmgr[3703]: socket 0: NetGear FA510C Fast Ethernet
Sep  7 17:37:47 beowulf cardmgr[3703]: executing: 'modprobe cb_enabler'
Sep  7 17:37:47 beowulf cardmgr[3703]: executing: 'modprobe tulip_cb'
Sep  7 17:37:47 beowulf cardmgr[3703]: executing: './network start eth0'
Sep  7 17:37:47 beowulf default.hotplug[4023]: arguments (net) env (OLDPWD=/
PATH=/bin:/sbin:/usr/sbin:/usr/bin ACTION=register PWD=/etc/hotplug HOME=/
SHLVL=2 INTERFACE=eth0 DEBUG=yes _=/usr/bin/env)
Sep  7 17:37:47 beowulf default.hotplug[4023]: invoke /etc/hotplug/net.agent ()
Sep  7 17:37:48 beowulf cardmgr[3703]: +  * WARNING:  "net.eth0" has already
been started.
Sep  7 17:37:48 beowulf rc-scripts: WARNING:  "net.eth0" has already been started.
-=Remove Card=-
Sep  7 17:40:33 beowulf cardmgr[3703]: executing: './network stop eth0'
Sep  7 17:40:34 beowulf cardmgr[3703]: +  * Bringing eth0 down...         [ ok ]
Sep  7 17:40:34 beowulf cardmgr[3703]: executing: 'modprobe -r tulip_cb'
Sep  7 17:40:34 beowulf default.hotplug[4111]: arguments (net) env (OLDPWD=/
PATH=/bin:/sbin:/usr/sbin:/usr/bin ACTION=unregister PWD=/etc/hotplug HOME=/
SHLVL=2 INTERFACE=eth0 DEBUG=yes _=/usr/bin/env)
Sep  7 17:40:34 beowulf cardmgr[3703]: executing: 'modprobe -r cb_enabler'
Sep  7 17:40:34 beowulf default.hotplug[4111]: invoke /etc/hotplug/net.agent ()

Hotplug starts the net.eth0 script, but cardmgr stops it.  It should be noted
that hotplug doesn't complain when it is beaten because net.eth* scripts are
called with the quiet option.  Maybe pcmcia-cs should use the --quiet option for
starting scripts too?

Reproducible: Always
Steps to Reproduce:
Comment 1 Jason Andryuk 2003-09-07 14:56:25 UTC
Created attachment 17238 [details, diff]
Patch to /etc/pcmcia/network adding check support
Comment 2 Jason Andryuk 2003-09-10 12:56:54 UTC
I started writing this comment to lobby for the above fix, but halfway through I changed my mind as to the correct line of action.

--------------------------------
Look in source file cardmgr/cardmgr.c to see that the above change should be made.

Here is a code walk through so you can see why the above change should be made.  I just include the relevant portions of the respective functions.

static void handle_signal(void)
        SIGTERM:
                if( do_check(i) == 0 )
                        do_remove(i);


do_check()
        if ( execute_on_all("check", ...) == 0 )
                return 0

int execute_on_all()
        ret |= execute_on_dev()
        return ret

int execute_on_dev()
        return execute()

int execute()
        return <return value of script called>

'/etc/init.d/pcmcia stop'  calls start-stop-daemon --stop no cardmgr.  I
believe that is sending SIGTERM, so that is where the walk starts.
As you can see, do_remove(i) is only called if do_check(i) returns 0.
do_check returns 0 if all the execute* functions return 0, which depends
on the network script having returned zero.

Since net.eth0 has already stopped, we don't want to stop it again.  So
we don't want to call do_remove(i).  That means we need to return a non-zero return value from the '/etc/pcmcia/network' script for the check case.

Wait a second.  We DO want to run the do_remove(i).  The interface has shutdown, but that does not mean that the pcmcia service has been cleaned up.  In other words, The modules are left loaded.  This isn't a big deal on shutdown, but it isn't the proper thing to do.

With the above fix, this can be observed with the following set of commands:
after booting and inserting a pcmcia network card:
# /etc/init.d/net.eth0 stop
# /etc/init.d/pcmcia stop
# lsmod
This will show the pcmcia and network drivers are still loaded.

So, check should always return 0.  This ensures that the modules will be removed.  In order to get ride of the errors about the network already being stopped, we should call the net.eth* scripts with the --quiet option.  That way we do not see the error, and there is no harm in calling the net.eth* script with stop twice.  Functionality is preserved.  As already noted this is how hotplug calls network scripts.
Comment 3 Jason Andryuk 2003-09-10 13:03:07 UTC
Created attachment 17458 [details, diff]
patch too /etc/pcmcia/network adding --quiet option

This is a patch to the /etc/pcmcia/network script to call
/etc/init.d/net.$DEVICE with --quiet.
Comment 4 Henrik Brix Andersen 2005-04-25 05:13:02 UTC
Fixed in sys-apps/pcmcia-cs-3.2.8. Thank you for reporting this.