blob: 6b2bfe89d44510e488df9940d7babf3463b90161 [file] [log] [blame]
Peter Krystad1b1c7a02020-03-27 14:48:38 -07001// SPDX-License-Identifier: GPL-2.0
2/* Multipath TCP
3 *
4 * Copyright (c) 2019, Intel Corporation.
5 */
Geliang Tangc85adce2020-04-03 17:14:08 +08006#define pr_fmt(fmt) "MPTCP: " fmt
7
Peter Krystad1b1c7a02020-03-27 14:48:38 -07008#include <linux/kernel.h>
9#include <net/tcp.h>
10#include <net/mptcp.h>
11#include "protocol.h"
12
Paolo Abenifc1b4e32021-08-13 15:15:46 -070013#include "mib.h"
14
Peter Krystad1b1c7a02020-03-27 14:48:38 -070015/* path manager command handlers */
16
17int mptcp_pm_announce_addr(struct mptcp_sock *msk,
Geliang Tang6a6c05a2020-09-24 08:29:50 +080018 const struct mptcp_addr_info *addr,
Geliang Tangf7efc772021-03-26 11:26:31 -070019 bool echo)
Peter Krystad1b1c7a02020-03-27 14:48:38 -070020{
Geliang Tang13ad9f02020-12-09 15:51:27 -080021 u8 add_addr = READ_ONCE(msk->pm.addr_signal);
Geliang Tangd91d3222020-11-19 11:45:59 -080022
Yonglong Li18fc1a92021-08-23 18:05:40 -070023 pr_debug("msk=%p, local_id=%d, echo=%d", msk, addr->id, echo);
Peter Krystad926bdea2020-03-27 14:48:41 -070024
Florian Westphal3abc05d2021-02-04 15:23:30 -080025 lockdep_assert_held(&msk->pm.lock);
26
Yonglong Li18fc1a92021-08-23 18:05:40 -070027 if (add_addr &
28 (echo ? BIT(MPTCP_ADD_ADDR_ECHO) : BIT(MPTCP_ADD_ADDR_SIGNAL))) {
29 pr_warn("addr_signal error, add_addr=%d, echo=%d", add_addr, echo);
Geliang Tang42842a42020-12-09 15:51:26 -080030 return -EINVAL;
31 }
32
Yonglong Li18fc1a92021-08-23 18:05:40 -070033 if (echo) {
34 msk->pm.remote = *addr;
Geliang Tangd91d3222020-11-19 11:45:59 -080035 add_addr |= BIT(MPTCP_ADD_ADDR_ECHO);
Yonglong Li18fc1a92021-08-23 18:05:40 -070036 } else {
37 msk->pm.local = *addr;
38 add_addr |= BIT(MPTCP_ADD_ADDR_SIGNAL);
39 }
Geliang Tang13ad9f02020-12-09 15:51:27 -080040 WRITE_ONCE(msk->pm.addr_signal, add_addr);
Peter Krystad926bdea2020-03-27 14:48:41 -070041 return 0;
Peter Krystad1b1c7a02020-03-27 14:48:38 -070042}
43
Geliang Tangcbde2782021-03-12 17:16:12 -080044int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list)
Peter Krystad1b1c7a02020-03-27 14:48:38 -070045{
Geliang Tang13ad9f02020-12-09 15:51:27 -080046 u8 rm_addr = READ_ONCE(msk->pm.addr_signal);
Geliang Tang42842a42020-12-09 15:51:26 -080047
Geliang Tangcbde2782021-03-12 17:16:12 -080048 pr_debug("msk=%p, rm_list_nr=%d", msk, rm_list->nr);
Geliang Tangb6c08382020-09-24 08:29:54 +080049
Geliang Tang42842a42020-12-09 15:51:26 -080050 if (rm_addr) {
51 pr_warn("addr_signal error, rm_addr=%d", rm_addr);
52 return -EINVAL;
53 }
54
Geliang Tangcbde2782021-03-12 17:16:12 -080055 msk->pm.rm_list_tx = *rm_list;
Geliang Tang42842a42020-12-09 15:51:26 -080056 rm_addr |= BIT(MPTCP_RM_ADDR_SIGNAL);
Geliang Tang13ad9f02020-12-09 15:51:27 -080057 WRITE_ONCE(msk->pm.addr_signal, rm_addr);
Geliang Tangb46a0232021-03-26 11:26:41 -070058 mptcp_pm_nl_addr_send_ack(msk);
Geliang Tangb6c08382020-09-24 08:29:54 +080059 return 0;
Peter Krystad1b1c7a02020-03-27 14:48:38 -070060}
61
Geliang Tangddd14bb2021-03-12 17:16:16 -080062int mptcp_pm_remove_subflow(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list)
Peter Krystad1b1c7a02020-03-27 14:48:38 -070063{
Geliang Tangddd14bb2021-03-12 17:16:16 -080064 pr_debug("msk=%p, rm_list_nr=%d", msk, rm_list->nr);
Geliang Tang0ee42612020-09-24 08:29:55 +080065
66 spin_lock_bh(&msk->pm.lock);
Geliang Tangddd14bb2021-03-12 17:16:16 -080067 mptcp_pm_nl_rm_subflow_received(msk, rm_list);
Geliang Tang0ee42612020-09-24 08:29:55 +080068 spin_unlock_bh(&msk->pm.lock);
69 return 0;
Peter Krystad1b1c7a02020-03-27 14:48:38 -070070}
71
72/* path manager event handlers */
73
Florian Westphal6c714f12021-02-12 15:59:58 -080074void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ssk, int server_side)
Peter Krystad1b1c7a02020-03-27 14:48:38 -070075{
76 struct mptcp_pm_data *pm = &msk->pm;
77
78 pr_debug("msk=%p, token=%u side=%d", msk, msk->token, server_side);
79
80 WRITE_ONCE(pm->server_side, server_side);
Florian Westphalb911c972021-02-12 16:00:01 -080081 mptcp_event(MPTCP_EVENT_CREATED, msk, ssk, GFP_ATOMIC);
Peter Krystad1b1c7a02020-03-27 14:48:38 -070082}
83
84bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk)
85{
Peter Krystad926bdea2020-03-27 14:48:41 -070086 struct mptcp_pm_data *pm = &msk->pm;
Geliang Tanga914e582021-02-01 15:09:07 -080087 unsigned int subflows_max;
Geliang Tangf58f0652020-09-24 08:29:53 +080088 int ret = 0;
Peter Krystad926bdea2020-03-27 14:48:41 -070089
Geliang Tanga914e582021-02-01 15:09:07 -080090 subflows_max = mptcp_pm_get_subflows_max(msk);
91
Peter Krystad926bdea2020-03-27 14:48:41 -070092 pr_debug("msk=%p subflows=%d max=%d allow=%d", msk, pm->subflows,
Geliang Tanga914e582021-02-01 15:09:07 -080093 subflows_max, READ_ONCE(pm->accept_subflow));
Peter Krystad926bdea2020-03-27 14:48:41 -070094
95 /* try to avoid acquiring the lock below */
96 if (!READ_ONCE(pm->accept_subflow))
97 return false;
98
99 spin_lock_bh(&pm->lock);
Geliang Tangf58f0652020-09-24 08:29:53 +0800100 if (READ_ONCE(pm->accept_subflow)) {
Geliang Tanga914e582021-02-01 15:09:07 -0800101 ret = pm->subflows < subflows_max;
102 if (ret && ++pm->subflows == subflows_max)
Geliang Tangf58f0652020-09-24 08:29:53 +0800103 WRITE_ONCE(pm->accept_subflow, false);
104 }
Peter Krystad926bdea2020-03-27 14:48:41 -0700105 spin_unlock_bh(&pm->lock);
106
107 return ret;
108}
109
110/* return true if the new status bit is currently cleared, that is, this event
111 * can be server, eventually by an already scheduled work
112 */
113static bool mptcp_pm_schedule_work(struct mptcp_sock *msk,
114 enum mptcp_pm_status new_status)
115{
116 pr_debug("msk=%p status=%x new=%lx", msk, msk->pm.status,
117 BIT(new_status));
118 if (msk->pm.status & BIT(new_status))
119 return false;
120
121 msk->pm.status |= BIT(new_status);
Paolo Abeniba8f48f2020-11-16 10:48:05 +0100122 mptcp_schedule_work((struct sock *)msk);
Peter Krystad926bdea2020-03-27 14:48:41 -0700123 return true;
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700124}
125
Florian Westphal6c714f12021-02-12 15:59:58 -0800126void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk, gfp_t gfp)
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700127{
Peter Krystad926bdea2020-03-27 14:48:41 -0700128 struct mptcp_pm_data *pm = &msk->pm;
Florian Westphalb911c972021-02-12 16:00:01 -0800129 bool announce = false;
Peter Krystad926bdea2020-03-27 14:48:41 -0700130
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700131 pr_debug("msk=%p", msk);
Peter Krystad926bdea2020-03-27 14:48:41 -0700132
Peter Krystad926bdea2020-03-27 14:48:41 -0700133 spin_lock_bh(&pm->lock);
134
Paolo Abeni5b950ff2020-12-09 12:03:29 +0100135 /* mptcp_pm_fully_established() can be invoked by multiple
136 * racing paths - accept() and check_fully_established()
137 * be sure to serve this event only once.
138 */
139 if (READ_ONCE(pm->work_pending) &&
140 !(msk->pm.status & BIT(MPTCP_PM_ALREADY_ESTABLISHED)))
Peter Krystad926bdea2020-03-27 14:48:41 -0700141 mptcp_pm_schedule_work(msk, MPTCP_PM_ESTABLISHED);
142
Florian Westphalb911c972021-02-12 16:00:01 -0800143 if ((msk->pm.status & BIT(MPTCP_PM_ALREADY_ESTABLISHED)) == 0)
144 announce = true;
145
146 msk->pm.status |= BIT(MPTCP_PM_ALREADY_ESTABLISHED);
Peter Krystad926bdea2020-03-27 14:48:41 -0700147 spin_unlock_bh(&pm->lock);
Florian Westphalb911c972021-02-12 16:00:01 -0800148
149 if (announce)
150 mptcp_event(MPTCP_EVENT_ESTABLISHED, msk, ssk, gfp);
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700151}
152
153void mptcp_pm_connection_closed(struct mptcp_sock *msk)
154{
155 pr_debug("msk=%p", msk);
156}
157
Geliang Tang625352002021-03-26 11:26:33 -0700158void mptcp_pm_subflow_established(struct mptcp_sock *msk)
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700159{
Peter Krystad926bdea2020-03-27 14:48:41 -0700160 struct mptcp_pm_data *pm = &msk->pm;
161
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700162 pr_debug("msk=%p", msk);
Peter Krystad926bdea2020-03-27 14:48:41 -0700163
164 if (!READ_ONCE(pm->work_pending))
165 return;
166
167 spin_lock_bh(&pm->lock);
168
169 if (READ_ONCE(pm->work_pending))
170 mptcp_pm_schedule_work(msk, MPTCP_PM_SUBFLOW_ESTABLISHED);
171
172 spin_unlock_bh(&pm->lock);
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700173}
174
175void mptcp_pm_subflow_closed(struct mptcp_sock *msk, u8 id)
176{
177 pr_debug("msk=%p", msk);
178}
179
180void mptcp_pm_add_addr_received(struct mptcp_sock *msk,
181 const struct mptcp_addr_info *addr)
182{
Peter Krystad926bdea2020-03-27 14:48:41 -0700183 struct mptcp_pm_data *pm = &msk->pm;
184
185 pr_debug("msk=%p remote_id=%d accept=%d", msk, addr->id,
186 READ_ONCE(pm->accept_addr));
187
Florian Westphalb911c972021-02-12 16:00:01 -0800188 mptcp_event_addr_announced(msk, addr);
189
Peter Krystad926bdea2020-03-27 14:48:41 -0700190 spin_lock_bh(&pm->lock);
191
Geliang Tang84dfe362020-11-19 11:46:00 -0800192 if (!READ_ONCE(pm->accept_addr)) {
Geliang Tangf7efc772021-03-26 11:26:31 -0700193 mptcp_pm_announce_addr(msk, addr, true);
Geliang Tang84dfe362020-11-19 11:46:00 -0800194 mptcp_pm_add_addr_send_ack(msk);
195 } else if (mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_RECEIVED)) {
Peter Krystad926bdea2020-03-27 14:48:41 -0700196 pm->remote = *addr;
Geliang Tang84dfe362020-11-19 11:46:00 -0800197 }
Peter Krystad926bdea2020-03-27 14:48:41 -0700198
199 spin_unlock_bh(&pm->lock);
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700200}
201
Geliang Tang557963c2021-03-26 11:26:38 -0700202void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk,
203 struct mptcp_addr_info *addr)
204{
205 struct mptcp_pm_data *pm = &msk->pm;
206
207 pr_debug("msk=%p", msk);
208
209 spin_lock_bh(&pm->lock);
210
211 if (mptcp_lookup_anno_list_by_saddr(msk, addr) && READ_ONCE(pm->work_pending))
212 mptcp_pm_schedule_work(msk, MPTCP_PM_SUBFLOW_ESTABLISHED);
213
214 spin_unlock_bh(&pm->lock);
215}
216
Geliang Tang84dfe362020-11-19 11:46:00 -0800217void mptcp_pm_add_addr_send_ack(struct mptcp_sock *msk)
218{
Geliang Tangb5a7acd2021-02-01 15:09:09 -0800219 if (!mptcp_pm_should_add_signal(msk))
Geliang Tang84dfe362020-11-19 11:46:00 -0800220 return;
221
222 mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_SEND_ACK);
223}
224
Geliang Tang5c4a8242021-03-12 17:16:13 -0800225void mptcp_pm_rm_addr_received(struct mptcp_sock *msk,
226 const struct mptcp_rm_list *rm_list)
Geliang Tangd0876b22020-09-24 08:29:49 +0800227{
228 struct mptcp_pm_data *pm = &msk->pm;
Geliang Tang5c4a8242021-03-12 17:16:13 -0800229 u8 i;
Geliang Tangd0876b22020-09-24 08:29:49 +0800230
Geliang Tang5c4a8242021-03-12 17:16:13 -0800231 pr_debug("msk=%p remote_ids_nr=%d", msk, rm_list->nr);
Geliang Tangd0876b22020-09-24 08:29:49 +0800232
Geliang Tang5c4a8242021-03-12 17:16:13 -0800233 for (i = 0; i < rm_list->nr; i++)
234 mptcp_event_addr_removed(msk, rm_list->ids[i]);
Florian Westphalb911c972021-02-12 16:00:01 -0800235
Geliang Tangd0876b22020-09-24 08:29:49 +0800236 spin_lock_bh(&pm->lock);
237 mptcp_pm_schedule_work(msk, MPTCP_PM_RM_ADDR_RECEIVED);
Geliang Tangb5c55f32021-03-12 17:16:14 -0800238 pm->rm_list_rx = *rm_list;
Geliang Tangd0876b22020-09-24 08:29:49 +0800239 spin_unlock_bh(&pm->lock);
240}
241
Geliang Tang40453a52021-01-08 16:47:58 -0800242void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup)
243{
244 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
245
246 pr_debug("subflow->backup=%d, bkup=%d\n", subflow->backup, bkup);
247 subflow->backup = bkup;
Florian Westphalb911c972021-02-12 16:00:01 -0800248
249 mptcp_event(MPTCP_EVENT_SUB_PRIORITY, mptcp_sk(subflow->conn), sk, GFP_ATOMIC);
Geliang Tang40453a52021-01-08 16:47:58 -0800250}
251
Geliang Tang5580d412021-08-24 16:26:16 -0700252void mptcp_pm_mp_fail_received(struct sock *sk, u64 fail_seq)
253{
254 pr_debug("fail_seq=%llu", fail_seq);
255}
256
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700257/* path manager helpers */
258
Yonglong Li1f5e9e22021-08-23 18:05:39 -0700259bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, struct sk_buff *skb,
260 unsigned int opt_size, unsigned int remaining,
Yonglong Lif462a442021-08-23 18:05:42 -0700261 struct mptcp_addr_info *addr, bool *echo,
Yonglong Li1f5e9e22021-08-23 18:05:39 -0700262 bool *port, bool *drop_other_suboptions)
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700263{
Peter Krystad926bdea2020-03-27 14:48:41 -0700264 int ret = false;
Yonglong Li119c0222021-08-23 18:05:41 -0700265 u8 add_addr;
Yonglong Lif462a442021-08-23 18:05:42 -0700266 u8 family;
Peter Krystad926bdea2020-03-27 14:48:41 -0700267
268 spin_lock_bh(&msk->pm.lock);
269
270 /* double check after the lock is acquired */
Geliang Tangf643b802020-09-24 08:29:47 +0800271 if (!mptcp_pm_should_add_signal(msk))
Peter Krystad926bdea2020-03-27 14:48:41 -0700272 goto out_unlock;
273
Yonglong Li1f5e9e22021-08-23 18:05:39 -0700274 /* always drop every other options for pure ack ADD_ADDR; this is a
275 * plain dup-ack from TCP perspective. The other MPTCP-relevant info,
276 * if any, will be carried by the 'original' TCP ack
277 */
278 if (skb && skb_is_tcp_pure_ack(skb)) {
279 remaining += opt_size;
280 *drop_other_suboptions = true;
281 }
282
Geliang Tangd91d3222020-11-19 11:45:59 -0800283 *echo = mptcp_pm_should_add_signal_echo(msk);
Yonglong Lic233ef12021-08-23 18:05:43 -0700284 *port = !!(*echo ? msk->pm.remote.port : msk->pm.local.port);
Matthieu Baerts456afe02020-10-03 17:36:56 +0200285
Yonglong Lif462a442021-08-23 18:05:42 -0700286 family = *echo ? msk->pm.remote.family : msk->pm.local.family;
287 if (remaining < mptcp_add_addr_len(family, *echo, *port))
Peter Krystad926bdea2020-03-27 14:48:41 -0700288 goto out_unlock;
289
Yonglong Lif462a442021-08-23 18:05:42 -0700290 if (*echo) {
291 *addr = msk->pm.remote;
Yonglong Li119c0222021-08-23 18:05:41 -0700292 add_addr = msk->pm.addr_signal & ~BIT(MPTCP_ADD_ADDR_ECHO);
Yonglong Lif462a442021-08-23 18:05:42 -0700293 } else {
294 *addr = msk->pm.local;
Yonglong Li119c0222021-08-23 18:05:41 -0700295 add_addr = msk->pm.addr_signal & ~BIT(MPTCP_ADD_ADDR_SIGNAL);
Yonglong Lif462a442021-08-23 18:05:42 -0700296 }
Yonglong Li119c0222021-08-23 18:05:41 -0700297 WRITE_ONCE(msk->pm.addr_signal, add_addr);
Peter Krystad926bdea2020-03-27 14:48:41 -0700298 ret = true;
299
300out_unlock:
301 spin_unlock_bh(&msk->pm.lock);
302 return ret;
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700303}
304
Geliang Tang5cb104a2020-09-24 08:29:48 +0800305bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
Geliang Tang6445e172021-03-12 17:16:11 -0800306 struct mptcp_rm_list *rm_list)
Geliang Tang5cb104a2020-09-24 08:29:48 +0800307{
Geliang Tangcbde2782021-03-12 17:16:12 -0800308 int ret = false, len;
Yonglong Li119c0222021-08-23 18:05:41 -0700309 u8 rm_addr;
Geliang Tang5cb104a2020-09-24 08:29:48 +0800310
311 spin_lock_bh(&msk->pm.lock);
312
313 /* double check after the lock is acquired */
314 if (!mptcp_pm_should_rm_signal(msk))
315 goto out_unlock;
316
Yonglong Li119c0222021-08-23 18:05:41 -0700317 rm_addr = msk->pm.addr_signal & ~BIT(MPTCP_RM_ADDR_SIGNAL);
Geliang Tangcbde2782021-03-12 17:16:12 -0800318 len = mptcp_rm_addr_len(&msk->pm.rm_list_tx);
319 if (len < 0) {
Yonglong Li119c0222021-08-23 18:05:41 -0700320 WRITE_ONCE(msk->pm.addr_signal, rm_addr);
Geliang Tangcbde2782021-03-12 17:16:12 -0800321 goto out_unlock;
322 }
323 if (remaining < len)
Geliang Tang5cb104a2020-09-24 08:29:48 +0800324 goto out_unlock;
325
Geliang Tangcbde2782021-03-12 17:16:12 -0800326 *rm_list = msk->pm.rm_list_tx;
Yonglong Li119c0222021-08-23 18:05:41 -0700327 WRITE_ONCE(msk->pm.addr_signal, rm_addr);
Geliang Tang5cb104a2020-09-24 08:29:48 +0800328 ret = true;
329
330out_unlock:
331 spin_unlock_bh(&msk->pm.lock);
332 return ret;
333}
334
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700335int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc)
336{
Paolo Abeni01cacb02020-03-27 14:48:51 -0700337 return mptcp_pm_nl_get_local_id(msk, skc);
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700338}
339
Paolo Abeni71b7dec2021-08-13 15:15:42 -0700340void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk)
341{
342 struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
343 u32 rcv_tstamp = READ_ONCE(tcp_sk(ssk)->rcv_tstamp);
344
345 /* keep track of rtx periods with no progress */
346 if (!subflow->stale_count) {
347 subflow->stale_rcv_tstamp = rcv_tstamp;
348 subflow->stale_count++;
349 } else if (subflow->stale_rcv_tstamp == rcv_tstamp) {
350 if (subflow->stale_count < U8_MAX)
351 subflow->stale_count++;
Paolo Abeniff5a0b42021-08-13 15:15:45 -0700352 mptcp_pm_nl_subflow_chk_stale(msk, ssk);
Paolo Abeni71b7dec2021-08-13 15:15:42 -0700353 } else {
354 subflow->stale_count = 0;
Paolo Abeniff5a0b42021-08-13 15:15:45 -0700355 mptcp_subflow_set_active(subflow);
Paolo Abeni71b7dec2021-08-13 15:15:42 -0700356 }
357}
358
Paolo Abenib29fcfb2022-01-06 16:20:16 -0800359void mptcp_pm_data_reset(struct mptcp_sock *msk)
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700360{
361 msk->pm.add_addr_signaled = 0;
362 msk->pm.add_addr_accepted = 0;
363 msk->pm.local_addr_used = 0;
364 msk->pm.subflows = 0;
Geliang Tangcbde2782021-03-12 17:16:12 -0800365 msk->pm.rm_list_tx.nr = 0;
Geliang Tangb5c55f32021-03-12 17:16:14 -0800366 msk->pm.rm_list_rx.nr = 0;
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700367 WRITE_ONCE(msk->pm.work_pending, false);
Geliang Tang13ad9f02020-12-09 15:51:27 -0800368 WRITE_ONCE(msk->pm.addr_signal, 0);
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700369 WRITE_ONCE(msk->pm.accept_addr, false);
370 WRITE_ONCE(msk->pm.accept_subflow, false);
Geliang Tangdf377be2021-06-22 12:25:20 -0700371 WRITE_ONCE(msk->pm.remote_deny_join_id0, false);
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700372 msk->pm.status = 0;
373
Paolo Abenib29fcfb2022-01-06 16:20:16 -0800374 mptcp_pm_nl_data_init(msk);
375}
376
377void mptcp_pm_data_init(struct mptcp_sock *msk)
378{
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700379 spin_lock_init(&msk->pm.lock);
Geliang Tangb6c08382020-09-24 08:29:54 +0800380 INIT_LIST_HEAD(&msk->pm.anno_list);
Paolo Abenib29fcfb2022-01-06 16:20:16 -0800381 mptcp_pm_data_reset(msk);
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700382}
383
Paolo Abenid39dcec2020-06-26 19:29:59 +0200384void __init mptcp_pm_init(void)
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700385{
Paolo Abeni01cacb02020-03-27 14:48:51 -0700386 mptcp_pm_nl_init();
Peter Krystad1b1c7a02020-03-27 14:48:38 -0700387}