From: Jakub Kicinski <kuba@kernel.org>
To: Paolo Abeni <pabeni@redhat.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
borisp@nvidia.com, john.fastabend@gmail.com, maximmi@nvidia.com,
tariqt@nvidia.com, vfedorenko@novek.ru
Subject: Re: [PATCH net-next v3 7/7] tls: rx: do not use the standard strparser
Date: Tue, 26 Jul 2022 10:01:12 -0700 [thread overview]
Message-ID: <20220726100112.6c82fdb5@kernel.org> (raw)
In-Reply-To: <506b4478378d5bdcdf4a43bd6e2b48dd0dcd6b5d.camel@redhat.com>
On Tue, 26 Jul 2022 11:27:36 +0200 Paolo Abeni wrote:
> On Fri, 2022-07-22 at 16:50 -0700, Jakub Kicinski wrote:
> > diff --git a/net/tls/tls.h b/net/tls/tls.h
> > index 154a3773e785..0e840a0c3437 100644
> > --- a/net/tls/tls.h
> > +++ b/net/tls/tls.h
> > @@ -1,4 +1,5 @@
> > /*
> > + * Copyright (c) 2016 Tom Herbert <tom@herbertland.com>
>
> It's a little strange to me the above line ??! digging this file
> history, you created it out of include/net/tls.h and the latter was
> originally authored by Dave Watson (modulo ENOCOFFEE here...)
>
> > +++ b/net/tls/tls_strp.c
> > @@ -1,37 +1,493 @@
> > // SPDX-License-Identifier: GPL-2.0-only
> > +/* Copyright (c) 2016 Tom Herbert <tom@herbertland.com> */
>
> Same here ...
I tried to add the Copyrights as I copied some code around, since I'm
lazy around legal stuff. I think I copied parts of the strparser
at some point and the structure definition (workqueue handling?).
I'd rather keep too many copyrights than too few, tho.
The semi-custom license is more annoying :(
> > +static int tls_strp_copyin(read_descriptor_t *desc, struct sk_buff *in_skb,
> > + unsigned int offset, size_t in_len)
> > +{
> > + struct tls_strparser *strp = (struct tls_strparser *)desc->arg.data;
> > + size_t sz, len, chunk;
> > + struct sk_buff *skb;
> > + skb_frag_t *frag;
> > +
> > + if (strp->msg_ready)
> > + return 0;
> > +
> > + skb = strp->anchor;
> > + frag = &skb_shinfo(skb)->frags[skb->len / PAGE_SIZE];
>
> I'm wondering if TSOv2 GRO packets can reach here? Even without TSO v2,
> I *think* the TCP stack is allowed to grow queued skbs above 64K via
> tcp_queue_rcv()/tcp_try_coalesce().
I don't think the TSO skbs can get here, the @skb is completely
constructed by me and the length is bounded by max TLS record size
(16k + overheads). We should be safe to use 4k pages, I think.
> > +static int tls_strp_read_copyin(struct tls_strparser *strp)
> > +{
> > + struct socket *sock = strp->sk->sk_socket;
> > + read_descriptor_t desc;
> > +
> > + desc.arg.data = strp;
> > + desc.error = 0;
> > + desc.count = 1; /* give more than one skb per call */
> > +
> > + /* sk should be locked here, so okay to do read_sock */
> > + sock->ops->read_sock(strp->sk, &desc, tls_strp_copyin);
>
> If you are concerned by indirect calls/retpoline, you can use directly
> tcp_read_sock here, as read_sock is always tcp_read_sock since commit
> 965b57b469a589d64d81b1688b38dcb537011bb0. Or you can use
> indirect_call_wrapper.h
This is a slowpath which only gets triggered if we are so rbuf
constrained that TCP will not be able to buffer a full record.
Otherwise we try to avoid doing any copying/read_sock at all.
> > -int tls_strp_msg_hold(struct sock *sk, struct sk_buff *skb,
> > - struct sk_buff_head *dst)
> > +/* strp must already be stopped so that tls_strp_recv will no longer be called.
> > + * Note that tls_strp_done is not called with the lower socket held.
> > + */
> > +void tls_strp_done(struct tls_strparser *strp)
> > {
> > - struct sk_buff *clone;
> > + WARN_ON(!strp->stopped);
> >
> > - clone = skb_clone(skb, sk->sk_allocation);
> > - if (!clone)
> > + cancel_work_sync(&strp->work);
> > + tls_strp_anchor_free(strp);
> > +}
> > +
> > +int __init tls_strp_dev_init(void)
> > +{
> > + tls_strp_wq = create_singlethread_workqueue("kstrp");
>
> I guess it's better to change the name to avoid confusing with plain
> strparser ?!?
>
> Out of sheer ignorance and not related to this patch: If I read
> correctly, the above means that multiple tls flows on top of different
> TCP sockets will use a single CPU, isn't that a relevant bottle-neck?
> isn't enough to rely on queue_work() to submit the work on the same CPU
> that just did the TCP stack processing?
Oh yeah, this is a slow/rare path too but you're right. I copied this
code from strparser without thinking, not sure what the motivation was
there.
next prev parent reply other threads:[~2022-07-26 17:01 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-22 23:50 [PATCH net-next v3 0/7] tls: rx: decrypt from the TCP queue Jakub Kicinski
2022-07-22 23:50 ` [PATCH net-next v3 1/7] tls: rx: wrap recv_pkt accesses in helpers Jakub Kicinski
2022-07-22 23:50 ` [PATCH net-next v3 2/7] tls: rx: factor SW handling out of tls_rx_one_record() Jakub Kicinski
2022-07-22 23:50 ` [PATCH net-next v3 3/7] tls: rx: don't free the output in case of zero-copy Jakub Kicinski
2022-07-22 23:50 ` [PATCH net-next v3 4/7] tls: rx: device: keep the zero copy status with offload Jakub Kicinski
2022-07-22 23:50 ` [PATCH net-next v3 5/7] tcp: allow tls to decrypt directly from the tcp rcv queue Jakub Kicinski
2022-07-22 23:50 ` [PATCH net-next v3 6/7] tls: rx: device: add input CoW helper Jakub Kicinski
2022-07-22 23:50 ` [PATCH net-next v3 7/7] tls: rx: do not use the standard strparser Jakub Kicinski
2022-07-26 9:27 ` Paolo Abeni
2022-07-26 17:01 ` Jakub Kicinski [this message]
2022-07-26 17:26 ` Paolo Abeni
2022-08-02 14:54 ` Tariq Toukan
2022-08-02 15:40 ` Jakub Kicinski
2022-08-04 1:24 ` Jakub Kicinski
2022-08-04 6:13 ` Tariq Toukan
2022-08-04 8:05 ` Tariq Toukan
2022-08-04 15:35 ` Jakub Kicinski
2022-08-07 6:01 ` Tariq Toukan
2022-08-04 15:59 ` Jakub Kicinski
2022-08-07 6:01 ` Tariq Toukan
2022-08-08 5:24 ` Tariq Toukan
2022-08-08 18:24 ` Jakub Kicinski
2022-08-09 8:47 ` Tariq Toukan
2023-03-09 15:15 ` Tariq Toukan
2023-03-09 17:54 ` Jakub Kicinski
2023-03-12 17:59 ` Tariq Toukan
2023-03-13 18:22 ` Jakub Kicinski
2023-03-15 20:26 ` Tariq Toukan
2023-03-16 1:41 ` Jakub Kicinski
2022-07-26 22:00 ` [PATCH net-next v3 0/7] tls: rx: decrypt from the TCP queue patchwork-bot+netdevbpf
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=20220726100112.6c82fdb5@kernel.org \
--to=kuba@kernel.org \
--cc=borisp@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=john.fastabend@gmail.com \
--cc=maximmi@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tariqt@nvidia.com \
--cc=vfedorenko@novek.ru \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.