Skip to content

Commit

Permalink
mptcp: remove id 0 subflow & 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 and the
ability to remove id 0 subflow.

Put id 0 into a removing list, pass it to mptcp_pm_remove_addr() to
remve id 0 address and pass it to mptcp_pm_nl_rm_subflow_received() to
remove id 0 subflow.

Closes: multipath-tcp/mptcp_net-next#379
Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
geliangtang authored and intel-lab-lkp committed Aug 9, 2023
1 parent 87ced2e commit 47f0900
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion net/mptcp/pm_userspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,21 @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info)
goto remove_err;
}

if (id_val == 0) {
struct mptcp_rm_list list = { .nr = 0 };

list.ids[list.nr++] = 0;

lock_sock((struct sock *)msk);
spin_lock_bh(&msk->pm.lock);
mptcp_pm_remove_addr(msk, &list);
spin_unlock_bh(&msk->pm.lock);
release_sock((struct sock *)msk);

err = 0;
goto remove_err;
}

lock_sock((struct sock *)msk);

list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) {
Expand Down Expand Up @@ -399,14 +414,16 @@ int mptcp_nl_cmd_sf_destroy(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 nlattr *id = info->attrs[MPTCP_PM_ATTR_LOC_ID];
struct mptcp_addr_info addr_l;
struct mptcp_addr_info addr_r;
struct mptcp_sock *msk;
struct sock *sk, *ssk;
int err = -EINVAL;
u32 token_val;
u8 id_val;

if (!laddr || !raddr || !token) {
if (((!laddr || !raddr) && !id) || !token) {
GENL_SET_ERR_MSG(info, "missing required inputs");
return err;
}
Expand All @@ -424,6 +441,27 @@ int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info)
goto destroy_err;
}

if (id) {
id_val = nla_get_u8(id);
if (id_val == 0) {
struct mptcp_rm_list list = { .nr = 0 };

list.ids[list.nr++] = 0;

sk = (struct sock *)msk;
lock_sock(sk);
spin_lock_bh(&msk->pm.lock);
mptcp_pm_nl_rm_subflow_received(msk, &list);
spin_unlock_bh(&msk->pm.lock);
release_sock(sk);

err = 0;
} else {
err = -EINVAL;
}
goto destroy_err;
}

err = mptcp_pm_parse_addr(laddr, info, &addr_l);
if (err < 0) {
NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr");
Expand Down

0 comments on commit 47f0900

Please sign in to comment.