2022-05-23 06:33:05

by Andrew Lunn

[permalink] [raw]
Subject: Re: RFC: Ioctl v2

> I want to circulate this and get some comments and feedback, and if
> no one raises any serious objections - I'd love to get collaborators
> to work on this with me. Flame away!

Hi Kent

I doubt you will get much interest from netdev. netdev already
considers ioctl as legacy, and mostly uses netlink and a message
passing structure, which is easy to extend in a backwards compatible
manor.

https://man7.org/linux/man-pages/man7/netlink.7.html

Andrew


2022-05-23 07:26:22

by Kent Overstreet

[permalink] [raw]
Subject: Re: RFC: Ioctl v2

On Fri, May 20, 2022 at 10:31:02PM +0200, Andrew Lunn wrote:
> > I want to circulate this and get some comments and feedback, and if
> > no one raises any serious objections - I'd love to get collaborators
> > to work on this with me. Flame away!
>
> Hi Kent
>
> I doubt you will get much interest from netdev. netdev already
> considers ioctl as legacy, and mostly uses netlink and a message
> passing structure, which is easy to extend in a backwards compatible
> manor.

The more I look at netlink the more I wonder what on earth it's targeted at or
was trying to solve. It must exist for a reason, but I've written a few ioctls
myself and I can't fathom a situation where I'd actually want any of the stuff
netlink provides.

Why bother with getting a special socket type? Why asynchronous messages with
all the marshalling/unmarshalling that entails?

From what I've seen all we really want is driver private syscalls, and the
things about ioctls that suck are where it's _not_ like syscalls. Let's just
make it work more like normal function calls.

2022-05-23 07:42:11

by Andrew Lunn

[permalink] [raw]
Subject: Re: RFC: Ioctl v2

On Sat, May 21, 2022 at 12:45:46PM -0400, Kent Overstreet wrote:
> On Fri, May 20, 2022 at 10:31:02PM +0200, Andrew Lunn wrote:
> > > I want to circulate this and get some comments and feedback, and if
> > > no one raises any serious objections - I'd love to get collaborators
> > > to work on this with me. Flame away!
> >
> > Hi Kent
> >
> > I doubt you will get much interest from netdev. netdev already
> > considers ioctl as legacy, and mostly uses netlink and a message
> > passing structure, which is easy to extend in a backwards compatible
> > manor.
>
> The more I look at netlink the more I wonder what on earth it's targeted at or
> was trying to solve. It must exist for a reason, but I've written a few ioctls
> myself and I can't fathom a situation where I'd actually want any of the stuff
> netlink provides.
>
> Why bother with getting a special socket type? Why asynchronous messages with
> all the marshalling/unmarshalling that entails?

Hi Kent

It has its uses, but my main point was, it is unlikely netdev will buy
into anything else.

> >From what I've seen all we really want is driver private syscalls

netdev is actually very opposed to private syscalls. Given the chance,
each driver will define its own vendor specific APIs, there will be
zero interoperability, you need vendor tools, the documentation will
be missing etc. So netdev tries very hard to have well defined APIs
which are vendor neutral to cover anything a driver, or the network
stack, wants to do.

Andrew

2022-05-23 08:09:58

by Stephen Hemminger

[permalink] [raw]
Subject: Re: RFC: Ioctl v2

On Sat, 21 May 2022 12:45:46 -0400
Kent Overstreet <[email protected]> wrote:

> On Fri, May 20, 2022 at 10:31:02PM +0200, Andrew Lunn wrote:
> > > I want to circulate this and get some comments and feedback, and if
> > > no one raises any serious objections - I'd love to get collaborators
> > > to work on this with me. Flame away!
> >
> > Hi Kent
> >
> > I doubt you will get much interest from netdev. netdev already
> > considers ioctl as legacy, and mostly uses netlink and a message
> > passing structure, which is easy to extend in a backwards compatible
> > manor.
>
> The more I look at netlink the more I wonder what on earth it's targeted at or
> was trying to solve. It must exist for a reason, but I've written a few ioctls
> myself and I can't fathom a situation where I'd actually want any of the stuff
> netlink provides.

Netlink was built for networking operations, you want to set something like a route with a large
number of varying parameters in one transaction. And you don't want to have to invent
a new system call every time a new option is added.

Also, you want to monitor changes and see these events for a userspace control
application such as a routing daemon.


2022-05-26 12:33:31

by Kent Overstreet

[permalink] [raw]
Subject: Re: RFC: Ioctl v2

On Sat, May 21, 2022 at 12:45:59PM -0700, Stephen Hemminger wrote:
> On Sat, 21 May 2022 12:45:46 -0400
> Kent Overstreet <[email protected]> wrote:
>
> > On Fri, May 20, 2022 at 10:31:02PM +0200, Andrew Lunn wrote:
> > > > I want to circulate this and get some comments and feedback, and if
> > > > no one raises any serious objections - I'd love to get collaborators
> > > > to work on this with me. Flame away!
> > >
> > > Hi Kent
> > >
> > > I doubt you will get much interest from netdev. netdev already
> > > considers ioctl as legacy, and mostly uses netlink and a message
> > > passing structure, which is easy to extend in a backwards compatible
> > > manor.
> >
> > The more I look at netlink the more I wonder what on earth it's targeted at or
> > was trying to solve. It must exist for a reason, but I've written a few ioctls
> > myself and I can't fathom a situation where I'd actually want any of the stuff
> > netlink provides.
>
> Netlink was built for networking operations, you want to set something like a route with a large
> number of varying parameters in one transaction. And you don't want to have to invent
> a new system call every time a new option is added.
>
> Also, you want to monitor changes and see these events for a userspace control
> application such as a routing daemon.

That makes sense - perhaps the new mount API could've been done as a netlink
interface :)

But perhaps it makes sense to have both - netlink for the big complicated
stateful operations, ioctl v2 for the simpler ones. I haven't looked at netlink
usage at all, but most of the filesystem ioctls I've looked at fall into the the
simple bucket, for me.

Actually, I have one in bcachefs that might fit better into the netlink bucket -
maybe while I've got your attention you could tell me what this is like in
netlink land.

In bcachefs, we have "data jobs", where userspace asks us to do something that
requires walking data and performing some operation on them - this is used for
manual rebalance, evacuating data off a device, scrub (when that gets
implemented), etc.

The way I did this was with an ioctl that takes as a parameter the job to
perform, then it kicks off a kernel thread to do the work and returns a file
descriptor, which userspace reads from to find out the current status of the job
(which it uses to implement a progress indicator). We kill off the kthread if
the file descriptor is closed, meaning ctrl-c works as expected.

I really like how this turned out, it's not much code and super slick - I was
considering abstracting it out as generic functionality. But this definitely
sounds like what netlink is targeted at - thoughts?

2022-06-01 20:09:36

by Leon Romanovsky

[permalink] [raw]
Subject: Re: RFC: Ioctl v2

On Wed, May 25, 2022 at 01:02:33PM -0400, Kent Overstreet wrote:
> On Sat, May 21, 2022 at 12:45:59PM -0700, Stephen Hemminger wrote:
> > On Sat, 21 May 2022 12:45:46 -0400
> > Kent Overstreet <[email protected]> wrote:
> >
> > > On Fri, May 20, 2022 at 10:31:02PM +0200, Andrew Lunn wrote:
> > > > > I want to circulate this and get some comments and feedback, and if
> > > > > no one raises any serious objections - I'd love to get collaborators
> > > > > to work on this with me. Flame away!
> > > >
> > > > Hi Kent
> > > >
> > > > I doubt you will get much interest from netdev. netdev already
> > > > considers ioctl as legacy, and mostly uses netlink and a message
> > > > passing structure, which is easy to extend in a backwards compatible
> > > > manor.
> > >
> > > The more I look at netlink the more I wonder what on earth it's targeted at or
> > > was trying to solve. It must exist for a reason, but I've written a few ioctls
> > > myself and I can't fathom a situation where I'd actually want any of the stuff
> > > netlink provides.
> >
> > Netlink was built for networking operations, you want to set something like a route with a large
> > number of varying parameters in one transaction. And you don't want to have to invent
> > a new system call every time a new option is added.
> >
> > Also, you want to monitor changes and see these events for a userspace control
> > application such as a routing daemon.
>
> That makes sense - perhaps the new mount API could've been done as a netlink
> interface :)
>
> But perhaps it makes sense to have both - netlink for the big complicated
> stateful operations, ioctl v2 for the simpler ones. I haven't looked at netlink
> usage at all, but most of the filesystem ioctls I've looked at fall into the the
> simple bucket, for me.

In RDMA, we solved this thing (standard entry points, multiple
parameters and vendor specific data) by combining netlink and ioctls.

The entry point is done with ioctls (mainly performance reason, but not
only) while data is passed in netlink attributes style.

ib_uverbs_ioctl:
https://elixir.bootlin.com/linux/v5.18/source/drivers/infiniband/core/uverbs_ioctl.c#L605

Latest example of newly added global to whole stack command:
RDMA/uverbs: Add uverbs command for dma-buf based MR registration
https://lore.kernel.org/linux-rdma/[email protected]/

Thanks