@@ -627,6 +627,9 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk)
pm->rm_list_tx.nr = 0;
pm->rm_list_rx.nr = 0;
WRITE_ONCE(pm->pm_type, pm_type);
+ rcu_read_lock();
+ mptcp_pm_initialize(msk, mptcp_pm_find(pm_type));
+ rcu_read_unlock();
if (pm_type == MPTCP_PM_TYPE_KERNEL) {
bool subflows_allowed = !!mptcp_pm_get_subflows_max(msk);
@@ -721,3 +724,33 @@ void mptcp_pm_unregister(struct mptcp_pm_ops *pm)
list_del_rcu(&pm->list);
spin_unlock(&mptcp_pm_list_lock);
}
+
+int mptcp_pm_initialize(struct mptcp_sock *msk, struct mptcp_pm_ops *pm)
+{
+ if (!pm)
+ return -EINVAL;
+
+ if (!bpf_try_module_get(pm, pm->owner))
+ return -EBUSY;
+
+ msk->pm.ops = pm;
+ if (msk->pm.ops->init)
+ msk->pm.ops->init(msk);
+
+ pr_debug("userspace_pm type %u initialized\n", msk->pm.ops->type);
+ return 0;
+}
+
+void mptcp_pm_release(struct mptcp_sock *msk)
+{
+ struct mptcp_pm_ops *pm = msk->pm.ops;
+
+ if (!pm)
+ return;
+
+ msk->pm.ops = NULL;
+ if (pm->release)
+ pm->release(msk);
+
+ bpf_module_put(pm, pm->owner);
+}
@@ -2944,6 +2944,7 @@ static void __mptcp_destroy_sock(struct sock *sk)
sk_stop_timer(sk, &sk->sk_timer);
msk->pm.status = 0;
mptcp_release_sched(msk);
+ mptcp_pm_release(msk);
sk->sk_prot->destroy(sk);
@@ -220,6 +220,7 @@ struct mptcp_pm_data {
struct mptcp_addr_info remote;
struct list_head anno_list;
struct list_head userspace_pm_local_addr_list;
+ struct mptcp_pm_ops *ops;
spinlock_t lock; /*protects the whole PM data */
@@ -1043,6 +1044,8 @@ struct mptcp_pm_ops *mptcp_pm_find(enum mptcp_pm_type type);
int mptcp_pm_validate(struct mptcp_pm_ops *pm);
int mptcp_pm_register(struct mptcp_pm_ops *pm);
void mptcp_pm_unregister(struct mptcp_pm_ops *pm);
+int mptcp_pm_initialize(struct mptcp_sock *msk, struct mptcp_pm_ops *pm);
+void mptcp_pm_release(struct mptcp_sock *msk);
void mptcp_free_local_addr_list(struct mptcp_sock *msk);