Skip to content

Commit

Permalink
mptcp: add addr into userspace pm list
Browse files Browse the repository at this point in the history
Add the address into userspace_pm_local_addr_list when the subflow is
created. And delete it in the new helper
mptcp_userspace_pm_delete_local_addr().

By doing that, the "REMOVE" command also works with subflows that have
been created via the "SUB_CREATE" command instead of restricting to
the addresses that have been announced via the "ANNOUNCE" command.

Fixes: d9a4594 ("mptcp: netlink: Add MPTCP_PM_CMD_REMOVE")
Link: multipath-tcp/mptcp_net-next#379
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
  • Loading branch information
geliangtang authored and intel-lab-lkp committed Apr 25, 2023
1 parent 4dba578 commit fc49ee4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions net/mptcp/pm_userspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,23 @@ int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk,
return ret;
}

static int mptcp_userspace_pm_delete_local_addr(struct mptcp_sock *msk,
struct mptcp_pm_addr_entry *addr)
{
struct mptcp_pm_addr_entry *entry, *tmp;

list_for_each_entry_safe(entry, tmp, &msk->pm.userspace_pm_local_addr_list, list) {
if (mptcp_addresses_equal(&entry->addr, &addr->addr, false) &&
msk->pm.subflows == 1) {
list_del_rcu(&entry->list);
kfree(entry);
return 0;
}
}

return -EINVAL;
}

int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk,
unsigned int id,
u8 *flags, int *ifindex)
Expand Down Expand Up @@ -251,6 +268,7 @@ int mptcp_nl_cmd_sf_create(struct sk_buff *skb, struct genl_info *info)
struct nlattr *raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE];
struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN];
struct nlattr *laddr = info->attrs[MPTCP_PM_ATTR_ADDR];
struct mptcp_pm_addr_entry local = { 0 };
struct mptcp_addr_info addr_r;
struct mptcp_addr_info addr_l;
struct mptcp_sock *msk;
Expand Down Expand Up @@ -302,12 +320,25 @@ int mptcp_nl_cmd_sf_create(struct sk_buff *skb, struct genl_info *info)
goto create_err;
}

local.addr = addr_l;
err = mptcp_userspace_pm_append_new_local_addr(msk, &local);
if (err < 0) {
GENL_SET_ERR_MSG(info, "did not match address and id");
goto create_err;
}

lock_sock(sk);

err = __mptcp_subflow_connect(sk, &addr_l, &addr_r);

release_sock(sk);

if (err) {
spin_lock_bh(&msk->pm.lock);
mptcp_userspace_pm_delete_local_addr(msk, &local);
spin_unlock_bh(&msk->pm.lock);
}

create_err:
sock_put((struct sock *)msk);
return err;
Expand Down

0 comments on commit fc49ee4

Please sign in to comment.