All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni at redhat.com>
To: mptcp at lists.01.org
Subject: [MPTCP] [PATCH] squash-to: mptcp: Implement MPTCP receive path
Date: Thu, 13 Jun 2019 17:25:46 +0200	[thread overview]
Message-ID: <3e99fc39ff57c97d9596c627c85a15f14b86560f.1560439435.git.pabeni@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2983 bytes --]

The usage of an atomic type for such field does not really protect
vs concurrent read/modify/update cycles, and makes the code less
readable, move to plain u64.

We already held the required lock in the relevant context

Signed-off-by: Paolo Abeni <pabeni(a)redhat.com>
---
 net/mptcp/options.c  | 2 +-
 net/mptcp/protocol.c | 8 ++++----
 net/mptcp/protocol.h | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index d285a33cd480..92cb0cb48f0c 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -319,7 +319,7 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
 
 		msk = mptcp_sk(subflow_ctx(sk)->conn);
 		if (msk) {
-			opts->ext_copy.data_ack = atomic64_read(&msk->ack_seq);
+			opts->ext_copy.data_ack = msk->ack_seq;
 		} else {
 			crypto_key_sha1(subflow_ctx(sk)->remote_key, NULL,
 					&opts->ext_copy.data_ack);
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 941988387ea0..91e913636c45 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -435,7 +435,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 		}
 
 		ssn = tcp_sk(ssk)->copied_seq - subflow->ssn_offset;
-		old_ack = atomic64_read(&msk->ack_seq);
+		old_ack = msk->ack_seq;
 
 		if (unlikely(before(ssn, subflow->map_subflow_seq))) {
 			/* Mapping covers data later in the subflow stream,
@@ -501,7 +501,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 		ack_seq = get_mapped_dsn(subflow);
 
 		if (before64(old_ack, ack_seq))
-			atomic64_set(&msk->ack_seq, ack_seq);
+			msk->ack_seq = ack_seq;
 
 		if (!before(tcp_sk(ssk)->copied_seq - subflow->ssn_offset,
 			    subflow->map_subflow_seq + subflow->map_data_len)) {
@@ -635,7 +635,7 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err,
 		crypto_key_sha1(msk->remote_key, NULL, &ack_seq);
 		msk->write_seq = subflow->idsn + 1;
 		ack_seq++;
-		atomic64_set(&msk->ack_seq, ack_seq);
+		msk->ack_seq = ack_seq;
 		subflow->map_seq = ack_seq;
 		subflow->map_subflow_seq = 1;
 		subflow->rel_write_seq = 1;
@@ -760,7 +760,7 @@ void mptcp_finish_connect(struct sock *sk, int mp_capable)
 		crypto_key_sha1(msk->remote_key, NULL, &ack_seq);
 		msk->write_seq = subflow->idsn + 1;
 		ack_seq++;
-		atomic64_set(&msk->ack_seq, ack_seq);
+		msk->ack_seq = ack_seq;
 		subflow->map_seq = ack_seq;
 		subflow->map_subflow_seq = 1;
 		subflow->rel_write_seq = 1;
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index a4f0e7d3bd62..4bc1a094aad6 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -43,7 +43,7 @@ struct mptcp_sock {
 	u64		local_key;
 	u64		remote_key;
 	u64		write_seq;
-	atomic64_t	ack_seq;
+	u64		ack_seq;
 	u32		token;
 	struct list_head conn_list;
 	struct socket	*subflow; /* outgoing connect/listener/!mp_capable */
-- 
2.20.1


             reply	other threads:[~2019-06-13 15:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13 15:25 Paolo Abeni [this message]
2019-06-13 18:23 [MPTCP] [PATCH] squash-to: mptcp: Implement MPTCP receive path Mat Martineau
2019-06-14 13:37 Matthieu Baerts
2019-06-14 13:45 Paolo Abeni
2019-06-14 13:51 Matthieu Baerts
2019-06-14 14:23 Matthieu Baerts

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=3e99fc39ff57c97d9596c627c85a15f14b86560f.1560439435.git.pabeni@redhat.com \
    --to=unknown@example.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.
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.