All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 mptcp-net] mptcp: fix 32 bit DSN expansion
@ 2021-06-16  8:19 Paolo Abeni
  2021-06-17  0:04 ` Mat Martineau
  2021-06-17 13:25 ` Matthieu Baerts
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Abeni @ 2021-06-16  8:19 UTC (permalink / raw)
  To: mptcp

The current implementation of 32 bit DSN expansion is buggy.
After the previous patch, we can simply reuse the newly
introduced helper to do the expansion safely.

Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/120
Fixes: 648ef4b88673 ("mptcp: Implement MPTCP receive path")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
v1 -> v2:
 - fix typo in the commit message
 - use the common helper
---
 net/mptcp/subflow.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index d55f4ef736a5..6772802737e4 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -781,15 +781,6 @@ enum mapping_status {
 	MAPPING_DUMMY
 };
 
-static u64 expand_seq(u64 old_seq, u16 old_data_len, u64 seq)
-{
-	if ((u32)seq == (u32)old_seq)
-		return old_seq;
-
-	/* Assume map covers data not mapped yet. */
-	return seq | ((old_seq + old_data_len + 1) & GENMASK_ULL(63, 32));
-}
-
 static void dbg_bad_map(struct mptcp_subflow_context *subflow, u32 ssn)
 {
 	pr_debug("Bad mapping: ssn=%d map_seq=%d map_data_len=%d",
@@ -995,13 +986,7 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
 		data_len--;
 	}
 
-	if (!mpext->dsn64) {
-		map_seq = expand_seq(subflow->map_seq, subflow->map_data_len,
-				     mpext->data_seq);
-		pr_debug("expanded seq=%llu", subflow->map_seq);
-	} else {
-		map_seq = mpext->data_seq;
-	}
+	map_seq = mptcp_expand_seq(READ_ONCE(msk->ack_seq), mpext->data_seq, mpext->dsn64);
 	WRITE_ONCE(mptcp_sk(subflow->conn)->use_64bit_ack, !!mpext->dsn64);
 
 	if (subflow->map_valid) {
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 mptcp-net] mptcp: fix 32 bit DSN expansion
  2021-06-16  8:19 [PATCH v2 mptcp-net] mptcp: fix 32 bit DSN expansion Paolo Abeni
@ 2021-06-17  0:04 ` Mat Martineau
  2021-06-17 13:25 ` Matthieu Baerts
  1 sibling, 0 replies; 3+ messages in thread
From: Mat Martineau @ 2021-06-17  0:04 UTC (permalink / raw)
  To: Paolo Abeni; +Cc: mptcp

On Wed, 16 Jun 2021, Paolo Abeni wrote:

> The current implementation of 32 bit DSN expansion is buggy.
> After the previous patch, we can simply reuse the newly
> introduced helper to do the expansion safely.
>
> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/120
> Fixes: 648ef4b88673 ("mptcp: Implement MPTCP receive path")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
> v1 -> v2:
> - fix typo in the commit message
> - use the common helper

Thanks for the v2, looks good to me.

Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>


> ---
> net/mptcp/subflow.c | 17 +----------------
> 1 file changed, 1 insertion(+), 16 deletions(-)
>
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index d55f4ef736a5..6772802737e4 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -781,15 +781,6 @@ enum mapping_status {
> 	MAPPING_DUMMY
> };
>
> -static u64 expand_seq(u64 old_seq, u16 old_data_len, u64 seq)
> -{
> -	if ((u32)seq == (u32)old_seq)
> -		return old_seq;
> -
> -	/* Assume map covers data not mapped yet. */
> -	return seq | ((old_seq + old_data_len + 1) & GENMASK_ULL(63, 32));
> -}
> -
> static void dbg_bad_map(struct mptcp_subflow_context *subflow, u32 ssn)
> {
> 	pr_debug("Bad mapping: ssn=%d map_seq=%d map_data_len=%d",
> @@ -995,13 +986,7 @@ static enum mapping_status get_mapping_status(struct sock *ssk,
> 		data_len--;
> 	}
>
> -	if (!mpext->dsn64) {
> -		map_seq = expand_seq(subflow->map_seq, subflow->map_data_len,
> -				     mpext->data_seq);
> -		pr_debug("expanded seq=%llu", subflow->map_seq);
> -	} else {
> -		map_seq = mpext->data_seq;
> -	}
> +	map_seq = mptcp_expand_seq(READ_ONCE(msk->ack_seq), mpext->data_seq, mpext->dsn64);
> 	WRITE_ONCE(mptcp_sk(subflow->conn)->use_64bit_ack, !!mpext->dsn64);
>
> 	if (subflow->map_valid) {
> -- 
> 2.26.3
>
>
>

--
Mat Martineau
Intel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 mptcp-net] mptcp: fix 32 bit DSN expansion
  2021-06-16  8:19 [PATCH v2 mptcp-net] mptcp: fix 32 bit DSN expansion Paolo Abeni
  2021-06-17  0:04 ` Mat Martineau
@ 2021-06-17 13:25 ` Matthieu Baerts
  1 sibling, 0 replies; 3+ messages in thread
From: Matthieu Baerts @ 2021-06-17 13:25 UTC (permalink / raw)
  To: Paolo Abeni, Mat Martineau; +Cc: mptcp

Hi Paolo, Mat,

On 16/06/2021 10:19, Paolo Abeni wrote:
> The current implementation of 32 bit DSN expansion is buggy.
> After the previous patch, we can simply reuse the newly
> introduced helper to do the expansion safely.
> 
> Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/120
> Fixes: 648ef4b88673 ("mptcp: Implement MPTCP receive path")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Thank you for the patch and the review!

Now in our tree (fix for net) with Mat's RvB tag:

- b976d9a38cfc: mptcp: fix 32 bit DSN expansion
- Results: 035a752fa93d..8db480094258

Builds and tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20210617T132456
https://github.com/multipath-tcp/mptcp_net-next/actions/workflows/build-validation.yml?query=branch:export/20210617T132456

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-17 13:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16  8:19 [PATCH v2 mptcp-net] mptcp: fix 32 bit DSN expansion Paolo Abeni
2021-06-17  0:04 ` Mat Martineau
2021-06-17 13:25 ` Matthieu Baerts

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.