@@ -2045,25 +2045,21 @@ static int mptcp_nl_set_flags(struct net *net,
return ret;
}
-static int mptcp_pm_nl_set_flags(struct genl_info *info)
+static int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *loc,
+ struct mptcp_addr_info *rem,
+ struct genl_info *info)
{
- struct mptcp_pm_addr_entry addr = { .addr = { .family = AF_UNSPEC }, };
- struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR];
u8 changed, mask = MPTCP_PM_ADDR_FLAG_BACKUP |
MPTCP_PM_ADDR_FLAG_FULLMESH;
+ struct mptcp_pm_addr_entry addr = *loc;
struct net *net = genl_info_net(info);
struct mptcp_pm_addr_entry *entry;
struct pm_nl_pernet *pernet;
u8 lookup_by_id = 0;
u8 bkup = 0;
- int ret;
pernet = pm_nl_get_pernet(net);
- ret = mptcp_pm_parse_entry(attr, info, false, &addr);
- if (ret < 0)
- return ret;
-
if (addr.addr.family == AF_UNSPEC) {
lookup_by_id = 1;
if (!addr.addr.id) {
@@ -2099,16 +2095,34 @@ static int mptcp_pm_nl_set_flags(struct genl_info *info)
return 0;
}
-static int mptcp_pm_set_flags(struct genl_info *info)
+static int mptcp_pm_set_flags(struct mptcp_pm_addr_entry *loc,
+ struct mptcp_addr_info *rem,
+ struct genl_info *info)
{
if (info->attrs[MPTCP_PM_ATTR_TOKEN])
- return mptcp_userspace_pm_set_flags(info);
- return mptcp_pm_nl_set_flags(info);
+ 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)
{
- return mptcp_pm_set_flags(info);
+ struct mptcp_pm_addr_entry loc = { .addr = { .family = AF_UNSPEC }, };
+ struct nlattr *attr_rem = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE];
+ struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR];
+ struct mptcp_addr_info rem = { .family = AF_UNSPEC, };
+ int ret;
+
+ ret = mptcp_pm_parse_entry(attr, info, false, &loc);
+ if (ret < 0)
+ return ret;
+
+ if (attr_rem) {
+ ret = mptcp_pm_parse_addr(attr_rem, info, &rem);
+ if (ret < 0)
+ return ret;
+ }
+
+ return mptcp_pm_set_flags(&loc, &rem, info);
}
static void mptcp_nl_mcast_send(struct net *net, struct sk_buff *nlskb, gfp_t gfp)
@@ -536,12 +536,10 @@ int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info
return err;
}
-int mptcp_userspace_pm_set_flags(struct genl_info *info)
+int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *loc,
+ struct mptcp_addr_info *rem,
+ struct genl_info *info)
{
- struct mptcp_pm_addr_entry loc = { .addr = { .family = AF_UNSPEC }, };
- struct nlattr *attr_rem = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE];
- struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR];
- struct mptcp_addr_info rem = { .family = AF_UNSPEC, };
struct mptcp_sock *msk;
int ret = -EINVAL;
struct sock *sk;
@@ -553,28 +551,18 @@ int mptcp_userspace_pm_set_flags(struct genl_info *info)
sk = (struct sock *)msk;
- ret = mptcp_pm_parse_entry(attr, info, false, &loc);
- if (ret < 0)
- goto set_flags_err;
-
- if (attr_rem) {
- ret = mptcp_pm_parse_addr(attr_rem, info, &rem);
- if (ret < 0)
- goto set_flags_err;
- }
-
- if (loc.addr.family == AF_UNSPEC ||
- rem.family == AF_UNSPEC) {
+ if (loc->addr.family == AF_UNSPEC ||
+ rem->family == AF_UNSPEC) {
GENL_SET_ERR_MSG(info, "invalid address families");
ret = -EINVAL;
goto set_flags_err;
}
- if (loc.flags & MPTCP_PM_ADDR_FLAG_BACKUP)
+ if (loc->flags & MPTCP_PM_ADDR_FLAG_BACKUP)
bkup = 1;
lock_sock(sk);
- ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc.addr, &rem, bkup);
+ ret = mptcp_pm_nl_mp_prio_send_ack(msk, &loc->addr, rem, bkup);
release_sock(sk);
set_flags_err:
@@ -1033,7 +1033,9 @@ mptcp_pm_del_add_timer(struct mptcp_sock *msk,
struct mptcp_pm_add_entry *
mptcp_lookup_anno_list_by_saddr(const struct mptcp_sock *msk,
const struct mptcp_addr_info *addr);
-int mptcp_userspace_pm_set_flags(struct genl_info *info);
+int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *loc,
+ struct mptcp_addr_info *rem,
+ struct genl_info *info);
int mptcp_pm_announce_addr(struct mptcp_sock *msk,
const struct mptcp_addr_info *addr,
bool echo);