Skip to content

Commit e026631

Browse files
Geliang Tangkuba-moo
authored andcommitted
mptcp: update local address flags when setting it
Just like in-kernel pm, when userspace pm does set_flags, it needs to send out MP_PRIO signal, and also modify the flags of the corresponding address entry in the local address list. This patch implements the missing logic. Traverse all address entries on userspace_pm_local_addr_list to find the local address entry, if bkup is true, set the flags of this entry with FLAG_BACKUP, otherwise, clear FLAG_BACKUP. Fixes: 892f396 ("mptcp: netlink: issue MP_PRIO signals from userspace PMs") Cc: [email protected] Signed-off-by: Geliang Tang <[email protected]> Reviewed-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 73af53d commit e026631

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

net/mptcp/pm_userspace.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info)
560560
struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN];
561561
struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR];
562562
struct net *net = sock_net(skb->sk);
563+
struct mptcp_pm_addr_entry *entry;
563564
struct mptcp_sock *msk;
564565
int ret = -EINVAL;
565566
struct sock *sk;
@@ -601,6 +602,17 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info)
601602
if (loc.flags & MPTCP_PM_ADDR_FLAG_BACKUP)
602603
bkup = 1;
603604

605+
spin_lock_bh(&msk->pm.lock);
606+
list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) {
607+
if (mptcp_addresses_equal(&entry->addr, &loc.addr, false)) {
608+
if (bkup)
609+
entry->flags |= MPTCP_PM_ADDR_FLAG_BACKUP;
610+
else
611+
entry->flags &= ~MPTCP_PM_ADDR_FLAG_BACKUP;
612+
}
613+
}
614+
spin_unlock_bh(&msk->pm.lock);
615+
604616
lock_sock(sk);
605617
ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem.addr, bkup);
606618
release_sock(sk);

0 commit comments

Comments
 (0)