Skip to content

Commit c157bbe

Browse files
Paolo Abenikuba-moo
authored andcommitted
mptcp: allow the in kernel PM to set MPC subflow priority
Any local endpoints configured on the address matching the MPC subflow are currently ignored. Specifically, setting a backup flag on them has no effect on the first subflow, as the MPC handshake can't carry such info. This change refactors the MPC endpoint id accounting to additionally fetch the priority info from the relevant endpoint and eventually trigger the MP_PRIO handshake as needed. As a result, the MPC subflow now switches to backup priority after that the MPTCP socket is fully established, according to the local endpoint configuration. Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent bedee0b commit c157bbe

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

net/mptcp/pm_netlink.c

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -514,30 +514,14 @@ __lookup_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_info *info,
514514
struct mptcp_pm_addr_entry *entry;
515515

516516
list_for_each_entry(entry, &pernet->local_addr_list, list) {
517-
if ((!lookup_by_id && mptcp_addresses_equal(&entry->addr, info, true)) ||
517+
if ((!lookup_by_id &&
518+
mptcp_addresses_equal(&entry->addr, info, entry->addr.port)) ||
518519
(lookup_by_id && entry->addr.id == info->id))
519520
return entry;
520521
}
521522
return NULL;
522523
}
523524

524-
static int
525-
lookup_id_by_addr(const struct pm_nl_pernet *pernet, const struct mptcp_addr_info *addr)
526-
{
527-
const struct mptcp_pm_addr_entry *entry;
528-
int ret = -1;
529-
530-
rcu_read_lock();
531-
list_for_each_entry(entry, &pernet->local_addr_list, list) {
532-
if (mptcp_addresses_equal(&entry->addr, addr, entry->addr.port)) {
533-
ret = entry->addr.id;
534-
break;
535-
}
536-
}
537-
rcu_read_unlock();
538-
return ret;
539-
}
540-
541525
static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
542526
{
543527
struct sock *sk = (struct sock *)msk;
@@ -555,13 +539,22 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk)
555539

556540
/* do lazy endpoint usage accounting for the MPC subflows */
557541
if (unlikely(!(msk->pm.status & BIT(MPTCP_PM_MPC_ENDPOINT_ACCOUNTED))) && msk->first) {
542+
struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(msk->first);
543+
struct mptcp_pm_addr_entry *entry;
558544
struct mptcp_addr_info mpc_addr;
559-
int mpc_id;
545+
bool backup = false;
560546

561547
local_address((struct sock_common *)msk->first, &mpc_addr);
562-
mpc_id = lookup_id_by_addr(pernet, &mpc_addr);
563-
if (mpc_id >= 0)
564-
__clear_bit(mpc_id, msk->pm.id_avail_bitmap);
548+
rcu_read_lock();
549+
entry = __lookup_addr(pernet, &mpc_addr, false);
550+
if (entry) {
551+
__clear_bit(entry->addr.id, msk->pm.id_avail_bitmap);
552+
backup = !!(entry->flags & MPTCP_PM_ADDR_FLAG_BACKUP);
553+
}
554+
rcu_read_unlock();
555+
556+
if (backup)
557+
mptcp_pm_send_ack(msk, subflow, true, backup);
565558

566559
msk->pm.status |= BIT(MPTCP_PM_MPC_ENDPOINT_ACCOUNTED);
567560
}

0 commit comments

Comments
 (0)