Netdev List
 help / color / mirror / Atom feed
From: "Chuck Lever" <cel@kernel.org>
To: "Sabrina Dubroca" <sd@queasysnail.net>
Cc: "John Fastabend" <john.fastabend@gmail.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	"Dave Watson" <davejwatson@fb.com>,
	"Shuah Khan" <shuah@kernel.org>,
	netdev@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net 1/9] net/tls: Bound time spent on no-data records in tls_sw_read_sock()
Date: Thu, 06 Aug 2026 20:17:33 -0400	[thread overview]
Message-ID: <2dc8c2c0-7b5a-4c1e-a9b9-e4d06977c0d1@app.fastmail.com> (raw)
In-Reply-To: <amuIA8GjpwBf1ecB@krikkit>



On Thu, Jul 30, 2026, at 1:21 PM, Sabrina Dubroca wrote:
> 2026-07-30, 09:05:17 -0400, Chuck Lever wrote:
>> 
>> 
>> On Thu, Jul 30, 2026, at 5:12 AM, Sabrina Dubroca wrote:
>> > 2026-07-26, 20:33:29 -0400, Chuck Lever wrote:
>> 
>> >> Bound a run of such records, as net_rx_action() bounds a softirq
>> >> poll. The first record that delivers no bytes arms a deadline
>> >> TLS_RX_NODATA_NS ahead; any record that delivers bytes disarms it,
>> >> so a normal stream never trips it. Breaking out with nothing copied
>> >
>> > Another thought here: I think a peer that sends "some" 0-length data
>> > records followed by one (possibly very small) data record, and then
>> > repeats that sequence, will not hit this "rate-limiting" of no-data
>> > records. Is that right? And if so, is that a problem?
>> 
>> That occurred to me too. It's right on the cusp between still
>> making progress and gumming things up. Neither the packet-count
>> limit nor the time-bound address this case.
>> 
>> I don't have a good answer.
>
> I'm not sure that can be addressed in a generic way within ktls. Maybe
> the caller needs to do its own accounting of "this read_sock/read_actor
> dance has been going on for too long now, let's stop".

The consumer can, but only by killing the connection. During a run of
empty records, read_actor is never called and nothing decrements
desc->count, so the consumer never regains control. The socket lock is
held throughout, and __sk_flush_backlog() takes only sk_lock.slock, so
sk_lock.owned stays set. Anything needing lock_sock() blocks behind the
reader, kernel_sock_shutdown() included. The one channel left is a
store to sk->sk_err, which tls_rx_rec_wait() tests first in its loop.
That works, but it is terminal for the connection.

To be non-lethal, the bound has to be inside ktls. v2 of this series
will use a count rather than a deadline, as Jakub requested.


> If we hit the nodata_deadline, we break out of the loop, read_actor
> returns 0 since it's an empty record, and we jump to
> read_sock_requeue.
  
Well, but consume_skb() has already run, and the break leaves the loop
for read_sock_end, which does not requeue. read_actor is never reached
for an empty record.


> sk->sk_data_ready is tls_data_ready at this point, no? I'm confused by
> "the consumer" here.

It depends on which callback was installed first, and unfortunately
two current in-tree read_sock consumers differ in that order.

svcsock (to become a read_sock consumer soon) installs svc_data_ready
at socket setup and the handshake runs later, so ktls sits on top:
sk_data_ready is tls_data_ready and saved_data_ready is svc_data_ready.
The release-time announce already reaches that consumer.

But nvme-tcp is the reverse. It starts TLS in nvme_tcp_alloc_queue() and
installs its own callback afterward in nvme_tcp_start_queue().
saved_data_ready is sock_def_readable and the announce never queues its
io_work.

The explicit poke is for the second case. v2 of this series will rewrite
the comment to state the condition rather than name a function.


-- 
Chuck Lever

  reply	other threads:[~2026-08-07  0:17 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-27  0:33 [PATCH net 0/9] net/tls: Receive-path fixes for zero-length data records Chuck Lever
2026-07-27  0:33 ` [PATCH net 1/9] net/tls: Bound time spent on no-data records in tls_sw_read_sock() Chuck Lever
2026-07-30  9:12   ` Sabrina Dubroca
2026-07-30 13:05     ` Chuck Lever
2026-07-30 17:21       ` Sabrina Dubroca
2026-08-07  0:17         ` Chuck Lever [this message]
2026-08-03 22:39   ` Jakub Kicinski
2026-08-04  0:35     ` Chuck Lever
2026-08-04  1:19       ` Jakub Kicinski
2026-07-27  0:33 ` [PATCH net 2/9] net/tls: Consume empty data records in tls_sw_splice_read() Chuck Lever
2026-07-30 10:38   ` Sabrina Dubroca
2026-08-07  0:19     ` Chuck Lever
2026-07-27  0:33 ` [PATCH net 3/9] net/tls: Fail tls_sw_splice_read() after a failed async decrypt Chuck Lever
2026-08-03 22:59   ` Jakub Kicinski
2026-07-27  0:33 ` [PATCH net 4/9] net/tls: Honor O_NONBLOCK in tls_sw_splice_read() Chuck Lever
2026-07-30 10:59   ` Sabrina Dubroca
2026-08-07  0:19     ` Chuck Lever
2026-07-27  0:33 ` [PATCH net 5/9] net/tls: Consume empty data records in tls_sw_recvmsg() Chuck Lever
2026-07-30 12:40   ` Sabrina Dubroca
2026-08-07  0:21     ` Chuck Lever
2026-08-03 22:47   ` Jakub Kicinski
2026-08-07  0:20     ` Chuck Lever
2026-07-27  0:33 ` [PATCH net 6/9] selftests: tls: add peek and splice coverage for zero-length records Chuck Lever
2026-07-27 14:07   ` Sabrina Dubroca
2026-07-27  0:33 ` [PATCH net 7/9] selftests: tls: skip the zero_len tests when TLS is unavailable Chuck Lever
2026-07-27  0:33 ` [PATCH net 8/9] selftests: tls: cover splice on a nonblocking socket Chuck Lever
2026-07-27  0:33 ` [PATCH net 9/9] selftests: tls: cover splice after a failed decrypt Chuck Lever
2026-07-27 15:19   ` Sabrina Dubroca
2026-08-03 22:58 ` [PATCH net 0/9] net/tls: Receive-path fixes for zero-length data records Jakub Kicinski

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=2dc8c2c0-7b5a-4c1e-a9b9-e4d06977c0d1@app.fastmail.com \
    --to=cel@kernel.org \
    --cc=davejwatson@fb.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sd@queasysnail.net \
    --cc=shuah@kernel.org \
    /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