Skip to content

Commit 47d4517

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
mptcp: add info parameter for dump_addr
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 <[email protected]>
1 parent 06d307b commit 47d4517

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

net/mptcp/pm.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -485,19 +485,20 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info)
485485
return ret;
486486
}
487487

488-
static int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb)
488+
static int mptcp_pm_dump_addr(struct sk_buff *msg, struct netlink_callback *cb,
489+
const struct genl_info *info)
489490
{
490-
const struct genl_info *info = genl_info_dump(cb);
491-
492491
if (info->attrs[MPTCP_PM_ATTR_TOKEN])
493-
return mptcp_userspace_pm_dump_addr(msg, cb);
494-
return mptcp_pm_nl_dump_addr(msg, cb);
492+
return mptcp_userspace_pm_dump_addr(msg, cb, info);
493+
return mptcp_pm_nl_dump_addr(msg, cb, info);
495494
}
496495

497496
int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg,
498497
struct netlink_callback *cb)
499498
{
500-
return mptcp_pm_dump_addr(msg, cb);
499+
const struct genl_info *info = genl_info_dump(cb);
500+
501+
return mptcp_pm_dump_addr(msg, cb, info);
501502
}
502503

503504
static int mptcp_pm_set_flags(struct sk_buff *skb, struct genl_info *info)

net/mptcp/pm_netlink.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,9 +1784,10 @@ int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,
17841784
}
17851785

17861786
int mptcp_pm_nl_dump_addr(struct sk_buff *msg,
1787-
struct netlink_callback *cb)
1787+
struct netlink_callback *cb,
1788+
const struct genl_info *info)
17881789
{
1789-
struct net *net = sock_net(msg->sk);
1790+
struct net *net = genl_info_net(info);
17901791
struct mptcp_pm_addr_entry *entry;
17911792
struct pm_nl_pernet *pernet;
17921793
int id = cb->args[0];

net/mptcp/pm_userspace.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,12 +615,12 @@ int mptcp_userspace_pm_set_flags(struct sk_buff *skb, struct genl_info *info)
615615
}
616616

617617
int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
618-
struct netlink_callback *cb)
618+
struct netlink_callback *cb,
619+
const struct genl_info *info)
619620
{
620621
struct id_bitmap {
621622
DECLARE_BITMAP(map, MPTCP_PM_MAX_ADDR_ID + 1);
622623
} *bitmap;
623-
const struct genl_info *info = genl_info_dump(cb);
624624
struct mptcp_pm_addr_entry *entry;
625625
struct mptcp_sock *msk;
626626
int ret = -EINVAL;

net/mptcp/protocol.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,9 +1128,11 @@ bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc);
11281128
bool mptcp_pm_nl_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc);
11291129
bool mptcp_userspace_pm_is_backup(struct mptcp_sock *msk, struct mptcp_addr_info *skc);
11301130
int mptcp_pm_nl_dump_addr(struct sk_buff *msg,
1131-
struct netlink_callback *cb);
1131+
struct netlink_callback *cb,
1132+
const struct genl_info *info);
11321133
int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
1133-
struct netlink_callback *cb);
1134+
struct netlink_callback *cb,
1135+
const struct genl_info *info);
11341136
int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,
11351137
const struct genl_info *info);
11361138
int mptcp_userspace_pm_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,

0 commit comments

Comments
 (0)