Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 118419 - [baselayout] Network scripts are started before the initialization (boot) phase is finished
Summary: [baselayout] Network scripts are started before the initialization (boot) pha...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-09 08:32 UTC by Oldrich Jedlicka
Modified: 2006-01-24 10:38 UTC (History)
2 users (show)

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


Attachments
Sleep init scripts until sysinit has completed (hotplug.patch,1.99 KB, patch)
2006-01-17 08:17 UTC, Roy Marples (RETIRED)
Details | Diff
Fixed hotplug patch for netlink (hotplug-2.patch,2.29 KB, patch)
2006-01-17 09:14 UTC, Oldrich Jedlicka
Details | Diff
Lock init scripts from running when /dev/.rcsysinit exists (baselayout-sysinit.patch,1.12 KB, patch)
2006-01-19 11:38 UTC, Roy Marples (RETIRED)
Details | Diff
udev creates /dev/.rcsysinit for locking (udev-sysinit.patch,482 bytes, patch)
2006-01-19 11:40 UTC, Roy Marples (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oldrich Jedlicka 2006-01-09 08:32:21 UTC
There is one problem with loading modules in modules.autoload.d - when the networking card is loaded, the hotplug agent catches this and tries to start the script. 

The major trouble here is that during the boot-up process the services are not marked as started, so the networking service tries to start everything from the beginning in the background - starts also the script 'Mounting root filesystem read-only' and so on! This is not good, the boot-up process can even freeze (happened to me if I added some dependencies to net.eth0).

I was thinking about some master execution plan thing, which is created every time something is going to be started. And if something wants to start and the master execution plan is already existing, it has to consult the execution with the master plan.

To implement such thing there has to be a locking functionality - see bug #118418 for implementation (in BASH).
Comment 1 Roy Marples (RETIRED) gentoo-dev 2006-01-09 08:57:26 UTC
Don't put network card modules in there then - use coldplug to load them.
Comment 2 Greg Kroah-Hartman (RETIRED) gentoo-dev 2006-01-09 09:11:55 UTC
Ick, don't use coldplug, that will load them even earlier, right?

And I'm trying to get rid of it (udev will do coldplug for you if you uncomment
out one line in the udev startup logic, much faster than the coldplug package
and works better...)
Comment 3 Oldrich Jedlicka 2006-01-09 09:19:26 UTC
I'm using coldplug, but I'm not happy with it. I also missed a BIG FAT WARNING somewhere. It would be nice to place the warning somewhere visible (and force people to use coldplug...).

I think there should be some more clever solution, not only say "use something else" - there is surely somebody, who doesn't want to use coldplug (for whatever reason). Coldplug is not an universal solution, so why to disallow to load network modules manually during the system boot-up?

Give me a reasonable answer and I will sleep better :-)
Comment 4 Roy Marples (RETIRED) gentoo-dev 2006-01-09 09:26:40 UTC
(In reply to comment #2)
> Ick, don't use coldplug, that will load them even earlier, right?
> 

Wrong.
modules is a CRITICAL_SERVICE is normally run early in the boot sequence so it loads disk drivers, etc so it can mount /var/lib rw

coldplug is not and depends on modules so it runs afterwards - and /var/lib is mounted rw at this point.

> And I'm trying to get rid of it (udev will do coldplug for you if you uncomment
> out one line in the udev startup logic, much faster than the coldplug package
> and works better...)
> 

As long as we can tell udev to "go" via an init script or the udev-startup scripts after /var/lib is mounted rw then I'm happy :)
Comment 5 Roy Marples (RETIRED) gentoo-dev 2006-01-09 09:32:58 UTC
Infact a quick look through the source shows that the commented line in trigger_events for the "real coldplug" shows that it would happen far far too early in the boot process.

imo, nothing should be triggered like this until after RC critical services have been started. Hence coldplug is doing just fine.
Comment 6 Roy Marples (RETIRED) gentoo-dev 2006-01-09 14:40:51 UTC
(In reply to comment #3)
> I'm using coldplug, but I'm not happy with it. I also missed a BIG FAT WARNING
> somewhere. It would be nice to place the warning somewhere visible (and force
> people to use coldplug...).

We shouldn't force people to use coldplug.
However, there's nothing wrong with a big fat warning either :)
I'll slap a warning into /etc/modules.autoload.d/kernel* telling them not to use this for loading network modules if they have hotplug or udev installed.
Comment 7 Craig 2006-01-13 17:35:16 UTC
> We shouldn't force people to use coldplug.
> However, there's nothing wrong with a big fat warning either :)
> I'll slap a warning into /etc/modules.autoload.d/kernel* telling them not to
> use this for loading network modules if they have hotplug or udev installed.

That "big fat warning" came through today and it reads:

# This file should only be used to load modules that are essential to the
# mounting of local partitions, such as RAID controllers.
# Coldplug or similar should be used to load the rest of the modules
# for your hardware automatically.
#
# WARNING: It is dangerous to put modules here which will cause hotplug to
# start services, for example network driver modules.

The wording in the first paragraph is misleading. I had nvidia, subfs and bc modules which this warning suggests should not be loaded in the autoload file. Ater removing these three modules as suggested and rebooting they were not reloaded. After putting them back in I could reboot and everything worked again.

I suggest the warning is reworded to only mention network cards specifically. Not a global "remove everything but raid" .
Comment 8 Roy Marples (RETIRED) gentoo-dev 2006-01-15 08:36:56 UTC
I've removed the first paragraph and changed the second one to read

# WARNING: It is dangerous to put modules here which will cause hotplug to
# start services, for example network driver modules.
# For network modules it is advisable to use coldplug to load your modules.
# You can do this by emerging coldplug and adding coldplug do the boot runlevel
# using rc-update. See bug #118419 for why this is.

Comment 9 Roy Marples (RETIRED) gentoo-dev 2006-01-15 23:08:02 UTC
Fixed in -r2
Comment 10 Volker Hemmann 2006-01-16 19:30:06 UTC
Hi,

could you please tell, WHICH modules might start services?

And btw, up until this moment, I loaded my networking modules with autoload and had no problems, but the one time I used coldplug everything was in a great mess.
Granted ,that was a long time ago, but I do not want to use any service that I could skip. 
Gentoo's booting became more and more time consuming over the years, and I hate waiting for the scripts (if I liked watching my box booting for ages, I could happily use SuSE).

Also,  IMHO, if hotplug starts services just based on loaded modules, hotplug is broken and should be fixed and not the user forced to add another boot service that could be skipped savely otherwise.

I have lots and lots of modules, which I only need occasionally,. Why do I want coldplug loading all of them, if I can load only the ones I want and need all the time with autoload, and load the ones I need less than once in a month when I need them with modprobe?
Comment 11 Oldrich Jedlicka 2006-01-17 00:42:27 UTC
Yes, I agree. Until now nobody offers really fix the problem - postpone module loading until the core system is completely up (only the CRITICAL_SERVICES in /sbin/rc).
Comment 12 Roy Marples (RETIRED) gentoo-dev 2006-01-17 08:15:06 UTC
(In reply to comment #11)
> Yes, I agree. Until now nobody offers really fix the problem - postpone module
> loading until the core system is completely up (only the CRITICAL_SERVICES in
> /sbin/rc).
> 

You see that's the problem - modules IS a CRITICAL_SERVICE .... it may be needed for things like localmount and other CRITICAL_SERVICEs.
Comment 13 Roy Marples (RETIRED) gentoo-dev 2006-01-17 08:17:53 UTC
Created attachment 77355 [details, diff]
Sleep init scripts until sysinit has completed

Attached is a patch that causes init scripts to sleep when /proc/sys/kernel/hotplug exists and is set to /dev/null,/bin/true or /bin/false - ie not a valid hotplug agent.

When it's set back to a valid hotplug agent then the init script is woken up.

Please test this against baselayout-1.12.0_pre14-r2
Comment 14 Oldrich Jedlicka 2006-01-17 09:14:13 UTC
Created attachment 77359 [details, diff]
Fixed hotplug patch for netlink

Patch against baselayout-1.12.0_pre14-r2

Fixes the problem with netlink: /lib/rcscripts/addons/udev-start.sh sets the hotplug agent to ""

  echo "" > /proc/sys/kernel/hotplug

so the restoring of the agent stops working.
Comment 15 Oldrich Jedlicka 2006-01-17 09:17:11 UTC
(In reply to comment #12)
> You see that's the problem - modules IS a CRITICAL_SERVICE .... it may be
> needed for things like localmount and other CRITICAL_SERVICEs.
> 
I had in mind postponing of the hotplug effect. And the real fix was introduced in comment #13 and fixed a little bit in comment #14 :-)
Comment 16 Roy Marples (RETIRED) gentoo-dev 2006-01-17 09:31:21 UTC
Does it fix your issue?
Comment 17 Oldrich Jedlicka 2006-01-17 10:36:44 UTC
Any yes, your patch with my update fixes this issue completely :-)
Comment 18 Greg Kroah-Hartman (RETIRED) gentoo-dev 2006-01-17 11:17:45 UTC
please do NOT mess with /proc/sys/kernel/hotplug, it is set to NULL for a 
good reason.

If you mess with it, after the udev startup script has modified it to be 
what it knows to be the proper program (or not), things can get very messed
up.

For newer udev versions, on the 2.6.15 kernel, we use netlink to get the 
messages, and udev fires off the proper old-style hotplug events when needed.
That is why that file is set to NULL.

I'm working with uberlord to get the proper resolution here.
Comment 19 Oldrich Jedlicka 2006-01-18 02:26:05 UTC
(In reply to comment #18)
> For newer udev versions, on the 2.6.15 kernel, we use netlink to get the 
> messages, and udev fires off the proper old-style hotplug events when needed.
> That is why that file is set to NULL.

Ok, I do not know problems of hotplugging. I have suspend2-sources-2.6.15-*. At least patch from uberlord introduced a lock that was needed: hotplug events still started my network scripts immediately after modules were loaded, but they were put into sleep until the hotplug agent changed back from /bin/false into NULL. At least it works (somehow) on 2.6.15.
Comment 20 Roy Marples (RETIRED) gentoo-dev 2006-01-19 11:38:49 UTC
Created attachment 77568 [details, diff]
Lock init scripts from running when /dev/.rcsysinit exists
Comment 21 Roy Marples (RETIRED) gentoo-dev 2006-01-19 11:40:05 UTC
Created attachment 77569 [details, diff]
udev creates /dev/.rcsysinit for locking

This is a needed patch to the udev addon scripts to create the lock
Comment 22 Oldrich Jedlicka 2006-01-19 12:45:36 UTC
Thanks, that works. Events are not postponed, they are ignored.

I think it would be better to stop execution of script before mylevel is taken from {svcdir}/softlevel (in runscript.sh on line 27) as the file softlevel doesn't exist - it generates an error (my modified net.agent writes output to console). I mean to put the check just after the check for EUID in runscript.sh.
Comment 23 Roy Marples (RETIRED) gentoo-dev 2006-01-20 02:50:18 UTC
baselayout-1.11.14-r2 and baselayout-1.12.0_pre15 have the patches in portage.

Awaiting on udev to be fixed in portage.
Comment 24 Roy Marples (RETIRED) gentoo-dev 2006-01-21 04:32:28 UTC
udev-079-r1 and udev-081-r1 have the fixes in portage.
Comment 25 Oldrich Jedlicka 2006-01-24 10:38:00 UTC
Thanks for very nice solution of this problem.