Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+441 -229
+10 -1
include/uapi/linux/mptcp.h
··· 39 39 #define MPTCP_PM_ADDR_FLAG_BACKUP _BITUL(2) 40 40 #define MPTCP_PM_ADDR_FLAG_FULLMESH _BITUL(3) 41 41 #define MPTCP_PM_ADDR_FLAG_IMPLICIT _BITUL(4) 42 + #define MPTCP_PM_ADDR_FLAG_LAMINAR _BITUL(5) 42 43 43 44 struct mptcp_info { 44 45 __u8 mptcpi_subflows; 46 + #define mptcpi_extra_subflows mptcpi_subflows 45 47 __u8 mptcpi_add_addr_signal; 46 48 __u8 mptcpi_add_addr_accepted; 47 49 __u8 mptcpi_subflows_max; 50 + #define mptcpi_limit_extra_subflows mptcpi_subflows_max 48 51 __u8 mptcpi_add_addr_signal_max; 52 + #define mptcpi_endp_signal_max mptcpi_add_addr_signal_max 49 53 __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 */ 50 56 __u32 mptcpi_flags; 51 57 __u32 mptcpi_token; 52 58 __u64 mptcpi_write_seq; ··· 60 54 __u64 mptcpi_rcv_nxt; 61 55 __u8 mptcpi_local_addr_used; 62 56 __u8 mptcpi_local_addr_max; 57 + #define mptcpi_endp_subflow_max mptcpi_local_addr_max 63 58 __u8 mptcpi_csum_enabled; 59 + /* 8-bit hole that can no longer be filled */ 64 60 __u32 mptcpi_retransmits; 65 61 __u64 mptcpi_bytes_retrans; 66 62 __u64 mptcpi_bytes_sent; 67 63 __u64 mptcpi_bytes_received; 68 64 __u64 mptcpi_bytes_acked; 69 65 __u8 mptcpi_subflows_total; 70 - __u8 reserved[3]; 66 + __u8 mptcpi_endp_laminar_max; 67 + __u8 reserved[2]; 71 68 __u32 mptcpi_last_data_sent; 72 69 __u32 mptcpi_last_data_recv; 73 70 __u32 mptcpi_last_ack_recv;
+18 -14
net/mptcp/pm.c
··· 483 483 bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk) 484 484 { 485 485 struct mptcp_pm_data *pm = &msk->pm; 486 - unsigned int subflows_max; 486 + unsigned int limit_extra_subflows; 487 487 int ret = 0; 488 488 489 489 if (mptcp_pm_is_userspace(msk)) { 490 490 if (mptcp_userspace_pm_active(msk)) { 491 491 spin_lock_bh(&pm->lock); 492 - pm->subflows++; 492 + pm->extra_subflows++; 493 493 spin_unlock_bh(&pm->lock); 494 494 return true; 495 495 } 496 496 return false; 497 497 } 498 498 499 - subflows_max = mptcp_pm_get_subflows_max(msk); 499 + limit_extra_subflows = mptcp_pm_get_limit_extra_subflows(msk); 500 500 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)); 503 504 504 505 /* try to avoid acquiring the lock below */ 505 506 if (!READ_ONCE(pm->accept_subflow)) ··· 508 507 509 508 spin_lock_bh(&pm->lock); 510 509 if (READ_ONCE(pm->accept_subflow)) { 511 - ret = pm->subflows < subflows_max; 512 - if (ret && ++pm->subflows == subflows_max) 510 + ret = pm->extra_subflows < limit_extra_subflows; 511 + if (ret && ++pm->extra_subflows == limit_extra_subflows) 513 512 WRITE_ONCE(pm->accept_subflow, false); 514 513 } 515 514 spin_unlock_bh(&pm->lock); ··· 595 594 if (mptcp_pm_is_userspace(msk)) { 596 595 if (update_subflows) { 597 596 spin_lock_bh(&pm->lock); 598 - pm->subflows--; 597 + pm->extra_subflows--; 599 598 spin_unlock_bh(&pm->lock); 600 599 } 601 600 return; ··· 638 637 } else { 639 638 __MPTCP_INC_STATS(sock_net((struct sock *)msk), MPTCP_MIB_ADDADDRDROP); 640 639 } 641 - /* id0 should not have a different address */ 640 + /* - id0 should not have a different address 641 + * - special case for C-flag: linked to fill_local_addresses_vec() 642 + */ 642 643 } else if ((addr->id == 0 && !mptcp_pm_is_init_remote_addr(msk, addr)) || 643 - (addr->id > 0 && !READ_ONCE(pm->accept_addr))) { 644 + (addr->id > 0 && !READ_ONCE(pm->accept_addr) && 645 + !mptcp_pm_add_addr_c_flag_case(msk))) { 644 646 mptcp_pm_announce_addr(msk, addr, true); 645 647 mptcp_pm_add_addr_send_ack(msk); 646 648 } else if (mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_RECEIVED)) { ··· 1029 1025 WRITE_ONCE(pm->pm_type, pm_type); 1030 1026 1031 1027 if (pm_type == MPTCP_PM_TYPE_KERNEL) { 1032 - bool subflows_allowed = !!mptcp_pm_get_subflows_max(msk); 1028 + bool subflows_allowed = !!mptcp_pm_get_limit_extra_subflows(msk); 1033 1029 1034 1030 /* pm->work_pending must be only be set to 'true' when 1035 1031 * pm->pm_type is set to MPTCP_PM_TYPE_KERNEL 1036 1032 */ 1037 1033 WRITE_ONCE(pm->work_pending, 1038 - (!!mptcp_pm_get_local_addr_max(msk) && 1034 + (!!mptcp_pm_get_endp_subflow_max(msk) && 1039 1035 subflows_allowed) || 1040 - !!mptcp_pm_get_add_addr_signal_max(msk)); 1036 + !!mptcp_pm_get_endp_signal_max(msk)); 1041 1037 WRITE_ONCE(pm->accept_addr, 1042 - !!mptcp_pm_get_add_addr_accept_max(msk) && 1038 + !!mptcp_pm_get_limit_add_addr_accepted(msk) && 1043 1039 subflows_allowed); 1044 1040 WRITE_ONCE(pm->accept_subflow, subflows_allowed); 1045 1041
+373 -196
net/mptcp/pm_kernel.c
··· 17 17 struct pm_nl_pernet { 18 18 /* protects pernet updates */ 19 19 spinlock_t lock; 20 - struct list_head local_addr_list; 21 - unsigned int addrs; 22 - unsigned int stale_loss_cnt; 23 - unsigned int add_addr_signal_max; 24 - unsigned int add_addr_accept_max; 25 - unsigned int local_addr_max; 26 - unsigned int subflows_max; 27 - unsigned int next_id; 20 + struct list_head endp_list; 21 + u8 endpoints; 22 + u8 endp_signal_max; 23 + u8 endp_subflow_max; 24 + u8 endp_laminar_max; 25 + u8 limit_add_addr_accepted; 26 + u8 limit_extra_subflows; 27 + u8 next_id; 28 28 DECLARE_BITMAP(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); 29 29 }; 30 30 ··· 46 46 return pm_nl_get_pernet(genl_info_net(info)); 47 47 } 48 48 49 - unsigned int mptcp_pm_get_add_addr_signal_max(const struct mptcp_sock *msk) 49 + u8 mptcp_pm_get_endp_signal_max(const struct mptcp_sock *msk) 50 50 { 51 51 const struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); 52 52 53 - return READ_ONCE(pernet->add_addr_signal_max); 53 + return READ_ONCE(pernet->endp_signal_max); 54 54 } 55 - EXPORT_SYMBOL_GPL(mptcp_pm_get_add_addr_signal_max); 55 + EXPORT_SYMBOL_GPL(mptcp_pm_get_endp_signal_max); 56 56 57 - unsigned int mptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk) 57 + u8 mptcp_pm_get_endp_subflow_max(const struct mptcp_sock *msk) 58 58 { 59 59 struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); 60 60 61 - return READ_ONCE(pernet->add_addr_accept_max); 61 + return READ_ONCE(pernet->endp_subflow_max); 62 62 } 63 - EXPORT_SYMBOL_GPL(mptcp_pm_get_add_addr_accept_max); 63 + EXPORT_SYMBOL_GPL(mptcp_pm_get_endp_subflow_max); 64 64 65 - unsigned int mptcp_pm_get_subflows_max(const struct mptcp_sock *msk) 65 + u8 mptcp_pm_get_endp_laminar_max(const struct mptcp_sock *msk) 66 66 { 67 67 struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); 68 68 69 - return READ_ONCE(pernet->subflows_max); 69 + return READ_ONCE(pernet->endp_laminar_max); 70 70 } 71 - EXPORT_SYMBOL_GPL(mptcp_pm_get_subflows_max); 71 + EXPORT_SYMBOL_GPL(mptcp_pm_get_endp_laminar_max); 72 72 73 - unsigned int mptcp_pm_get_local_addr_max(const struct mptcp_sock *msk) 73 + u8 mptcp_pm_get_limit_add_addr_accepted(const struct mptcp_sock *msk) 74 74 { 75 75 struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); 76 76 77 - return READ_ONCE(pernet->local_addr_max); 77 + return READ_ONCE(pernet->limit_add_addr_accepted); 78 78 } 79 - EXPORT_SYMBOL_GPL(mptcp_pm_get_local_addr_max); 79 + EXPORT_SYMBOL_GPL(mptcp_pm_get_limit_add_addr_accepted); 80 + 81 + u8 mptcp_pm_get_limit_extra_subflows(const struct mptcp_sock *msk) 82 + { 83 + struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); 84 + 85 + return READ_ONCE(pernet->limit_extra_subflows); 86 + } 87 + EXPORT_SYMBOL_GPL(mptcp_pm_get_limit_extra_subflows); 80 88 81 89 static bool lookup_subflow_by_daddr(const struct list_head *list, 82 90 const struct mptcp_addr_info *daddr) ··· 118 110 msk_owned_by_me(msk); 119 111 120 112 rcu_read_lock(); 121 - list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) { 113 + list_for_each_entry_rcu(entry, &pernet->endp_list, list) { 122 114 if (!(entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW)) 123 115 continue; 124 116 ··· 149 141 * Note: removal from the local address list during the msk life-cycle 150 142 * can lead to additional addresses not being announced. 151 143 */ 152 - list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) { 144 + list_for_each_entry_rcu(entry, &pernet->endp_list, list) { 153 145 if (!test_bit(entry->addr.id, msk->pm.id_avail_bitmap)) 154 146 continue; 155 147 ··· 167 159 return found; 168 160 } 169 161 170 - /* Fill all the remote addresses into the array addrs[], 171 - * and return the array size. 172 - */ 173 - static unsigned int fill_remote_addresses_vec(struct mptcp_sock *msk, 174 - struct mptcp_addr_info *local, 175 - bool fullmesh, 176 - struct mptcp_addr_info *addrs) 162 + static unsigned int 163 + fill_remote_addr(struct mptcp_sock *msk, struct mptcp_addr_info *local, 164 + struct mptcp_addr_info *addrs) 177 165 { 178 166 bool deny_id0 = READ_ONCE(msk->pm.remote_deny_join_id0); 179 - struct sock *sk = (struct sock *)msk, *ssk; 180 - struct mptcp_subflow_context *subflow; 181 167 struct mptcp_addr_info remote = { 0 }; 182 - unsigned int subflows_max; 183 - int i = 0; 168 + struct sock *sk = (struct sock *)msk; 184 169 185 - subflows_max = mptcp_pm_get_subflows_max(msk); 170 + if (deny_id0) 171 + return 0; 172 + 186 173 mptcp_remote_address((struct sock_common *)sk, &remote); 187 174 188 - /* Non-fullmesh endpoint, fill in the single entry 189 - * corresponding to the primary MPC subflow remote address 175 + if (!mptcp_pm_addr_families_match(sk, local, &remote)) 176 + return 0; 177 + 178 + msk->pm.extra_subflows++; 179 + *addrs = remote; 180 + 181 + return 1; 182 + } 183 + 184 + static unsigned int 185 + fill_remote_addresses_fullmesh(struct mptcp_sock *msk, 186 + struct mptcp_addr_info *local, 187 + struct mptcp_addr_info *addrs) 188 + { 189 + u8 limit_extra_subflows = mptcp_pm_get_limit_extra_subflows(msk); 190 + bool deny_id0 = READ_ONCE(msk->pm.remote_deny_join_id0); 191 + DECLARE_BITMAP(unavail_id, MPTCP_PM_MAX_ADDR_ID + 1); 192 + struct sock *sk = (struct sock *)msk, *ssk; 193 + struct mptcp_subflow_context *subflow; 194 + int i = 0; 195 + 196 + /* Forbid creation of new subflows matching existing ones, possibly 197 + * already created by incoming ADD_ADDR 190 198 */ 191 - if (!fullmesh) { 192 - if (deny_id0) 193 - return 0; 199 + bitmap_zero(unavail_id, MPTCP_PM_MAX_ADDR_ID + 1); 200 + mptcp_for_each_subflow(msk, subflow) 201 + if (READ_ONCE(subflow->local_id) == local->id) 202 + __set_bit(subflow->remote_id, unavail_id); 194 203 195 - if (!mptcp_pm_addr_families_match(sk, local, &remote)) 196 - return 0; 204 + mptcp_for_each_subflow(msk, subflow) { 205 + ssk = mptcp_subflow_tcp_sock(subflow); 206 + mptcp_remote_address((struct sock_common *)ssk, &addrs[i]); 207 + addrs[i].id = READ_ONCE(subflow->remote_id); 208 + if (deny_id0 && !addrs[i].id) 209 + continue; 197 210 198 - msk->pm.subflows++; 199 - addrs[i++] = remote; 200 - } else { 201 - DECLARE_BITMAP(unavail_id, MPTCP_PM_MAX_ADDR_ID + 1); 211 + if (test_bit(addrs[i].id, unavail_id)) 212 + continue; 202 213 203 - /* Forbid creation of new subflows matching existing 204 - * ones, possibly already created by incoming ADD_ADDR 205 - */ 206 - bitmap_zero(unavail_id, MPTCP_PM_MAX_ADDR_ID + 1); 207 - mptcp_for_each_subflow(msk, subflow) 208 - if (READ_ONCE(subflow->local_id) == local->id) 209 - __set_bit(subflow->remote_id, unavail_id); 214 + if (!mptcp_pm_addr_families_match(sk, local, &addrs[i])) 215 + continue; 210 216 211 - mptcp_for_each_subflow(msk, subflow) { 212 - ssk = mptcp_subflow_tcp_sock(subflow); 213 - mptcp_remote_address((struct sock_common *)ssk, &addrs[i]); 214 - addrs[i].id = READ_ONCE(subflow->remote_id); 215 - if (deny_id0 && !addrs[i].id) 216 - continue; 217 + /* forbid creating multiple address towards this id */ 218 + __set_bit(addrs[i].id, unavail_id); 219 + msk->pm.extra_subflows++; 220 + i++; 217 221 218 - if (test_bit(addrs[i].id, unavail_id)) 219 - continue; 220 - 221 - if (!mptcp_pm_addr_families_match(sk, local, &addrs[i])) 222 - continue; 223 - 224 - if (msk->pm.subflows < subflows_max) { 225 - /* forbid creating multiple address towards 226 - * this id 227 - */ 228 - __set_bit(addrs[i].id, unavail_id); 229 - msk->pm.subflows++; 230 - i++; 231 - } 232 - } 222 + if (msk->pm.extra_subflows >= limit_extra_subflows) 223 + break; 233 224 } 234 225 235 226 return i; 227 + } 228 + 229 + /* Fill all the remote addresses into the array addrs[], 230 + * and return the array size. 231 + */ 232 + static unsigned int 233 + fill_remote_addresses_vec(struct mptcp_sock *msk, struct mptcp_addr_info *local, 234 + bool fullmesh, struct mptcp_addr_info *addrs) 235 + { 236 + /* Non-fullmesh: fill in the single entry corresponding to the primary 237 + * MPC subflow remote address, and return 1, corresponding to 1 entry. 238 + */ 239 + if (!fullmesh) 240 + return fill_remote_addr(msk, local, addrs); 241 + 242 + /* Fullmesh endpoint: fill all possible remote addresses */ 243 + return fill_remote_addresses_fullmesh(msk, local, addrs); 236 244 } 237 245 238 246 static struct mptcp_pm_addr_entry * ··· 256 232 { 257 233 struct mptcp_pm_addr_entry *entry; 258 234 259 - list_for_each_entry_rcu(entry, &pernet->local_addr_list, list, 235 + list_for_each_entry_rcu(entry, &pernet->endp_list, list, 260 236 lockdep_is_held(&pernet->lock)) { 261 237 if (entry->addr.id == id) 262 238 return entry; ··· 269 245 { 270 246 struct mptcp_pm_addr_entry *entry; 271 247 272 - list_for_each_entry_rcu(entry, &pernet->local_addr_list, list, 248 + list_for_each_entry_rcu(entry, &pernet->endp_list, list, 273 249 lockdep_is_held(&pernet->lock)) { 274 250 if (mptcp_addresses_equal(&entry->addr, info, entry->addr.port)) 275 251 return entry; ··· 277 253 return NULL; 278 254 } 279 255 280 - static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) 256 + static u8 mptcp_endp_get_local_id(struct mptcp_sock *msk, 257 + const struct mptcp_addr_info *addr) 281 258 { 282 - struct sock *sk = (struct sock *)msk; 283 - unsigned int add_addr_signal_max; 284 - bool signal_and_subflow = false; 285 - unsigned int local_addr_max; 259 + return msk->mpc_endpoint_id == addr->id ? 0 : addr->id; 260 + } 261 + 262 + /* Set mpc_endpoint_id, and send MP_PRIO for ID0 if needed */ 263 + static void mptcp_mpc_endpoint_setup(struct mptcp_sock *msk) 264 + { 265 + struct mptcp_subflow_context *subflow; 266 + struct mptcp_pm_addr_entry *entry; 267 + struct mptcp_addr_info mpc_addr; 286 268 struct pm_nl_pernet *pernet; 287 - struct mptcp_pm_local local; 288 - unsigned int subflows_max; 289 - 290 - pernet = pm_nl_get_pernet(sock_net(sk)); 291 - 292 - add_addr_signal_max = mptcp_pm_get_add_addr_signal_max(msk); 293 - local_addr_max = mptcp_pm_get_local_addr_max(msk); 294 - subflows_max = mptcp_pm_get_subflows_max(msk); 269 + bool backup = false; 295 270 296 271 /* do lazy endpoint usage accounting for the MPC subflows */ 297 - if (unlikely(!(msk->pm.status & BIT(MPTCP_PM_MPC_ENDPOINT_ACCOUNTED))) && msk->first) { 298 - struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(msk->first); 299 - struct mptcp_pm_addr_entry *entry; 300 - struct mptcp_addr_info mpc_addr; 301 - bool backup = false; 272 + if (likely(msk->pm.status & BIT(MPTCP_PM_MPC_ENDPOINT_ACCOUNTED)) || 273 + !msk->first) 274 + return; 302 275 303 - mptcp_local_address((struct sock_common *)msk->first, &mpc_addr); 304 - rcu_read_lock(); 305 - entry = __lookup_addr(pernet, &mpc_addr); 306 - if (entry) { 307 - __clear_bit(entry->addr.id, msk->pm.id_avail_bitmap); 308 - msk->mpc_endpoint_id = entry->addr.id; 309 - backup = !!(entry->flags & MPTCP_PM_ADDR_FLAG_BACKUP); 310 - } 311 - rcu_read_unlock(); 276 + subflow = mptcp_subflow_ctx(msk->first); 277 + pernet = pm_nl_get_pernet_from_msk(msk); 312 278 313 - if (backup) 314 - mptcp_pm_send_ack(msk, subflow, true, backup); 315 - 316 - msk->pm.status |= BIT(MPTCP_PM_MPC_ENDPOINT_ACCOUNTED); 279 + mptcp_local_address((struct sock_common *)msk->first, &mpc_addr); 280 + rcu_read_lock(); 281 + entry = __lookup_addr(pernet, &mpc_addr); 282 + if (entry) { 283 + __clear_bit(entry->addr.id, msk->pm.id_avail_bitmap); 284 + msk->mpc_endpoint_id = entry->addr.id; 285 + backup = !!(entry->flags & MPTCP_PM_ADDR_FLAG_BACKUP); 317 286 } 287 + rcu_read_unlock(); 288 + 289 + /* Send MP_PRIO */ 290 + if (backup) 291 + mptcp_pm_send_ack(msk, subflow, true, backup); 292 + 293 + msk->pm.status |= BIT(MPTCP_PM_MPC_ENDPOINT_ACCOUNTED); 294 + } 295 + 296 + static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) 297 + { 298 + u8 limit_extra_subflows = mptcp_pm_get_limit_extra_subflows(msk); 299 + struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); 300 + u8 endp_subflow_max = mptcp_pm_get_endp_subflow_max(msk); 301 + u8 endp_signal_max = mptcp_pm_get_endp_signal_max(msk); 302 + struct sock *sk = (struct sock *)msk; 303 + bool signal_and_subflow = false; 304 + struct mptcp_pm_local local; 305 + 306 + mptcp_mpc_endpoint_setup(msk); 318 307 319 308 pr_debug("local %d:%d signal %d:%d subflows %d:%d\n", 320 - msk->pm.local_addr_used, local_addr_max, 321 - msk->pm.add_addr_signaled, add_addr_signal_max, 322 - msk->pm.subflows, subflows_max); 309 + msk->pm.local_addr_used, endp_subflow_max, 310 + msk->pm.add_addr_signaled, endp_signal_max, 311 + msk->pm.extra_subflows, limit_extra_subflows); 323 312 324 313 /* check first for announce */ 325 - if (msk->pm.add_addr_signaled < add_addr_signal_max) { 314 + if (msk->pm.add_addr_signaled < endp_signal_max) { 326 315 /* due to racing events on both ends we can reach here while 327 316 * previous add address is still running: if we invoke now 328 317 * mptcp_pm_announce_addr(), that will fail and the ··· 371 334 372 335 subflow: 373 336 /* check if should create a new subflow */ 374 - while (msk->pm.local_addr_used < local_addr_max && 375 - msk->pm.subflows < subflows_max) { 337 + while (msk->pm.local_addr_used < endp_subflow_max && 338 + msk->pm.extra_subflows < limit_extra_subflows) { 376 339 struct mptcp_addr_info addrs[MPTCP_PM_ADDR_MAX]; 377 340 bool fullmesh; 378 341 int i, nr; ··· 414 377 mptcp_pm_create_subflow_or_signal_addr(msk); 415 378 } 416 379 417 - /* Fill all the local addresses into the array addrs[], 418 - * and return the array size. 419 - */ 420 - static unsigned int fill_local_addresses_vec(struct mptcp_sock *msk, 421 - struct mptcp_addr_info *remote, 422 - struct mptcp_pm_local *locals) 380 + static unsigned int 381 + fill_local_addresses_vec_fullmesh(struct mptcp_sock *msk, 382 + struct mptcp_addr_info *remote, 383 + struct mptcp_pm_local *locals, 384 + bool c_flag_case) 423 385 { 386 + u8 limit_extra_subflows = mptcp_pm_get_limit_extra_subflows(msk); 387 + struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); 424 388 struct sock *sk = (struct sock *)msk; 425 389 struct mptcp_pm_addr_entry *entry; 426 - struct mptcp_addr_info mpc_addr; 427 - struct pm_nl_pernet *pernet; 428 - unsigned int subflows_max; 390 + struct mptcp_pm_local *local; 429 391 int i = 0; 430 392 431 - pernet = pm_nl_get_pernet_from_msk(msk); 432 - subflows_max = mptcp_pm_get_subflows_max(msk); 433 - 434 - mptcp_local_address((struct sock_common *)msk, &mpc_addr); 435 - 436 393 rcu_read_lock(); 437 - list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) { 394 + list_for_each_entry_rcu(entry, &pernet->endp_list, list) { 395 + bool is_id0; 396 + 438 397 if (!(entry->flags & MPTCP_PM_ADDR_FLAG_FULLMESH)) 439 398 continue; 440 399 441 400 if (!mptcp_pm_addr_families_match(sk, &entry->addr, remote)) 442 401 continue; 443 402 444 - if (msk->pm.subflows < subflows_max) { 445 - locals[i].addr = entry->addr; 446 - locals[i].flags = entry->flags; 447 - locals[i].ifindex = entry->ifindex; 403 + local = &locals[i]; 404 + local->addr = entry->addr; 405 + local->flags = entry->flags; 406 + local->ifindex = entry->ifindex; 448 407 449 - /* Special case for ID0: set the correct ID */ 450 - if (mptcp_addresses_equal(&locals[i].addr, &mpc_addr, locals[i].addr.port)) 451 - locals[i].addr.id = 0; 408 + is_id0 = local->addr.id == msk->mpc_endpoint_id; 452 409 453 - msk->pm.subflows++; 454 - i++; 410 + if (c_flag_case && 411 + (entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW)) { 412 + __clear_bit(local->addr.id, msk->pm.id_avail_bitmap); 413 + 414 + if (!is_id0) 415 + msk->pm.local_addr_used++; 455 416 } 417 + 418 + /* Special case for ID0: set the correct ID */ 419 + if (is_id0) 420 + local->addr.id = 0; 421 + 422 + msk->pm.extra_subflows++; 423 + i++; 424 + 425 + if (msk->pm.extra_subflows >= limit_extra_subflows) 426 + break; 456 427 } 457 428 rcu_read_unlock(); 458 429 459 - /* If the array is empty, fill in the single 460 - * 'IPADDRANY' local address 430 + return i; 431 + } 432 + 433 + static unsigned int 434 + fill_local_laminar_endp(struct mptcp_sock *msk, struct mptcp_addr_info *remote, 435 + struct mptcp_pm_local *locals) 436 + { 437 + struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); 438 + DECLARE_BITMAP(unavail_id, MPTCP_PM_MAX_ADDR_ID + 1); 439 + struct mptcp_subflow_context *subflow; 440 + struct sock *sk = (struct sock *)msk; 441 + struct mptcp_pm_addr_entry *entry; 442 + struct mptcp_pm_local *local; 443 + int found = 0; 444 + 445 + /* Forbid creation of new subflows matching existing ones, possibly 446 + * already created by 'subflow' endpoints 461 447 */ 462 - if (!i) { 463 - memset(&locals[i], 0, sizeof(locals[i])); 464 - locals[i].addr.family = 465 - #if IS_ENABLED(CONFIG_MPTCP_IPV6) 466 - remote->family == AF_INET6 && 467 - ipv6_addr_v4mapped(&remote->addr6) ? AF_INET : 468 - #endif 469 - remote->family; 448 + bitmap_zero(unavail_id, MPTCP_PM_MAX_ADDR_ID + 1); 449 + mptcp_for_each_subflow(msk, subflow) { 450 + struct sock *ssk = mptcp_subflow_tcp_sock(subflow); 470 451 471 - if (!mptcp_pm_addr_families_match(sk, &locals[i].addr, remote)) 472 - return 0; 452 + if ((1 << inet_sk_state_load(ssk)) & 453 + (TCPF_FIN_WAIT1 | TCPF_FIN_WAIT2 | TCPF_CLOSING | 454 + TCPF_CLOSE)) 455 + continue; 473 456 474 - msk->pm.subflows++; 457 + __set_bit(subflow_get_local_id(subflow), unavail_id); 458 + } 459 + 460 + rcu_read_lock(); 461 + list_for_each_entry_rcu(entry, &pernet->endp_list, list) { 462 + if (!(entry->flags & MPTCP_PM_ADDR_FLAG_LAMINAR)) 463 + continue; 464 + 465 + if (!mptcp_pm_addr_families_match(sk, &entry->addr, remote)) 466 + continue; 467 + 468 + if (test_bit(mptcp_endp_get_local_id(msk, &entry->addr), 469 + unavail_id)) 470 + continue; 471 + 472 + local = &locals[0]; 473 + local->addr = entry->addr; 474 + local->flags = entry->flags; 475 + local->ifindex = entry->ifindex; 476 + 477 + if (entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) { 478 + __clear_bit(local->addr.id, msk->pm.id_avail_bitmap); 479 + 480 + if (local->addr.id != msk->mpc_endpoint_id) 481 + msk->pm.local_addr_used++; 482 + } 483 + 484 + msk->pm.extra_subflows++; 485 + found = 1; 486 + break; 487 + } 488 + rcu_read_unlock(); 489 + 490 + return found; 491 + } 492 + 493 + static unsigned int 494 + fill_local_addresses_vec_c_flag(struct mptcp_sock *msk, 495 + struct mptcp_addr_info *remote, 496 + struct mptcp_pm_local *locals) 497 + { 498 + u8 limit_extra_subflows = mptcp_pm_get_limit_extra_subflows(msk); 499 + struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); 500 + u8 endp_subflow_max = mptcp_pm_get_endp_subflow_max(msk); 501 + struct sock *sk = (struct sock *)msk; 502 + struct mptcp_pm_local *local; 503 + int i = 0; 504 + 505 + while (msk->pm.local_addr_used < endp_subflow_max) { 506 + local = &locals[i]; 507 + 508 + if (!select_local_address(pernet, msk, local)) 509 + break; 510 + 511 + __clear_bit(local->addr.id, msk->pm.id_avail_bitmap); 512 + 513 + if (!mptcp_pm_addr_families_match(sk, &local->addr, remote)) 514 + continue; 515 + 516 + if (local->addr.id == msk->mpc_endpoint_id) 517 + continue; 518 + 519 + msk->pm.local_addr_used++; 520 + msk->pm.extra_subflows++; 475 521 i++; 522 + 523 + if (msk->pm.extra_subflows >= limit_extra_subflows) 524 + break; 476 525 } 477 526 478 527 return i; 479 528 } 480 529 530 + static unsigned int 531 + fill_local_address_any(struct mptcp_sock *msk, struct mptcp_addr_info *remote, 532 + struct mptcp_pm_local *local) 533 + { 534 + struct sock *sk = (struct sock *)msk; 535 + 536 + memset(local, 0, sizeof(*local)); 537 + local->addr.family = 538 + #if IS_ENABLED(CONFIG_MPTCP_IPV6) 539 + remote->family == AF_INET6 && 540 + ipv6_addr_v4mapped(&remote->addr6) ? AF_INET : 541 + #endif 542 + remote->family; 543 + 544 + if (!mptcp_pm_addr_families_match(sk, &local->addr, remote)) 545 + return 0; 546 + 547 + msk->pm.extra_subflows++; 548 + 549 + return 1; 550 + } 551 + 552 + /* Fill all the local addresses into the array addrs[], 553 + * and return the array size. 554 + */ 555 + static unsigned int 556 + fill_local_addresses_vec(struct mptcp_sock *msk, struct mptcp_addr_info *remote, 557 + struct mptcp_pm_local *locals) 558 + { 559 + bool c_flag_case = remote->id && mptcp_pm_add_addr_c_flag_case(msk); 560 + int i; 561 + 562 + /* If there is at least one MPTCP endpoint with a fullmesh flag */ 563 + i = fill_local_addresses_vec_fullmesh(msk, remote, locals, c_flag_case); 564 + if (i) 565 + return i; 566 + 567 + /* If there is at least one MPTCP endpoint with a laminar flag */ 568 + if (mptcp_pm_get_endp_laminar_max(msk)) 569 + return fill_local_laminar_endp(msk, remote, locals); 570 + 571 + /* Special case: peer sets the C flag, accept one ADD_ADDR if default 572 + * limits are used -- accepting no ADD_ADDR -- and use subflow endpoints 573 + */ 574 + if (c_flag_case) 575 + return fill_local_addresses_vec_c_flag(msk, remote, locals); 576 + 577 + /* No special case: fill in the single 'IPADDRANY' local address */ 578 + return fill_local_address_any(msk, remote, &locals[0]); 579 + } 580 + 481 581 static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) 482 582 { 583 + u8 limit_add_addr_accepted = mptcp_pm_get_limit_add_addr_accepted(msk); 584 + u8 limit_extra_subflows = mptcp_pm_get_limit_extra_subflows(msk); 483 585 struct mptcp_pm_local locals[MPTCP_PM_ADDR_MAX]; 484 586 struct sock *sk = (struct sock *)msk; 485 - unsigned int add_addr_accept_max; 486 587 struct mptcp_addr_info remote; 487 - unsigned int subflows_max; 488 588 bool sf_created = false; 489 589 int i, nr; 490 590 491 - add_addr_accept_max = mptcp_pm_get_add_addr_accept_max(msk); 492 - subflows_max = mptcp_pm_get_subflows_max(msk); 493 - 494 591 pr_debug("accepted %d:%d remote family %d\n", 495 - msk->pm.add_addr_accepted, add_addr_accept_max, 592 + msk->pm.add_addr_accepted, limit_add_addr_accepted, 496 593 msk->pm.remote.family); 497 594 498 595 remote = msk->pm.remote; 499 596 mptcp_pm_announce_addr(msk, &remote, true); 500 597 mptcp_pm_addr_send_ack(msk); 598 + mptcp_mpc_endpoint_setup(msk); 501 599 502 600 if (lookup_subflow_by_daddr(&msk->conn_list, &remote)) 503 601 return; ··· 658 486 /* add_addr_accepted is not decr for ID 0 */ 659 487 if (remote.id) 660 488 msk->pm.add_addr_accepted++; 661 - if (msk->pm.add_addr_accepted >= add_addr_accept_max || 662 - msk->pm.subflows >= subflows_max) 489 + if (msk->pm.add_addr_accepted >= limit_add_addr_accepted || 490 + msk->pm.extra_subflows >= limit_extra_subflows) 663 491 WRITE_ONCE(msk->pm.accept_addr, false); 664 492 } 665 493 } ··· 667 495 void mptcp_pm_nl_rm_addr(struct mptcp_sock *msk, u8 rm_id) 668 496 { 669 497 if (rm_id && WARN_ON_ONCE(msk->pm.add_addr_accepted == 0)) { 498 + u8 limit_add_addr_accepted = 499 + mptcp_pm_get_limit_add_addr_accepted(msk); 500 + 670 501 /* Note: if the subflow has been closed before, this 671 502 * add_addr_accepted counter will not be decremented. 672 503 */ 673 - if (--msk->pm.add_addr_accepted < mptcp_pm_get_add_addr_accept_max(msk)) 504 + if (--msk->pm.add_addr_accepted < limit_add_addr_accepted) 674 505 WRITE_ONCE(msk->pm.accept_addr, true); 675 506 } 676 507 } ··· 698 523 bool needs_id, bool replace) 699 524 { 700 525 struct mptcp_pm_addr_entry *cur, *del_entry = NULL; 701 - unsigned int addr_max; 702 526 int ret = -EINVAL; 527 + u8 addr_max; 703 528 704 529 spin_lock_bh(&pernet->lock); 705 530 /* to keep the code simple, don't do IDR-like allocation for address ID, ··· 707 532 */ 708 533 if (pernet->next_id == MPTCP_PM_MAX_ADDR_ID) 709 534 pernet->next_id = 1; 710 - if (pernet->addrs >= MPTCP_PM_ADDR_MAX) { 535 + if (pernet->endpoints >= MPTCP_PM_ADDR_MAX) { 711 536 ret = -ERANGE; 712 537 goto out; 713 538 } ··· 721 546 */ 722 547 if (!address_use_port(entry)) 723 548 entry->addr.port = 0; 724 - list_for_each_entry(cur, &pernet->local_addr_list, list) { 549 + list_for_each_entry(cur, &pernet->endp_list, list) { 725 550 if (mptcp_addresses_equal(&cur->addr, &entry->addr, 726 551 cur->addr.port || entry->addr.port)) { 727 552 /* allow replacing the exiting endpoint only if such ··· 746 571 goto out; 747 572 } 748 573 749 - pernet->addrs--; 574 + pernet->endpoints--; 750 575 entry->addr.id = cur->addr.id; 751 576 list_del_rcu(&cur->list); 752 577 del_entry = cur; ··· 773 598 pernet->next_id = entry->addr.id; 774 599 775 600 if (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL) { 776 - addr_max = pernet->add_addr_signal_max; 777 - WRITE_ONCE(pernet->add_addr_signal_max, addr_max + 1); 601 + addr_max = pernet->endp_signal_max; 602 + WRITE_ONCE(pernet->endp_signal_max, addr_max + 1); 778 603 } 779 604 if (entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) { 780 - addr_max = pernet->local_addr_max; 781 - WRITE_ONCE(pernet->local_addr_max, addr_max + 1); 605 + addr_max = pernet->endp_subflow_max; 606 + WRITE_ONCE(pernet->endp_subflow_max, addr_max + 1); 607 + } 608 + if (entry->flags & MPTCP_PM_ADDR_FLAG_LAMINAR) { 609 + addr_max = pernet->endp_laminar_max; 610 + WRITE_ONCE(pernet->endp_laminar_max, addr_max + 1); 782 611 } 783 612 784 - pernet->addrs++; 613 + pernet->endpoints++; 785 614 if (!entry->addr.port) 786 - list_add_tail_rcu(&entry->list, &pernet->local_addr_list); 615 + list_add_tail_rcu(&entry->list, &pernet->endp_list); 787 616 else 788 - list_add_rcu(&entry->list, &pernet->local_addr_list); 617 + list_add_rcu(&entry->list, &pernet->endp_list); 789 618 ret = entry->addr.id; 790 619 791 620 out: ··· 1024 845 return ret; 1025 846 } 1026 847 1027 - static u8 mptcp_endp_get_local_id(struct mptcp_sock *msk, 1028 - const struct mptcp_addr_info *addr) 1029 - { 1030 - return msk->mpc_endpoint_id == addr->id ? 0 : addr->id; 1031 - } 1032 - 1033 848 static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk, 1034 849 const struct mptcp_addr_info *addr, 1035 850 bool force) ··· 1142 969 { 1143 970 struct pm_nl_pernet *pernet = genl_info_pm_nl(info); 1144 971 struct mptcp_pm_addr_entry addr, *entry; 1145 - unsigned int addr_max; 1146 972 struct nlattr *attr; 973 + u8 addr_max; 1147 974 int ret; 1148 975 1149 976 if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR)) ··· 1170 997 return -EINVAL; 1171 998 } 1172 999 if (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL) { 1173 - addr_max = pernet->add_addr_signal_max; 1174 - WRITE_ONCE(pernet->add_addr_signal_max, addr_max - 1); 1000 + addr_max = pernet->endp_signal_max; 1001 + WRITE_ONCE(pernet->endp_signal_max, addr_max - 1); 1175 1002 } 1176 1003 if (entry->flags & MPTCP_PM_ADDR_FLAG_SUBFLOW) { 1177 - addr_max = pernet->local_addr_max; 1178 - WRITE_ONCE(pernet->local_addr_max, addr_max - 1); 1004 + addr_max = pernet->endp_subflow_max; 1005 + WRITE_ONCE(pernet->endp_subflow_max, addr_max - 1); 1006 + } 1007 + if (entry->flags & MPTCP_PM_ADDR_FLAG_LAMINAR) { 1008 + addr_max = pernet->endp_laminar_max; 1009 + WRITE_ONCE(pernet->endp_laminar_max, addr_max - 1); 1179 1010 } 1180 1011 1181 - pernet->addrs--; 1012 + pernet->endpoints--; 1182 1013 list_del_rcu(&entry->list); 1183 1014 __clear_bit(entry->addr.id, pernet->id_bitmap); 1184 1015 spin_unlock_bh(&pernet->lock); ··· 1261 1084 1262 1085 static void __reset_counters(struct pm_nl_pernet *pernet) 1263 1086 { 1264 - WRITE_ONCE(pernet->add_addr_signal_max, 0); 1265 - WRITE_ONCE(pernet->local_addr_max, 0); 1266 - pernet->addrs = 0; 1087 + WRITE_ONCE(pernet->endp_signal_max, 0); 1088 + WRITE_ONCE(pernet->endp_subflow_max, 0); 1089 + WRITE_ONCE(pernet->endp_laminar_max, 0); 1090 + pernet->endpoints = 0; 1267 1091 } 1268 1092 1269 1093 int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *info) ··· 1273 1095 LIST_HEAD(free_list); 1274 1096 1275 1097 spin_lock_bh(&pernet->lock); 1276 - list_splice_init(&pernet->local_addr_list, &free_list); 1098 + list_splice_init(&pernet->endp_list, &free_list); 1277 1099 __reset_counters(pernet); 1278 1100 pernet->next_id = 1; 1279 1101 bitmap_zero(pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); ··· 1359 1181 int ret; 1360 1182 1361 1183 spin_lock_bh(&pernet->lock); 1362 - rcv_addrs = pernet->add_addr_accept_max; 1184 + rcv_addrs = pernet->limit_add_addr_accepted; 1363 1185 ret = parse_limit(info, MPTCP_PM_ATTR_RCV_ADD_ADDRS, &rcv_addrs); 1364 1186 if (ret) 1365 1187 goto unlock; 1366 1188 1367 - subflows = pernet->subflows_max; 1189 + subflows = pernet->limit_extra_subflows; 1368 1190 ret = parse_limit(info, MPTCP_PM_ATTR_SUBFLOWS, &subflows); 1369 1191 if (ret) 1370 1192 goto unlock; 1371 1193 1372 - WRITE_ONCE(pernet->add_addr_accept_max, rcv_addrs); 1373 - WRITE_ONCE(pernet->subflows_max, subflows); 1194 + WRITE_ONCE(pernet->limit_add_addr_accepted, rcv_addrs); 1195 + WRITE_ONCE(pernet->limit_extra_subflows, subflows); 1374 1196 1375 1197 unlock: 1376 1198 spin_unlock_bh(&pernet->lock); ··· 1393 1215 goto fail; 1394 1216 1395 1217 if (nla_put_u32(msg, MPTCP_PM_ATTR_RCV_ADD_ADDRS, 1396 - READ_ONCE(pernet->add_addr_accept_max))) 1218 + READ_ONCE(pernet->limit_add_addr_accepted))) 1397 1219 goto fail; 1398 1220 1399 1221 if (nla_put_u32(msg, MPTCP_PM_ATTR_SUBFLOWS, 1400 - READ_ONCE(pernet->subflows_max))) 1222 + READ_ONCE(pernet->limit_extra_subflows))) 1401 1223 goto fail; 1402 1224 1403 1225 genlmsg_end(msg, reply); ··· 1506 1328 { 1507 1329 struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); 1508 1330 1509 - if (msk->pm.subflows == mptcp_pm_get_subflows_max(msk) || 1331 + if (msk->pm.extra_subflows == mptcp_pm_get_limit_extra_subflows(msk) || 1510 1332 (find_next_and_bit(pernet->id_bitmap, msk->pm.id_avail_bitmap, 1511 1333 MPTCP_PM_MAX_ADDR_ID + 1, 0) == MPTCP_PM_MAX_ADDR_ID + 1)) { 1512 1334 WRITE_ONCE(msk->pm.work_pending, false); ··· 1538 1360 { 1539 1361 struct pm_nl_pernet *pernet = pm_nl_get_pernet(net); 1540 1362 1541 - INIT_LIST_HEAD_RCU(&pernet->local_addr_list); 1363 + INIT_LIST_HEAD_RCU(&pernet->endp_list); 1542 1364 1543 1365 /* Cit. 2 subflows ought to be enough for anybody. */ 1544 - pernet->subflows_max = 2; 1366 + pernet->limit_extra_subflows = 2; 1545 1367 pernet->next_id = 1; 1546 - pernet->stale_loss_cnt = 4; 1547 1368 spin_lock_init(&pernet->lock); 1548 1369 1549 1370 /* No need to initialize other pernet fields, the struct is zeroed at ··· 1563 1386 * other modifiers, also netns core already waited for a 1564 1387 * RCU grace period. 1565 1388 */ 1566 - __flush_addrs(&pernet->local_addr_list); 1389 + __flush_addrs(&pernet->endp_list); 1567 1390 } 1568 1391 } 1569 1392
+1 -1
net/mptcp/pm_userspace.c
··· 419 419 if (err) 420 420 mptcp_userspace_pm_delete_local_addr(msk, &entry); 421 421 else 422 - msk->pm.subflows++; 422 + msk->pm.extra_subflows++; 423 423 spin_unlock_bh(&msk->pm.lock); 424 424 425 425 create_err:
+15 -6
net/mptcp/protocol.h
··· 235 235 u8 add_addr_accepted; 236 236 u8 local_addr_used; 237 237 u8 pm_type; 238 - u8 subflows; 238 + u8 extra_subflows; 239 239 u8 status; 240 240 241 241 ); ··· 1180 1180 void __init mptcp_pm_nl_init(void); 1181 1181 void mptcp_pm_worker(struct mptcp_sock *msk); 1182 1182 void __mptcp_pm_kernel_worker(struct mptcp_sock *msk); 1183 - unsigned int mptcp_pm_get_add_addr_signal_max(const struct mptcp_sock *msk); 1184 - unsigned int mptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk); 1185 - unsigned int mptcp_pm_get_subflows_max(const struct mptcp_sock *msk); 1186 - unsigned int mptcp_pm_get_local_addr_max(const struct mptcp_sock *msk); 1183 + u8 mptcp_pm_get_endp_signal_max(const struct mptcp_sock *msk); 1184 + u8 mptcp_pm_get_endp_subflow_max(const struct mptcp_sock *msk); 1185 + u8 mptcp_pm_get_endp_laminar_max(const struct mptcp_sock *msk); 1186 + u8 mptcp_pm_get_limit_add_addr_accepted(const struct mptcp_sock *msk); 1187 + u8 mptcp_pm_get_limit_extra_subflows(const struct mptcp_sock *msk); 1187 1188 1188 1189 /* called under PM lock */ 1189 1190 static inline void __mptcp_pm_close_subflow(struct mptcp_sock *msk) 1190 1191 { 1191 - if (--msk->pm.subflows < mptcp_pm_get_subflows_max(msk)) 1192 + if (--msk->pm.extra_subflows < mptcp_pm_get_limit_extra_subflows(msk)) 1192 1193 WRITE_ONCE(msk->pm.accept_subflow, true); 1193 1194 } 1194 1195 ··· 1198 1197 spin_lock_bh(&msk->pm.lock); 1199 1198 __mptcp_pm_close_subflow(msk); 1200 1199 spin_unlock_bh(&msk->pm.lock); 1200 + } 1201 + 1202 + static inline bool mptcp_pm_add_addr_c_flag_case(struct mptcp_sock *msk) 1203 + { 1204 + return READ_ONCE(msk->pm.remote_deny_join_id0) && 1205 + msk->pm.local_addr_used == 0 && 1206 + mptcp_pm_get_limit_add_addr_accepted(msk) == 0 && 1207 + msk->pm.extra_subflows < mptcp_pm_get_limit_extra_subflows(msk); 1201 1208 } 1202 1209 1203 1210 void mptcp_sockopt_sync_locked(struct mptcp_sock *msk, struct sock *ssk);
+12 -10
net/mptcp/sockopt.c
··· 962 962 963 963 memset(info, 0, sizeof(*info)); 964 964 965 - info->mptcpi_subflows = READ_ONCE(msk->pm.subflows); 965 + info->mptcpi_extra_subflows = READ_ONCE(msk->pm.extra_subflows); 966 966 info->mptcpi_add_addr_signal = READ_ONCE(msk->pm.add_addr_signaled); 967 967 info->mptcpi_add_addr_accepted = READ_ONCE(msk->pm.add_addr_accepted); 968 968 info->mptcpi_local_addr_used = READ_ONCE(msk->pm.local_addr_used); ··· 972 972 973 973 /* The following limits only make sense for the in-kernel PM */ 974 974 if (mptcp_pm_is_kernel(msk)) { 975 - info->mptcpi_subflows_max = 976 - mptcp_pm_get_subflows_max(msk); 977 - info->mptcpi_add_addr_signal_max = 978 - mptcp_pm_get_add_addr_signal_max(msk); 979 - info->mptcpi_add_addr_accepted_max = 980 - mptcp_pm_get_add_addr_accept_max(msk); 981 - info->mptcpi_local_addr_max = 982 - mptcp_pm_get_local_addr_max(msk); 975 + info->mptcpi_limit_extra_subflows = 976 + mptcp_pm_get_limit_extra_subflows(msk); 977 + info->mptcpi_endp_signal_max = 978 + mptcp_pm_get_endp_signal_max(msk); 979 + info->mptcpi_limit_add_addr_accepted = 980 + mptcp_pm_get_limit_add_addr_accepted(msk); 981 + info->mptcpi_endp_subflow_max = 982 + mptcp_pm_get_endp_subflow_max(msk); 983 + info->mptcpi_endp_laminar_max = 984 + mptcp_pm_get_endp_laminar_max(msk); 983 985 } 984 986 985 987 if (__mptcp_check_fallback(msk)) ··· 998 996 info->mptcpi_bytes_sent = msk->bytes_sent; 999 997 info->mptcpi_bytes_received = msk->bytes_received; 1000 998 info->mptcpi_bytes_retrans = msk->bytes_retrans; 1001 - info->mptcpi_subflows_total = info->mptcpi_subflows + 999 + info->mptcpi_subflows_total = info->mptcpi_extra_subflows + 1002 1000 __mptcp_has_initial_subflow(msk); 1003 1001 now = tcp_jiffies32; 1004 1002 info->mptcpi_last_data_sent = jiffies_to_msecs(now - msk->last_data_sent);
+1 -1
tools/testing/selftests/bpf/progs/mptcp_subflow.c
··· 117 117 return 1; 118 118 119 119 msk = bpf_core_cast(sk, struct mptcp_sock); 120 - if (msk->pm.subflows != 1) { 120 + if (msk->pm.extra_subflows != 1) { 121 121 ctx->retval = -1; 122 122 return 1; 123 123 }
+11
tools/testing/selftests/net/mptcp/mptcp_join.sh
··· 3306 3306 run_tests $ns1 $ns2 10.0.1.1 3307 3307 chk_join_nr 1 1 1 3308 3308 fi 3309 + 3310 + # default limits, server deny join id 0 + signal 3311 + if reset_with_allow_join_id0 "default limits, server deny join id 0" 0 1; then 3312 + pm_nl_set_limits $ns1 0 2 3313 + pm_nl_set_limits $ns2 0 2 3314 + pm_nl_add_endpoint $ns1 10.0.2.1 flags signal 3315 + pm_nl_add_endpoint $ns2 10.0.3.2 flags subflow 3316 + pm_nl_add_endpoint $ns2 10.0.4.2 flags subflow 3317 + run_tests $ns1 $ns2 10.0.1.1 3318 + chk_join_nr 2 2 2 3319 + fi 3309 3320 } 3310 3321 3311 3322 fullmesh_tests()