Hi Martin,
On Wed, Dec 14, 2022 at 11:52:08AM +0100, Martin Pitt wrote:
Hello Coiby,
thanks for the fix!
Coiby Xu [2022-12-14 14:48 +0800]:
> diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> index 13e99015..f82349cb 100755
> --- a/dracut-module-setup.sh
> +++ b/dracut-module-setup.sh
> @@ -387,6 +387,7 @@ kdump_install_nic_driver() {
> _drivers=()
>
> for _netif in $1; do
> + ! ip addr show "$_netif" | grep "link/loopback" ||
continue
I confirm that this works, in the sense of "kdump to ssh localhost succeeds
again".
Thanks for reviewing the patch!
But it is a bit heavy (calling `ip` and `grep`) and brittle (relying on precise
output format of `ip show`, which isn't very machine-readable).
Thanks for raising the above concerns! To find a simpler solution, I
checked linux/drivers/net/loopback.c and find there is only one loopback
interface and the name always "lo". So the following code would be
sufficient,
[ $_netif != lo ] || continue
Btw, ip and grep are used quite often in kexec-tools. I'm curious in
what way do you feel they are heavy? In fact, the cost of ip and grep
is negligible compared with the cost of calling dracut to build
initramfs.
I'm also
worried that this might apply to other virtual devices as well, such as veth or
wireguard. My laptop has a wireguard device which might also cause trouble:
$ ip link show wgpitti
4: wgpitti: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN
mode DEFAULT group default qlen 1000
link/none
$ ls -l /sys/class/net/wgpitti/device
ls: cannot access '/sys/class/net/wgpitti/device': No such file or directory
Hence I would recommend this instead:
[ -e "/sys/class/net/$_netif/device/driver" ] || continue
and rename the commit to "skip installing driver for virtual devices" or so.
I tested this with ssh/localhost as well. It has the added benefit of not
relying on "ip show" format, is more robust, more generic, and not even a new
concept: that script already looks at /sys/class/net anyway.
Unfortunately what you propose won't work.
1. kexec-tools wants to only install needed drivers to save memory and
it's this dracut module's job to install needed drivers which may
include the drivers of virtual devices e.g. bond, team or vlan device
as well i.e. no one else will install these drivers.
2. ethtool talks to the driver via the netlink interface [1]. It doesn't
use /sys/class/net/$_netif/device/driver to get the driver info.
[1]
https://www.kernel.org/doc/html/v5.8/networking/ethtool-netlink.html
> _driver=$(_get_nic_driver "$_netif")
> if [[ -z $_driver ]]; then
> derror "Failed to get the driver of $_netif"
> @@ -404,6 +405,7 @@ kdump_install_nic_driver() {
> _drivers+=("$_driver")
> done
>
> + [[ -n ${_drivers[*]} ]] || return
This is fine of course.
Thanks for the confirmation!
> instmods "${_drivers[@]}"
> }
Thanks,
Martin
--
Best regards,
Coiby