From: Tom Herbert <tom@herbertland.com>
To: Christoph Paasch <christoph.paasch@gmail.com>
Cc: "Dave Watson" <davejwatson@fb.com>,
"Ilya Lesokhin" <ilyal@mellanox.com>,
"Aviad Yehezkel" <aviadye@mellanox.com>,
"Boris Pismenny" <borisp@mellanox.com>,
"Liran Liss" <liranl@mellanox.com>,
"Matan Barak" <matanb@mellanox.com>,
"David Miller" <davem@davemloft.net>,
"Linux Kernel Network Developers" <netdev@vger.kernel.org>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
"Linux Crypto Mailing List" <linux-crypto@vger.kernel.org>,
"Hannes Frederic Sowa" <hannes@stressinduktion.org>,
"Eric Dumazet" <eric.dumazet@gmail.com>,
"Alexei Starovoitov" <alexei.starovoitov@gmail.com>,
"Nikos Mavrogiannopoulos" <nmav@gnutls.org>,
"Fridolín Pokorný" <fridolin.pokorny@gmail.com>
Subject: Re: [PATCH v3 net-next 1/4] tcp: ULP infrastructure
Date: Sat, 29 Jul 2017 13:19:05 -0700 [thread overview]
Message-ID: <CALx6S37pcti4jb6ysb=qO622go6FD_bDmb59v6QOSk+9z4zUkA@mail.gmail.com> (raw)
In-Reply-To: <20170617001455.GB82626@Chimay.local>
On Fri, Jun 16, 2017 at 5:14 PM, Christoph Paasch
<christoph.paasch@gmail.com> wrote:
> Hello,
>
> On 14/06/17 - 11:37:14, Dave Watson wrote:
>> Add the infrustructure for attaching Upper Layer Protocols (ULPs) over TCP
>> sockets. Based on a similar infrastructure in tcp_cong. The idea is that any
>> ULP can add its own logic by changing the TCP proto_ops structure to its own
>> methods.
>>
>> Example usage:
>>
>> setsockopt(sock, SOL_TCP, TCP_ULP, "tls", sizeof("tls"));
>>
>> modules will call:
>> tcp_register_ulp(&tcp_tls_ulp_ops);
>>
>> to register/unregister their ulp, with an init function and name.
>>
>> A list of registered ulps will be returned by tcp_get_available_ulp, which is
>> hooked up to /proc. Example:
>>
>> $ cat /proc/sys/net/ipv4/tcp_available_ulp
>> tls
>>
>> There is currently no functionality to remove or chain ULPs, but
>> it should be possible to add these in the future if needed.
>>
>> Signed-off-by: Boris Pismenny <borisp@mellanox.com>
>> Signed-off-by: Dave Watson <davejwatson@fb.com>
>> ---
>> include/net/inet_connection_sock.h | 4 ++
>> include/net/tcp.h | 25 +++++++
>> include/uapi/linux/tcp.h | 1 +
>> net/ipv4/Makefile | 2 +-
>> net/ipv4/sysctl_net_ipv4.c | 25 +++++++
>> net/ipv4/tcp.c | 28 ++++++++
>> net/ipv4/tcp_ipv4.c | 2 +
>> net/ipv4/tcp_ulp.c | 134 +++++++++++++++++++++++++++++++++++++
>> 8 files changed, 220 insertions(+), 1 deletion(-)
>> create mode 100644 net/ipv4/tcp_ulp.c
>
> I know I'm pretty late to the game (and maybe this has already been
> discussed but I couldn't find anything in the archives), but I am wondering
> what the take is on potential races of the setsockopt() vs other system-calls.
>
> For example one might race the setsockopt() with a sendmsg() and the sendmsg
> might end up blocking on the lock_sock in tcp_sendmsg, waiting for
> tcp_set_ulp() to finish changing sk_prot. When the setsockopt() finishes, we
> are then inside tcp_sendmsg() coming directly from sendmsg(), while we
> should have been in the ULP's sendmsg.
>
> It seems like TLS-ULP is resilient to this (or at least, won't cause a panic),
> but there might be more exotic users of ULP in the future, that change other
> callbacks and then things might go wrong.
Christoph,
I noticed this also. I think the easiest answer would be to just
assume the caller understands the race condition and can synchronize
itself. Other than that we'd probably have wake up everyone blocking
on the socket without something like EAGAIN so they're forced to retry
the operation. But even that might not easily yield an obvious point
at which the socket can be safely changed.
Tom
>
>
> Thoughts?
>
>
> Thanks,
> Christoph
>
next prev parent reply other threads:[~2017-07-29 20:19 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1497465295.git.davejwatson@fb.com>
2017-06-14 18:37 ` [PATCH v3 net-next 1/4] tcp: ULP infrastructure Dave Watson
2017-06-17 0:14 ` Christoph Paasch
2017-07-29 20:19 ` Tom Herbert [this message]
2017-06-25 2:42 ` Levin, Alexander (Sasha Levin)
2017-06-26 14:30 ` Dave Watson
2017-06-26 15:07 ` Levin, Alexander (Sasha Levin)
2017-07-29 20:12 ` Tom Herbert
2017-07-31 22:16 ` Dave Watson
2017-08-01 18:27 ` Tom Herbert
2017-06-14 18:37 ` [PATCH v3 net-next 2/4] tcp: export do_tcp_sendpages and tcp_rate_check_app_limited functions Dave Watson
2017-06-14 18:37 ` [PATCH v3 net-next 3/4] tls: kernel TLS support Dave Watson
2017-06-16 20:56 ` Stephen Hemminger
2017-06-16 20:58 ` Stephen Hemminger
2017-06-17 0:35 ` Dave Watson
2017-07-11 6:29 ` Steffen Klassert
2017-07-11 18:53 ` Dave Watson
2017-07-11 20:24 ` Eric Biggers
2017-07-12 7:20 ` Steffen Klassert
2017-07-12 18:34 ` Dave Watson
2017-06-14 18:37 ` [PATCH v3 net-next 4/4] tls: Documentation Dave Watson
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='CALx6S37pcti4jb6ysb=qO622go6FD_bDmb59v6QOSk+9z4zUkA@mail.gmail.com' \
--to=tom@herbertland.com \
--cc=alexei.starovoitov@gmail.com \
--cc=aviadye@mellanox.com \
--cc=borisp@mellanox.com \
--cc=christoph.paasch@gmail.com \
--cc=davejwatson@fb.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=fridolin.pokorny@gmail.com \
--cc=hannes@stressinduktion.org \
--cc=herbert@gondor.apana.org.au \
--cc=ilyal@mellanox.com \
--cc=linux-crypto@vger.kernel.org \
--cc=liranl@mellanox.com \
--cc=matanb@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=nmav@gnutls.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;
as well as URLs for NNTP newsgroup(s).