public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Jon Maloy <jmaloy@redhat.com>
To: Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, davem@davemloft.net
Cc: kuba@kernel.org, passt-dev@passt.top, sbrivio@redhat.com,
	lvivier@redhat.com, dgibson@redhat.com
Subject: Re: [RFC net-next] tcp: add support for read with offset when using MSG_PEEK
Date: Thu, 18 Jan 2024 17:22:52 -0500	[thread overview]
Message-ID: <595d89f1-15b1-537d-f876-0ac4627db535@redhat.com> (raw)
In-Reply-To: <df3045c3ec7a4b3c417699ff4950d3d977a0a944.camel@redhat.com>



On 2024-01-16 05:49, Paolo Abeni wrote:
> On Thu, 2024-01-11 at 18:00 -0500, jmaloy@redhat.com wrote:
>> From: Jon Maloy <jmaloy@redhat.com>
>>
>> When reading received messages from a socket with MSG_PEEK, we may want
>> to read the contents with an offset, like we can do with pread/preadv()
>> when reading files. Currently, it is not possible to do that.
[...]
>> +				err = -EINVAL;
>> +				goto out;
>> +			}
>> +			peek_offset = msg->msg_iter.__iov[0].iov_len;
>> +			msg->msg_iter.__iov = &msg->msg_iter.__iov[1];
>> +			msg->msg_iter.nr_segs -= 1;
>> +			msg->msg_iter.count -= peek_offset;
>> +			len -= peek_offset;
>> +			*seq += peek_offset;
>> +		}
> IMHO this does not look like the correct interface to expose such
> functionality. Doing the same with a different protocol should cause a
> SIGSEG or the like, right?
I would expect doing the same thing with a different protocol to cause 
an EFAULT, as it should. But I haven't tried it.
This is a change to TCP only, at least until somebody decides to 
implement it elsewhere (why not?)
>
> What about using/implementing SO_PEEK_OFF support instead?
I looked at SO_PEEK_OFF, and it honestly looks both awkward and limited.
We would have to make frequent calls to setsockopt(), something that 
would beat much of the purpose of this feature.
I stand by my opinion here.
This feature is simple, non-intrusive, totally backwards compatible and 
implies no changes to the API or BPI.

I would love to hear other opinions on this, though.

Regards
/jon


>
> Cheers,
>
> Paolo
>


  reply	other threads:[~2024-01-18 22:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-11 23:00 [RFC net-next] tcp: add support for read with offset when using MSG_PEEK jmaloy
2024-01-16 10:49 ` Paolo Abeni
2024-01-18 22:22   ` Jon Maloy [this message]
2024-01-21 22:16     ` Stefano Brivio
2024-01-22 16:22       ` Jon Maloy
  -- strict thread matches above, loose matches on Subject: below --
2024-01-11 22:22 jmaloy

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=595d89f1-15b1-537d-f876-0ac4627db535@redhat.com \
    --to=jmaloy@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dgibson@redhat.com \
    --cc=kuba@kernel.org \
    --cc=lvivier@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --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).