@@ -531,7 +531,8 @@ int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg,
static int mptcp_pm_set_flags(struct genl_info *info)
{
struct mptcp_pm_addr_entry loc = { .addr = { .family = AF_UNSPEC }, };
- struct nlattr *attr_loc;
+ struct mptcp_pm_addr_entry rem = { .addr = { .family = AF_UNSPEC }, };
+ struct nlattr *attr_loc, *attr_rem;
int ret = -EINVAL;
if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR))
@@ -542,9 +543,20 @@ static int mptcp_pm_set_flags(struct genl_info *info)
if (ret < 0)
return ret;
- if (info->attrs[MPTCP_PM_ATTR_TOKEN])
- return mptcp_userspace_pm_set_flags(&loc, info);
- return mptcp_pm_nl_set_flags(&loc, info);
+ if (info->attrs[MPTCP_PM_ATTR_TOKEN]) {
+ attr_rem = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE];
+ ret = mptcp_pm_parse_entry(attr_rem, info, false, &rem);
+ if (ret < 0)
+ return ret;
+
+ if (rem.addr.family == AF_UNSPEC) {
+ NL_SET_ERR_MSG_ATTR(info->extack, attr_rem,
+ "invalid remote address family");
+ return -EINVAL;
+ }
+ return mptcp_userspace_pm_set_flags(&loc, &rem, info);
+ }
+ return mptcp_pm_nl_set_flags(&loc, &rem, info);
}
int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info)
@@ -1949,6 +1949,7 @@ static void mptcp_nl_set_flags(struct net *net,
}
int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local,
+ struct mptcp_pm_addr_entry *remote,
struct genl_info *info)
{
struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR];
@@ -553,19 +553,16 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info
}
int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local,
+ struct mptcp_pm_addr_entry *remote,
struct genl_info *info)
{
- struct mptcp_addr_info rem = { .family = AF_UNSPEC, };
struct mptcp_pm_addr_entry *entry;
- struct nlattr *attr, *attr_rem;
struct mptcp_sock *msk;
+ struct nlattr *attr;
int ret = -EINVAL;
struct sock *sk;
u8 bkup = 0;
- if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ATTR_ADDR_REMOTE))
- return ret;
-
msk = mptcp_userspace_pm_get_sock(info);
if (!msk)
return ret;
@@ -580,18 +577,6 @@ int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local,
goto set_flags_err;
}
- attr_rem = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE];
- ret = mptcp_pm_parse_addr(attr_rem, info, &rem);
- if (ret < 0)
- goto set_flags_err;
-
- if (rem.family == AF_UNSPEC) {
- NL_SET_ERR_MSG_ATTR(info->extack, attr_rem,
- "invalid remote address family");
- ret = -EINVAL;
- goto set_flags_err;
- }
-
if (local->flags & MPTCP_PM_ADDR_FLAG_BACKUP)
bkup = 1;
@@ -606,7 +591,7 @@ int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local,
spin_unlock_bh(&msk->pm.lock);
lock_sock(sk);
- ret = mptcp_pm_nl_mp_prio_send_ack(msk, &local->addr, &rem, bkup);
+ ret = mptcp_pm_nl_mp_prio_send_ack(msk, &local->addr, &remote->addr, bkup);
release_sock(sk);
/* mptcp_pm_nl_mp_prio_send_ack() only fails in one case */
@@ -1038,8 +1038,10 @@ bool mptcp_lookup_subflow_by_saddr(const struct list_head *list,
bool mptcp_remove_anno_list_by_saddr(struct mptcp_sock *msk,
const struct mptcp_addr_info *addr);
int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local,
+ struct mptcp_pm_addr_entry *remote,
struct genl_info *info);
int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local,
+ struct mptcp_pm_addr_entry *remote,
struct genl_info *info);
int mptcp_pm_announce_addr(struct mptcp_sock *msk,
const struct mptcp_addr_info *addr,