diff mbox series

[mptcp-next,v2,4/9] mptcp: add start_seq in the msk

Message ID 48b3740fe2e7339114c7aa8278e5615cdb6b997b.1631188109.git.geliangtang@xiaomi.com (mailing list archive)
State Superseded, archived
Headers show
Series The infinite mapping support | expand

Commit Message

Geliang Tang Sept. 9, 2021, 11:51 a.m. UTC
From: Geliang Tang <geliangtang@xiaomi.com>

This patch added a new member named start_seq to the msk to keep track of
the beginning of the last fully-acked data segment. This would be updated
in __mptcp_move_skb and mptcp_pending_data_fin.

Signed-off-by: Geliang Tang <geliangtang@xiaomi.com>
---
 net/mptcp/protocol.c | 4 ++++
 net/mptcp/protocol.h | 1 +
 2 files changed, 5 insertions(+)

Comments

Mat Martineau Sept. 10, 2021, 12:39 a.m. UTC | #1
On Thu, 9 Sep 2021, Geliang Tang wrote:

> From: Geliang Tang <geliangtang@xiaomi.com>
>
> This patch added a new member named start_seq to the msk to keep track of
> the beginning of the last fully-acked data segment. This would be updated
> in __mptcp_move_skb and mptcp_pending_data_fin.
>
> Signed-off-by: Geliang Tang <geliangtang@xiaomi.com>
> ---
> net/mptcp/protocol.c | 4 ++++
> net/mptcp/protocol.h | 1 +
> 2 files changed, 5 insertions(+)
>
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 81ea03b9fff6..c7ecd3e3b537 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -308,6 +308,7 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk,
>
> 	if (MPTCP_SKB_CB(skb)->map_seq == msk->ack_seq) {
> 		/* in sequence */
> +		WRITE_ONCE(msk->start_seq, msk->ack_seq);

This is tracking the previous value of ack_seq, which is not always 
aligned with the beginning of a DSS segment. It's also recording a 
sequence number for data received by this peer... but I think the RFC is 
asking for the inifinite mapping sequence number to be for data *sent* by 
this peer and acked by the other side.

This peer has already sent acknowledgements for the data received, so 
there's no need to send information (old rx sequence numbers) that the 
other side already has.

- Mat


> 		WRITE_ONCE(msk->ack_seq, msk->ack_seq + copy_len);
> 		tail = skb_peek_tail(&sk->sk_receive_queue);
> 		if (tail && mptcp_try_coalesce(sk, tail, skb))
> @@ -523,6 +524,7 @@ static bool mptcp_check_data_fin(struct sock *sk)
> 	 */
>
> 	if (mptcp_pending_data_fin(sk, &rcv_data_fin_seq)) {
> +		WRITE_ONCE(msk->start_seq, msk->ack_seq);
> 		WRITE_ONCE(msk->ack_seq, msk->ack_seq + 1);
> 		WRITE_ONCE(msk->rcv_data_fin, 0);
>
> @@ -2894,6 +2896,7 @@ struct sock *mptcp_sk_clone(const struct sock *sk,
> 		WRITE_ONCE(msk->ack_seq, ack_seq);
> 		WRITE_ONCE(msk->rcv_wnd_sent, ack_seq);
> 	}
> +	WRITE_ONCE(msk->start_seq, 0);
>
> #if !IS_ENABLED(CONFIG_KASAN)
> 	sock_reset_flag(nsk, SOCK_RCU_FREE);
> @@ -3141,6 +3144,7 @@ void mptcp_finish_connect(struct sock *ssk)
> 	WRITE_ONCE(msk->rcv_wnd_sent, ack_seq);
> 	WRITE_ONCE(msk->can_ack, 1);
> 	WRITE_ONCE(msk->snd_una, msk->write_seq);
> +	WRITE_ONCE(msk->start_seq, 0);
>
> 	mptcp_pm_new_connection(msk, ssk, 0);
>
> diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
> index 5644a361b9c7..77af55171ded 100644
> --- a/net/mptcp/protocol.h
> +++ b/net/mptcp/protocol.h
> @@ -226,6 +226,7 @@ struct mptcp_sock {
> 	u64		remote_key;
> 	u64		write_seq;
> 	u64		snd_nxt;
> +	u64		start_seq;
> 	u64		ack_seq;
> 	u64		rcv_wnd_sent;
> 	u64		rcv_data_fin_seq;
> -- 
> 2.31.1
>
>
>

--
Mat Martineau
Intel
diff mbox series

Patch

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 81ea03b9fff6..c7ecd3e3b537 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -308,6 +308,7 @@  static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk,
 
 	if (MPTCP_SKB_CB(skb)->map_seq == msk->ack_seq) {
 		/* in sequence */
+		WRITE_ONCE(msk->start_seq, msk->ack_seq);
 		WRITE_ONCE(msk->ack_seq, msk->ack_seq + copy_len);
 		tail = skb_peek_tail(&sk->sk_receive_queue);
 		if (tail && mptcp_try_coalesce(sk, tail, skb))
@@ -523,6 +524,7 @@  static bool mptcp_check_data_fin(struct sock *sk)
 	 */
 
 	if (mptcp_pending_data_fin(sk, &rcv_data_fin_seq)) {
+		WRITE_ONCE(msk->start_seq, msk->ack_seq);
 		WRITE_ONCE(msk->ack_seq, msk->ack_seq + 1);
 		WRITE_ONCE(msk->rcv_data_fin, 0);
 
@@ -2894,6 +2896,7 @@  struct sock *mptcp_sk_clone(const struct sock *sk,
 		WRITE_ONCE(msk->ack_seq, ack_seq);
 		WRITE_ONCE(msk->rcv_wnd_sent, ack_seq);
 	}
+	WRITE_ONCE(msk->start_seq, 0);
 
 #if !IS_ENABLED(CONFIG_KASAN)
 	sock_reset_flag(nsk, SOCK_RCU_FREE);
@@ -3141,6 +3144,7 @@  void mptcp_finish_connect(struct sock *ssk)
 	WRITE_ONCE(msk->rcv_wnd_sent, ack_seq);
 	WRITE_ONCE(msk->can_ack, 1);
 	WRITE_ONCE(msk->snd_una, msk->write_seq);
+	WRITE_ONCE(msk->start_seq, 0);
 
 	mptcp_pm_new_connection(msk, ssk, 0);
 
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 5644a361b9c7..77af55171ded 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -226,6 +226,7 @@  struct mptcp_sock {
 	u64		remote_key;
 	u64		write_seq;
 	u64		snd_nxt;
+	u64		start_seq;
 	u64		ack_seq;
 	u64		rcv_wnd_sent;
 	u64		rcv_data_fin_seq;