[systemd-devel] Recommendation for "systemd.module" unit

Larry Baker baker at usgs.gov
Thu Jan 24 16:18:54 PST 2013


Lennart,

There's more to it than that.  The DECnet kernel module must first be loaded so that it creates /proc/net/decnet*.  When the dnetd service is started, it parses /etc/decnet.conf and writes the DECnet host address to /proc/sys/net/decnet/node_address and the default DECnet device (interface) to /proc/sys/net/decnet/default_device.  The MAC address of all the DECnet interfaces has to be changed to a special multicast address.  This all usually must be done before IP networking is started.  I am not sure that a socket can be opened before networking is up.

Larry Baker
US Geological Survey
650-329-5608
baker at usgs.gov



On 24 Jan 2013, at 4:03 PM, Lennart Poettering wrote:

> On Thu, 24.01.13 14:08, Larry Baker (baker at usgs.gov) wrote:
> 
>> I am converting the init script (see below) for Linux DECnet (http://sourceforge.net/projects/linux-decnet).  This is my first exposure to systemd.  Naturally, my first try failed.  So, now I am taking baby steps.
>> 
>> The Linux DECnet init script can start either or both the dnetd or
>> phoned daemons.  (I do not use the phoned daemon.)  I think the best
>> thing to do with smartd is make them separate service units.  I will
>> create /etc/systemd/system/dnetd.service and .../phoned.service.
>> 
>> Prior to starting the daemons, the init script verifies the
>> /etc/decnet.conf configuration file exists.  I will use the [Unit]
>> option ConditionFileNotEmpty=/etc/decnet.conf to replicate that
>> behavior.
>> 
>> Then it looks for evidence that the decnet kernel module is loaded by
>> testing for the file /proc/net/decnet.  If necessary, it loads the
>> decnet kernel module and checks again for /proc/net/decnet.  I have
>> already built the decnet kernel module and I can load it with
>> modprobe.  I do not wish to force an unconditional load of the decnet
>> kernel module using /etc/modules-load.d/decnet.conf; I prefer the
>> services that need it (dnetd and phoned) trigger the load.  However, I
>> find no mention of the standard systemd "load a kernel module"
>> practice.  I.e., there is no "systemd.module" unit.  What is the
>> recommended method in the systemd framework to trigger a unit that
>> loads a kernel module?  If the modprobe command fails, I presume that
>> will cause the systemd start command to fail.  I would also like the
>> systemd start command to fail if /proc/net/decnet is not created (a
>> sign that the module has not initialized itself correctly).  Is there
>> a syntax in a systemd unit for that as well?
> 
> Usually the best way to handle this is to make the module auto-loadable
> by the kernel, which makes the whole thing entirely transparent to
> userspace. The first process using a DECNET socket would implicitly load
> the module, just by invoking socket() and the kernel would do the rest.
> 
> This is usually done via MODALIAS strings for "net-pf-xyz" in the kernel
> modules. If the decnet module currently doesn't support this it should
> be a single line change.
> 
> Currently, many other protocol families that are implemented in kernel
> modules already do that, including bluetooth, atm, irda, nfc. For a
> precise list, see:
> 
> grep net-pf /lib/modules/`uname -r`/modules.alias
> 
> You have a good chance that adding that one MODALIAS name to your kernel
> module will already allow you to drop any explicit modprobes from your
> init scripts/units.
> 
> A temporary hack to achieve the same is by adding an "alias" line to
> /etc/modprobe.d/ for the same mapping. That said, ultimately this really
> should be fixed in the kernel.
> 
> Lennart
> 
> -- 
> Lennart Poettering - Red Hat, Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20130124/a5f6b1dd/attachment.html>


More information about the systemd-devel mailing list