Skip to contentSkip to conversation

mptcp: pm: in-kernel: C-flag: handle late ADD_ADDR + misc.

PATCH In review Matthieu Baerts (NGI0) 3 participants 22 messages Oct 8, 2025 – Oct 17, 2025

Subsystems (3)
lore
Share & tools
lore

Matthieu Baerts (NGI0)

author maintainer
#0 lore raw

cover mptcp: pm: in-kernel: C-flag: handle late ADD_ADDR + misc.

On NIPA, the new test validating the special case for the C-flag failed a few times, e.g.

102 default limits, server deny join id 0
syn rx [FAIL] got 0 JOIN[s] syn rx expected 2
Server ns stats

  TcpPassiveOpens                 1                  0.0
  TcpInSegs                       9                  0.0
  TcpOutSegs                      10                 0.0
  TcpExtTW                        1                  0.0
  TcpExtTCPPureAcks               5                  0.0
  TcpExtTCPOrigDataSent           3                  0.0
  TcpExtTCPDelivered              3                  0.0
  MPTcpExtMPCapableSYNRX          1                  0.0
  MPTcpExtMPCapableACKRX          1                  0.0
  MPTcpExtAddAddrTx               1                  0.0
  MPTcpExtEchoAdd                 1                  0.0
  Client ns stats
  TcpActiveOpens                  1                  0.0
  TcpInSegs                       10                 0.0
  TcpOutSegs                      9                  0.0
  TcpExtTCPPureAcks               6                  0.0
  TcpExtTCPOrigDataSent           3                  0.0
  TcpExtTCPDelivered              4                  0.0
  MPTcpExtMPCapableSYNTX          1                  0.0
  MPTcpExtMPCapableSYNACKRX       1                  0.0
  MPTcpExtAddAddr                 1                  0.0
  MPTcpExtEchoAddTx               1                  0.0
        synack rx              [FAIL] got 0 JOIN[s] synack rx expected 2
        ack rx                 [FAIL] got 0 JOIN[s] ack rx expected 2
        join Rx                [FAIL] see above
        syn tx                 [FAIL] got 0 JOIN[s] syn tx expected 2
        join Tx                [FAIL] see above

I had a suspicion about what the issue could be: the ADD_ADDR might have been received with a delay, not when switching to 'fully-established'. The issue was not easy to reproduce on my side, but when I did, the packet capture shown that the ADD_ADDR can indeed be received with a delay, and the client would not try to establish subflows to it as expected.

Patch 1 fixes that, simply by not marking the endpoints as 'used' in the C-flag case, when looking at creating subflows to the remote initial IP address and port: in this case, there is no need to try.

Patches 2 to 5 are not directly related, but seen when working on patch 7: they fix subtests not being marked as 'skipped' on older kernels.

Patches 6 and 7 are for net-next:

- The first one avoids iterating over all endpoints just to check if one of them has the 'fullmesh' flag.

- The second one clarifies what is done when an ADD_ADDR is received and there are endpoints with the fullmesh flag: only these endpoints are used, even if there are none defined for this address family.

---
Matthieu Baerts (NGI0) (7):
mptcp: pm: in-kernel: C-flag: handle late ADD_ADDR
selftests: mptcp: join: mark 'flush re-add' as skipped if not supported
selftests: mptcp: join: mark 'delete re-add signal' as skipped if not supported
selftests: mptcp: join: mark implicit tests as skipped if not supported
selftests: mptcp: join: mark laminar tests as skipped if not supported
mptcp: pm: in-kernel: record fullmesh endp nb
mptcp: pm: in kernel: only use fullmesh endp if any

 include/uapi/linux/mptcp.h                      |  3 +-
 net/mptcp/pm_kernel.c                           | 42 ++++++++++++++++++++++---
 net/mptcp/protocol.h                            |  1 +
 net/mptcp/sockopt.c                             |  2 ++
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 24 ++++++++------
 5 files changed, 57 insertions(+), 15 deletions(-)

---
base-commit: 3afc295b5e6e698696cf1fd75db194db2c7f64cd
change-id: 20251003-c-flag-add-addr-delay-4e9e57789c36

Best regards,

Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
author maintainer
#1 lore raw

PATCH 1/7 mptcp: pm: in-kernel: C-flag: handle late ADD_ADDR

The special C-flag case expects the ADD_ADDR to be received when switching to 'fully-established'. But for various reasons, the ADD_ADDR could be sent after the "4th ACK", and the special case doesn't work.

On NIPA, the new test validating this special case for the C-flag failed a few times, e.g.

102 default limits, server deny join id 0
syn rx [FAIL] got 0 JOIN[s] syn rx expected 2

Server ns stats
(...)
MPTcpExtAddAddrTx 1
MPTcpExtEchoAdd 1

Client ns stats
(...)
MPTcpExtAddAddr 1
MPTcpExtEchoAddTx 1

        synack rx              [FAIL] got 0 JOIN[s] synack rx expected 2
        ack rx                 [FAIL] got 0 JOIN[s] ack rx expected 2
        join Rx                [FAIL] see above
        syn tx                 [FAIL] got 0 JOIN[s] syn tx expected 2
        join Tx                [FAIL] see above

I had a suspicion about what the issue could be: the ADD_ADDR might have been received after the switch to the 'fully-established' state. The issue was not easy to reproduce. The packet capture shown that the ADD_ADDR can indeed be sent with a delay, and the client would not try to establish subflows to it as expected.

A simple fix is not to mark the endpoints as 'used' in the C-flag case, when looking at creating subflows to the remote initial IP address and port. In this case, there is no need to try.

Note: newly added fullmesh endpoints will still continue to be used as expected, thanks to the conditions behind mptcp_pm_add_addr_c_flag_case.

Fixes 4b1ff850e0c1 ("mptcp: pm: in-kernel: usable client side with C-flag")
---
 net/mptcp/pm_kernel.c | 6 ++++++
 1 file changed, 6 insertions(+)
net/mptcp/pm_kernel.c +6 -0
index da431da16ae0..df2bc36593d0 100644
@@ -370,6 +370,10 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
 	}
 
 subflow:
+	/* No need to try establishing subflows to remote id0 if not allowed */
+	if (mptcp_pm_add_addr_c_flag_case(msk))
+		goto exit;
+
 	/* check if should create a new subflow */
 	while (msk->pm.local_addr_used < endp_subflow_max &&
 	       msk->pm.extra_subflows < limit_extra_subflows) {
@@ -401,6 +405,8 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
 			__mptcp_subflow_connect(sk, &local, &addrs[i]);
 		spin_lock_bh(&msk->pm.lock);
 	}
+
+exit:
 	mptcp_pm_nl_check_work_pending(msk);
 }
 
Signature · 1 line
2.51.0
reviewer
#2 lore raw

Re: [PATCH mptcp-net 1/7] mptcp: pm: in-kernel: C-flag: handle late ADD_ADDR

Hi Matt,

Quoted 29 lines · On Wed, 2025-10-08 at 15:59 +0200, Matthieu Baerts (NGI0) wrote:

The special C-flag case expects the ADD_ADDR to be received when switching to 'fully-established'. But for various reasons, the ADD_ADDR
could be sent after the "4th ACK", and the special case doesn't work.

On NIPA, the new test validating this special case for the C-flag failed
a few times, e.g.

  102 default limits, server deny join id 0
        syn rx                 [FAIL] got 0 JOIN[s] syn rx expected 2

  Server ns stats
  (...)
  MPTcpExtAddAddrTx  1
  MPTcpExtEchoAdd    1

  Client ns stats
  (...)
  MPTcpExtAddAddr    1
  MPTcpExtEchoAddTx  1

        synack rx              [FAIL] got 0 JOIN[s] synack rx expected 2
        ack rx                 [FAIL] got 0 JOIN[s] ack rx expected 2 join Rx                [FAIL] see above
        syn tx                 [FAIL] got 0 JOIN[s] syn tx expected 2 join Tx                [FAIL] see above

Quoted 4 lines

I had a suspicion about what the issue could be: the ADD_ADDR might have
been received after the switch to the 'fully-established' state. The issue was not easy to reproduce. The packet capture shown that the

It was indeed not easy to reproduce, but after spending a lot of time, I finally managed to reproduce it and also verified that this patch indeed works.

Quoted 33 lines

ADD_ADDR can indeed be sent with a delay, and the client would not try
to establish subflows to it as expected.

A simple fix is not to mark the endpoints as 'used' in the C-flag case,
when looking at creating subflows to the remote initial IP address and
port. In this case, there is no need to try.

Note: newly added fullmesh endpoints will still continue to be used as
expected, thanks to the conditions behind mptcp_pm_add_addr_c_flag_case.

Fixes 4b1ff850e0c1 ("mptcp: pm: in-kernel: usable client side with

C-flag")

---
 net/mptcp/pm_kernel.c | 6 ++++++

 1 file changed, 6 insertions(+)
net/mptcp/pm_kernel.c +0 -0
index da431da16ae0..df2bc36593d0 100644
@@ -370,6 +370,10 @@ static void
 mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
  	}


 subflow:

net/mptcp/pm_kernel.c +1 -0
+	/* No need to try establishing subflows to remote id0 if not

allowed */

net/mptcp/pm_kernel.c static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) · line 376

Quoted 3 lines
net/mptcp/pm_kernel.c +3 -0
+	if (mptcp_pm_add_addr_c_flag_case(msk))
+		goto exit;
+

I think it would be better to place this c_flag check inside the while loop below.

net/mptcp/pm_kernel.c static void · line 411

Quoted 11 lines

  /* check if should create a new subflow */ while (msk->pm.local_addr_used < endp_subflow_max && msk->pm.extra_subflows < limit_extra_subflows) {

net/mptcp/pm_kernel.c +2 -0
@@ -401,6 +405,8 @@ static void
 mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
  			__mptcp_subflow_connect(sk, &local,
 &addrs[i]);
  		spin_lock_bh(&msk->pm.lock);
  	}
+
+exit:

This way, we won't need to add an exit label and can simply use a break. Something like this:

subflow:

        /* check if should create a new subflow */
        while (msk->pm.local_addr_used < endp_subflow_max &&
               msk->pm.extra_subflows < limit_extra_subflows) {
                struct mptcp_addr_info addrs[MPTCP_PM_ADDR_MAX];
                bool fullmesh;
                int i, nr;

                /* No need to try establishing subflows to remote
                   id0 if not allowed */
                if (mptcp_pm_add_addr_c_flag_case(msk))
                        break;

                if (signal_and_subflow)
                        signal_and_subflow = false;
                else if (!select_local_address(pernet, msk, &local))
                        break;

WDYT?

Thanks,
-Geliang

Quoted 4 lines
net/mptcp/pm_kernel.c +0 -0
  	mptcp_pm_nl_check_work_pending(msk);

 }

author maintainer
#3 lore raw

Re: [PATCH mptcp-net 1/7] mptcp: pm: in-kernel: C-flag: handle late ADD_ADDR

Hi Geliang,

Thank you for the review!

17 Oct 2025 08:11:37 Geliang Tang <[email protected]>:

Quoted 32 lines

Hi Matt,

Quoted 29 lines · On Wed, 2025-10-08 at 15:59 +0200, Matthieu Baerts (NGI0) wrote:

The special C-flag case expects the ADD_ADDR to be received when switching to 'fully-established'. But for various reasons, the ADD_ADDR
could be sent after the "4th ACK", and the special case doesn't work.

On NIPA, the new test validating this special case for the C-flag failed
a few times, e.g.

  102 default limits, server deny join id 0
        syn rx                 [FAIL] got 0 JOIN[s] syn rx expected 2

  Server ns stats
  (...)
  MPTcpExtAddAddrTx  1
  MPTcpExtEchoAdd    1

  Client ns stats
  (...)
  MPTcpExtAddAddr    1
  MPTcpExtEchoAddTx  1

        synack rx              [FAIL] got 0 JOIN[s] synack rx expected 2
        ack rx                 [FAIL] got 0 JOIN[s] ack rx expected 2 join Rx                [FAIL] see above
        syn tx                 [FAIL] got 0 JOIN[s] syn tx expected 2 join Tx                [FAIL] see above

Quoted 8 lines
Quoted 4 lines

I had a suspicion about what the issue could be: the ADD_ADDR might have
been received after the switch to the 'fully-established' state. The issue was not easy to reproduce. The packet capture shown that the

It was indeed not easy to reproduce, but after spending a lot of time, I finally managed to reproduce it and also verified that this patch indeed works.

Thanks!

Quoted 63 lines
Quoted 29 lines

ADD_ADDR can indeed be sent with a delay, and the client would not try
to establish subflows to it as expected.

A simple fix is not to mark the endpoints as 'used' in the C-flag case,
when looking at creating subflows to the remote initial IP address and
port. In this case, there is no need to try.

Note: newly added fullmesh endpoints will still continue to be used as
expected, thanks to the conditions behind mptcp_pm_add_addr_c_flag_case.

Fixes 4b1ff850e0c1 ("mptcp: pm: in-kernel: usable client side with

C-flag")

---
 net/mptcp/pm_kernel.c | 6 ++++++

 1 file changed, 6 insertions(+)
net/mptcp/pm_kernel.c +0 -0
index da431da16ae0..df2bc36593d0 100644
@@ -370,6 +370,10 @@ static void
 mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
     }
Quoted 7 lines


 subflow:
+   /* No need to try establishing subflows to remote id0 if not allowed */
+   if (mptcp_pm_add_addr_c_flag_case(msk))
+       goto exit;
+

I think it would be better to place this c_flag check inside the while loop below.

net/mptcp/pm_kernel.c static void · line 411

Quoted 11 lines

    /* check if should create a new subflow */ while (msk->pm.local_addr_used < endp_subflow_max && msk->pm.extra_subflows < limit_extra_subflows) {

net/mptcp/pm_kernel.c +2 -0
@@ -401,6 +405,8 @@ static void
 mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
             __mptcp_subflow_connect(sk, &local,
 &addrs[i]);
         spin_lock_bh(&msk->pm.lock);
     }
+
+exit:

This way, we won't need to add an exit label and can simply use a break. Something like this:

subflow:
        /* check if should create a new subflow */ while (msk->pm.local_addr_used < endp_subflow_max && msk->pm.extra_subflows < limit_extra_subflows) { struct mptcp_addr_info addrs[MPTCP_PM_ADDR_MAX]; bool fullmesh;
                int i, nr;

Quoted 4 lines

                /* No need to try establishing subflows to remote id0 if not allowed */
                if (mptcp_pm_add_addr_c_flag_case(msk)) break;

I'm not convinced: that means these conditions will be checked for each local address, for each iteration here, while the result will be always the same.

Here it sounds better to me to skip the selection before starting, if there is no need to do that.

Cheers,
Matt

Quoted 15 lines

                if (signal_and_subflow) signal_and_subflow = false;
                else if (!select_local_address(pernet, msk, &local)) break;

WDYT?

Thanks,
-Geliang

Quoted 4 lines
net/mptcp/pm_kernel.c +0 -0
     mptcp_pm_nl_check_work_pending(msk);

 }

reviewer Reviewed-by
#4 lore raw

Re: [PATCH mptcp-net 1/7] mptcp: pm: in-kernel: C-flag: handle late ADD_ADDR

Quoted 136 lines · Matthieu Baerts

Hi Geliang,

Thank you for the review!

17 Oct 2025 08:11:37 Geliang Tang <[email protected]>:

Quoted 44 lines

Hi Matt,

Quoted 33 lines · On Wed, 2025-10-08 at 15:59 +0200, Matthieu Baerts (NGI0) wrote:

The special C-flag case expects the ADD_ADDR to be received when switching to 'fully-established'. But for various reasons, the ADD_ADDR
could be sent after the "4th ACK", and the special case doesn't work.

On NIPA, the new test validating this special case for the C-flag failed
a few times, e.g.

  102 default limits, server deny join id 0
        syn rx                 [FAIL] got 0 JOIN[s] syn rx expected 2

  Server ns stats
  (...)
  MPTcpExtAddAddrTx  1
  MPTcpExtEchoAdd    1

  Client ns stats
  (...)
  MPTcpExtAddAddr    1
  MPTcpExtEchoAddTx  1

        synack rx              [FAIL] got 0 JOIN[s] synack rx expected 2
        ack rx                 [FAIL] got 0 JOIN[s] ack rx expected 2
        join Rx                [FAIL] see above
        syn tx                 [FAIL] got 0 JOIN[s] syn tx expected 2
        join Tx                [FAIL] see above

Quoted 7 lines

I had a suspicion about what the issue could be: the ADD_ADDR might
have
been received after the switch to the 'fully-established' state. The
issue was not easy to reproduce. The packet capture shown that the

Quoted 4 lines

It was indeed not easy to reproduce, but after spending a lot of time,
I finally managed to reproduce it and also verified that this patch indeed works.

Thanks!

Quoted 68 lines
Quoted 33 lines

ADD_ADDR can indeed be sent with a delay, and the client would not
try
to establish subflows to it as expected.

A simple fix is not to mark the endpoints as 'used' in the C-flag case,
when looking at creating subflows to the remote initial IP address
and
port. In this case, there is no need to try.

Note: newly added fullmesh endpoints will still continue to be used
as
expected, thanks to the conditions behind mptcp_pm_add_addr_c_flag_case.

Fixes 4b1ff850e0c1 ("mptcp: pm: in-kernel: usable client side

with
C-flag")

---
 net/mptcp/pm_kernel.c | 6 ++++++

 1 file changed, 6 insertions(+)
net/mptcp/pm_kernel.c +0 -0
index da431da16ae0..df2bc36593d0 100644
@@ -370,6 +370,10 @@ static void
 mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
     }
Quoted 7 lines


 subflow:
+   /* No need to try establishing subflows to remote id0 if not allowed */
+   if (mptcp_pm_add_addr_c_flag_case(msk))
+       goto exit;
+

I think it would be better to place this c_flag check inside the while
loop below.

net/mptcp/pm_kernel.c static void · line 411

Quoted 11 lines

    /* check if should create a new subflow */ while (msk->pm.local_addr_used < endp_subflow_max && msk->pm.extra_subflows < limit_extra_subflows) {

net/mptcp/pm_kernel.c +2 -0
@@ -401,6 +405,8 @@ static void
 mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
             __mptcp_subflow_connect(sk, &local,
 &addrs[i]);
         spin_lock_bh(&msk->pm.lock);
     }
+
+exit:

This way, we won't need to add an exit label and can simply use a break. Something like this:

subflow:
        /* check if should create a new subflow */ while (msk->pm.local_addr_used < endp_subflow_max && msk->pm.extra_subflows < limit_extra_subflows) { struct mptcp_addr_info addrs[MPTCP_PM_ADDR_MAX]; bool fullmesh;
                int i, nr;

Quoted 4 lines

                /* No need to try establishing subflows to remote id0 if not allowed */
                if (mptcp_pm_add_addr_c_flag_case(msk)) break;

I'm not convinced: that means these conditions will be checked for each
local address, for each iteration here, while the result will be always the
same.

Quoted 3 lines

Here it sounds better to me to skip the selection before starting, if there
is no need to do that.

If so, please add my reviewed-by tag and apply this set. Sorry for the delay.

Thanks,
-Geliang

Quoted 21 lines

Cheers,
Matt

Quoted 16 lines

                if (signal_and_subflow) signal_and_subflow = false; else if (!select_local_address(pernet, msk, &local))
                        break;

WDYT?

Thanks,
-Geliang

Quoted 4 lines
net/mptcp/pm_kernel.c +0 -0
     mptcp_pm_nl_check_work_pending(msk);

 }

author maintainer
#5 lore raw

PATCH 2/7 selftests: mptcp: join: mark 'flush re-add' as skipped if not supported

In reply to Matthieu Baerts (NGI0)

The call to 'continue_if' was missing: it properly marks a subtest as 'skipped' if the attached condition is not valid.

Without that, the test is wrongly marked as passed on older kernels.

Fixes e06959e9eebd ("selftests: mptcp: join: test for flush/re-add endpoints")
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -1
index c90d8e8b95cb..deba21ca5a97 100755
@@ -4115,7 +4115,7 @@ endpoint_tests()
 
 	# flush and re-add
 	if reset_with_tcp_filter "flush re-add" ns2 10.0.3.2 REJECT OUTPUT &&
-	   mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
+	   continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
 		pm_nl_set_limits $ns1 0 2
 		pm_nl_set_limits $ns2 1 2
 		# broadcast IP: no packet for this address will be received on ns1
Signature · 1 line
2.51.0
reviewer Reviewed-by on v1 2/7
#6 lore raw

Re: [PATCH mptcp-net 2/7] selftests: mptcp: join: mark 'flush re-add' as skipped if not supported

Hi Matt,

Quoted 8 lines · On Wed, 2025-10-08 at 15:59 +0200, Matthieu Baerts (NGI0) wrote:

The call to 'continue_if' was missing: it properly marks a subtest as 'skipped' if the attached condition is not valid.

Without that, the test is wrongly marked as passed on older kernels.

Fixes e06959e9eebd ("selftests: mptcp: join: test for flush/re-add

endpoints")

This patch looks good to me.

Thanks,
-Geliang

Quoted 22 lines

---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -0
index c90d8e8b95cb..deba21ca5a97 100755
@@ -4115,7 +4115,7 @@ endpoint_tests()

 	# flush and re-add
 	if reset_with_tcp_filter "flush re-add" ns2 10.0.3.2 REJECT
OUTPUT &&
tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -1
-	   mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
+	   continue_if mptcp_lib_kallsyms_has

"subflow_rebuild_header$"; then
  pm_nl_set_limits $ns1 0 2
  pm_nl_set_limits $ns2 1 2

 		# broadcast IP: no packet for this address will be
received on ns1
author maintainer
#7 lore raw

PATCH 3/7 selftests: mptcp: join: mark 'delete re-add signal' as skipped if not supported

In reply to Matthieu Baerts (NGI0)

The call to 'continue_if' was missing: it properly marks a subtest as 'skipped' if the attached condition is not valid.

Without that, the test is wrongly marked as passed on older kernels.

Fixes b5e2fb832f48 ("selftests: mptcp: add explicit test case for remove/readd")
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -1
index deba21ca5a97..59983aed2591 100755
@@ -4040,7 +4040,7 @@ endpoint_tests()
 
 	# remove and re-add
 	if reset_with_events "delete re-add signal" &&
-	   mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
+	   continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
 		ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=0
 		pm_nl_set_limits $ns1 0 3
 		pm_nl_set_limits $ns2 3 3
Signature · 1 line
2.51.0
reviewer Reviewed-by on v1 3/7
#8 lore raw

Re: [PATCH mptcp-net 3/7] selftests: mptcp: join: mark 'delete re-add signal' as skipped if not supported

Hi Matt,

Quoted 8 lines · On Wed, 2025-10-08 at 15:59 +0200, Matthieu Baerts (NGI0) wrote:

The call to 'continue_if' was missing: it properly marks a subtest as 'skipped' if the attached condition is not valid.

Without that, the test is wrongly marked as passed on older kernels.

Fixes b5e2fb832f48 ("selftests: mptcp: add explicit test case for

remove/readd")

This patch looks good to me.

Thanks,
-Geliang

Quoted 21 lines

---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -0
index deba21ca5a97..59983aed2591 100755
@@ -4040,7 +4040,7 @@ endpoint_tests()

 	# remove and re-add
 	if reset_with_events "delete re-add signal" &&
tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -1
-	   mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
+	   continue_if mptcp_lib_kallsyms_has

"subflow_rebuild_header$"; then
  ip netns exec $ns1 sysctl -q
net.mptcp.add_addr_timeout=0
  pm_nl_set_limits $ns1 0 3
  pm_nl_set_limits $ns2 3 3

author maintainer
#9 lore raw

PATCH 4/7 selftests: mptcp: join: mark implicit tests as skipped if not supported

In reply to Matthieu Baerts (NGI0)

The call to 'continue_if' was missing: it properly marks a subtest as 'skipped' if the attached condition is not valid.

Without that, the test is wrongly marked as passed on older kernels.

Fixes 36c4127ae8dd ("selftests: mptcp: join: skip implicit tests if not supported")
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +2 -2
index 59983aed2591..b2a8c51a3969 100755
@@ -3939,7 +3939,7 @@ endpoint_tests()
 	# subflow_rebuild_header is needed to support the implicit flag
 	# userspace pm type prevents add_addr
 	if reset "implicit EP" &&
-	   mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
+	   continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
 		pm_nl_set_limits $ns1 2 2
 		pm_nl_set_limits $ns2 2 2
 		pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
@@ -3964,7 +3964,7 @@ endpoint_tests()
 	fi
 
 	if reset_with_tcp_filter "delete and re-add" ns2 10.0.3.2 REJECT OUTPUT &&
-	   mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
+	   continue_if mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
 		start_events
 		pm_nl_set_limits $ns1 0 3
 		pm_nl_set_limits $ns2 0 3
Signature · 1 line
2.51.0
reviewer Reviewed-by on v1 4/7
#10 lore raw

Re: [PATCH mptcp-net 4/7] selftests: mptcp: join: mark implicit tests as skipped if not supported

Hi Matt,

Quoted 8 lines · On Wed, 2025-10-08 at 15:59 +0200, Matthieu Baerts (NGI0) wrote:

The call to 'continue_if' was missing: it properly marks a subtest as 'skipped' if the attached condition is not valid.

Without that, the test is wrongly marked as passed on older kernels.

Fixes 36c4127ae8dd ("selftests: mptcp: join: skip implicit tests if

not supported")

This patch looks good to me.

Thanks,
-Geliang

Quoted 32 lines

---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -0
index 59983aed2591..b2a8c51a3969 100755
@@ -3939,7 +3939,7 @@ endpoint_tests()
  	# subflow_rebuild_header is needed to support the implicit

flag

 	# userspace pm type prevents add_addr
 	if reset "implicit EP" &&
tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -1
-	   mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
+	   continue_if mptcp_lib_kallsyms_has

"subflow_rebuild_header$"; then
  pm_nl_set_limits $ns1 2 2 pm_nl_set_limits $ns2 2 2 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal

tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -0
@@ -3964,7 +3964,7 @@ endpoint_tests()

  fi

  if reset_with_tcp_filter "delete and re-add" ns2 10.0.3.2 REJECT OUTPUT &&

tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -1
-	   mptcp_lib_kallsyms_has "subflow_rebuild_header$"; then
+	   continue_if mptcp_lib_kallsyms_has

"subflow_rebuild_header$"; then
  start_events
  pm_nl_set_limits $ns1 0 3
  pm_nl_set_limits $ns2 0 3

author maintainer
#11 lore raw

PATCH 5/7 selftests: mptcp: join: mark laminar tests as skipped if not supported

In reply to Matthieu Baerts (NGI0)

The call to 'continue_if' was missing: it properly marks a subtest as 'skipped' if the attached condition is not valid.

Without that, the test is wrongly marked as passed on older kernels.

Fixes c912f935a5c7 ("selftests: mptcp: join: validate new laminar endp")
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +5 -5
index b2a8c51a3969..78a1aa4ecff2 100755
@@ -2324,7 +2324,7 @@ laminar_endp_tests()
 {
 	# no laminar endpoints: routing rules are used
 	if reset_with_tcp_filter "without a laminar endpoint" ns1 10.0.2.2 REJECT &&
-	   mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$"; then
+	   continue_if mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$"; then
 		pm_nl_set_limits $ns1 0 2
 		pm_nl_set_limits $ns2 2 2
 		pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
@@ -2336,7 +2336,7 @@ laminar_endp_tests()
 
 	# laminar endpoints: this endpoint is used
 	if reset_with_tcp_filter "with a laminar endpoint" ns1 10.0.2.2 REJECT &&
-	   mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$"; then
+	   continue_if mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$"; then
 		pm_nl_set_limits $ns1 0 2
 		pm_nl_set_limits $ns2 2 2
 		pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
@@ -2348,7 +2348,7 @@ laminar_endp_tests()
 
 	# laminar endpoints: these endpoints are used
 	if reset_with_tcp_filter "with multiple laminar endpoints" ns1 10.0.2.2 REJECT &&
-	   mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$"; then
+	   continue_if mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$"; then
 		pm_nl_set_limits $ns1 0 2
 		pm_nl_set_limits $ns2 2 2
 		pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
@@ -2363,7 +2363,7 @@ laminar_endp_tests()
 
 	# laminar endpoints: only one endpoint is used
 	if reset_with_tcp_filter "single laminar endpoint" ns1 10.0.2.2 REJECT &&
-	   mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$"; then
+	   continue_if mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$"; then
 		pm_nl_set_limits $ns1 0 2
 		pm_nl_set_limits $ns2 2 2
 		pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
@@ -2376,7 +2376,7 @@ laminar_endp_tests()
 
 	# laminar endpoints: subflow and laminar flags
 	if reset_with_tcp_filter "sublow + laminar endpoints" ns1 10.0.2.2 REJECT &&
-	   mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$"; then
+	   continue_if mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$"; then
 		pm_nl_set_limits $ns1 0 4
 		pm_nl_set_limits $ns2 2 4
 		pm_nl_add_endpoint $ns1 10.0.2.1 flags signal
Signature · 1 line
2.51.0
reviewer Reviewed-by on v1 5/7
#12 lore raw

Re: [PATCH mptcp-net 5/7] selftests: mptcp: join: mark laminar tests as skipped if not supported

Hi Matt,

Quoted 8 lines · On Wed, 2025-10-08 at 15:59 +0200, Matthieu Baerts (NGI0) wrote:

The call to 'continue_if' was missing: it properly marks a subtest as 'skipped' if the attached condition is not valid.

Without that, the test is wrongly marked as passed on older kernels.

Fixes c912f935a5c7 ("selftests: mptcp: join: validate new laminar

endp")

This patch looks good to me.

Thanks,
-Geliang

Quoted 70 lines

---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 10 +++++-----

 1 file changed, 5 insertions(+), 5 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -0
index b2a8c51a3969..78a1aa4ecff2 100755
@@ -2324,7 +2324,7 @@ laminar_endp_tests()
  {
  	# no laminar endpoints: routing rules are used

  if reset_with_tcp_filter "without a laminar endpoint" ns1 10.0.2.2 REJECT &&

tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -1
-	   mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$";

then

tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -0
+	   continue_if mptcp_lib_kallsyms_has

"mptcp_pm_get_endp_laminar_max$"; then pm_nl_set_limits $ns1 0 2 pm_nl_set_limits $ns2 2 2 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal

tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -0
@@ -2336,7 +2336,7 @@ laminar_endp_tests()

 	# laminar endpoints: this endpoint is used
 	if reset_with_tcp_filter "with a laminar endpoint" ns1
10.0.2.2 REJECT &&
tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -1
-	   mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$";

then

tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -0
+	   continue_if mptcp_lib_kallsyms_has

"mptcp_pm_get_endp_laminar_max$"; then pm_nl_set_limits $ns1 0 2 pm_nl_set_limits $ns2 2 2 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal

tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -0
@@ -2348,7 +2348,7 @@ laminar_endp_tests()

 	# laminar endpoints: these endpoints are used
 	if reset_with_tcp_filter "with multiple laminar endpoints"
ns1 10.0.2.2 REJECT &&
tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -1
-	   mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$";

then

tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -0
+	   continue_if mptcp_lib_kallsyms_has

"mptcp_pm_get_endp_laminar_max$"; then pm_nl_set_limits $ns1 0 2 pm_nl_set_limits $ns2 2 2 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal

tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -0
@@ -2363,7 +2363,7 @@ laminar_endp_tests()

 	# laminar endpoints: only one endpoint is used
 	if reset_with_tcp_filter "single laminar endpoint" ns1
10.0.2.2 REJECT &&
tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -1
-	   mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$";

then

tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -0
+	   continue_if mptcp_lib_kallsyms_has

"mptcp_pm_get_endp_laminar_max$"; then pm_nl_set_limits $ns1 0 2 pm_nl_set_limits $ns2 2 2 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal

tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -0
@@ -2376,7 +2376,7 @@ laminar_endp_tests()

 	# laminar endpoints: subflow and laminar flags
 	if reset_with_tcp_filter "sublow + laminar endpoints" ns1
10.0.2.2 REJECT &&
tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -1
-	   mptcp_lib_kallsyms_has "mptcp_pm_get_endp_laminar_max$";

then

tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -0
+	   continue_if mptcp_lib_kallsyms_has

"mptcp_pm_get_endp_laminar_max$"; then pm_nl_set_limits $ns1 0 4 pm_nl_set_limits $ns2 2 4 pm_nl_add_endpoint $ns1 10.0.2.1 flags signal

author maintainer
#13 lore raw

PATCH 6/7 mptcp: pm: in-kernel: record fullmesh endp nb

In reply to Matthieu Baerts (NGI0)

Instead of iterating over all endpoints, under RCU read lock, just to check if one of them as the fullmesh flag, we can keep a counter of fullmesh endpoint, similar to what is done with the other flags.

This counter is now checked, before iterating over all endpoints.

Similar to the other counters, this new one is also exposed. A userspace app can then know when it is being used in a fullmesh mode, with potentially (too) many subflows.

---
 include/uapi/linux/mptcp.h |  3 ++-
 net/mptcp/pm_kernel.c      | 38 +++++++++++++++++++++++++++++++++++---
 net/mptcp/protocol.h       |  1 +
 net/mptcp/sockopt.c        |  2 ++
 4 files changed, 40 insertions(+), 4 deletions(-)
include/uapi/linux/mptcp.h +2 -1
index 87cfab874e24..04eea6d1d0a9 100644
@@ -70,7 +70,8 @@ struct mptcp_info {
 	__u64	mptcpi_bytes_acked;
 	__u8	mptcpi_subflows_total;
 	__u8	mptcpi_endp_laminar_max;
-	__u8	reserved[2];
+	__u8	mptcpi_endp_fullmesh_max;
+	__u8	reserved;
 	__u32	mptcpi_last_data_sent;
 	__u32	mptcpi_last_data_recv;
 	__u32	mptcpi_last_ack_recv;
net/mptcp/pm_kernel.c +35 -3
index df2bc36593d0..054d85045381 100644
@@ -22,6 +22,7 @@ struct pm_nl_pernet {
 	u8			endp_signal_max;
 	u8			endp_subflow_max;
 	u8			endp_laminar_max;
+	u8			endp_fullmesh_max;
 	u8			limit_add_addr_accepted;
 	u8			limit_extra_subflows;
 	u8			next_id;
@@ -70,6 +71,14 @@ u8 mptcp_pm_get_endp_laminar_max(const struct mptcp_sock *msk)
 }
 EXPORT_SYMBOL_GPL(mptcp_pm_get_endp_laminar_max);
 
+u8 mptcp_pm_get_endp_fullmesh_max(const struct mptcp_sock *msk)
+{
+	struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk);
+
+	return READ_ONCE(pernet->endp_fullmesh_max);
+}
+EXPORT_SYMBOL_GPL(mptcp_pm_get_endp_fullmesh_max);
+
 u8 mptcp_pm_get_limit_add_addr_accepted(const struct mptcp_sock *msk)
 {
 	struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk);
@@ -603,9 +612,12 @@ fill_local_addresses_vec(struct mptcp_sock *msk, struct mptcp_addr_info *remote,
 	int i;
 
 	/* If there is at least one MPTCP endpoint with a fullmesh flag */
-	i = fill_local_addresses_vec_fullmesh(msk, remote, locals, c_flag_case);
-	if (i)
-		return i;
+	if (mptcp_pm_get_endp_fullmesh_max(msk)) {
+		i = fill_local_addresses_vec_fullmesh(msk, remote, locals,
+						      c_flag_case);
+		if (i)
+			return i;
+	}
 
 	/* If there is at least one MPTCP endpoint with a laminar flag */
 	if (mptcp_pm_get_endp_laminar_max(msk))
@@ -790,6 +802,10 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
 		addr_max = pernet->endp_laminar_max;
 		WRITE_ONCE(pernet->endp_laminar_max, addr_max + 1);
 	}
+	if (entry->flags & MPTCP_PM_ADDR_FLAG_FULLMESH) {
+		addr_max = pernet->endp_fullmesh_max;
+		WRITE_ONCE(pernet->endp_fullmesh_max, addr_max + 1);
+	}
 
 	pernet->endpoints++;
 	if (!entry->addr.port)
@@ -1188,6 +1204,10 @@ int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info)
 		addr_max = pernet->endp_laminar_max;
 		WRITE_ONCE(pernet->endp_laminar_max, addr_max - 1);
 	}
+	if (entry->flags & MPTCP_PM_ADDR_FLAG_FULLMESH) {
+		addr_max = pernet->endp_fullmesh_max;
+		WRITE_ONCE(pernet->endp_fullmesh_max, addr_max - 1);
+	}
 
 	pernet->endpoints--;
 	list_del_rcu(&entry->list);
@@ -1503,6 +1523,18 @@ int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local,
 	changed = (local->flags ^ entry->flags) & mask;
 	entry->flags = (entry->flags & ~mask) | (local->flags & mask);
 	*local = *entry;
+
+	if (changed & MPTCP_PM_ADDR_FLAG_FULLMESH) {
+		u8 addr_max = pernet->endp_fullmesh_max;
+
+		if (entry->flags & MPTCP_PM_ADDR_FLAG_FULLMESH)
+			addr_max++;
+		else
+			addr_max--;
+
+		WRITE_ONCE(pernet->endp_fullmesh_max, addr_max);
+	}
+
 	spin_unlock_bh(&pernet->lock);
 
 	mptcp_pm_nl_set_flags_all(net, local, changed);
net/mptcp/protocol.h +1 -0
index 0545eab23125..1e8f40bb7870 100644
@@ -1180,6 +1180,7 @@ void __mptcp_pm_kernel_worker(struct mptcp_sock *msk);
 u8 mptcp_pm_get_endp_signal_max(const struct mptcp_sock *msk);
 u8 mptcp_pm_get_endp_subflow_max(const struct mptcp_sock *msk);
 u8 mptcp_pm_get_endp_laminar_max(const struct mptcp_sock *msk);
+u8 mptcp_pm_get_endp_fullmesh_max(const struct mptcp_sock *msk);
 u8 mptcp_pm_get_limit_add_addr_accepted(const struct mptcp_sock *msk);
 u8 mptcp_pm_get_limit_extra_subflows(const struct mptcp_sock *msk);
 
net/mptcp/sockopt.c +2 -0
index a28a48385885..de90a2897d2d 100644
@@ -982,6 +982,8 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info)
 			mptcp_pm_get_endp_subflow_max(msk);
 		info->mptcpi_endp_laminar_max =
 			mptcp_pm_get_endp_laminar_max(msk);
+		info->mptcpi_endp_fullmesh_max =
+			mptcp_pm_get_endp_fullmesh_max(msk);
 	}
 
 	if (__mptcp_check_fallback(msk))
Signature · 1 line
2.51.0
reviewer
#14 lore raw

Re: [PATCH mptcp-net 6/7] mptcp: pm: in-kernel: record fullmesh endp nb

Hi Matt,

Thanks for this patch.

Quoted 78 lines · On Wed, 2025-10-08 at 16:00 +0200, Matthieu Baerts (NGI0) wrote:

Instead of iterating over all endpoints, under RCU read lock, just to check if one of them as the fullmesh flag, we can keep a counter of fullmesh endpoint, similar to what is done with the other flags.

This counter is now checked, before iterating over all endpoints.

Similar to the other counters, this new one is also exposed. A userspace
app can then know when it is being used in a fullmesh mode, with potentially (too) many subflows.

---
 include/uapi/linux/mptcp.h |  3 ++-
 net/mptcp/pm_kernel.c      | 38 +++++++++++++++++++++++++++++++++++- --
 net/mptcp/protocol.h       |  1 +
 net/mptcp/sockopt.c        |  2 ++

 4 files changed, 40 insertions(+), 4 deletions(-)
include/uapi/linux/mptcp.h +2 -1
index 87cfab874e24..04eea6d1d0a9 100644
@@ -70,7 +70,8 @@ struct mptcp_info {
  	__u64	mptcpi_bytes_acked;
  	__u8	mptcpi_subflows_total;
  	__u8	mptcpi_endp_laminar_max;
-	__u8	reserved[2];
+	__u8	mptcpi_endp_fullmesh_max;
+	__u8	reserved;
  	__u32	mptcpi_last_data_sent;
  	__u32	mptcpi_last_data_recv;
  	__u32	mptcpi_last_ack_recv;
net/mptcp/pm_kernel.c +1 -0
index df2bc36593d0..054d85045381 100644
@@ -22,6 +22,7 @@ struct pm_nl_pernet {
  	u8			endp_signal_max;
  	u8			endp_subflow_max;
  	u8			endp_laminar_max;
+	u8			endp_fullmesh_max;
  	u8			limit_add_addr_accepted;
  	u8			limit_extra_subflows;
  	u8			next_id;
@@ -70,6 +71,14 @@ u8 mptcp_pm_get_endp_laminar_max(const struct
 mptcp_sock *msk)
  }
  EXPORT_SYMBOL_GPL(mptcp_pm_get_endp_laminar_max);

net/mptcp/pm_kernel.c +3 -0
+u8 mptcp_pm_get_endp_fullmesh_max(const struct mptcp_sock *msk)
+{
+	struct pm_nl_pernet *pernet =

pm_nl_get_pernet_from_msk(msk);

net/mptcp/pm_kernel.c +5 -0
+
+	return READ_ONCE(pernet->endp_fullmesh_max);
+}
+EXPORT_SYMBOL_GPL(mptcp_pm_get_endp_fullmesh_max);
+

 u8 mptcp_pm_get_limit_add_addr_accepted(const struct mptcp_sock *msk)
 {
  struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk);

net/mptcp/pm_kernel.c +0 -0
@@ -603,9 +612,12 @@ fill_local_addresses_vec(struct mptcp_sock *msk,
 struct mptcp_addr_info *remote,
  	int i;


  /* If there is at least one MPTCP endpoint with a fullmesh flag */

net/mptcp/pm_kernel.c +0 -1
-	i = fill_local_addresses_vec_fullmesh(msk, remote, locals,

c_flag_case);

net/mptcp/pm_kernel.c +2 -2
-	if (i)
-		return i;
+	if (mptcp_pm_get_endp_fullmesh_max(msk)) {
+		i = fill_local_addresses_vec_fullmesh(msk, remote,

locals,

net/mptcp/pm_kernel.c fill_local_addresses_vec(struct mptcp_sock *msk, struct mptcp_addr_info *remote, · line 620

Quoted 4 lines
net/mptcp/pm_kernel.c +4 -0
+						      c_flag_case);
+		if (i)
+			return i;
+	}

I'm not sure if endp_fullmesh_max needs to be checked in fill_remote_addresses_vec() too, something like:

   if (mptcp_pm_get_endp_fullmesh_max(msk))
           return fill_remote_addresses_fullmesh(msk, local, addrs);

Thanks,
-Geliang

Quoted 78 lines


  /* If there is at least one MPTCP endpoint with a laminar flag */
  if (mptcp_pm_get_endp_laminar_max(msk))

net/mptcp/pm_kernel.c +4 -0
@@ -790,6 +802,10 @@ static int
 mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet,
  		addr_max = pernet->endp_laminar_max;
  		WRITE_ONCE(pernet->endp_laminar_max, addr_max + 1);
  	}
+	if (entry->flags & MPTCP_PM_ADDR_FLAG_FULLMESH) {
+		addr_max = pernet->endp_fullmesh_max;
+		WRITE_ONCE(pernet->endp_fullmesh_max, addr_max + 1);
+	}


  pernet->endpoints++;
  if (!entry->addr.port)

net/mptcp/pm_kernel.c +4 -0
@@ -1188,6 +1204,10 @@ int mptcp_pm_nl_del_addr_doit(struct sk_buff
 *skb, struct genl_info *info)
  		addr_max = pernet->endp_laminar_max;
  		WRITE_ONCE(pernet->endp_laminar_max, addr_max - 1);
  	}
+	if (entry->flags & MPTCP_PM_ADDR_FLAG_FULLMESH) {
+		addr_max = pernet->endp_fullmesh_max;
+		WRITE_ONCE(pernet->endp_fullmesh_max, addr_max - 1);
+	}


  pernet->endpoints--;
  list_del_rcu(&entry->list);

net/mptcp/pm_kernel.c +0 -0
@@ -1503,6 +1523,18 @@ int mptcp_pm_nl_set_flags(struct
 mptcp_pm_addr_entry *local,
  	changed = (local->flags ^ entry->flags) & mask;

  entry->flags = (entry->flags & ~mask) | (local->flags & mask);
  *local = *entry;

net/mptcp/pm_kernel.c +12 -0
+
+	if (changed & MPTCP_PM_ADDR_FLAG_FULLMESH) {
+		u8 addr_max = pernet->endp_fullmesh_max;
+
+		if (entry->flags & MPTCP_PM_ADDR_FLAG_FULLMESH)
+			addr_max++;
+		else
+			addr_max--;
+
+		WRITE_ONCE(pernet->endp_fullmesh_max, addr_max);
+	}
+

  spin_unlock_bh(&pernet->lock);

  mptcp_pm_nl_set_flags_all(net, local, changed);

net/mptcp/protocol.h +1 -0
index 0545eab23125..1e8f40bb7870 100644
@@ -1180,6 +1180,7 @@ void __mptcp_pm_kernel_worker(struct mptcp_sock
 *msk);
  u8 mptcp_pm_get_endp_signal_max(const struct mptcp_sock *msk);
  u8 mptcp_pm_get_endp_subflow_max(const struct mptcp_sock *msk);
  u8 mptcp_pm_get_endp_laminar_max(const struct mptcp_sock *msk);
+u8 mptcp_pm_get_endp_fullmesh_max(const struct mptcp_sock *msk);

 u8 mptcp_pm_get_limit_add_addr_accepted(const struct mptcp_sock *msk);
 u8 mptcp_pm_get_limit_extra_subflows(const struct mptcp_sock *msk);

net/mptcp/sockopt.c +0 -0
index a28a48385885..de90a2897d2d 100644
@@ -982,6 +982,8 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk,
 struct mptcp_info *info)
  			mptcp_pm_get_endp_subflow_max(msk);

  info->mptcpi_endp_laminar_max = mptcp_pm_get_endp_laminar_max(msk);

net/mptcp/sockopt.c +2 -0
+		info->mptcpi_endp_fullmesh_max =
+			mptcp_pm_get_endp_fullmesh_max(msk);

  }

  if (__mptcp_check_fallback(msk))

author maintainer
#15 lore raw

Re: [PATCH mptcp-net 6/7] mptcp: pm: in-kernel: record fullmesh endp nb

Hi Geliang,

Quoted 15 lines · Geliang Tang

Hi Matt,

Thanks for this patch.

Quoted 10 lines · On Wed, 2025-10-08 at 16:00 +0200, Matthieu Baerts (NGI0) wrote:

Instead of iterating over all endpoints, under RCU read lock, just to check if one of them as the fullmesh flag, we can keep a counter of fullmesh endpoint, similar to what is done with the other flags.

This counter is now checked, before iterating over all endpoints.

Similar to the other counters, this new one is also exposed. A userspace
app can then know when it is being used in a fullmesh mode, with potentially (too) many subflows.

(...)

Quoted 4 lines
Quoted 4 lines
net/mptcp/pm_kernel.c +0 -0
index df2bc36593d0..054d85045381 100644

(...)

Quoted 21 lines
Quoted 13 lines
net/mptcp/pm_kernel.c +0 -0
@@ -603,9 +612,12 @@ fill_local_addresses_vec(struct mptcp_sock *msk,
 struct mptcp_addr_info *remote,
  	int i;


  /* If there is at least one MPTCP endpoint with a fullmesh flag */

net/mptcp/pm_kernel.c +0 -1
-	i = fill_local_addresses_vec_fullmesh(msk, remote, locals,

c_flag_case);

net/mptcp/pm_kernel.c +2 -2
-	if (i)
-		return i;
+	if (mptcp_pm_get_endp_fullmesh_max(msk)) {
+		i = fill_local_addresses_vec_fullmesh(msk, remote,

locals,

net/mptcp/pm_kernel.c fill_local_addresses_vec(struct mptcp_sock *msk, struct mptcp_addr_info *remote, · line 620

Quoted 4 lines
net/mptcp/pm_kernel.c +4 -0
+						      c_flag_case);
+		if (i)
+			return i;
+	}

I'm not sure if endp_fullmesh_max needs to be checked in fill_remote_addresses_vec() too, something like:

Quoted 2 lines
   if (mptcp_pm_get_endp_fullmesh_max(msk))
           return fill_remote_addresses_fullmesh(msk, local, addrs);

No, it doesn't need to be used with fill_remote_addresses_fullmesh(), because this helper is only called if the local endpoint has the fullmesh flag, see fill_remote_addresses_vec().

In other words, when calling fill_remote_(...), we have the local endpoint (where the fullmesh flag might be set), and we need the remote addresses. When calling fill_local_(...), it is the opposite: we have a remote address, and we need to find local endpoint(s). It is only in this case we need to know in advance if there are any "fullmesh" local endpoints.

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
reviewer Reviewed-by
#16 lore raw

Re: [PATCH mptcp-net 6/7] mptcp: pm: in-kernel: record fullmesh endp nb

Hi Matt,

Quoted 65 lines · Matthieu Baerts

Hi Geliang,

Quoted 17 lines · Geliang Tang

Hi Matt,

Thanks for this patch.

Quoted 12 lines · On Wed, 2025-10-08 at 16:00 +0200, Matthieu Baerts (NGI0) wrote:

Instead of iterating over all endpoints, under RCU read lock, just to
check if one of them as the fullmesh flag, we can keep a counter of
fullmesh endpoint, similar to what is done with the other flags.

This counter is now checked, before iterating over all endpoints.

Similar to the other counters, this new one is also exposed. A userspace
app can then know when it is being used in a fullmesh mode, with potentially (too) many subflows.

(...)

Quoted 4 lines
Quoted 4 lines
net/mptcp/pm_kernel.c +0 -0
index df2bc36593d0..054d85045381 100644

(...)

Quoted 26 lines
Quoted 19 lines
net/mptcp/pm_kernel.c +0 -0
@@ -603,9 +612,12 @@ fill_local_addresses_vec(struct mptcp_sock
 *msk,
 struct mptcp_addr_info *remote,
  	int i;


  /* If there is at least one MPTCP endpoint with a fullmesh
flag */

net/mptcp/pm_kernel.c +0 -1
-	i = fill_local_addresses_vec_fullmesh(msk, remote,

locals,
c_flag_case);

net/mptcp/pm_kernel.c +2 -2
-	if (i)
-		return i;
+	if (mptcp_pm_get_endp_fullmesh_max(msk)) {
+		i = fill_local_addresses_vec_fullmesh(msk,

remote,
locals,

net/mptcp/pm_kernel.c +1 -0
+						     

c_flag_case);

net/mptcp/pm_kernel.c fill_local_addresses_vec(struct mptcp_sock *msk, struct mptcp_addr_info *remote, · line 620

Quoted 3 lines
net/mptcp/pm_kernel.c +3 -0
+		if (i)
+			return i;
+	}

I'm not sure if endp_fullmesh_max needs to be checked in fill_remote_addresses_vec() too, something like:

Quoted 3 lines

   if (mptcp_pm_get_endp_fullmesh_max(msk))
           return fill_remote_addresses_fullmesh(msk, local, addrs);

No, it doesn't need to be used with fill_remote_addresses_fullmesh(), because this helper is only called if the local endpoint has the fullmesh flag, see fill_remote_addresses_vec().

Quoted 9 lines

In other words, when calling fill_remote_(...), we have the local endpoint (where the fullmesh flag might be set), and we need the remote
addresses. When calling fill_local_(...), it is the opposite: we have a
remote address, and we need to find local endpoint(s). It is only in this case we need to know in advance if there are any "fullmesh" local
endpoints.

Thank you for your explanation. If that's the case, please add my review-by tag:

Thanks,
-Geliang

Quoted 3 lines

Cheers,
Matt

author maintainer
#17 lore raw

PATCH 7/7 mptcp: pm: in kernel: only use fullmesh endp if any

In reply to Matthieu Baerts (NGI0)

Our documentation is saying that the in-kernel PM is only using fullmesh endpoints to establish subflows to announced addresses when at least one endpoint has a fullmesh flag. But this was not totally correct: only fullmesh endpoints were used if at least one endpoint *from the same address family as the received ADD_ADDR* has the fullmesh flag.

This is confusing, and it seems clearer not to have differences depending on the address family.

So, now, when at least one MPTCP endpoint has a fullmesh flag, the local addresses are picked from all fullmesh endpoints, which might be 0 if there are no endpoints for the correct address family.

One selftest needs to be adapted for this behaviour change.

---
 net/mptcp/pm_kernel.c                           | 10 +++-------
 tools/testing/selftests/net/mptcp/mptcp_join.sh |  6 +++++-
 2 files changed, 8 insertions(+), 8 deletions(-)
net/mptcp/pm_kernel.c +3 -7
index 054d85045381..40a0572b3149 100644
@@ -609,15 +609,11 @@ fill_local_addresses_vec(struct mptcp_sock *msk, struct mptcp_addr_info *remote,
 			 struct mptcp_pm_local *locals)
 {
 	bool c_flag_case = remote->id && mptcp_pm_add_addr_c_flag_case(msk);
-	int i;
 
 	/* If there is at least one MPTCP endpoint with a fullmesh flag */
-	if (mptcp_pm_get_endp_fullmesh_max(msk)) {
-		i = fill_local_addresses_vec_fullmesh(msk, remote, locals,
-						      c_flag_case);
-		if (i)
-			return i;
-	}
+	if (mptcp_pm_get_endp_fullmesh_max(msk))
+		return fill_local_addresses_vec_fullmesh(msk, remote, locals,
+							 c_flag_case);
 
 	/* If there is at least one MPTCP endpoint with a laminar flag */
 	if (mptcp_pm_get_endp_laminar_max(msk))
tools/testing/selftests/net/mptcp/mptcp_join.sh +5 -1
index 78a1aa4ecff2..e7a498dd5a46 100755
@@ -2952,7 +2952,11 @@ mixed_tests()
 		pm_nl_add_endpoint $ns1 10.0.1.1 flags signal
 		speed=slow \
 			run_tests $ns1 $ns2 dead:beef:2::1
-		chk_join_nr 1 1 1
+		if mptcp_lib_kallsyms_has "mptcp_pm_get_endp_fullmesh_max$"; then
+			chk_join_nr 0 0 0
+		else
+			chk_join_nr 1 1 1
+		fi
 	fi
 
 	# fullmesh still tries to create all the possibly subflows with
Signature · 1 line
2.51.0
reviewer Reviewed-by on v1 7/7
#18 lore raw

Re: [PATCH mptcp-net 7/7] mptcp: pm: in kernel: only use fullmesh endp if any

Hi Matt,

Quoted 11 lines · On Wed, 2025-10-08 at 16:00 +0200, Matthieu Baerts (NGI0) wrote:

Our documentation is saying that the in-kernel PM is only using fullmesh
endpoints to establish subflows to announced addresses when at least one
endpoint has a fullmesh flag. But this was not totally correct: only fullmesh endpoints were used if at least one endpoint *from the same address family as the received ADD_ADDR* has the fullmesh flag.

This is confusing, and it seems clearer not to have differences depending on the address family.

Quoted 8 lines

So, now, when at least one MPTCP endpoint has a fullmesh flag, the local
addresses are picked from all fullmesh endpoints, which might be 0 if there are no endpoints for the correct address family.

One selftest needs to be adapted for this behaviour change.

This patch LGTM!

Except for patch 1, I have added my reviewed-by tags to all other patches. Please give me some more time to review patch 1. If you're willing, please apply patches 2-7 first.

Thanks,
-Geliang

Quoted 56 lines

---
 net/mptcp/pm_kernel.c                           | 10 +++------- tools/testing/selftests/net/mptcp/mptcp_join.sh |  6 +++++-

 2 files changed, 8 insertions(+), 8 deletions(-)
net/mptcp/pm_kernel.c +0 -0
index 054d85045381..40a0572b3149 100644
@@ -609,15 +609,11 @@ fill_local_addresses_vec(struct mptcp_sock
 *msk, struct mptcp_addr_info *remote,
  			 struct mptcp_pm_local *locals)
  {

  bool c_flag_case = remote->id &&
mptcp_pm_add_addr_c_flag_case(msk);

net/mptcp/pm_kernel.c +0 -1
-	int i;


  /* If there is at least one MPTCP endpoint with a fullmesh flag */

net/mptcp/pm_kernel.c +0 -2
-	if (mptcp_pm_get_endp_fullmesh_max(msk)) {
-		i = fill_local_addresses_vec_fullmesh(msk, remote,

locals,

net/mptcp/pm_kernel.c +2 -4
-						      c_flag_case);
-		if (i)
-			return i;
-	}
+	if (mptcp_pm_get_endp_fullmesh_max(msk))
+		return fill_local_addresses_vec_fullmesh(msk,

remote, locals,

net/mptcp/pm_kernel.c +1 -0
+							

c_flag_case);

  /* If there is at least one MPTCP endpoint with a laminar flag */
  if (mptcp_pm_get_endp_laminar_max(msk))

tools/testing/selftests/net/mptcp/mptcp_join.sh +0 -0
index 78a1aa4ecff2..e7a498dd5a46 100755
@@ -2952,7 +2952,11 @@ mixed_tests()

  pm_nl_add_endpoint $ns1 10.0.1.1 flags signal speed=slow \
  run_tests $ns1 $ns2 dead:beef:2::1

tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -1
-		chk_join_nr 1 1 1
+		if mptcp_lib_kallsyms_has

"mptcp_pm_get_endp_fullmesh_max$"; then

tools/testing/selftests/net/mptcp/mptcp_join.sh +4 -0
+			chk_join_nr 0 0 0
+		else
+			chk_join_nr 1 1 1
+		fi

  fi

 	# fullmesh still tries to create all the possibly subflows
with
author maintainer
#19 lore raw

Re: [PATCH mptcp-net 7/7] mptcp: pm: in kernel: only use fullmesh endp if any

Hi Geliang,

Quoted 23 lines · Geliang Tang

Hi Matt,

Quoted 11 lines · On Wed, 2025-10-08 at 16:00 +0200, Matthieu Baerts (NGI0) wrote:

Our documentation is saying that the in-kernel PM is only using fullmesh
endpoints to establish subflows to announced addresses when at least one
endpoint has a fullmesh flag. But this was not totally correct: only fullmesh endpoints were used if at least one endpoint *from the same address family as the received ADD_ADDR* has the fullmesh flag.

This is confusing, and it seems clearer not to have differences depending on the address family.

Quoted 8 lines

So, now, when at least one MPTCP endpoint has a fullmesh flag, the local
addresses are picked from all fullmesh endpoints, which might be 0 if there are no endpoints for the correct address family.

One selftest needs to be adapted for this behaviour change.

Quoted 7 lines

This patch LGTM!

Except for patch 1, I have added my reviewed-by tags to all other patches. Please give me some more time to review patch 1. If you're willing, please apply patches 2-7 first.

Thank you for your reviews.

I will wait for the review of patch 1: that's the most "urgent" one (fixing a small behavioural issue), the other ones can wait.

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
#20 lore raw
In reply to Matthieu Baerts (NGI0)

Hi Matthieu,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Unstable: 1 failed test(s): selftest_simult_flows 🔴
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/18347885638

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/51b6ddb50104
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1009412

If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

https://github.com/multipath-tcp/mptcp-upstream-virtme-docker

Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)

author maintainer
#21 lore raw
In reply to Matthieu Baerts (NGI0)

Hi Geliang,

Quoted 2 lines · On 08/10/2025 15:59, Matthieu Baerts (NGI0) wrote:

On NIPA, the new test validating the special case for the C-flag failed a few times, e.g.

(...)

Quoted 7 lines

mptcp: pm: in-kernel: C-flag: handle late ADD_ADDR
selftests: mptcp: join: mark 'flush re-add' as skipped if not supported
selftests: mptcp: join: mark 'delete re-add signal' as skipped if not supported
selftests: mptcp: join: mark implicit tests as skipped if not supported
selftests: mptcp: join: mark laminar tests as skipped if not supported
mptcp: pm: in-kernel: record fullmesh endp nb
mptcp: pm: in kernel: only use fullmesh endp if any

Thank you for the review! Now in our trees:

New patches for t/upstream-net and t/upstream:
- 83d8fae94043: mptcp: pm: in-kernel: C-flag: handle late ADD_ADDR
- 0e8cd327f4e5: selftests: mptcp: join: mark 'flush re-add' as skipped if not supported
- 716e6b76040b: selftests: mptcp: join: mark 'delete re-add signal' as skipped if not supported
- d03f66d8df45: selftests: mptcp: join: mark implicit tests as skipped if not supported
- 8942269563cf: selftests: mptcp: join: mark laminar tests as skipped if not supported
- Results: 447b1b798733..6b1d2535995a (export-net)
- Results: e50f1e61a2cc..9908a13fba7c (export)

New patches for t/upstream:
- 5f417bb6c462: mptcp: pm: in-kernel: record fullmesh endp nb
- 9acc176eae6c: mptcp: pm: in kernel: only use fullmesh endp if any
- Results: 9908a13fba7c..78fb62108556 (export)

Tests are now in progress:

- export-net:
https://github.com/multipath-tcp/mptcp_net-next/commit/3d8750d216b4299e258dda3979c4e42f7b64c06d/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/ec4b20675929eae392f14e23067ad34180848874/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/7bf4874aee41205fa1d7ca954b68091371f9dd67/checks

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.