Re: git: 2c24ad3377a6 - main - ifconfig: abort if loading a module fails other than for ENOENT

From: Alan Somers <asomers_at_freebsd.org>
Date: Fri, 20 Jan 2023 17:12:52 UTC
On Fri, Jan 20, 2023 at 9:49 AM Gleb Smirnoff <glebius@freebsd.org> wrote:
>
> On Fri, Jan 20, 2023 at 11:04:33AM +0000, Alexander Chernikov wrote:
> A> I think another question is that if if should be done by ifconfig(8) at all. Kernel can take care of trying to load the required modules, checking the privileges.
> A> I’m considering adding such code for the netlink-based interface creation.
>
> This is already done in netgraph, but I won't call this solution a
> pretty one. You ask kernel to do some network related ioctl(2), but
> it actually does kldload(2).
>
> At what stage of the syscall we understand that kldload(2) needs to
> be done? Are we free of network locks at this stage? Cause kldload
> will take a very different set of locks, possibly creating a LOR,
> and in an edge case will go into NFS taking network locks.
>
> --
> Gleb Smirnoff

ifconfig tries to load a KLD preemptively, long before it does the
hard work (cloning an interface or something).  Trying to teach the
kernel to load the module on-demand would be hard, we would probably
have to do it in many different places.