Skip to contentSkip to conversation

mptcp: Re-factor expand_ack

PATCH In review Peter Krystad 2 participants 3 messages Jan 16, 2020 – Jan 21, 2020

Subsystems (2)
lore
Share & tools
lore

Peter Krystad

author
#0 lore raw

PATCH 1/1 mptcp: Re-factor expand_ack

Modify this commit to handle separately-stored 32-bit data acks.

squashto: update per unacked sequence on pkt reception

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 net/mptcp/options.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
net/mptcp/options.c +11 -11
index bd1c3ba134ae..6ad0cdfa6de2 100644
@@ -674,15 +674,16 @@ static bool check_fourth_ack(struct mptcp_subflow_context *subflow,
 	return true;
 }
 
-static u64 expand_ack(u64 old_ack, u64 cur_ack, bool use_64bit)
+static u64 expand_ack(u64 old_ack, u32 cur_ack32)
 {
-	u32 old_ack32, cur_ack32;
-
-	if (use_64bit)
-		return cur_ack;
+	u32 old_ack32;
+	u64 cur_ack;
 
+	/* avoid ack expansion on update conflict, to reduce the risk of
+	 * wrongly expanding to a future ack sequence number, which is way
+	 * more dangerous than missing an ack
+	 */
 	old_ack32 = (u32)old_ack;
-	cur_ack32 = (u32)cur_ack;
 	cur_ack = (old_ack & GENMASK_ULL(63, 32)) + cur_ack32;
 	if (unlikely(before(cur_ack32, old_ack32)))
 		return cur_ack + (1LL << 32);
@@ -695,11 +696,10 @@ static void update_una(struct mptcp_sock *msk,
 	u64 new_snd_una, snd_una, old_snd_una = atomic64_read(&msk->snd_una);
 	u64 write_seq = READ_ONCE(msk->write_seq);
 
-	/* avoid ack expansion on update conflict, to reduce the risk of
-	 * wrongly expanding to a future ack sequence number, which is way
-	 * more dangerous than missing an ack
-	 */
-	new_snd_una = expand_ack(old_snd_una, mp_opt->data_ack, mp_opt->ack64);
+	if (mp_opt->ack64)
+		new_snd_una = mp_opt->data_ack;
+	else
+		new_snd_una = expand_ack(old_snd_una, (u32)mp_opt->data_ack);
 
 	/* ACK for data not even sent yet? Ignore. */
 	if (after64(new_snd_una, write_seq))
Signature · 1 line
2.17.2
#1 lore raw
Quoted 21 lines · Peter Krystad

Modify this commit to handle separately-stored 32-bit data acks.

squashto: update per unacked sequence on pkt reception

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>

---
net/mptcp/options.c | 22 +++++++++++-----------

1 file changed, 11 insertions(+), 11 deletions(-)
net/mptcp/options.c +1 -2
index bd1c3ba134ae..6ad0cdfa6de2 100644
@@ -674,15 +674,16 @@ static bool check_fourth_ack(struct mptcp_subflow_context *subflow,
 	return true;
 }
 
-static u64 expand_ack(u64 old_ack, u64 cur_ack, bool use_64bit)
+static u64 expand_ack(u64 old_ack, u32 cur_ack32)
 {
-	u32 old_ack32, cur_ack32;

net/mptcp/options.c static bool check_fourth_ack(struct mptcp_subflow_context *subflow, · line 685

Quoted 10 lines
net/mptcp/options.c +6 -3
-
-	if (use_64bit)
-		return cur_ack;
+	u32 old_ack32;
+	u64 cur_ack;
 
+	/* avoid ack expansion on update conflict, to reduce the risk of
+	 * wrongly expanding to a future ack sequence number, which is way
+	 * more dangerous than missing an ack
+	 */

I think this comment belongs in the original function - there's no conflict detection going on in this function.

net/mptcp/options.c static void update_una(struct mptcp_sock *msk, · line 701

Quoted 13 lines
net/mptcp/options.c +0 -5
 	old_ack32 = (u32)old_ack;
-	cur_ack32 = (u32)cur_ack;
 	cur_ack = (old_ack & GENMASK_ULL(63, 32)) + cur_ack32;
 	if (unlikely(before(cur_ack32, old_ack32)))
 		return cur_ack + (1LL << 32);
@@ -695,11 +696,10 @@ static void update_una(struct mptcp_sock *msk,
 	u64 new_snd_una, snd_una, old_snd_una = atomic64_read(&msk->snd_una);
 	u64 write_seq = READ_ONCE(msk->write_seq);
 
-	/* avoid ack expansion on update conflict, to reduce the risk of
-	 * wrongly expanding to a future ack sequence number, which is way
-	 * more dangerous than missing an ack
-	 */

I have to admit this comment does seem out of place here too. In an earlier version, the comment was closer to the while loop (see
https://www.spinics.net/lists/netdev/msg602279.html )

Quoted 10 lines
net/mptcp/options.c +4 -1
-	new_snd_una = expand_ack(old_snd_una, mp_opt->data_ack, mp_opt->ack64);
+	if (mp_opt->ack64)
+		new_snd_una = mp_opt->data_ack;
+	else
+		new_snd_una = expand_ack(old_snd_una, (u32)mp_opt->data_ack);
 
 	/* ACK for data not even sent yet? Ignore. */
 	if (after64(new_snd_una, write_seq))
Signature · 1 line
2.17.2

--
Mat Martineau
Intel

author
#2 lore raw
In reply to Peter Krystad

Same here, drop this patch.

Peter.

Quoted 52 lines · Peter Krystad

Modify this commit to handle separately-stored 32-bit data acks.

squashto: update per unacked sequence on pkt reception

Signed-off-by Peter Krystad <peter.krystad(a)linux.intel.com>
---
 net/mptcp/options.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
net/mptcp/options.c +11 -11
index bd1c3ba134ae..6ad0cdfa6de2 100644
@@ -674,15 +674,16 @@ static bool check_fourth_ack(struct mptcp_subflow_context *subflow,
 	return true;
 }
 
-static u64 expand_ack(u64 old_ack, u64 cur_ack, bool use_64bit)
+static u64 expand_ack(u64 old_ack, u32 cur_ack32)
 {
-	u32 old_ack32, cur_ack32;
-
-	if (use_64bit)
-		return cur_ack;
+	u32 old_ack32;
+	u64 cur_ack;
 
+	/* avoid ack expansion on update conflict, to reduce the risk of
+	 * wrongly expanding to a future ack sequence number, which is way
+	 * more dangerous than missing an ack
+	 */
 	old_ack32 = (u32)old_ack;
-	cur_ack32 = (u32)cur_ack;
 	cur_ack = (old_ack & GENMASK_ULL(63, 32)) + cur_ack32;
 	if (unlikely(before(cur_ack32, old_ack32)))
 		return cur_ack + (1LL << 32);
@@ -695,11 +696,10 @@ static void update_una(struct mptcp_sock *msk,
 	u64 new_snd_una, snd_una, old_snd_una = atomic64_read(&msk->snd_una);
 	u64 write_seq = READ_ONCE(msk->write_seq);
 
-	/* avoid ack expansion on update conflict, to reduce the risk of
-	 * wrongly expanding to a future ack sequence number, which is way
-	 * more dangerous than missing an ack
-	 */
-	new_snd_una = expand_ack(old_snd_una, mp_opt->data_ack, mp_opt->ack64);
+	if (mp_opt->ack64)
+		new_snd_una = mp_opt->data_ack;
+	else
+		new_snd_una = expand_ack(old_snd_una, (u32)mp_opt->data_ack);
 
 	/* ACK for data not even sent yet? Ignore. */
 	if (after64(new_snd_una, write_seq))