Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 125819 - baselayout 1.12.0 pre16 : incorrect service scheduling when the service depends on net
Summary: baselayout 1.12.0 pre16 : incorrect service scheduling when the service depen...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Roy Marples (RETIRED)
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2006-03-11 05:32 UTC by Arnaud Fabre
Modified: 2006-04-11 08:49 UTC (History)
1 user (show)

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


Attachments
Patch that correct the problem for me (runscript.patch,591 bytes, patch)
2006-03-11 05:33 UTC, Arnaud Fabre
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arnaud Fabre 2006-03-11 05:32:08 UTC
My box contains two ethernet cards: net.eth0 and net.eth1. They are configured to start at boot, using ifplugd. net.eth0 is often unplugged so that its state is inactive.
The problem arise when another service (say apache2) depends on 'net'. When that service starts, both net.eth0 and net.eth1 are inactive (net.eth1 has not yet been started by ifplugd), but apache2 is scheduled to start only after net.eth0. As a consequence, apache2 is never started, despite the fact that net.eth1 finally started.

That can be reproduced at any time this way:
- unplug cable of net.eth0
- plug cable of net.eth1
- /etc/init.d/net.eth0 stop
- /etc/init.d/net.eth1 stop
- /etc/init.d/apache2 start

The last command output this:
 * Service apache2 starting
 * Service net.eth1 starting
 * Service net.eth0 starting
 * Service netmount starting
 * Service dnsmasq starting
 * WARNING:  net.eth1 has started but is inactive
 * WARNING:  net.eth0 has started but is inactive
 * WARNING:  dnsmasq is scheduled to start when net.eth0 has started.
 * WARNING:  netmount is scheduled to start when net.eth0 has started.
 * WARNING:  apache2 is scheduled to start when net.eth0 has started.


This behaviour would be correct if RC_NET_STRICT_CHECKING was set to "yes", but I set it to "no" (requiring only one network interface to be up).

I've looked at /sbin/runscript.sh and found what seems to me the source of the bug: when checking needed dependencies of a service, runscript stops at the first stopped or inactive dependency. This is ok for traditional dependencies but not for net.

I'll attach a patch that corrected the problem for me, there may be a better way of fixing it however :)


#emerge -pv baselayout
[ebuild   R   ] sys-apps/baselayout-1.12.0_pre16-r3  USE="unicode -bootstrap -build -static" 0 kB


#emerge --info
Portage 2.1_pre5-r4 (default-linux/amd64/2006.0, gcc-3.4.5, glibc-2.3.6-r3, 2.6.15-gentoo-r7 x86_64)
=================================================================
System uname: 2.6.15-gentoo-r7 x86_64 AMD Athlon(tm) 64 Processor 3200+
Gentoo Base System version 1.12.0_pre16
dev-lang/python:     2.3.5-r2, 2.4.2
sys-apps/sandbox:    1.2.12
sys-devel/autoconf:  2.13, 2.59-r6
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1
sys-devel/binutils:  2.16.1
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="amd64"
AUTOCLEAN="yes"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=athlon64 -O2 -pipe -fomit-frame-pointer -funit-at-a-time -ftracer -frename-registers -msse -m3dnow"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/kde/3/share/config /usr/share/X11/xkb /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/splash /etc/terminfo /etc/env.d"
CXXFLAGS="-march=athlon64 -O2 -pipe -fomit-frame-pointer -funit-at-a-time -ftracer -frename-registers -msse -m3dnow -fvisibility-inlines-hidden"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig confcache distlocks sandbox sfperms strict"
GENTOO_MIRRORS="http://mir1.ovh.net/gentoo-distfiles/ ftp://ftp.belnet.be/mirror/rsync.gentoo.org/gentoo/ ftp://194.117.143.70/mirrors/gentoo"
LC_ALL="en_US.UTF-8"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage/myoverlay"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="amd64 X alsa apache2 arts avi berkdb bitmap-fonts cjk crypt cups dri eds emacs emboss encode ffmpeg flac foomaticdb fortran gif gpm gtk gtk2 hal imlib ipv6 jpeg kde kdeenablefinal lzw lzw-tiff mad mp3 mpeg ncurses nls nptl ogg oggvorbis opengl pam pdflib perl php png python qt quicktime readline ruby samba sdl spell ssl subversion tcpd theora threads tiff truetype truetype-fonts type1-fonts unicode usb userlocales v4l vhosts vorbis xinerama xml xpm xv xvid zlib elibc_glibc kernel_linux userland_GNU video_cards_nvidia"
Unset:  ASFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, LANG, LDFLAGS, LINGUAS, MAKEOPTS
Comment 1 Arnaud Fabre 2006-03-11 05:33:39 UTC
Created attachment 81916 [details, diff]
Patch that correct the problem for me
Comment 2 Roy Marples (RETIRED) gentoo-dev 2006-03-13 03:17:33 UTC
Thanks for the patch - will be in pre17.

Although we seperate with commas and change the last comma to an or for correct grammar.
Comment 3 Roy Marples (RETIRED) gentoo-dev 2006-04-08 01:49:51 UTC
pre17 is out
Comment 4 Antti Mäkelä 2006-04-09 23:36:30 UTC
Does not work for me after upgrading to baselayout 1.12.0_pre17.

The problem is that I have a following module config option:

options ipw2200 disable=1

Which means that my wlan interface starts up with the transmitter down (equal to iwconfig wlan txpower off). I don't want my computer to start broadcasting on WLAN unless I excplicitly enable it (via Fn-F5), since I may be turning the laptop on anywhere..

If I start up with new baselayout, net.wlan is started up at boot (even though I don't even have net.wlan on any runlevel!). The ntpd, sshd and other net-dependant services still only list "will start up when net.lan is started". 

If I remove the "disable=1" option everything works ok, but my WLAN interface starts screaming for access point that may or may not be there.

Proposed change (haven't tested yet):

In iwconfig.sh, change the return code to 0 so that the interface configuration is considered a success, even though in a "null" config sort of way.

        # Check for rf_kill - only ipw supports this at present, but other
        # cards may in the future.
        if [[ -e "/sys/class/net/${iface}/device/rf_kill" ]]; then
                if [[ $( < "/sys/class/net/${iface}/device/rf_kill" ) != 0 ]]; t
hen
                        eerror "Wireless radio has been killed for interface ${i
face}"
                        return 1
                fi
        fi
Comment 5 Antti Mäkelä 2006-04-09 23:45:35 UTC
Oops, that simple change was not enough - result is that the wlan interface attempts to run DHCP even with radio disabled :(
Comment 6 Roy Marples (RETIRED) gentoo-dev 2006-04-10 00:52:49 UTC
(In reply to comment #4)
> If I start up with new baselayout, net.wlan is started up at boot (even though
> I don't even have net.wlan on any runlevel!).

Nothing todo with this bug.

Bug #129331 has a patch to solve this.
Comment 7 Antti Mäkelä 2006-04-10 01:05:41 UTC
Applied the coldplug_rc patch and set coldplug_rc to "no". There is no more attempt to start up net.wlan, but now the message is back to "ntpd will start when net.lan is started", no mention of net.wlan. 

Comment 8 Antti Mäkelä 2006-04-10 01:08:43 UTC
I could get this to work by patching runscript.sh and hardcoding in "net.wlan" to "startinactive", but I wouldn't exactly call this elegant.
Comment 9 Roy Marples (RETIRED) gentoo-dev 2006-04-10 04:35:38 UTC
(In reply to comment #7)
> Applied the coldplug_rc patch and set coldplug_rc to "no". There is no more
> attempt to start up net.wlan, but now the message is back to "ntpd will start
> when net.lan is started", no mention of net.wlan. 
> 

That is correct. How is ntp supposed to know it's can start when net.wlan starts if net.wlan isn't in your runlevel OR started by coldplug?
Comment 10 Antti Mäkelä 2006-04-10 04:39:37 UTC
(In reply to comment #9)
> That is correct. How is ntp supposed to know it's can start when net.wlan
> starts if net.wlan isn't in your runlevel OR started by coldplug?

  By the fact that /etc/init.d/net.X exists?

  This also applies to net.pppX and similar ones that may not be brought up at boot time (for example, a modem or mobile phone connection). They don't exist in any runlevel, but will probably be manually brought up by the user at some time during normal operation.

  If the simple existence of net.X cannot be considered, maybe some explicit list 'NET_INTERFACES_TO_CONSIDER="lan wlan ppp0 pan0"' would work.
Comment 11 Roy Marples (RETIRED) gentoo-dev 2006-04-10 04:48:18 UTC
(In reply to comment #10)
> By the fact that /etc/init.d/net.X exists?

Sorry, that's not going to fly.
If you require services to start off specific net services then alter the init scripts for this dependency OR do something like this in conf.d/net

postup() {
   [[ ${IFACE} == "wlan" ]] && /etc/init.d/ntpd start
}

predown() {
   [[ ${IFACE} == "wlan" ]] && /etc/init.d/ntpd stop
}

OR you can file a bug asking for conf.d files to append dependency information to the init script so you could do this in conf.d/ntpd

depend() {
   need net.wlan
}
Comment 12 Antti Mäkelä 2006-04-10 04:59:03 UTC
(In reply to comment #11)
> (In reply to comment #10)
> > By the fact that /etc/init.d/net.X exists?
> If you require services to start off specific net services then alter the init
> scripts for this dependency OR do something like this in conf.d/net
> 
> postup() {
>    [[ ${IFACE} == "wlan" ]] && /etc/init.d/ntpd start
> }
> 
> predown() {
>    [[ ${IFACE} == "wlan" ]] && /etc/init.d/ntpd stop
> }

  This does not work (not without some modifying) because it then shuts down ntpd in the situation where multiple interfaces are up and only wlan is taken down (but NET in general is up). 

> OR you can file a bug asking for conf.d files to append dependency information
> to the init script so you could do this in conf.d/ntpd
> 
> depend() {
>    need net.wlan
> }

  Do the depend() atoms support OR logical operators? Ie. 

depend () {
    need net.lan || net.wlan || net.ppp0
}

  Which would cause ntpd to go up when ANY of the interfaces goes up (via rc or otherwise).

  Oh well, I'll do some testing..
Comment 13 Antti Mäkelä 2006-04-11 08:49:01 UTC
(In reply to comment #11)
> (In reply to comment #10)
> > By the fact that /etc/init.d/net.X exists?
> 
> Sorry, that's not going to fly.

  Ok, since I have no real bash scripting experience and couldn't really start disassembling the entire rc structure, I settled for the postup() functions that check if lan OR wlan is up and activate ntpd and sshd based on that.

  Still, one last argument came to mind why some sort of additional way of telling the system about "potential" network interfaces should be in place - hotpluggable network interfaces. If I plug in a PCMCIA NIC, or USB NIC during runtime (and remove them just as well), I can hardly have those start up during bootup at any runlevel. Especially in the case of laptop environment where I rather suspend/hibernate than shutdown when I go to another site.

  Oh well..thanks anyway.