[PATCH net-next v3 2/6] mptcp: keep rcv_mwnd_seq in sync with subflow rcv_wnd

Simon Baatz via B4 Relay posted 6 patches 1 week, 6 days ago
[PATCH net-next v3 2/6] mptcp: keep rcv_mwnd_seq in sync with subflow rcv_wnd
Posted by Simon Baatz via B4 Relay 1 week, 6 days ago
From: Simon Baatz <gmbnomis@gmail.com>

MPTCP shares a receive window across subflows and applies it at the
subflow level by adjusting each subflow's rcv_wnd when needed.  With
the new TCP tracking of the maximum advertised window sequence,
rcv_mwnd_seq must stay consistent with these subflow-level rcv_wnd
adjustments.

Signed-off-by: Simon Baatz <gmbnomis@gmail.com>
---
 net/mptcp/options.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index 43df4293f58bfbd8a8df6bf24b9f15e0f9e238f6..8a1c5698983cff3082d68290626dd8f1e044527f 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -1076,6 +1076,7 @@ static void rwin_update(struct mptcp_sock *msk, struct sock *ssk,
 	 * resync.
 	 */
 	tp->rcv_wnd += mptcp_rcv_wnd - subflow->rcv_wnd_sent;
+	tcp_update_max_rcv_wnd_seq(tp);
 	subflow->rcv_wnd_sent = mptcp_rcv_wnd;
 }
 
@@ -1338,8 +1339,9 @@ static void mptcp_set_rwin(struct tcp_sock *tp, struct tcphdr *th)
 		 */
 		rcv_wnd_new = rcv_wnd_old;
 		win = rcv_wnd_old - ack_seq;
-		tp->rcv_wnd = min_t(u64, win, U32_MAX);
-		new_win = tp->rcv_wnd;
+		new_win = min_t(u64, win, U32_MAX);
+		tp->rcv_wnd = new_win;
+		tcp_update_max_rcv_wnd_seq(tp);
 
 		/* Make sure we do not exceed the maximum possible
 		 * scaled window.

-- 
2.53.0
Re: [PATCH net-next v3 2/6] mptcp: keep rcv_mwnd_seq in sync with subflow rcv_wnd
Posted by Matthieu Baerts 1 week, 3 days ago
Hi Simon,

On 09/03/2026 09:02, Simon Baatz via B4 Relay wrote:
> From: Simon Baatz <gmbnomis@gmail.com>
> 
> MPTCP shares a receive window across subflows and applies it at the
> subflow level by adjusting each subflow's rcv_wnd when needed.  With
> the new TCP tracking of the maximum advertised window sequence,
> rcv_mwnd_seq must stay consistent with these subflow-level rcv_wnd
> adjustments.

Thank you for these modifications!

> Signed-off-by: Simon Baatz <gmbnomis@gmail.com>
> ---
>  net/mptcp/options.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/net/mptcp/options.c b/net/mptcp/options.c
> index 43df4293f58bfbd8a8df6bf24b9f15e0f9e238f6..8a1c5698983cff3082d68290626dd8f1e044527f 100644
> --- a/net/mptcp/options.c
> +++ b/net/mptcp/options.c

(...)

> @@ -1338,8 +1339,9 @@ static void mptcp_set_rwin(struct tcp_sock *tp, struct tcphdr *th)
>  		 */
>  		rcv_wnd_new = rcv_wnd_old;
>  		win = rcv_wnd_old - ack_seq;
> -		tp->rcv_wnd = min_t(u64, win, U32_MAX);
> -		new_win = tp->rcv_wnd;
> +		new_win = min_t(u64, win, U32_MAX);
> +		tp->rcv_wnd = new_win;

Out of curiosity, why did you change the two lines above?
(even if it makes sense, the diff is a bit confusing, and the commit
message doesn't mention this :) )

> +		tcp_update_max_rcv_wnd_seq(tp);


This patch adding this new helper each time rcv_wnd is modified looks
good to me:

Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>


Note: just in case a new version is needed, checkpatch reported an error
in patch 4/6 because of a trailing whitespace (+ No space is necessary
after a cast in patch 1/6), see:

  https://github.com/multipath-tcp/mptcp_net-next/actions/runs/22844479818

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.
Re: [PATCH net-next v3 2/6] mptcp: keep rcv_mwnd_seq in sync with subflow rcv_wnd
Posted by Simon Baatz 1 week, 3 days ago
Hi Matt,

On Wed, Mar 11, 2026 at 07:27:34PM +0100, Matthieu Baerts wrote:
> Hi Simon,
> 
> On 09/03/2026 09:02, Simon Baatz via B4 Relay wrote:
> > From: Simon Baatz <gmbnomis@gmail.com>
> > 
> > MPTCP shares a receive window across subflows and applies it at the
> > subflow level by adjusting each subflow's rcv_wnd when needed.  With
> > the new TCP tracking of the maximum advertised window sequence,
> > rcv_mwnd_seq must stay consistent with these subflow-level rcv_wnd
> > adjustments.
> 
> Thank you for these modifications!
> 
> > Signed-off-by: Simon Baatz <gmbnomis@gmail.com>
> > ---
> >  net/mptcp/options.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/net/mptcp/options.c b/net/mptcp/options.c
> > index 43df4293f58bfbd8a8df6bf24b9f15e0f9e238f6..8a1c5698983cff3082d68290626dd8f1e044527f 100644
> > --- a/net/mptcp/options.c
> > +++ b/net/mptcp/options.c
> 
> (...)
> 
> > @@ -1338,8 +1339,9 @@ static void mptcp_set_rwin(struct tcp_sock *tp, struct tcphdr *th)
> >  		 */
> >  		rcv_wnd_new = rcv_wnd_old;
> >  		win = rcv_wnd_old - ack_seq;
> > -		tp->rcv_wnd = min_t(u64, win, U32_MAX);
> > -		new_win = tp->rcv_wnd;
> > +		new_win = min_t(u64, win, U32_MAX);
> > +		tp->rcv_wnd = new_win;
> 
> Out of curiosity, why did you change the two lines above?
> (even if it makes sense, the diff is a bit confusing, and the commit
> message doesn't mention this :) )

I wanted to keep tcp_update_max_rcv_wnd_seq() calls close to the
respective update sites (same pattern everywhere).  In the original
form

tp->rcv_wnd = min_t(u64, win, U32_MAX);
tcp_update_max_rcv_wnd_seq(tp);
new_win = tp->rcv_wnd;

the ordering suggests that tcp_update_max_rcv_wnd_seq() might modify
tp->rcv_wnd.

So, I changed it for legibility.  Now, I realize it made the
diff harder to read.  I might have optimized the wrong metric here ;-)

> 
> > +		tcp_update_max_rcv_wnd_seq(tp);
> 
> 
> This patch adding this new helper each time rcv_wnd is modified looks
> good to me:
> 
> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> 
> 
> Note: just in case a new version is needed, checkpatch reported an error
> in patch 4/6 because of a trailing whitespace (+ No space is necessary
> after a cast in patch 1/6), see:
> 
>   https://github.com/multipath-tcp/mptcp_net-next/actions/runs/22844479818

Thanks. I will change that if there is a v4.


-- 
Simon Baatz <gmbnomis@gmail.com>
Re: [PATCH net-next v3 2/6] mptcp: keep rcv_mwnd_seq in sync with subflow rcv_wnd
Posted by Matthieu Baerts 1 week, 2 days ago
Hi Simon,

On 11/03/2026 23:08, Simon Baatz wrote:
> On Wed, Mar 11, 2026 at 07:27:34PM +0100, Matthieu Baerts wrote:
>> On 09/03/2026 09:02, Simon Baatz via B4 Relay wrote:
>>> From: Simon Baatz <gmbnomis@gmail.com>
>>>
>>> MPTCP shares a receive window across subflows and applies it at the
>>> subflow level by adjusting each subflow's rcv_wnd when needed.  With
>>> the new TCP tracking of the maximum advertised window sequence,
>>> rcv_mwnd_seq must stay consistent with these subflow-level rcv_wnd
>>> adjustments.
>>
>> Thank you for these modifications!
>>
>>> Signed-off-by: Simon Baatz <gmbnomis@gmail.com>
>>> ---
>>>  net/mptcp/options.c | 6 ++++--
>>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/net/mptcp/options.c b/net/mptcp/options.c
>>> index 43df4293f58bfbd8a8df6bf24b9f15e0f9e238f6..8a1c5698983cff3082d68290626dd8f1e044527f 100644
>>> --- a/net/mptcp/options.c
>>> +++ b/net/mptcp/options.c
>>
>> (...)
>>
>>> @@ -1338,8 +1339,9 @@ static void mptcp_set_rwin(struct tcp_sock *tp, struct tcphdr *th)
>>>  		 */
>>>  		rcv_wnd_new = rcv_wnd_old;
>>>  		win = rcv_wnd_old - ack_seq;
>>> -		tp->rcv_wnd = min_t(u64, win, U32_MAX);
>>> -		new_win = tp->rcv_wnd;
>>> +		new_win = min_t(u64, win, U32_MAX);
>>> +		tp->rcv_wnd = new_win;
>>
>> Out of curiosity, why did you change the two lines above?
>> (even if it makes sense, the diff is a bit confusing, and the commit
>> message doesn't mention this :) )
> 
> I wanted to keep tcp_update_max_rcv_wnd_seq() calls close to the
> respective update sites (same pattern everywhere).

Thanks, I now understand the reason.

> In the original form
> 
> tp->rcv_wnd = min_t(u64, win, U32_MAX);
> tcp_update_max_rcv_wnd_seq(tp);
> new_win = tp->rcv_wnd;
> 
> the ordering suggests that tcp_update_max_rcv_wnd_seq() might modify
> tp->rcv_wnd.

Note that if tp->rcv_mwnd_seq always needs to be modified when
tp->rcv_wnd and/or tp->rcv_wup are modified, maybe a single helper could
be called to modify all of them, so it might be less likely to forget
about modifying tp->rcv_mwnd_seq as well in the future.

But probably it might be unlikely to have new places where tp->rcv_wnd
and/or tp->rcv_wup need to be modified like here with MPTCP. So probably
fine like that.

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.
Re: [PATCH net-next v3 2/6] mptcp: keep rcv_mwnd_seq in sync with subflow rcv_wnd
Posted by Eric Dumazet 1 week, 4 days ago
On Mon, Mar 9, 2026 at 9:03 AM Simon Baatz via B4 Relay
<devnull+gmbnomis.gmail.com@kernel.org> wrote:
>
> From: Simon Baatz <gmbnomis@gmail.com>
>
> MPTCP shares a receive window across subflows and applies it at the
> subflow level by adjusting each subflow's rcv_wnd when needed.  With
> the new TCP tracking of the maximum advertised window sequence,
> rcv_mwnd_seq must stay consistent with these subflow-level rcv_wnd
> adjustments.
>
> Signed-off-by: Simon Baatz <gmbnomis@gmail.com>

Reviewed-by: Eric Dumazet <edumazet@google.com>