From: Adrien Delorme <[email protected]>
To: Pavel Begunkov <[email protected]>,
"[email protected]" <[email protected]>
Cc: "[email protected]" <[email protected]>,
"[email protected]" <[email protected]>,
"[email protected]" <[email protected]>,
"[email protected]" <[email protected]>,
"[email protected]" <[email protected]>,
"[email protected]" <[email protected]>,
"[email protected]" <[email protected]>, "[email protected]" <[email protected]>,
"[email protected]" <[email protected]>,
"[email protected]" <[email protected]>,
"[email protected]" <[email protected]>,
"[email protected]" <[email protected]>,
"[email protected]" <[email protected]>,
"[email protected]" <[email protected]>,
"[email protected]" <[email protected]>,
"[email protected]" <[email protected]>,
"[email protected]"
<[email protected]>
Subject: RE: [PATCH 0/5] add initial io_uring_cmd support for sockets
Date: Wed, 3 May 2023 13:11:22 +0000 [thread overview]
Message-ID: <GV1P193MB2005214F383309B8466C6361EA6C9@GV1P193MB2005.EURP193.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <[email protected]>
From Adrien Delorme
> From : Pavel Begunkov
> Sent : 2 May 2023 15:04
> On 5/2/23 10:21, Adrien Delorme wrote:
> > From Adrien Delorme
> >
> >> From: David Ahern
> >> Sent: 12 April 2023 7:39
> >>> Sent: 11 April 2023 16:28
> >> ....
> >> One problem is that not all sockopt calls pass the correct length.
> >> And some of them can have very long buffers.
> >> Not to mention the ones that are read-modify-write.
> >>
> >> A plausible solution is to pass a 'fat pointer' that contains some,
> >> or all, of:
> >> - A userspace buffer pointer.
> >> - A kernel buffer pointer.
> >> - The length supplied by the user.
> >> - The length of the kernel buffer.
> >> = The number of bytes to copy on completion.
> >> For simple user requests the syscall entry/exit code would copy the
> >> data to a short on-stack buffer.
> >> Kernel users just pass the kernel address.
> >> Odd requests can just use the user pointer.
> >>
> >> Probably needs accessors that add in an offset.
> >>
> >> It might also be that some of the problematic sockopt were in decnet
> >> - now removed.
> >
> > Hello everyone,
> >
> > I'm currently working on an implementation of {get,set} sockopt.
> > Since this thread is already talking about it, I hope that I replying at the
> correct place.
>
> Hi Adrien, I believe Breno is working on set/getsockopt as well and had
> similar patches for awhile, but that would need for some problems to be
> solved first, e.g. try and decide whether it copies to a ptr as the syscall
> versions or would get/return optval directly in sqe/cqe. And also where to
> store bits that you pass in struct args_setsockopt_uring, and whether to rely
> on SQE128 or not.
>
Hello Pavel,
That is good to hear. If possible I would like to provide some help.
I looked at the getsockopt implementation. From what I'm seeing, I believe that it would be easier to copies to a ptr as the syscall.
The length of the output is usually 4 bytes (sometimes less) but in a lot of cases, this length is variable. Sometime it can even be bigger that the SQE128 ring.
Here is a non-exhaustive list of those cases :
/net/ipv4/tcp.c : int do_tcp_getsockopt(...)
- TCP_INFO : up to 240 bytes
- TCP_CC_INFO and TCP_REPAIR_WINDOW : up to 20 bytes
- TCP_CONGESTION and TCP_ULP : up to 16 bytes
- TCP_ZEROCPOY_RECEIVE : up to 64 bytes
/net/atm/commun.c : int vcc_getsockopt(...)
- SO_ATMQOS : up to 88 bytes
- SO_ATMPVC : up to 16 bytes
/net/ipv4/io_sockglue.c : int do_ip_getsockopt(...)
- MCAST_MSFILTER : up to 144 bytes
- IP_MSFILTER : 16 bytes minimum
I will look into setsockopt but I believe it might be the same.
If needed I can also complete this list.
However there are some cases where it is hard to determinate a maximum amount of bytes in advance.
As to where the bytes should be stored I was thinking of either :
- As a pointer in sqe->addr so the SQE128 is not needed
- In sqe->cmd as a struct but from my understanding, the SQE128 is needed
>
> > My implementation is rather simple using a struct that will be used to pass
> the necessary info throught sqe->cmd.
> >
> > Here is my implementation based of kernel version 6.3 :
> > ...
> > +/* Struct to pass args for IO_URING_CMD_OP_GETSOCKOPT and
> > +IO_URING_CMD_OP_SETSOCKOPT operations */ struct
> > +args_setsockopt_uring{
>
> The name of the structure is quite inconsistent with the rest. It's better to be
> io_[uring_]_sockopt_arg or some variation.
>
> > + int level;
> > + int optname;
> > + char __user * user_optval;
> > + int optlen;
>
> That's uapi, there should not be __user, and field sizes should be more
> portable, i.e. use __u32, __u64, etc, look through the file.
>
> Would need to look into the get/setsockopt implementation before saying
> anything about uring_cmd_{set,get}sockopt.
> ...
> Pavel Begunkov
Thank you for the review.
Adrien Delorme
--
next prev parent reply other threads:[~2023-05-03 13:12 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-02 9:21 [PATCH 0/5] add initial io_uring_cmd support for sockets Adrien Delorme
2023-05-02 13:03 ` Pavel Begunkov
2023-05-03 13:11 ` Adrien Delorme [this message]
2023-05-03 13:27 ` David Laight
-- strict thread matches above, loose matches on Subject: below --
2023-04-06 14:43 Breno Leitao
2023-04-06 15:34 ` Willem de Bruijn
2023-04-06 15:59 ` Breno Leitao
2023-04-06 18:16 ` Willem de Bruijn
2023-04-07 2:46 ` David Ahern
2023-04-11 12:00 ` Breno Leitao
2023-04-11 14:36 ` David Ahern
2023-04-11 14:41 ` Jens Axboe
2023-04-11 14:51 ` Willem de Bruijn
2023-04-11 14:54 ` Jens Axboe
2023-04-11 15:00 ` Willem de Bruijn
2023-04-11 15:06 ` Jens Axboe
2023-04-11 15:24 ` Willem de Bruijn
2023-04-11 15:28 ` Jens Axboe
2023-04-12 13:53 ` Breno Leitao
2023-04-12 14:28 ` Willem de Bruijn
2023-04-13 0:02 ` Breno Leitao
2023-04-13 14:24 ` Willem de Bruijn
2023-04-13 14:45 ` Jakub Kicinski
2023-04-13 14:57 ` David Laight
2023-04-18 13:23 ` Breno Leitao
2023-04-18 19:41 ` Willem de Bruijn
2023-04-20 14:43 ` Breno Leitao
2023-04-20 16:48 ` Willem de Bruijn
2023-04-11 15:10 ` David Ahern
2023-04-11 15:17 ` Jens Axboe
2023-04-11 15:27 ` David Ahern
2023-04-11 15:29 ` Jens Axboe
2023-04-12 7:39 ` David Laight
2023-04-06 16:41 ` Keith Busch
2023-04-06 16:49 ` Jens Axboe
2023-04-06 16:58 ` Breno Leitao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=GV1P193MB2005214F383309B8466C6361EA6C9@GV1P193MB2005.EURP193.PROD.OUTLOOK.COM \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox