Skip to content

Commit

Permalink
Squash-to: mptcp: netlink: Add MPTCP_PM_CMD_ANNOUNCE
Browse files Browse the repository at this point in the history
Signed-off-by: Kishen Maloor <kishen.maloor@intel.com>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
  • Loading branch information
kmaloor authored and matttbe committed Apr 20, 2022
1 parent 717b19b commit b5427dc
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions net/mptcp/pm_userspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,42 +126,42 @@ int mptcp_nl_cmd_announce(struct sk_buff *skb, struct genl_info *info)
struct nlattr *addr = info->attrs[MPTCP_PM_ATTR_ADDR];
struct mptcp_pm_addr_entry addr_val;
struct mptcp_sock *msk;
int err = -EINVAL;
u32 token_val;
int err;

if (!addr || !token) {
GENL_SET_ERR_MSG(info, "missing required inputs");
return -EINVAL;
return err;
}

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 -EINVAL;
return err;
}

if (!mptcp_pm_is_userspace(msk)) {
GENL_SET_ERR_MSG(info, "invalid request; userspace PM not selected");
return -EINVAL;
goto announce_err;
}

err = mptcp_pm_parse_entry(addr, info, true, &addr_val);
if (err < 0) {
GENL_SET_ERR_MSG(info, "error parsing local address");
return err;
goto announce_err;
}

if (addr_val.addr.id == 0 || !(addr_val.flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) {
GENL_SET_ERR_MSG(info, "invalid addr id or flags");
return -EINVAL;
goto announce_err;
}

err = mptcp_userspace_pm_append_new_local_addr(msk, &addr_val);
if (err < 0) {
GENL_SET_ERR_MSG(info, "did not match address and id");
return err;
goto announce_err;
}

lock_sock((struct sock *)msk);
Expand All @@ -175,5 +175,8 @@ int mptcp_nl_cmd_announce(struct sk_buff *skb, struct genl_info *info)
spin_unlock_bh(&msk->pm.lock);
release_sock((struct sock *)msk);

return 0;
err = 0;
announce_err:
sock_put((struct sock *)msk);
return err;
}

0 comments on commit b5427dc

Please sign in to comment.