From: Dmytro Shytyi <dmytro@shytyi.net>
To: mptcp@lists.linux.dev
Cc: Dmytro Shytyi <dmytro@shytyi.net>
Subject: [RFC PATCH mptcp-next v7 05/11] Initiator: add locks() to mptcp_sendmsg_fastopen.
Date: Sun, 18 Sep 2022 00:28:47 +0200 [thread overview]
Message-ID: <20220917222853.2406-6-dmytro@shytyi.net> (raw)
In-Reply-To: <20220917222853.2406-1-dmytro@shytyi.net>
Suggestion of @mmartineau : 'add locks' is implemented in this patch
Signed-off-by: Dmytro Shytyi <dmytro@shytyi.net>
---
net/mptcp/fastopen.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c
index 9974508e0f4c..50b5c3376672 100644
--- a/net/mptcp/fastopen.c
+++ b/net/mptcp/fastopen.c
@@ -16,6 +16,7 @@ int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
struct socket *ssk;
int ret;
+ lock_sock((struct sock *)msk);
ssk = __mptcp_nmpc_socket(msk);
if (unlikely(!ssk))
goto out_EFAULT;
@@ -30,26 +31,35 @@ int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg,
goto out_EFAULT;
uaddr = msg->msg_name;
+ lock_sock(ssk->sk);
+
tp = tcp_sk(ssk->sk);
if (unlikely(!tp))
- goto out_EFAULT;
+ goto out_lock_EFAULT;
if (!tp->fastopen_req)
tp->fastopen_req = kzalloc(sizeof(*tp->fastopen_req),
ssk->sk->sk_allocation);
if (unlikely(!tp->fastopen_req))
- goto out_EFAULT;
+ goto out_lock_EFAULT;
tp->fastopen_req->data = msg;
tp->fastopen_req->size = len;
tp->fastopen_req->uarg = uarg;
+ release_sock(ssk->sk);
+ release_sock((struct sock *)msk);
+
/* requests a cookie */
ret = mptcp_stream_connect(sk->sk_socket, uaddr,
msg->msg_namelen, msg->msg_flags);
if (!ret)
*copied = len;
return ret;
+
+out_lock_EFAULT:
+ release_sock(ssk->sk);
out_EFAULT:
+ release_sock((struct sock *)msk);
ret = -EFAULT;
return ret;
}
--
2.25.1
next prev parent reply other threads:[~2022-09-17 22:29 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-17 22:28 [RFC PATCH mptcp-next v7 00/11] mptcp: Fast Open Mechanism Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 01/11] Add separate fastopen.c file Dmytro Shytyi
2022-09-19 10:21 ` Paolo Abeni
2022-09-20 13:29 ` Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 02/11] add mptcp_stream_connect to protocol.h Dmytro Shytyi
2022-09-19 10:19 ` Paolo Abeni
2022-09-20 13:30 ` Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 03/11] Initiator: MSG_FASTOPEN sendto(). request cookie Dmytro Shytyi
2022-09-19 10:35 ` Paolo Abeni
2022-09-19 10:44 ` Paolo Abeni
2022-09-19 11:22 ` Matthieu Baerts
2022-09-20 13:32 ` Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 04/11] rfree(), rmem_uncharge() prototypes to protocol.h Dmytro Shytyi
2022-09-17 22:28 ` Dmytro Shytyi [this message]
2022-09-19 10:46 ` [RFC PATCH mptcp-next v7 05/11] Initiator: add locks() to mptcp_sendmsg_fastopen Paolo Abeni
2022-09-20 13:33 ` Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 06/11] add mptcp_setsockopt_fastopen Dmytro Shytyi
2022-09-19 10:48 ` Paolo Abeni
2022-09-20 13:33 ` Dmytro Shytyi
2022-09-20 9:37 ` Matthieu Baerts
2022-09-20 13:34 ` Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 07/11] mptfo variables for msk, options. Fix loop retrans Dmytro Shytyi
2022-09-19 11:11 ` Paolo Abeni
2022-09-19 11:26 ` Paolo Abeni
2022-09-20 16:32 ` Christoph Paasch
2022-09-20 13:40 ` Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 08/11] Fix unxpctd val of subflow->map_seq(dscrd packet) Dmytro Shytyi
2022-09-19 11:27 ` Paolo Abeni
2022-09-19 11:31 ` Matthieu Baerts
2022-09-19 14:02 ` Paolo Abeni
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 09/11] Listener: Add received skb to msk Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 10/11] mptcp_fastopen_add_skb() helpers (skb to msk) Dmytro Shytyi
2022-09-19 14:06 ` Paolo Abeni
2022-09-20 13:36 ` Dmytro Shytyi
2022-09-17 22:28 ` [RFC PATCH mptcp-next v7 11/11] selftests: mptfo initiator/listener Dmytro Shytyi
2022-09-19 14:11 ` Paolo Abeni
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=20220917222853.2406-6-dmytro@shytyi.net \
--to=dmytro@shytyi.net \
--cc=mptcp@lists.linux.dev \
/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).