Skip to content

Commit e293102

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
mptcp: pm: validate mandatory ops
This patch adds a helper mptcp_pm_validate() to check whether required ops are defined. It will be invoked in .validate of struct bpf_struct_ops. Currently mandatory ops of mptcp_pm_ops are get_local_id and get_priority. Signed-off-by: Geliang Tang <[email protected]>
1 parent dccd5d5 commit e293102

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

net/mptcp/pm.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,8 +1045,24 @@ struct mptcp_pm_ops *mptcp_pm_find(const char *name)
10451045
return NULL;
10461046
}
10471047

1048+
int mptcp_pm_validate(struct mptcp_pm_ops *pm_ops)
1049+
{
1050+
if (!pm_ops->get_local_id || !pm_ops->get_priority) {
1051+
pr_err("%s does not implement required ops\n", pm_ops->name);
1052+
return -EINVAL;
1053+
}
1054+
1055+
return 0;
1056+
}
1057+
10481058
int mptcp_pm_register(struct mptcp_pm_ops *pm_ops)
10491059
{
1060+
int ret;
1061+
1062+
ret = mptcp_pm_validate(pm_ops);
1063+
if (ret)
1064+
return ret;
1065+
10501066
spin_lock(&mptcp_pm_list_lock);
10511067
if (mptcp_pm_find(pm_ops->name)) {
10521068
spin_unlock(&mptcp_pm_list_lock);

net/mptcp/protocol.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,7 @@ extern struct mptcp_pm_ops mptcp_pm_kernel;
10591059
struct mptcp_pm_ops *mptcp_pm_find(const char *name);
10601060
int mptcp_pm_register(struct mptcp_pm_ops *pm_ops);
10611061
void mptcp_pm_unregister(struct mptcp_pm_ops *pm_ops);
1062+
int mptcp_pm_validate(struct mptcp_pm_ops *pm_ops);
10621063

10631064
void mptcp_userspace_pm_free_local_addr_list(struct mptcp_sock *msk);
10641065

0 commit comments

Comments
 (0)