On Thu, Dec 15, 2022 at 05:32:02PM +0100, Martin Pitt wrote:
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.
Thanks for the explanation! Yeah, I also prefer to avoid parsing text
using grep/sed if possible. In fact, one motivation behind the recent
network changes is also to avoid parsing NetworkManager connection
profiles.
> > 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.
Thanks for the clarification! I just checked veth has the API for
ethtool to get driver info but this is not case for wireguard. Note even
if ethtool can get driver info for wireguard, kexec-tools doesn't
support wireguard as it depends on dracut to install the necessary
binary's like the ones in wireguard-tools.
This discussion makes me realize ethtool may not be robust as I have
expected and it also inspires me to do an exhaustive test on how many
drivers supports ethtool by iterating all network drivers. So thank you!
> 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?
Glad to know that:)
Cheers!
Martin
--
Best regards,
Coiby