mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
mptcp: netlink: Add MPTCP_PM_CMD_REMOVE
This change adds a MPTCP netlink command for issuing a REMOVE_ADDR signal for an address over the chosen MPTCP connection from a userspace path manager. The command requires the following parameters: {token, loc_id}. Acked-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Kishen Maloor <kishen.maloor@intel.com> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
9a0b36509d
commit
d9a4594eda
4 changed files with 76 additions and 2 deletions
|
@ -180,3 +180,65 @@ int mptcp_nl_cmd_announce(struct sk_buff *skb, struct genl_info *info)
|
|||
sock_put((struct sock *)msk);
|
||||
return err;
|
||||
}
|
||||
|
||||
int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info)
|
||||
{
|
||||
struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN];
|
||||
struct nlattr *id = info->attrs[MPTCP_PM_ATTR_LOC_ID];
|
||||
struct mptcp_pm_addr_entry *match = NULL;
|
||||
struct mptcp_pm_addr_entry *entry;
|
||||
struct mptcp_sock *msk;
|
||||
LIST_HEAD(free_list);
|
||||
int err = -EINVAL;
|
||||
u32 token_val;
|
||||
u8 id_val;
|
||||
|
||||
if (!id || !token) {
|
||||
GENL_SET_ERR_MSG(info, "missing required inputs");
|
||||
return err;
|
||||
}
|
||||
|
||||
id_val = nla_get_u8(id);
|
||||
token_val = nla_get_u32(token);
|
||||
|
||||
msk = mptcp_token_get_sock(sock_net(skb->sk), token_val);
|
||||
if (!msk) {
|
||||
NL_SET_ERR_MSG_ATTR(info->extack, token, "invalid token");
|
||||
return err;
|
||||
}
|
||||
|
||||
if (!mptcp_pm_is_userspace(msk)) {
|
||||
GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected");
|
||||
goto remove_err;
|
||||
}
|
||||
|
||||
lock_sock((struct sock *)msk);
|
||||
|
||||
list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) {
|
||||
if (entry->addr.id == id_val) {
|
||||
match = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!match) {
|
||||
GENL_SET_ERR_MSG(info, "address with specified id not found");
|
||||
release_sock((struct sock *)msk);
|
||||
goto remove_err;
|
||||
}
|
||||
|
||||
list_move(&match->list, &free_list);
|
||||
|
||||
mptcp_pm_remove_addrs_and_subflows(msk, &free_list);
|
||||
|
||||
release_sock((struct sock *)msk);
|
||||
|
||||
list_for_each_entry_safe(match, entry, &free_list, list) {
|
||||
sock_kfree_s((struct sock *)msk, match, sizeof(*match));
|
||||
}
|
||||
|
||||
err = 0;
|
||||
remove_err:
|
||||
sock_put((struct sock *)msk);
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue