]> git.ipfire.org Git - thirdparty/kmod.git/commit
libkmod: add weak dependecies master
authorJose Ignacio Tornos Martinez <jtornosm@redhat.com>
Wed, 27 Mar 2024 14:11:16 +0000 (15:11 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Thu, 9 May 2024 04:37:38 +0000 (23:37 -0500)
commit05828b4a6e9327a63ef94df544a042b5e9ce4fe7
tree9834a6dc6e47ff86e91f78557e1caa4e264976e2
parent5a8b16b7189d5a2b99bfd536962a36e390dd124f
libkmod: add weak dependecies

It has been seen that for some network mac drivers (i.e. lan78xx) the
related module for the phy is loaded dynamically depending on the current
hardware. In this case, the associated phy is read using mdio bus and then
the associated phy module is loaded during runtime (kernel function
phy_request_driver_module). However, no software dependency is defined, so
the user tools will no be able to get this dependency. For example, if
dracut is used and the hardware is present, lan78xx will be included but no
phy module will be added, and in the next restart the device will not work
from boot because no related phy will be found during initramfs stage.

In order to solve this, we could define a normal 'pre' software dependency
in lan78xx module with all the possible phy modules (there may be some),
but proceeding in that way, all the possible phy modules would be loaded
while only one is necessary.

The idea is to create a new type of dependency, that we are going to call
'weak' to be used only by the user tools that need to detect this situation.
In that way, for example, dracut could check the 'weak' dependency of the
modules involved in order to install these dependencies in initramfs too.
That is, for the commented lan78xx module, defining the 'weak' dependency
with the possible phy modules list, only the necessary phy would be loaded
on demand keeping the same behavior, but all the possible phy modules would
be available from initramfs.

A new function 'kmod_module_get_weakdeps' in libkmod will be added for
this to avoid breaking the API and maintain backward compatibility. This
general procedure could be useful for other similar cases (not only for
dynamic phy loading).

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
Link: https://lore.kernel.org/r/20240327141116.97587-1-jtornosm@redhat.com
libkmod/docs/libkmod-sections.txt
libkmod/libkmod-config.c
libkmod/libkmod-internal.h
libkmod/libkmod-module.c
libkmod/libkmod.h
libkmod/libkmod.sym
man/modprobe.d.5.xml
tools/depmod.c
tools/modprobe.c