Hello Coiby,
Coiby Xu [2022-12-15 18:46 +0800]:
Hi Martin,
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
Sure, that looks nice and clean, especially if you *don't* want to apply this
to other virtual devices.
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.
It's ok, I just generally try to avoid grepping text meant for human
consumption (this might even be translated!), and avoiding calling two programs
and a shell when a shell builtin and proper API is available.
> 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.
Right, I just meant that it might crash the same way for other virtual devices
like veth or wireguard. I didn't test this.
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.
Ack, if that's what the dracut function uses, that sounds fine.
So in summary, your `[ $_netif != lo ]` looks preferable to me (simpler, more
obvious, and much more robust), and it seems you ruled out my generalized
patch, so it seems we have a winner?
Cheers!
Martin