Skip to content

Commit 9ccec26

Browse files
committed
Merge branch 'mptcp-pm-special-case-for-c-flag-luminar-endp'
Matthieu Baerts says: ==================== mptcp: pm: special case for c-flag + luminar endp Here are some patches for the MPTCP PM, including some refactoring that I thought it would be best to send at the end of a cycle to avoid conflicts between net and net-next that could last a few weeks. The most interesting changes are in the first and last patch, the rest are patches refactoring the code & tests to validate the modifications. - Patches 1 & 2: When servers set the C-flag in their MP_CAPABLE to tell clients not to create subflows to the initial address and port -- e.g. a deployment behind a L4 load balancer like a typical CDN deployment -- clients will not use their other endpoints when default settings are used. That's because the in-kernel path-manager uses the 'subflow' endpoints to create subflows only to the initial address and port. The first patch fixes that (for >=v5.14), and the second one validates it. - Patches 3-14: various patches refactoring the code around the in-kernel PM (mainly): split too long functions, rename variables and functions to avoid confusions, reduce structure size, and compare IDs instead of IP addresses. Note that one patch modifies one internal variable used in one BPF selftest. - Patch 15: ability to control endpoints that are used in reaction to a new address announced by the other peer. With that, endpoints can be used only once. ==================== Link: https://patch.msgid.link/20250925-net-next-mptcp-c-flag-laminar-v1-0-ad126cc47c6b@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 1d312d5 + 539f6b9 commit 9ccec26

File tree

8 files changed

+441
-229
lines changed

8 files changed

+441
-229
lines changed

include/uapi/linux/mptcp.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,38 @@
3939
#define MPTCP_PM_ADDR_FLAG_BACKUP _BITUL(2)
4040
#define MPTCP_PM_ADDR_FLAG_FULLMESH _BITUL(3)
4141
#define MPTCP_PM_ADDR_FLAG_IMPLICIT _BITUL(4)
42+
#define MPTCP_PM_ADDR_FLAG_LAMINAR _BITUL(5)
4243

4344
struct mptcp_info {
4445
__u8 mptcpi_subflows;
46+
#define mptcpi_extra_subflows mptcpi_subflows
4547
__u8 mptcpi_add_addr_signal;
4648
__u8 mptcpi_add_addr_accepted;
4749
__u8 mptcpi_subflows_max;
50+
#define mptcpi_limit_extra_subflows mptcpi_subflows_max
4851
__u8 mptcpi_add_addr_signal_max;
52+
#define mptcpi_endp_signal_max mptcpi_add_addr_signal_max
4953
__u8 mptcpi_add_addr_accepted_max;
54+
#define mptcpi_limit_add_addr_accepted mptcpi_add_addr_accepted_max
55+
/* 16-bit hole that can no longer be filled */
5056
__u32 mptcpi_flags;
5157
__u32 mptcpi_token;
5258
__u64 mptcpi_write_seq;
5359
__u64 mptcpi_snd_una;
5460
__u64 mptcpi_rcv_nxt;
5561
__u8 mptcpi_local_addr_used;
5662
__u8 mptcpi_local_addr_max;
63+
#define mptcpi_endp_subflow_max mptcpi_local_addr_max
5764
__u8 mptcpi_csum_enabled;
65+
/* 8-bit hole that can no longer be filled */
5866
__u32 mptcpi_retransmits;
5967
__u64 mptcpi_bytes_retrans;
6068
__u64 mptcpi_bytes_sent;
6169
__u64 mptcpi_bytes_received;
6270
__u64 mptcpi_bytes_acked;
6371
__u8 mptcpi_subflows_total;
64-
__u8 reserved[3];
72+
__u8 mptcpi_endp_laminar_max;
73+
__u8 reserved[2];
6574
__u32 mptcpi_last_data_sent;
6675
__u32 mptcpi_last_data_recv;
6776
__u32 mptcpi_last_ack_recv;

net/mptcp/pm.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -483,32 +483,33 @@ void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ssk, int
483483
bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk)
484484
{
485485
struct mptcp_pm_data *pm = &msk->pm;
486-
unsigned int subflows_max;
486+
unsigned int limit_extra_subflows;
487487
int ret = 0;
488488

489489
if (mptcp_pm_is_userspace(msk)) {
490490
if (mptcp_userspace_pm_active(msk)) {
491491
spin_lock_bh(&pm->lock);
492-
pm->subflows++;
492+
pm->extra_subflows++;
493493
spin_unlock_bh(&pm->lock);
494494
return true;
495495
}
496496
return false;
497497
}
498498

499-
subflows_max = mptcp_pm_get_subflows_max(msk);
499+
limit_extra_subflows = mptcp_pm_get_limit_extra_subflows(msk);
500500

501-
pr_debug("msk=%p subflows=%d max=%d allow=%d\n", msk, pm->subflows,
502-
subflows_max, READ_ONCE(pm->accept_subflow));
501+
pr_debug("msk=%p subflows=%d max=%d allow=%d\n", msk,
502+
pm->extra_subflows, limit_extra_subflows,
503+
READ_ONCE(pm->accept_subflow));
503504

504505
/* try to avoid acquiring the lock below */
505506
if (!READ_ONCE(pm->accept_subflow))
506507
return false;
507508

508509
spin_lock_bh(&pm->lock);
509510
if (READ_ONCE(pm->accept_subflow)) {
510-
ret = pm->subflows < subflows_max;
511-
if (ret && ++pm->subflows == subflows_max)
511+
ret = pm->extra_subflows < limit_extra_subflows;
512+
if (ret && ++pm->extra_subflows == limit_extra_subflows)
512513
WRITE_ONCE(pm->accept_subflow, false);
513514
}
514515
spin_unlock_bh(&pm->lock);
@@ -594,7 +595,7 @@ void mptcp_pm_subflow_check_next(struct mptcp_sock *msk,
594595
if (mptcp_pm_is_userspace(msk)) {
595596
if (update_subflows) {
596597
spin_lock_bh(&pm->lock);
597-
pm->subflows--;
598+
pm->extra_subflows--;
598599
spin_unlock_bh(&pm->lock);
599600
}
600601
return;
@@ -637,9 +638,12 @@ void mptcp_pm_add_addr_received(const struct sock *ssk,
637638
} else {
638639
__MPTCP_INC_STATS(sock_net((struct sock *)msk), MPTCP_MIB_ADDADDRDROP);
639640
}
640-
/* id0 should not have a different address */
641+
/* - id0 should not have a different address
642+
* - special case for C-flag: linked to fill_local_addresses_vec()
643+
*/
641644
} else if ((addr->id == 0 && !mptcp_pm_is_init_remote_addr(msk, addr)) ||
642-
(addr->id > 0 && !READ_ONCE(pm->accept_addr))) {
645+
(addr->id > 0 && !READ_ONCE(pm->accept_addr) &&
646+
!mptcp_pm_add_addr_c_flag_case(msk))) {
643647
mptcp_pm_announce_addr(msk, addr, true);
644648
mptcp_pm_add_addr_send_ack(msk);
645649
} else if (mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_RECEIVED)) {
@@ -1025,17 +1029,17 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk)
10251029
WRITE_ONCE(pm->pm_type, pm_type);
10261030

10271031
if (pm_type == MPTCP_PM_TYPE_KERNEL) {
1028-
bool subflows_allowed = !!mptcp_pm_get_subflows_max(msk);
1032+
bool subflows_allowed = !!mptcp_pm_get_limit_extra_subflows(msk);
10291033

10301034
/* pm->work_pending must be only be set to 'true' when
10311035
* pm->pm_type is set to MPTCP_PM_TYPE_KERNEL
10321036
*/
10331037
WRITE_ONCE(pm->work_pending,
1034-
(!!mptcp_pm_get_local_addr_max(msk) &&
1038+
(!!mptcp_pm_get_endp_subflow_max(msk) &&
10351039
subflows_allowed) ||
1036-
!!mptcp_pm_get_add_addr_signal_max(msk));
1040+
!!mptcp_pm_get_endp_signal_max(msk));
10371041
WRITE_ONCE(pm->accept_addr,
1038-
!!mptcp_pm_get_add_addr_accept_max(msk) &&
1042+
!!mptcp_pm_get_limit_add_addr_accepted(msk) &&
10391043
subflows_allowed);
10401044
WRITE_ONCE(pm->accept_subflow, subflows_allowed);
10411045

0 commit comments

Comments
 (0)