Skip to content

Commit

Permalink
mptcp: userspace pm remove id 0 address
Browse files Browse the repository at this point in the history
This patch adds the ability to send RM_ADDR for local ID 0. Check
whether id 0 address is removed, if not, put id 0 into a removing
list, pass it to mptcp_pm_remove_addr() to remove id 0 address.

There is no reason not to allow the userspace to remove the initial
address (ID 0). This special case was not taken into account not
letting the userspace to delete all addresses as announced.

Closes: multipath-tcp/mptcp_net-next#379
Fixes: d9a4594 ("mptcp: netlink: Add MPTCP_PM_CMD_REMOVE")
Signed-off-by: Geliang Tang <geliang.tang@suse.com>
  • Loading branch information
geliangtang authored and intel-lab-lkp committed Sep 14, 2023
1 parent a1e84b7 commit ecbe03a
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions net/mptcp/pm_userspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,30 @@ int mptcp_nl_cmd_announce(struct sk_buff *skb, struct genl_info *info)
return err;
}

static int mptcp_userspace_remove_id_zero_address(struct mptcp_sock *msk,
struct genl_info *info)
{
struct mptcp_rm_list list = { .nr = 0 };
struct sock *sk = (struct sock *)msk;
int err = -EINVAL;

lock_sock(sk);
spin_lock_bh(&msk->pm.lock);
if (!__mptcp_check_initial_subflow(msk)) {
GENL_SET_ERR_MSG(info, "address with id 0 not found");
goto out;
}

list.ids[list.nr++] = 0;
mptcp_pm_remove_addr(msk, &list);
err = 0;
out:
spin_unlock_bh(&msk->pm.lock);
release_sock(sk);
sock_put(sk);
return err;
}

int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info)
{
struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN];
Expand Down Expand Up @@ -239,6 +263,9 @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info)
goto remove_err;
}

if (id_val == 0)
return mptcp_userspace_remove_id_zero_address(msk, info);

lock_sock((struct sock *)msk);

list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) {
Expand Down

0 comments on commit ecbe03a

Please sign in to comment.