From: Geliang Tang <tanggeliang@kylinos.cn>
The genl_info information is useful for dump_addr() interface in both
in-kernel PM and userspace PM. The former can use it to get pm_nl_pernet,
the latter can use it to get msk through mptcp_userspace_pm_get_sock().
So this patch adds an "info" parameter to dump_addr interface, so that
"info" can be obtained in mptcp_pm_nl_get_addr_dumpit() and then passed to
mptcp_pm_nl_dump_addr() or mptcp_userspace_pm_dump_addr(), without having
to get it again in these two functions.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
net/mptcp/pm.c | 13 +++++++------
net/mptcp/pm_netlink.c | 5 +++--
net/mptcp/pm_userspace.c | 4 ++--
net/mptcp/protocol.h | 6 ++++--
4 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c
index 080c842e9e90..0aaf16319c34 100644
--- a/net/mptcp/pm.c
+++ b/net/mptcp/pm.c
@@ -485,19 +485,20 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info)
return ret;
}
-static int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb)
+static int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb,
+ const struct genl_info *info)
{
- const struct genl_info *info = genl_info_dump(cb);
-
if (info->attrs[MPTCP_PM_ATTR_TOKEN])
- return mptcp_userspace_pm_dump_addr(msg, cb);
- return mptcp_pm_nl_dump_addr(msg, cb);
+ return mptcp_userspace_pm_dump_addr(msg, cb, info);
+ return mptcp_pm_nl_dump_addr(msg, cb, info);
}
int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg,
struct netlink_callback *cb)
{
- return mptcp_pm_dump_addr(msg, cb);
+ const struct genl_info *info = genl_info_dump(cb);
+
+ return mptcp_pm_dump_addr(msg, cb, info);
}
static int mptcp_pm_set_flags(struct sk_buff *skb, struct genl_info *info)
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index eb5f48e45187..0d826bfc4718 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -1784,9 +1784,10 @@ int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,
}
int mptcp_pm_nl_dump_addr(struct sk_buff *msg,
- struct netlink_callback *cb)
+ struct netlink_callback *cb,
+ const struct genl_info *info)
{
- struct net *net = sock_net(msg->sk);
+ struct net *net = genl_info_net(info);
struct mptcp_pm_addr_entry *entry;
struct pm_nl_pernet *pernet;
int id = cb->args[0];
diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c
index 7c5914012947..7dc417255e8f 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -615,12 +615,12 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info)
}
int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
- struct netlink_callback *cb)
+ struct netlink_callback *cb,
+ const struct genl_info *info)
{
struct id_bitmap {
DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1);
} *bitmap;
- const struct genl_info *info = genl_info_dump(cb);
struct mptcp_pm_addr_entry *entry;
struct mptcp_sock *msk;
int ret = -EINVAL;
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index a9fc30f20376..1f9c66f53865 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -1128,9 +1128,11 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc);
bool mptcp_pm_nl_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc);
bool mptcp_userspace_pm_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc);
int mptcp_pm_nl_dump_addr(struct sk_buff *msg,
- struct netlink_callback *cb);
+ struct netlink_callback *cb,
+ const struct genl_info *info);
int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
- struct netlink_callback *cb);
+ struct netlink_callback *cb,
+ const struct genl_info *info);
int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,
const struct genl_info *info);
int mptcp_userspace_pm_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,
--
2.45.2