From: Paolo Abeni <pabeni@redhat.com>
To: Eric Dumazet <edumazet@google.com>
Cc: kuba@kernel.org, passt-dev@passt.top, sbrivio@redhat.com,
lvivier@redhat.com, dgibson@redhat.com, jmaloy@redhat.com,
netdev@vger.kernel.org, davem@davemloft.net
Subject: Re: [PATCH v3] tcp: add support for SO_PEEK_OFF
Date: Tue, 13 Feb 2024 19:39:19 +0100 [thread overview]
Message-ID: <725a92b4813242549f2316e6682d3312b5e658d8.camel@redhat.com> (raw)
In-Reply-To: <CANn89iL2FvTVYv6ym58=4L-K-kSan6R4PEv488ztyX4HsNquug@mail.gmail.com>
On Tue, 2024-02-13 at 16:49 +0100, Eric Dumazet wrote:
> On Tue, Feb 13, 2024 at 4:28 PM Paolo Abeni <pabeni@redhat.com> wrote:
> > On Tue, 2024-02-13 at 14:34 +0100, Eric Dumazet wrote:
> > > This sk_peek_offset protocol, needing sk_peek_offset_bwd() in the non
> > > MSG_PEEK case is very strange IMO.
> > >
> > > Ideally, we should read/write over sk_peek_offset only when MSG_PEEK
> > > is used by the caller.
> > >
> > > That would only touch non fast paths.
> > >
> > > Since the API is mono-threaded anyway, the caller should not rely on
> > > the fact that normal recvmsg() call
> > > would 'consume' sk_peek_offset.
> >
> > Storing in sk_peek_seq the tcp next sequence number to be peeked should
> > avoid changes in the non MSG_PEEK cases.
> >
> > AFAICS that would need a new get_peek_off() sock_op and a bit somewhere
> > (in sk_flags?) to discriminate when sk_peek_seq is actually set. Would
> > that be acceptable?
>
> We could have a parallel SO_PEEK_OFFSET option, reusing the same socket field.
>
> The new semantic would be : Supported by TCP (so far), and tcp
> recvmsg() only reads/writes this field when MSG_PEEK is used.
> Applications would have to clear the values themselves.
I feel like there is some misunderstanding, or at least I can't follow.
Let me be more verbose, to try to clarify my reasoning.
Two consecutive recvmsg(MSG_PEEK) calls for TCP after SO_PEEK_OFF will
return adjacent data. AFAICS this is the same semantic currently
implemented by UDP and unix sockets.
Currently 'sk_peek_off' maintains the next offset to be peeked into the
current receive queue. To implement the above behaviour, tcp_recvmsg()
has to update 'sk_peek_off' after MSG_PEEK, to move the offset to the
next data, and after a plain read, to account for the data removed from
the receive queue.
I proposed to let introduce a tcp-specific set_peek_off doing something
alike:
WRTIE_ONCE(sk->sk_peek_off, tcp_sk(sk)->copied_seq + val);
so that the recvmsg will need to update sk_peek_off only for MSG_PEEK,
while retaining the semantic described above.
To keep the userspace interface unchanged that will need a paired
tcp_get_peek_off(), so that getsockopt(SO_PEEK_OFF) could return to the
user a plain offset. An additional bit flag will be needed to store the
information "the user-space enabled peek with offset".
I don't understand how a setsockopt(PEEK_OFFSET) variant would help
avoiding touching sk->sk_peek_offset?
Thanks!
Paolo
next prev parent reply other threads:[~2024-02-13 18:39 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-09 22:12 [PATCH v3] tcp: add support for SO_PEEK_OFF jmaloy
2024-02-11 23:17 ` Stefano Brivio
2024-02-13 10:49 ` Paolo Abeni
2024-02-13 12:24 ` Eric Dumazet
2024-02-13 13:02 ` Paolo Abeni
2024-02-13 13:34 ` Eric Dumazet
2024-02-13 15:28 ` Paolo Abeni
2024-02-13 15:49 ` Eric Dumazet
2024-02-13 18:39 ` Paolo Abeni [this message]
2024-02-13 19:31 ` Eric Dumazet
[not found] ` <20687849-ec5c-9ce5-0a18-cc80f5b64816@redhat.com>
2024-02-15 17:41 ` Paolo Abeni
2024-02-15 17:46 ` Eric Dumazet
2024-02-15 22:24 ` Jon Maloy
2024-02-16 9:14 ` Paolo Abeni
2024-02-16 9:21 ` Eric Dumazet
[not found] ` <6a9f5dec-eb0c-51ef-0911-7345f50e08f0@redhat.com>
2024-02-16 10:55 ` Eric Dumazet
2024-02-19 2:02 ` David Gibson
2024-02-13 23:34 ` David Gibson
2024-02-14 3:41 ` Eric Dumazet
2024-02-15 3:16 ` David Gibson
2024-02-15 3:21 ` David Gibson
2024-02-15 9:15 ` Eric Dumazet
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=725a92b4813242549f2316e6682d3312b5e658d8.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=dgibson@redhat.com \
--cc=edumazet@google.com \
--cc=jmaloy@redhat.com \
--cc=kuba@kernel.org \
--cc=lvivier@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/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.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).