Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jan 2023 17:30:49 +0000
From:      Alexander Chernikov <melifaro@freebsd.org>
To:        Gleb Smirnoff <glebius@FreeBSD.org>
Cc:        Alan Somers <asomers@freebsd.org>, "Danilo G. Baio" <dbaio@freebsd.org>, dev-commits-src-all@freebsd.org
Subject:   Re: git: 2c24ad3377a6 - main - ifconfig: abort if loading a module fails other than for ENOENT
Message-ID:  <CCEE62A0-2AD9-4CA3-B773-0B9DEF7C4163@freebsd.org>
In-Reply-To: <Y8rF/IkQwllzGVhJ@cell.glebi.us>
References:  <202301091857.309Iv87L068285@gitrepo.freebsd.org> <2f4e4ccf-b19a-4f8f-a9e0-72298e500d7c@app.fastmail.com> <CAOtMX2hv182P2HTAPkbYDZiwNxkV2-C%2BWp2%2BL0SpfDpqn2Zccw@mail.gmail.com> <1E9FAE83-B5C2-4E1F-8D04-CF4F477F76C7@freebsd.org> <Y8rF/IkQwllzGVhJ@cell.glebi.us>

next in thread | previous in thread | raw e-mail | index | archive | help

> On 20 Jan 2023, at 16:49, Gleb Smirnoff <glebius@FreeBSD.org> wrote:
>=20
> 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=E2=80=99m considering adding such code for the netlink-based =
interface creation.
>=20
> 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).
Partially I agree.
Let me try to rephrase it. The intent is to create a network interface =
and it is implemented using SIOCIFCREATE[2] and, potentially, =
kldload(2).
As the idea behind many ioctl=E2=80=99s is to do a single thing at a =
time, coupling it with kldload may indeed not look pretty.
For Netlink, it=E2=80=99s different - it=E2=80=99s meant to be a broker =
and provide a higher-level interfaces. You can ask it to create an =
interface, set its flags, description, fib, mtu and so on via a single =
request.

>=20
> 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
For example, if one decide to enhance `SIOCIFCREATE`, it can be done =
somewhere around `if_clone_create()`. No locks are held in `ifioctl()` =
that handles it. Also, we=E2=80=99re in the sys call and can sleep.
For Netlink, - probably in the netlink =
sys/netlink/route/iface.c:create_link before using the generic cloner. =
Netlink handlers run in dedicated taskques and can sleep as well.

> will take a very different set of locks, possibly creating a LOR,
> and in an edge case will go into NFS taking network locks.
>=20
> --=20
> Gleb Smirnoff




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CCEE62A0-2AD9-4CA3-B773-0B9DEF7C4163>