Branch data Line data Source code
1 : : /* SPDX-License-Identifier: GPL-2.0 */
2 : : /* Multipath TCP
3 : : *
4 : : * Copyright (c) 2017 - 2019, Intel Corporation.
5 : : */
6 : :
7 : : #ifndef __MPTCP_PROTOCOL_H
8 : : #define __MPTCP_PROTOCOL_H
9 : :
10 : : #include <linux/random.h>
11 : : #include <net/tcp.h>
12 : : #include <net/inet_connection_sock.h>
13 : : #include <uapi/linux/mptcp.h>
14 : : #include <net/genetlink.h>
15 : : #include <net/rstreason.h>
16 : :
17 : : #define MPTCP_SUPPORTED_VERSION 1
18 : :
19 : : /* MPTCP option bits */
20 : : #define OPTION_MPTCP_MPC_SYN BIT(0)
21 : : #define OPTION_MPTCP_MPC_SYNACK BIT(1)
22 : : #define OPTION_MPTCP_MPC_ACK BIT(2)
23 : : #define OPTION_MPTCP_MPJ_SYN BIT(3)
24 : : #define OPTION_MPTCP_MPJ_SYNACK BIT(4)
25 : : #define OPTION_MPTCP_MPJ_ACK BIT(5)
26 : : #define OPTION_MPTCP_ADD_ADDR BIT(6)
27 : : #define OPTION_MPTCP_RM_ADDR BIT(7)
28 : : #define OPTION_MPTCP_FASTCLOSE BIT(8)
29 : : #define OPTION_MPTCP_PRIO BIT(9)
30 : : #define OPTION_MPTCP_RST BIT(10)
31 : : #define OPTION_MPTCP_DSS BIT(11)
32 : : #define OPTION_MPTCP_FAIL BIT(12)
33 : :
34 : : #define OPTION_MPTCP_CSUMREQD BIT(13)
35 : :
36 : : #define OPTIONS_MPTCP_MPC (OPTION_MPTCP_MPC_SYN | OPTION_MPTCP_MPC_SYNACK | \
37 : : OPTION_MPTCP_MPC_ACK)
38 : : #define OPTIONS_MPTCP_MPJ (OPTION_MPTCP_MPJ_SYN | OPTION_MPTCP_MPJ_SYNACK | \
39 : : OPTION_MPTCP_MPJ_ACK)
40 : : #define OPTIONS_MPTCP_DSS (OPTION_MPTCP_DSS | OPTION_MPTCP_CSUMREQD)
41 : :
42 : : /* MPTCP option subtypes */
43 : : #define MPTCPOPT_MP_CAPABLE 0
44 : : #define MPTCPOPT_MP_JOIN 1
45 : : #define MPTCPOPT_DSS 2
46 : : #define MPTCPOPT_ADD_ADDR 3
47 : : #define MPTCPOPT_RM_ADDR 4
48 : : #define MPTCPOPT_MP_PRIO 5
49 : : #define MPTCPOPT_MP_FAIL 6
50 : : #define MPTCPOPT_MP_FASTCLOSE 7
51 : : #define MPTCPOPT_RST 8
52 : :
53 : : /* MPTCP suboption lengths */
54 : : #define TCPOLEN_MPTCP_MPC_SYN 4
55 : : #define TCPOLEN_MPTCP_MPC_SYNACK 12
56 : : #define TCPOLEN_MPTCP_MPC_ACK 20
57 : : #define TCPOLEN_MPTCP_MPC_ACK_DATA 22
58 : : #define TCPOLEN_MPTCP_MPJ_SYN 12
59 : : #define TCPOLEN_MPTCP_MPJ_SYNACK 16
60 : : #define TCPOLEN_MPTCP_MPJ_ACK 24
61 : : #define TCPOLEN_MPTCP_DSS_BASE 4
62 : : #define TCPOLEN_MPTCP_DSS_ACK32 4
63 : : #define TCPOLEN_MPTCP_DSS_ACK64 8
64 : : #define TCPOLEN_MPTCP_DSS_MAP32 10
65 : : #define TCPOLEN_MPTCP_DSS_MAP64 14
66 : : #define TCPOLEN_MPTCP_DSS_CHECKSUM 2
67 : : #define TCPOLEN_MPTCP_ADD_ADDR 16
68 : : #define TCPOLEN_MPTCP_ADD_ADDR_PORT 18
69 : : #define TCPOLEN_MPTCP_ADD_ADDR_BASE 8
70 : : #define TCPOLEN_MPTCP_ADD_ADDR_BASE_PORT 10
71 : : #define TCPOLEN_MPTCP_ADD_ADDR6 28
72 : : #define TCPOLEN_MPTCP_ADD_ADDR6_PORT 30
73 : : #define TCPOLEN_MPTCP_ADD_ADDR6_BASE 20
74 : : #define TCPOLEN_MPTCP_ADD_ADDR6_BASE_PORT 22
75 : : #define TCPOLEN_MPTCP_PORT_LEN 2
76 : : #define TCPOLEN_MPTCP_PORT_ALIGN 2
77 : : #define TCPOLEN_MPTCP_RM_ADDR_BASE 3
78 : : #define TCPOLEN_MPTCP_PRIO 3
79 : : #define TCPOLEN_MPTCP_PRIO_ALIGN 4
80 : : #define TCPOLEN_MPTCP_FASTCLOSE 12
81 : : #define TCPOLEN_MPTCP_RST 4
82 : : #define TCPOLEN_MPTCP_FAIL 12
83 : :
84 : : #define TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM (TCPOLEN_MPTCP_DSS_CHECKSUM + TCPOLEN_MPTCP_MPC_ACK_DATA)
85 : :
86 : : /* MPTCP MP_JOIN flags */
87 : : #define MPTCPOPT_BACKUP BIT(0)
88 : : #define MPTCPOPT_THMAC_LEN 8
89 : :
90 : : /* MPTCP MP_CAPABLE flags */
91 : : #define MPTCP_VERSION_MASK (0x0F)
92 : : #define MPTCP_CAP_CHECKSUM_REQD BIT(7)
93 : : #define MPTCP_CAP_EXTENSIBILITY BIT(6)
94 : : #define MPTCP_CAP_DENY_JOIN_ID0 BIT(5)
95 : : #define MPTCP_CAP_HMAC_SHA256 BIT(0)
96 : : #define MPTCP_CAP_FLAG_MASK (0x1F)
97 : :
98 : : /* MPTCP DSS flags */
99 : : #define MPTCP_DSS_DATA_FIN BIT(4)
100 : : #define MPTCP_DSS_DSN64 BIT(3)
101 : : #define MPTCP_DSS_HAS_MAP BIT(2)
102 : : #define MPTCP_DSS_ACK64 BIT(1)
103 : : #define MPTCP_DSS_HAS_ACK BIT(0)
104 : : #define MPTCP_DSS_FLAG_MASK (0x1F)
105 : :
106 : : /* MPTCP ADD_ADDR flags */
107 : : #define MPTCP_ADDR_ECHO BIT(0)
108 : :
109 : : /* MPTCP MP_PRIO flags */
110 : : #define MPTCP_PRIO_BKUP BIT(0)
111 : :
112 : : /* MPTCP TCPRST flags */
113 : : #define MPTCP_RST_TRANSIENT BIT(0)
114 : :
115 : : /* MPTCP socket atomic flags */
116 : : #define MPTCP_WORK_RTX 1
117 : : #define MPTCP_FALLBACK_DONE 2
118 : : #define MPTCP_WORK_CLOSE_SUBFLOW 3
119 : : #define MPTCP_RTX_ENABLED 4
120 : :
121 : : /* MPTCP socket release cb flags */
122 : : #define MPTCP_PUSH_PENDING 1
123 : : #define MPTCP_CLEAN_UNA 2
124 : : #define MPTCP_ERROR_REPORT 3
125 : : #define MPTCP_RETRANSMIT 4
126 : : #define MPTCP_FLUSH_JOIN_LIST 5
127 : : #define MPTCP_SYNC_STATE 6
128 : : #define MPTCP_SYNC_SNDBUF 7
129 : :
130 : : struct mptcp_skb_cb {
131 : : u64 map_seq;
132 : : u64 end_seq;
133 : : u32 offset;
134 : : u8 has_rxtstamp;
135 : : u8 cant_coalesce;
136 : : };
137 : :
138 : : #define MPTCP_SKB_CB(__skb) ((struct mptcp_skb_cb *)&((__skb)->cb[0]))
139 : :
140 : 80637 : static inline bool before64(__u64 seq1, __u64 seq2)
141 : : {
142 [ + ][ + + + : 11859323 : return (__s64)(seq1 - seq2) < 0;
+ + + +
+ ][ + + +
+ + + + +
+ + + + +
+ + + + +
+ - ][ + ]
[ + + + +
+ + + + ]
[ + + + +
+ + + + +
+ + + + +
+ + + + +
- ]
143 : : }
144 : :
145 : : #define after64(seq2, seq1) before64(seq1, seq2)
146 : :
147 : : struct mptcp_options_received {
148 : : struct { /* DSS, also used by MP_CAPABLE with data */
149 : : u64 data_ack;
150 : : u64 data_seq;
151 : : u32 subflow_seq;
152 : : u16 data_len;
153 : : __sum16 csum;
154 : : };
155 : : struct_group(status,
156 : : u16 suboptions;
157 : : u16 use_map:1,
158 : : dsn64:1,
159 : : data_fin:1,
160 : : use_ack:1,
161 : : ack64:1,
162 : : mpc_map:1,
163 : : reset_reason:4,
164 : : reset_transient:1,
165 : : echo:1,
166 : : backup:1,
167 : : deny_join_id0:1,
168 : : __unused:2;
169 : : );
170 : : struct mptcp_rm_list rm_list;
171 : : /* Options below are mutually exclusive, see mptcp_parse_option() */
172 : : union {
173 : : struct { /* MP_CAPABLE */
174 : : u64 sndr_key;
175 : : u64 rcvr_key;
176 : : };
177 : : struct { /* MP_JOIN */
178 : : u32 nonce;
179 : : u8 join_id;
180 : : union {
181 : : u32 token; /* SYN */
182 : : u64 thmac; /* SYN + ACK */
183 : : u8 hmac[MPTCPOPT_HMAC_LEN]; /* ACK */
184 : : };
185 : : };
186 : : struct { /* ADD_ADDR */
187 : : struct mptcp_addr_info addr;
188 : : u64 ahmac;
189 : : };
190 : : u64 fail_seq; /* MP_FAIL */
191 : : u64 fc_recv_key; /* MP_FASTCLOSE */
192 : : };
193 : : };
194 : :
195 : 0 : static inline __be32 mptcp_option(u8 subopt, u8 len, u8 nib, u8 field)
196 : : {
197 [ - + + ]: 1580365 : return htonl((TCPOPT_MPTCP << 24) | (len << 16) | (subopt << 12) |
[ - + + - ]
198 : : ((nib & 0xF) << 8) | field);
199 : : }
200 : :
201 : : enum mptcp_pm_status {
202 : : MPTCP_PM_ADD_ADDR_RECEIVED,
203 : : MPTCP_PM_ADD_ADDR_SEND_ACK,
204 : : MPTCP_PM_RM_ADDR_RECEIVED,
205 : : MPTCP_PM_ESTABLISHED,
206 : : MPTCP_PM_SUBFLOW_ESTABLISHED,
207 : : MPTCP_PM_ALREADY_ESTABLISHED, /* persistent status, set after ESTABLISHED event */
208 : : MPTCP_PM_MPC_ENDPOINT_ACCOUNTED, /* persistent status, set after MPC local address is
209 : : * accounted int id_avail_bitmap
210 : : */
211 : : MPTCP_PM_DESTROYING, /* To fence out PM list allocs */
212 : : };
213 : :
214 : : enum mptcp_pm_type {
215 : : MPTCP_PM_TYPE_KERNEL = 0,
216 : : MPTCP_PM_TYPE_USERSPACE,
217 : :
218 : : __MPTCP_PM_TYPE_NR,
219 : : __MPTCP_PM_TYPE_MAX = __MPTCP_PM_TYPE_NR - 1,
220 : : };
221 : :
222 : : /* Status bits below MPTCP_PM_ALREADY_ESTABLISHED need pm worker actions */
223 : : #define MPTCP_PM_WORK_MASK ((1 << MPTCP_PM_ALREADY_ESTABLISHED) - 1)
224 : :
225 : : enum mptcp_addr_signal_status {
226 : : MPTCP_ADD_ADDR_SIGNAL,
227 : : MPTCP_ADD_ADDR_ECHO,
228 : : MPTCP_RM_ADDR_SIGNAL,
229 : : };
230 : :
231 : : /* max value of mptcp_addr_info.id */
232 : : #define MPTCP_PM_MAX_ADDR_ID U8_MAX
233 : :
234 : : struct mptcp_pm_data {
235 : : struct mptcp_addr_info local;
236 : : struct mptcp_addr_info remote;
237 : : struct list_head anno_list;
238 : : struct list_head userspace_pm_local_addr_list;
239 : : struct mptcp_pm_ops *ops;
240 : :
241 : : spinlock_t lock; /*protects the whole PM data */
242 : :
243 : : struct_group(reset,
244 : :
245 : : u8 addr_signal;
246 : : bool server_side;
247 : : bool work_pending;
248 : : bool accept_addr;
249 : : bool accept_subflow;
250 : : bool remote_deny_join_id0;
251 : : u8 add_addr_signaled;
252 : : u8 add_addr_accepted;
253 : : u8 local_addr_used;
254 : : u8 pm_type;
255 : : u8 extra_subflows;
256 : : u8 status;
257 : :
258 : : );
259 : :
260 : : DECLARE_BITMAP(id_avail_bitmap, MPTCP_PM_MAX_ADDR_ID + 1);
261 : : struct mptcp_rm_list rm_list_tx;
262 : : struct mptcp_rm_list rm_list_rx;
263 : : };
264 : :
265 : : struct mptcp_pm_local {
266 : : struct mptcp_addr_info addr;
267 : : u32 flags;
268 : : int ifindex;
269 : : };
270 : :
271 : : struct mptcp_pm_addr_entry {
272 : : struct list_head list;
273 : : struct mptcp_addr_info addr;
274 : : u32 flags;
275 : : int ifindex;
276 : : struct socket *lsk;
277 : : };
278 : :
279 : : struct mptcp_data_frag {
280 : : struct list_head list;
281 : : u64 data_seq;
282 : : u16 data_len;
283 : : u16 offset;
284 : : u8 overhead;
285 : : u8 eor; /* currently using 1 bit */
286 : : u16 already_sent;
287 : : struct page *page;
288 : : };
289 : :
290 : : /* Arbitrary compromise between as low as possible to react timely to subflow
291 : : * close event and as big as possible to avoid being fouled by biased large
292 : : * samples due to peer sending data on a different subflow WRT to the incoming
293 : : * ack.
294 : : */
295 : : #define MPTCP_RTT_SAMPLES 5
296 : :
297 : : /* MPTCP connection sock */
298 : : struct mptcp_sock {
299 : : /* inet_connection_sock must be the first member */
300 : : struct inet_connection_sock sk;
301 : : u64 local_key; /* protected by the first subflow socket lock
302 : : * lockless access read
303 : : */
304 : : u64 remote_key; /* same as above */
305 : : u64 write_seq;
306 : : u64 bytes_sent;
307 : : u64 snd_nxt;
308 : : u64 bytes_received;
309 : : u64 ack_seq;
310 : : atomic64_t rcv_wnd_sent;
311 : : u64 rcv_data_fin_seq;
312 : : u64 bytes_retrans;
313 : : u64 bytes_consumed;
314 : : int snd_burst;
315 : : int old_wspace;
316 : : u64 recovery_snd_nxt; /* in recovery mode accept up to this seq;
317 : : * recovery related fields are under data_lock
318 : : * protection
319 : : */
320 : : u64 bytes_acked;
321 : : u64 snd_una;
322 : : u64 wnd_end;
323 : : u32 last_data_sent;
324 : : u32 last_data_recv;
325 : : u32 last_ack_recv;
326 : : unsigned long timer_ival;
327 : : u32 token;
328 : : unsigned long flags;
329 : : unsigned long cb_flags;
330 : : bool recovery; /* closing subflow write queue reinjected */
331 : : bool can_ack;
332 : : bool fully_established;
333 : : bool rcv_data_fin;
334 : : bool snd_data_fin_enable;
335 : : bool rcv_fastclose;
336 : : bool use_64bit_ack; /* Set when we received a 64-bit DSN */
337 : : bool csum_enabled;
338 : : bool allow_infinite_fallback;
339 : : u8 pending_state; /* A subflow asked to set this sk_state,
340 : : * protected by the msk data lock
341 : : */
342 : : u8 mpc_endpoint_id;
343 : : u8 recvmsg_inq:1,
344 : : cork:1,
345 : : nodelay:1,
346 : : fastopening:1,
347 : : in_accept_queue:1,
348 : : free_first:1,
349 : : rcvspace_init:1,
350 : : fastclosing:1;
351 : : u32 notsent_lowat;
352 : : int keepalive_cnt;
353 : : int keepalive_idle;
354 : : int keepalive_intvl;
355 : : int maxseg;
356 : : struct work_struct work;
357 : : struct sk_buff *ooo_last_skb;
358 : : struct rb_root out_of_order_queue;
359 : : struct list_head conn_list;
360 : : struct list_head rtx_queue;
361 : : struct mptcp_data_frag *first_pending;
362 : : struct list_head join_list;
363 : : struct sock *first; /* The mptcp ops can safely dereference, using suitable
364 : : * ONCE annotation, the subflow outside the socket
365 : : * lock as such sock is freed after close().
366 : : */
367 : : struct mptcp_pm_data pm;
368 : : struct mptcp_sched_ops *sched;
369 : :
370 : : /* Most recent rtt_us observed by in use incoming subflows. */
371 : : struct {
372 : : u32 samples[MPTCP_RTT_SAMPLES];
373 : : u32 next_sample;
374 : : } rcv_rtt_est;
375 : :
376 : : struct {
377 : : int space; /* bytes copied in last measurement window */
378 : : int copied; /* bytes copied in this measurement window */
379 : : u64 time; /* start time of measurement window */
380 : : } rcvq_space;
381 : : u8 scaling_ratio;
382 : : bool allow_subflows;
383 : :
384 : : u32 subflow_id;
385 : : u32 setsockopt_seq;
386 : : char ca_name[TCP_CA_NAME_MAX];
387 : :
388 : : spinlock_t fallback_lock; /* protects fallback,
389 : : * allow_infinite_fallback and
390 : : * allow_join
391 : : */
392 : :
393 : : struct list_head backlog_list; /* protected by the data lock */
394 : : u32 backlog_len;
395 : : u32 backlog_unaccounted;
396 : : };
397 : :
398 : : #define mptcp_data_lock(sk) spin_lock_bh(&(sk)->sk_lock.slock)
399 : : #define mptcp_data_unlock(sk) spin_unlock_bh(&(sk)->sk_lock.slock)
400 : :
401 : : #define mptcp_for_each_subflow(__msk, __subflow) \
402 : : list_for_each_entry(__subflow, &((__msk)->conn_list), node)
403 : : #define mptcp_for_each_subflow_safe(__msk, __subflow, __tmp) \
404 : : list_for_each_entry_safe(__subflow, __tmp, &((__msk)->conn_list), node)
405 : : #define mptcp_next_subflow(__msk, __subflow) \
406 : : list_next_entry_circular(__subflow, &((__msk)->conn_list), node)
407 : :
408 : : extern struct genl_family mptcp_genl_family;
409 : :
410 : 254605 : static inline void msk_owned_by_me(const struct mptcp_sock *msk)
411 : : {
412 : 1384627 : sock_owned_by_me((const struct sock *)msk);
413 : : }
414 : :
415 : : #ifdef CONFIG_DEBUG_NET
416 : : /* MPTCP-specific: we might (indirectly) call this helper with the wrong sk */
417 : : #undef tcp_sk
418 : : #define tcp_sk(ptr) ({ \
419 : : typeof(ptr) _ptr = (ptr); \
420 : : WARN_ON(_ptr->sk_protocol != IPPROTO_TCP); \
421 : : container_of_const(_ptr, struct tcp_sock, inet_conn.icsk_inet.sk); \
422 : : })
423 : : #define mptcp_sk(ptr) ({ \
424 : : typeof(ptr) _ptr = (ptr); \
425 : : WARN_ON(_ptr->sk_protocol != IPPROTO_MPTCP); \
426 : : container_of_const(_ptr, struct mptcp_sock, sk.icsk_inet.sk); \
427 : : })
428 : :
429 : : #else /* !CONFIG_DEBUG_NET */
430 : : #define mptcp_sk(ptr) container_of_const(ptr, struct mptcp_sock, sk.icsk_inet.sk)
431 : : #endif
432 : :
433 : 6354650 : static inline int mptcp_win_from_space(const struct sock *sk, int space)
434 : : {
435 [ + ]: 6354650 : return __tcp_win_from_space(READ_ONCE(mptcp_sk(sk)->scaling_ratio),
436 : : space);
437 : : }
438 : :
439 : 5105 : static inline int mptcp_space_from_win(const struct sock *sk, int win)
440 : : {
441 [ + ]: 5105 : return __tcp_space_from_win(READ_ONCE(mptcp_sk(sk)->scaling_ratio),
442 : : win);
443 : : }
444 : :
445 : 3964409 : static inline int __mptcp_space(const struct sock *sk)
446 : : {
447 : 14111313 : return mptcp_win_from_space(sk, READ_ONCE(sk->sk_rcvbuf) -
448 [ + ]: 3964409 : READ_ONCE(mptcp_sk(sk)->backlog_len) -
449 : 3964409 : sk_rmem_alloc_get(sk));
450 : : }
451 : :
452 : 4061085 : static inline struct mptcp_data_frag *mptcp_send_head(const struct sock *sk)
453 : : {
454 [ + ]: 4061085 : const struct mptcp_sock *msk = mptcp_sk(sk);
455 : :
456 : 4061085 : return msk->first_pending;
457 : : }
458 : :
459 : 0 : static inline void mptcp_init_rtt_est(struct mptcp_sock *msk)
460 : : {
461 : 5181 : int i;
462 : :
463 [ + + ][ + + ]: 32382 : for (i = 0; i < MPTCP_RTT_SAMPLES; ++i)
464 : 25905 : msk->rcv_rtt_est.samples[i] = U32_MAX;
465 : 5181 : msk->rcv_rtt_est.next_sample = 0;
466 : 5181 : msk->scaling_ratio = TCP_DEFAULT_SCALING_RATIO;
467 : : }
468 : :
469 : 0 : static inline u32 mptcp_rtt_us_est(const struct mptcp_sock *msk)
470 : : {
471 : 0 : u32 rtt_us = READ_ONCE(msk->rcv_rtt_est.samples[0]);
472 : 0 : int i;
473 : :
474 : : /* Lockless access of collected samples. */
475 [ + - - ]: 6005505 : for (i = 1; i < MPTCP_RTT_SAMPLES; ++i)
[ + - - ]
476 : 0 : rtt_us = min(rtt_us, READ_ONCE(msk->rcv_rtt_est.samples[i]));
477 [ + ][ + ]: 1201101 : return rtt_us;
478 : : }
479 : :
480 : 597732 : static inline struct mptcp_data_frag *mptcp_send_next(struct sock *sk)
481 : : {
482 [ + ]: 597732 : struct mptcp_sock *msk = mptcp_sk(sk);
483 : 597732 : struct mptcp_data_frag *cur;
484 : :
485 : 597732 : cur = msk->first_pending;
486 [ + ]: 597732 : return list_is_last(&cur->list, &msk->rtx_queue) ? NULL :
487 : : list_next_entry(cur, list);
488 : : }
489 : :
490 : 812466 : static inline struct mptcp_data_frag *mptcp_pending_tail(const struct sock *sk)
491 : : {
492 [ + ]: 812466 : const struct mptcp_sock *msk = mptcp_sk(sk);
493 : :
494 [ + ]: 812466 : if (!msk->first_pending)
495 : : return NULL;
496 : :
497 [ + - ]: 385893 : if (WARN_ON_ONCE(list_empty(&msk->rtx_queue)))
498 : : return NULL;
499 : :
500 : 385893 : return list_last_entry(&msk->rtx_queue, struct mptcp_data_frag, list);
501 : : }
502 : :
503 : 414175 : static inline struct mptcp_data_frag *mptcp_rtx_head(struct sock *sk)
504 : : {
505 [ + ]: 414175 : struct mptcp_sock *msk = mptcp_sk(sk);
506 : :
507 [ + ]: 414175 : if (msk->snd_una == msk->snd_nxt)
508 : : return NULL;
509 : :
510 [ + ]: 339162 : return list_first_entry_or_null(&msk->rtx_queue, struct mptcp_data_frag, list);
511 : : }
512 : :
513 : : struct csum_pseudo_header {
514 : : __be64 data_seq;
515 : : __be32 subflow_seq;
516 : : __be16 data_len;
517 : : __sum16 csum;
518 : : };
519 : :
520 : : struct mptcp_subflow_request_sock {
521 : : struct tcp_request_sock sk;
522 : : u16 mp_capable : 1,
523 : : mp_join : 1,
524 : : backup : 1,
525 : : request_bkup : 1,
526 : : csum_reqd : 1,
527 : : allow_join_id0 : 1;
528 : : u8 local_id;
529 : : u8 remote_id;
530 : : u64 local_key;
531 : : u64 idsn;
532 : : u32 token;
533 : : u32 ssn_offset;
534 : : u64 thmac;
535 : : u32 local_nonce;
536 : : u32 remote_nonce;
537 : : struct mptcp_sock *msk;
538 : : struct hlist_nulls_node token_node;
539 : : };
540 : :
541 : : static inline struct mptcp_subflow_request_sock *
542 : : mptcp_subflow_rsk(const struct request_sock *rsk)
543 : : {
544 : : return (struct mptcp_subflow_request_sock *)rsk;
545 : : }
546 : :
547 : : struct mptcp_delegated_action {
548 : : struct napi_struct napi;
549 : : local_lock_t bh_lock;
550 : : struct list_head head;
551 : : };
552 : :
553 : : DECLARE_PER_CPU(struct mptcp_delegated_action, mptcp_delegated_actions);
554 : :
555 : : #define MPTCP_DELEGATE_SCHEDULED 0
556 : : #define MPTCP_DELEGATE_SEND 1
557 : : #define MPTCP_DELEGATE_ACK 2
558 : : #define MPTCP_DELEGATE_SNDBUF 3
559 : :
560 : : #define MPTCP_DELEGATE_ACTIONS_MASK (~BIT(MPTCP_DELEGATE_SCHEDULED))
561 : : /* MPTCP subflow context */
562 : : struct mptcp_subflow_context {
563 : : struct list_head node;/* conn_list of subflows */
564 : :
565 : : struct_group(reset,
566 : :
567 : : unsigned long avg_pacing_rate; /* protected by msk socket lock */
568 : : u64 local_key;
569 : : u64 remote_key;
570 : : u64 idsn;
571 : : u64 map_seq;
572 : : u64 rcv_wnd_sent;
573 : : u32 snd_isn;
574 : : u32 token;
575 : : u32 rel_write_seq;
576 : : u32 map_subflow_seq;
577 : : u32 ssn_offset;
578 : : u32 map_data_len;
579 : : __wsum map_data_csum;
580 : : u32 map_csum_len;
581 : : u32 prev_rtt_seq;
582 : : u32 request_mptcp : 1, /* send MP_CAPABLE */
583 : : request_join : 1, /* send MP_JOIN */
584 : : request_bkup : 1,
585 : : mp_capable : 1, /* remote is MPTCP capable */
586 : : mp_join : 1, /* remote is JOINing */
587 : : pm_notified : 1, /* PM hook called for established status */
588 : : conn_finished : 1,
589 : : map_valid : 1,
590 : : map_csum_reqd : 1,
591 : : map_data_fin : 1,
592 : : mpc_map : 1,
593 : : backup : 1,
594 : : send_mp_prio : 1,
595 : : send_mp_fail : 1,
596 : : send_fastclose : 1,
597 : : send_infinite_map : 1,
598 : : remote_key_valid : 1, /* received the peer key from */
599 : : disposable : 1, /* ctx can be free at ulp release time */
600 : : closing : 1, /* must not pass rx data to msk anymore */
601 : : valid_csum_seen : 1, /* at least one csum validated */
602 : : is_mptfo : 1, /* subflow is doing TFO */
603 : : mpc_drop : 1, /* the MPC option has been dropped in a rtx */
604 : : resetting : 1, /* subflow is resetting */
605 : : __unused : 9;
606 : : bool data_avail;
607 : : bool scheduled;
608 : : bool pm_listener; /* a listener managed by the kernel PM? */
609 : : bool fully_established; /* path validated */
610 : : bool close_event_done; /* has done the post-closed part,
611 : : * protected by msk socket lock
612 : : */
613 : : u32 lent_mem_frag;
614 : : u32 remote_nonce;
615 : : u32 local_nonce;
616 : : u32 remote_token;
617 : : union {
618 : : u8 hmac[MPTCPOPT_HMAC_LEN]; /* MPJ subflow only */
619 : : u64 iasn; /* initial ack sequence number, MPC subflows only */
620 : : };
621 : : s16 local_id; /* if negative not initialized yet */
622 : : u8 remote_id;
623 : : u8 reset_seen:1;
624 : : u8 reset_transient:1;
625 : : u8 reset_reason:4;
626 : : u8 stale_count; /* Protected by the msk socket lock */
627 : : u8 stale; /* Protected by the msk socket lock,
628 : : * if set the subflow is unable to snd/rcv
629 : : * data, the schedule should skip it
630 : : */
631 : :
632 : : u32 subflow_id;
633 : :
634 : : long delegated_status;
635 : : unsigned long fail_tout;
636 : :
637 : : );
638 : :
639 : : struct list_head delegated_node; /* link into delegated_action, protected by local BH */
640 : :
641 : : u32 setsockopt_seq;
642 : : u32 stale_rcv_tstamp;
643 : : int cached_sndbuf; /* sndbuf size when last synced with the msk sndbuf,
644 : : * protected by the msk socket lock
645 : : */
646 : :
647 : : struct sock *tcp_sock; /* tcp sk backpointer */
648 : : struct sock *conn; /* parent mptcp_sock */
649 : : const struct inet_connection_sock_af_ops *icsk_af_ops;
650 : : void (*tcp_state_change)(struct sock *sk);
651 : : void (*tcp_error_report)(struct sock *sk);
652 : :
653 : : struct rcu_head rcu;
654 : : };
655 : :
656 : : static inline struct mptcp_subflow_context *
657 : 90 : mptcp_subflow_ctx(const struct sock *sk)
658 : : {
659 [ + ][ + - ]: 517437 : const struct inet_connection_sock *icsk = inet_csk(sk);
660 : :
661 : : /* Use RCU on icsk_ulp_data only for sock diag code */
662 [ - + ][ + ]: 51728894 : return (__force struct mptcp_subflow_context *)icsk->icsk_ulp_data;
[ + - + +
+ + - + -
+ + + +
- ][ + + -
+ + + + +
+ - + + +
+ + + ][ -
- - - + +
+ + + + +
+ + - - +
- + - - +
+ - + - ]
[ + - + +
+ + - - +
- + + + +
- - ][ + -
- - + + +
+ + + + -
+ - - + -
+ - - + -
- - - ][ -
- - - + +
+ + + + +
- + - - +
- + - - +
- - - - ]
[ + - + ]
[ + - + + ]
[ + + + +
+ + + + -
+ + + + +
+ ][ + - +
+ + + - -
+ - + + +
+ - - ][ +
- - - + +
+ + + + +
+ + - - +
- + - - +
+ - - - ]
[ + ][ - + ]
[ + ]
663 : : }
664 : :
665 : : static inline struct sock *
666 : 87805 : mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow)
667 : : {
668 [ - ][ + ]: 5954600 : return subflow->tcp_sock;
[ + + + + ]
[ - + + +
- + + -
- ][ + ][ -
+ + + - -
+ + - - ]
[ + ]
669 : : }
670 : :
671 : : static inline void
672 : 0 : mptcp_subflow_ctx_reset(struct mptcp_subflow_context *subflow)
673 : : {
674 : 1318 : memset(&subflow->reset, 0, sizeof(subflow->reset));
675 : 1318 : subflow->request_mptcp = 1;
676 : 6 : WRITE_ONCE(subflow->local_id, -1);
677 : 1676 : }
678 : :
679 : : /* Convert reset reasons in MPTCP to enum sk_rst_reason type */
680 : : static inline enum sk_rst_reason
681 : : sk_rst_convert_mptcp_reason(u32 reason)
682 : : {
683 : : switch (reason) {
684 : : case MPTCP_RST_EUNSPEC:
685 : : return SK_RST_REASON_MPTCP_RST_EUNSPEC;
686 : : case MPTCP_RST_EMPTCP:
687 : : return SK_RST_REASON_MPTCP_RST_EMPTCP;
688 : : case MPTCP_RST_ERESOURCE:
689 : : return SK_RST_REASON_MPTCP_RST_ERESOURCE;
690 : : case MPTCP_RST_EPROHIBIT:
691 : : return SK_RST_REASON_MPTCP_RST_EPROHIBIT;
692 : : case MPTCP_RST_EWQ2BIG:
693 : : return SK_RST_REASON_MPTCP_RST_EWQ2BIG;
694 : : case MPTCP_RST_EBADPERF:
695 : : return SK_RST_REASON_MPTCP_RST_EBADPERF;
696 : : case MPTCP_RST_EMIDDLEBOX:
697 : : return SK_RST_REASON_MPTCP_RST_EMIDDLEBOX;
698 : : default:
699 : : /* It should not happen, or else errors may occur
700 : : * in MPTCP layer
701 : : */
702 : : return SK_RST_REASON_ERROR;
703 : : }
704 : : }
705 : :
706 : : static inline void
707 : 52 : mptcp_send_active_reset_reason(struct sock *sk)
708 : : {
709 : 52 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
710 : 52 : enum sk_rst_reason reason;
711 : :
712 [ - ]: 52 : reason = sk_rst_convert_mptcp_reason(subflow->reset_reason);
713 : 52 : tcp_send_active_reset(sk, reason);
714 : 52 : }
715 : :
716 : : /* Made the fwd mem carried by the given skb available to the msk,
717 : : * To be paired with a previous mptcp_subflow_lend_fwdmem() before freeing
718 : : * the skb or setting the skb ownership.
719 : : */
720 : 1079276 : static inline void mptcp_borrow_fwdmem(struct sock *sk, struct sk_buff *skb)
721 : : {
722 : 1079276 : struct sock *ssk = skb->sk;
723 : :
724 : : /* The subflow just lend the skb fwd memory; if the subflow meanwhile
725 : : * closed, mptcp_close_ssk() already released the ssk rcv memory.
726 : : */
727 [ + ]: 1079276 : DEBUG_NET_WARN_ON_ONCE(skb->destructor);
728 [ - ][ - ]: 1079276 : sk_forward_alloc_add(sk, skb->truesize);
729 [ - ][ - ]: 1079276 : if (!ssk)
730 : : return;
731 : :
732 : 1079276 : atomic_sub(skb->truesize, &ssk->sk_rmem_alloc);
733 : 1079276 : skb->sk = NULL;
734 : : }
735 : :
736 : : static inline void
737 : 73370 : __mptcp_subflow_lend_fwdmem(struct mptcp_subflow_context *subflow, int size)
738 : : {
739 : 1114535 : int frag = (subflow->lent_mem_frag + size) & (PAGE_SIZE - 1);
740 : :
741 : 35309 : subflow->lent_mem_frag = frag;
742 : : }
743 : :
744 : : static inline void
745 : 73302 : mptcp_subflow_lend_fwdmem(struct mptcp_subflow_context *subflow,
746 : : struct sk_buff *skb)
747 : : {
748 : 1079276 : __mptcp_subflow_lend_fwdmem(subflow, skb->truesize);
749 : 1079276 : skb->destructor = NULL;
750 : : }
751 : :
752 : : static inline u64
753 : 5035855 : mptcp_subflow_get_map_offset(const struct mptcp_subflow_context *subflow)
754 : : {
755 [ + ]: 5035855 : return tcp_sk(mptcp_subflow_tcp_sock(subflow))->copied_seq -
756 : 5035855 : subflow->ssn_offset -
757 : 5035855 : subflow->map_subflow_seq;
758 : : }
759 : :
760 : : static inline u64
761 : 154007 : mptcp_subflow_get_mapped_dsn(const struct mptcp_subflow_context *subflow)
762 : : {
763 [ - ][ - ]: 2187754 : return subflow->map_seq + mptcp_subflow_get_map_offset(subflow);
764 : : }
765 : :
766 : : void mptcp_subflow_process_delegated(struct sock *ssk, long actions);
767 : :
768 : 142861 : static inline void mptcp_subflow_delegate(struct mptcp_subflow_context *subflow, int action)
769 : : {
770 [ + ]: 142861 : long old, set_bits = BIT(MPTCP_DELEGATE_SCHEDULED) | BIT(action);
771 : 142861 : struct mptcp_delegated_action *delegated;
772 : 142861 : bool schedule;
773 : :
774 : : /* the caller held the subflow bh socket lock */
775 [ - - - - : 142861 : lockdep_assert_in_softirq();
+ ]
776 : :
777 : : /* The implied barrier pairs with tcp_release_cb_override()
778 : : * mptcp_napi_poll(), and ensures the below list check sees list
779 : : * updates done prior to delegated status bits changes
780 : : */
781 [ + - ][ + - ]: 142861 : old = set_mask_bits(&subflow->delegated_status, 0, set_bits);
782 [ + ][ + ]: 142861 : if (!(old & BIT(MPTCP_DELEGATE_SCHEDULED))) {
783 [ + - ][ + - ]: 95365 : if (WARN_ON_ONCE(!list_empty(&subflow->delegated_node)))
784 : : return;
785 : :
786 [ - - - - : 95365 : local_lock_nested_bh(&mptcp_delegated_actions.bh_lock);
+ ]
787 : 95365 : delegated = this_cpu_ptr(&mptcp_delegated_actions);
788 : 95365 : schedule = list_empty(&delegated->head);
789 : 95365 : list_add_tail(&subflow->delegated_node, &delegated->head);
790 : 95365 : local_unlock_nested_bh(&mptcp_delegated_actions.bh_lock);
791 : 95365 : sock_hold(mptcp_subflow_tcp_sock(subflow));
792 [ + ][ + ]: 95365 : if (schedule)
793 : 93938 : napi_schedule(&delegated->napi);
794 : : }
795 : : }
796 : :
797 : : static inline struct mptcp_subflow_context *
798 : 188959 : mptcp_subflow_delegated_next(struct mptcp_delegated_action *delegated)
799 : : {
800 : 188959 : struct mptcp_subflow_context *ret;
801 : :
802 [ - - - - : 188959 : local_lock_nested_bh(&mptcp_delegated_actions.bh_lock);
+ ]
803 [ + ][ + ]: 188959 : if (list_empty(&delegated->head)) {
804 : 75985 : local_unlock_nested_bh(&mptcp_delegated_actions.bh_lock);
805 : 75388 : return NULL;
806 : : }
807 : :
808 : 95365 : ret = list_first_entry(&delegated->head, struct mptcp_subflow_context, delegated_node);
809 : 95365 : list_del_init(&ret->delegated_node);
810 : 95365 : local_unlock_nested_bh(&mptcp_delegated_actions.bh_lock);
811 : 95365 : return ret;
812 : : }
813 : :
814 : : void __mptcp_inherit_memcg(struct sock *sk, struct sock *ssk, gfp_t gfp);
815 : : void __mptcp_inherit_cgrp_data(struct sock *sk, struct sock *ssk);
816 : :
817 : : int mptcp_is_enabled(const struct net *net);
818 : : unsigned int mptcp_get_add_addr_timeout(const struct net *net);
819 : : int mptcp_is_checksum_enabled(const struct net *net);
820 : : int mptcp_allow_join_id0(const struct net *net);
821 : : unsigned int mptcp_stale_loss_cnt(const struct net *net);
822 : : unsigned int mptcp_close_timeout(const struct sock *sk);
823 : : int mptcp_get_pm_type(const struct net *net);
824 : : const char *mptcp_get_path_manager(const struct net *net);
825 : : const char *mptcp_get_scheduler(const struct net *net);
826 : : unsigned int mptcp_add_addr_v6_port_drop_ts(const struct net *net);
827 : :
828 : : void mptcp_active_disable(struct sock *sk);
829 : : bool mptcp_active_should_disable(struct sock *ssk);
830 : : void mptcp_active_enable(struct sock *sk);
831 : :
832 : : void mptcp_get_available_schedulers(char *buf, size_t maxlen);
833 : : void __mptcp_subflow_fully_established(struct mptcp_sock *msk,
834 : : struct mptcp_subflow_context *subflow,
835 : : const struct mptcp_options_received *mp_opt);
836 : : bool __mptcp_retransmit_pending_data(struct sock *sk);
837 : : void mptcp_check_and_set_pending(struct sock *sk);
838 : : void __mptcp_push_pending(struct sock *sk, unsigned int flags);
839 : : bool mptcp_subflow_data_available(struct sock *sk);
840 : : void __init mptcp_subflow_init(void);
841 : : void mptcp_subflow_shutdown(struct sock *sk, struct sock *ssk, int how);
842 : : void mptcp_close_ssk(struct sock *sk, struct sock *ssk,
843 : : struct mptcp_subflow_context *subflow);
844 : : void __mptcp_subflow_send_ack(struct sock *ssk);
845 : : void mptcp_subflow_reset(struct sock *ssk);
846 : : void mptcp_subflow_queue_clean(struct sock *sk, struct sock *ssk);
847 : : void mptcp_sock_graft(struct sock *sk, struct socket *parent);
848 : : u64 mptcp_wnd_end(const struct mptcp_sock *msk);
849 : : void mptcp_set_timeout(struct sock *sk);
850 : : struct sock *__mptcp_nmpc_sk(struct mptcp_sock *msk);
851 : : bool __mptcp_close(struct sock *sk, long timeout);
852 : : void mptcp_cancel_work(struct sock *sk);
853 : : void __mptcp_unaccepted_force_close(struct sock *sk);
854 : : void mptcp_set_state(struct sock *sk, int state);
855 : :
856 : : bool mptcp_addresses_equal(const struct mptcp_addr_info *a,
857 : : const struct mptcp_addr_info *b, bool use_port);
858 : : void mptcp_local_address(const struct sock_common *skc,
859 : : struct mptcp_addr_info *addr);
860 : : void mptcp_remote_address(const struct sock_common *skc,
861 : : struct mptcp_addr_info *addr);
862 : :
863 : : /* called with sk socket lock held */
864 : : int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_pm_local *local,
865 : : const struct mptcp_addr_info *remote);
866 : : int mptcp_subflow_create_socket(struct sock *sk, unsigned short family,
867 : : struct socket **new_sock);
868 : : void mptcp_info2sockaddr(const struct mptcp_addr_info *info,
869 : : struct sockaddr_storage *addr,
870 : : unsigned short family);
871 : : struct mptcp_sched_ops *mptcp_sched_find(const char *name);
872 : : int mptcp_validate_scheduler(struct mptcp_sched_ops *sched);
873 : : int mptcp_register_scheduler(struct mptcp_sched_ops *sched);
874 : : void mptcp_unregister_scheduler(struct mptcp_sched_ops *sched);
875 : : void mptcp_sched_init(void);
876 : : int mptcp_init_sched(struct mptcp_sock *msk,
877 : : struct mptcp_sched_ops *sched);
878 : : void mptcp_release_sched(struct mptcp_sock *msk);
879 : : void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
880 : : bool scheduled);
881 : : struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk);
882 : : struct sock *mptcp_subflow_get_retrans(struct mptcp_sock *msk);
883 : : int mptcp_sched_get_send(struct mptcp_sock *msk);
884 : : int mptcp_sched_get_retrans(struct mptcp_sock *msk);
885 : :
886 : 102918 : static inline u64 mptcp_data_avail(const struct mptcp_sock *msk)
887 : : {
888 [ + ][ + ][ + ]: 1063851 : return READ_ONCE(msk->bytes_received) - READ_ONCE(msk->bytes_consumed);
[ + ]
889 : : }
890 : :
891 : 1616862 : static inline bool mptcp_epollin_ready(const struct sock *sk)
892 : : {
893 [ + ]: 1616862 : u64 data_avail = mptcp_data_avail(mptcp_sk(sk));
894 : :
895 [ + ]: 1616862 : if (!data_avail)
896 : : return false;
897 : :
898 : : /* mptcp doesn't have to deal with small skbs in the receive queue,
899 : : * as it can always coalesce them
900 : : */
901 [ + - ]: 2276816 : return (data_avail >= sk->sk_rcvlowat) ||
902 : 0 : tcp_under_memory_pressure(sk);
903 : : }
904 : :
905 : : int mptcp_set_rcvlowat(struct sock *sk, int val);
906 : :
907 : 1558958 : static inline bool __tcp_can_send(const struct sock *ssk)
908 : : {
909 : : /* only send if our side has not closed yet */
910 [ + ][ - ]: 2025373 : return ((1 << inet_sk_state_load(ssk)) & (TCPF_ESTABLISHED | TCPF_CLOSE_WAIT));
911 : : }
912 : :
913 : 1466014 : static inline bool __mptcp_subflow_active(struct mptcp_subflow_context *subflow)
914 : : {
915 : : /* can't send if JOIN hasn't completed yet (i.e. is usable for mptcp) */
916 [ + + + ]: 1466014 : if (subflow->request_join && !READ_ONCE(subflow->fully_established))
[ + + ]
917 : : return false;
918 : :
919 : 1465554 : return __tcp_can_send(mptcp_subflow_tcp_sock(subflow));
920 : : }
921 : :
922 : : void mptcp_subflow_set_active(struct mptcp_subflow_context *subflow);
923 : :
924 : : bool mptcp_subflow_active(struct mptcp_subflow_context *subflow);
925 : :
926 : : void mptcp_subflow_drop_ctx(struct sock *ssk);
927 : :
928 : 36 : static inline void mptcp_subflow_tcp_fallback(struct sock *sk,
929 : : struct mptcp_subflow_context *ctx)
930 : : {
931 : 228 : sk->sk_data_ready = sock_def_readable;
932 : 228 : sk->sk_state_change = ctx->tcp_state_change;
933 : 228 : sk->sk_write_space = sk_stream_write_space;
934 : 228 : sk->sk_error_report = ctx->tcp_error_report;
935 : :
936 [ + ]: 228 : inet_csk(sk)->icsk_af_ops = ctx->icsk_af_ops;
937 : : }
938 : :
939 : : void __init mptcp_proto_init(void);
940 : : #if IS_ENABLED(CONFIG_MPTCP_IPV6)
941 : : int __init mptcp_proto_v6_init(void);
942 : : void __init mptcp_subflow_v6_init(void);
943 : : #endif
944 : :
945 : : struct sock *mptcp_sk_clone_init(const struct sock *sk,
946 : : const struct mptcp_options_received *mp_opt,
947 : : struct sock *ssk,
948 : : struct request_sock *req);
949 : : void mptcp_get_options(const struct sk_buff *skb,
950 : : struct mptcp_options_received *mp_opt);
951 : :
952 : : void mptcp_finish_connect(struct sock *sk);
953 : : void __mptcp_sync_state(struct sock *sk, int state);
954 : : void mptcp_reset_tout_timer(struct mptcp_sock *msk, unsigned long fail_tout);
955 : :
956 : 1342 : static inline void mptcp_stop_tout_timer(struct sock *sk)
957 : : {
958 [ + ]: 1342 : if (!inet_csk(sk)->icsk_mtup.probe_timestamp)
959 : : return;
960 : :
961 : 4 : sk_stop_timer(sk, &inet_csk(sk)->mptcp_tout_timer);
962 : 4 : inet_csk(sk)->icsk_mtup.probe_timestamp = 0;
963 : : }
964 : :
965 : 138 : static inline void mptcp_set_close_tout(struct sock *sk, unsigned long tout)
966 : : {
967 : : /* avoid 0 timestamp, as that means no close timeout */
968 : 42 : inet_csk(sk)->icsk_mtup.probe_timestamp = tout ? : 1;
969 : : }
970 : :
971 : 1529 : static inline void mptcp_start_tout_timer(struct sock *sk)
972 : : {
973 : 1529 : mptcp_set_close_tout(sk, tcp_jiffies32);
974 [ + ]: 1529 : mptcp_reset_tout_timer(mptcp_sk(sk), 0);
975 : 1529 : }
976 : :
977 : 4533 : static inline bool mptcp_is_fully_established(struct sock *sk)
978 : : {
979 [ + ][ + ]: 4533 : return inet_sk_state_load(sk) == TCP_ESTABLISHED &&
980 [ + + + ]: 3913 : READ_ONCE(mptcp_sk(sk)->fully_established);
[ + + ]
981 : : }
982 : :
983 : 253440 : static inline u64 mptcp_stamp(void)
984 : : {
985 : 1204304 : return div_u64(tcp_clock_ns(), NSEC_PER_USEC);
986 : : }
987 : :
988 : : void mptcp_data_ready(struct sock *sk, struct sock *ssk);
989 : : bool mptcp_finish_join(struct sock *sk);
990 : : bool mptcp_schedule_work(struct sock *sk);
991 : : int mptcp_setsockopt(struct sock *sk, int level, int optname,
992 : : sockptr_t optval, unsigned int optlen);
993 : : int mptcp_getsockopt(struct sock *sk, int level, int optname,
994 : : char __user *optval, int __user *option);
995 : :
996 : : u64 __mptcp_expand_seq(u64 old_seq, u64 cur_seq);
997 : 222431 : static inline u64 mptcp_expand_seq(u64 old_seq, u64 cur_seq, bool use_64bit)
998 : : {
999 [ + ][ + + ]: 2952237 : if (use_64bit)
[ + ][ + + ]
1000 : : return cur_seq;
1001 : :
1002 : 194683 : return __mptcp_expand_seq(old_seq, cur_seq);
1003 : : }
1004 : : void __mptcp_check_push(struct sock *sk, struct sock *ssk);
1005 : : void __mptcp_data_acked(struct sock *sk);
1006 : : void __mptcp_error_report(struct sock *sk);
1007 : : bool mptcp_update_rcv_data_fin(struct mptcp_sock *msk, u64 data_fin_seq, bool use_64bit);
1008 : 2038445 : static inline bool mptcp_data_fin_enabled(const struct mptcp_sock *msk)
1009 : : {
1010 [ + + ][ + ]: 3524537 : return READ_ONCE(msk->snd_data_fin_enable) &&
[ + + ]
1011 [ + ][ + ]: 174574 : READ_ONCE(msk->write_seq) == READ_ONCE(msk->snd_nxt);
[ + + ]
1012 : : }
1013 : :
1014 : 2986957 : static inline u32 mptcp_notsent_lowat(const struct sock *sk)
1015 : : {
1016 [ + ]: 2986957 : struct net *net = sock_net(sk);
1017 : 2986957 : u32 val;
1018 : :
1019 [ + ][ + ]: 2986957 : val = READ_ONCE(mptcp_sk(sk)->notsent_lowat);
1020 [ + ][ + ]: 2986957 : return val ?: READ_ONCE(net->ipv4.sysctl_tcp_notsent_lowat);
1021 : : }
1022 : :
1023 : 2174491 : static inline bool mptcp_stream_memory_free(const struct sock *sk, int wake)
1024 : : {
1025 [ + ]: 2174491 : const struct mptcp_sock *msk = mptcp_sk(sk);
1026 : 2174491 : u32 notsent_bytes;
1027 : :
1028 : 2174491 : notsent_bytes = READ_ONCE(msk->write_seq) - READ_ONCE(msk->snd_nxt);
1029 [ + ]: 2174491 : return (notsent_bytes << wake) < mptcp_notsent_lowat(sk);
1030 : : }
1031 : :
1032 : 650155 : static inline bool __mptcp_stream_is_writeable(const struct sock *sk, int wake)
1033 : : {
1034 [ - + ]: 1300310 : return mptcp_stream_memory_free(sk, wake) &&
1035 : 650155 : __sk_stream_is_writeable(sk, wake);
1036 : : }
1037 : :
1038 : 943177 : static inline void mptcp_write_space(struct sock *sk)
1039 : : {
1040 : : /* pairs with memory barrier in mptcp_poll */
1041 : 943177 : smp_mb();
1042 [ + ]: 943177 : if (mptcp_stream_memory_free(sk, 1))
1043 [ - ]: 943116 : INDIRECT_CALL_1(sk->sk_write_space, sk_stream_write_space, sk);
1044 : 943177 : }
1045 : :
1046 : 28415 : static inline void __mptcp_sync_sndbuf(struct sock *sk)
1047 : : {
1048 : 28415 : struct mptcp_subflow_context *subflow;
1049 : 28415 : int ssk_sndbuf, new_sndbuf;
1050 : :
1051 [ - ][ - ]: 28415 : if (sk->sk_userlocks & SOCK_SNDBUF_LOCK)
1052 : : return;
1053 : :
1054 [ + ]: 28415 : new_sndbuf = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_wmem[0]);
1055 [ + + + ]: 88298 : mptcp_for_each_subflow(mptcp_sk(sk), subflow) {
[ + + + ]
1056 : 59883 : ssk_sndbuf = READ_ONCE(mptcp_subflow_tcp_sock(subflow)->sk_sndbuf);
1057 : :
1058 : 59883 : subflow->cached_sndbuf = ssk_sndbuf;
1059 : 59883 : new_sndbuf += ssk_sndbuf;
1060 : : }
1061 : :
1062 : : /* the msk max wmem limit is <nr_subflows> * tcp wmem[2] */
1063 : 28415 : WRITE_ONCE(sk->sk_sndbuf, new_sndbuf);
1064 : 28415 : mptcp_write_space(sk);
1065 : : }
1066 : :
1067 : : /* The called held both the msk socket and the subflow socket locks,
1068 : : * possibly under BH
1069 : : */
1070 : 156 : static inline void __mptcp_propagate_sndbuf(struct sock *sk, struct sock *ssk)
1071 : : {
1072 : 3989 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
1073 : :
1074 [ + ][ + - ]: 3989 : if (READ_ONCE(ssk->sk_sndbuf) != subflow->cached_sndbuf)
[ + - ]
1075 : 3891 : __mptcp_sync_sndbuf(sk);
1076 : : }
1077 : :
1078 : : /* the caller held only the subflow socket lock, either in process or
1079 : : * BH context. Additionally this can be called under the msk data lock,
1080 : : * so we can't acquire such lock here: let the delegate action acquires
1081 : : * the needed locks in suitable order.
1082 : : */
1083 : 771580 : static inline void mptcp_propagate_sndbuf(struct sock *sk, struct sock *ssk)
1084 : : {
1085 : 771580 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
1086 : :
1087 [ + ]: 771580 : if (likely(READ_ONCE(ssk->sk_sndbuf) == subflow->cached_sndbuf))
1088 : : return;
1089 : :
1090 : 133552 : local_bh_disable();
1091 : 133552 : mptcp_subflow_delegate(subflow, MPTCP_DELEGATE_SNDBUF);
1092 : 133552 : local_bh_enable();
1093 : : }
1094 : :
1095 : : #define MPTCP_TOKEN_MAX_RETRIES 4
1096 : :
1097 : : void __init mptcp_token_init(void);
1098 : 126 : static inline void mptcp_token_init_request(struct request_sock *req)
1099 : : {
1100 : 2624 : mptcp_subflow_rsk(req)->token_node.pprev = NULL;
1101 : 0 : }
1102 : :
1103 : : int mptcp_token_new_request(struct request_sock *req);
1104 : : void mptcp_token_move_request(struct request_sock *req,
1105 : : struct request_sock *new_req);
1106 : : void mptcp_token_destroy_request(struct request_sock *req);
1107 : : int mptcp_token_new_connect(struct sock *ssk);
1108 : : bool mptcp_token_accept(struct mptcp_subflow_request_sock *r,
1109 : : struct mptcp_sock *msk);
1110 : : bool mptcp_token_exists(u32 token);
1111 : : struct mptcp_sock *mptcp_token_get_sock(struct net *net, u32 token);
1112 : : struct mptcp_sock *mptcp_token_iter_next(const struct net *net, long *s_slot,
1113 : : long *s_num);
1114 : : void mptcp_token_destroy(struct mptcp_sock *msk);
1115 : :
1116 : : void mptcp_crypto_key_sha(u64 key, u32 *token, u64 *idsn);
1117 : :
1118 : : void mptcp_crypto_hmac_sha(u64 key1, u64 key2, u8 *msg, int len, void *hmac);
1119 : : __sum16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum sum);
1120 : :
1121 : : void __init mptcp_pm_init(void);
1122 : : void mptcp_pm_data_init(struct mptcp_sock *msk);
1123 : : void mptcp_pm_data_reset(struct mptcp_sock *msk);
1124 : : void mptcp_pm_destroy(struct mptcp_sock *msk);
1125 : : int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info,
1126 : : struct mptcp_addr_info *addr);
1127 : : int mptcp_pm_parse_entry(struct nlattr *attr, struct genl_info *info,
1128 : : bool require_family,
1129 : : struct mptcp_pm_addr_entry *entry);
1130 : : bool mptcp_pm_addr_families_match(const struct sock *sk,
1131 : : const struct mptcp_addr_info *loc,
1132 : : const struct mptcp_addr_info *rem);
1133 : : void mptcp_pm_chk_stale(const struct mptcp_sock *msk);
1134 : : void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ssk, int server_side);
1135 : : void mptcp_pm_fully_established(struct mptcp_sock *msk, const struct sock *ssk);
1136 : : bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk);
1137 : : void mptcp_pm_connection_closed(struct mptcp_sock *msk);
1138 : : void mptcp_pm_subflow_established(struct mptcp_sock *msk);
1139 : : bool mptcp_pm_nl_check_work_pending(struct mptcp_sock *msk);
1140 : : void mptcp_pm_subflow_check_next(struct mptcp_sock *msk,
1141 : : const struct mptcp_subflow_context *subflow);
1142 : : void mptcp_pm_add_addr_received(const struct sock *ssk,
1143 : : const struct mptcp_addr_info *addr);
1144 : : void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk,
1145 : : const struct mptcp_addr_info *addr);
1146 : : void mptcp_pm_send_ack(struct mptcp_sock *msk,
1147 : : struct mptcp_subflow_context *subflow,
1148 : : bool prio, bool backup);
1149 : : void mptcp_pm_addr_send_ack(struct mptcp_sock *msk);
1150 : : void mptcp_pm_nl_rm_addr(struct mptcp_sock *msk, u8 rm_id);
1151 : : void mptcp_pm_rm_subflow(struct mptcp_sock *msk,
1152 : : const struct mptcp_rm_list *rm_list);
1153 : : void mptcp_pm_rm_addr_received(struct mptcp_sock *msk,
1154 : : const struct mptcp_rm_list *rm_list);
1155 : : void mptcp_pm_mp_prio_received(struct sock *sk, u8 bkup);
1156 : : void mptcp_pm_mp_fail_received(struct sock *sk, u64 fail_seq);
1157 : : int mptcp_pm_mp_prio_send_ack(struct mptcp_sock *msk,
1158 : : struct mptcp_addr_info *addr,
1159 : : struct mptcp_addr_info *rem,
1160 : : u8 bkup);
1161 : : bool mptcp_pm_announced_alloc(struct mptcp_sock *msk,
1162 : : const struct mptcp_addr_info *addr);
1163 : : bool mptcp_pm_announced_remove(struct mptcp_sock *msk,
1164 : : const struct mptcp_addr_info *addr);
1165 : : bool mptcp_pm_announced_has_ssk(struct mptcp_sock *msk, const struct sock *ssk);
1166 : : bool mptcp_pm_has_subflow_saddr(const struct mptcp_sock *msk,
1167 : : const struct mptcp_addr_info *saddr);
1168 : : int mptcp_pm_nl_set_flags(struct mptcp_pm_addr_entry *local,
1169 : : struct genl_info *info);
1170 : : int mptcp_userspace_pm_set_flags(struct mptcp_pm_addr_entry *local,
1171 : : struct genl_info *info);
1172 : : int mptcp_pm_announce_addr(struct mptcp_sock *msk,
1173 : : const struct mptcp_addr_info *addr,
1174 : : bool echo);
1175 : : int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list);
1176 : :
1177 : : /* the default path manager, used in mptcp_pm_unregister */
1178 : : extern struct mptcp_pm_ops mptcp_pm_kernel;
1179 : :
1180 : : struct mptcp_pm_ops *mptcp_pm_find(const char *name);
1181 : : int mptcp_pm_register(struct mptcp_pm_ops *pm_ops);
1182 : : void mptcp_pm_unregister(struct mptcp_pm_ops *pm_ops);
1183 : : int mptcp_pm_validate(struct mptcp_pm_ops *pm_ops);
1184 : : void mptcp_pm_get_available(char *buf, size_t maxlen);
1185 : :
1186 : : void mptcp_userspace_pm_free_local_addr_list(struct mptcp_sock *msk);
1187 : :
1188 : : void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
1189 : : const struct sock *ssk, gfp_t gfp);
1190 : : void mptcp_event_addr_announced(const struct sock *ssk, const struct mptcp_addr_info *info);
1191 : : void mptcp_event_addr_removed(const struct mptcp_sock *msk, u8 id);
1192 : : void mptcp_event_pm_listener(const struct sock *ssk,
1193 : : enum mptcp_event_type event);
1194 : : bool mptcp_userspace_pm_active(const struct mptcp_sock *msk);
1195 : :
1196 : : void mptcp_fastopen_subflow_synack_set_params(struct mptcp_subflow_context *subflow,
1197 : : struct request_sock *req);
1198 : : int mptcp_pm_genl_fill_addr(struct sk_buff *msg,
1199 : : struct netlink_callback *cb,
1200 : : struct mptcp_pm_addr_entry *entry);
1201 : :
1202 : 453618 : static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk)
1203 : : {
1204 [ + ]: 3478222 : return READ_ONCE(msk->pm.addr_signal) &
[ + - + - ]
[ + - + - ]
1205 : : (BIT(MPTCP_ADD_ADDR_SIGNAL) | BIT(MPTCP_ADD_ADDR_ECHO));
1206 : : }
1207 : :
1208 : 0 : static inline bool mptcp_pm_should_add_signal_addr(struct mptcp_sock *msk)
1209 : : {
1210 [ + - ][ + - ]: 134 : return READ_ONCE(msk->pm.addr_signal) & BIT(MPTCP_ADD_ADDR_SIGNAL);
1211 : : }
1212 : :
1213 : 6 : static inline bool mptcp_pm_should_add_signal_echo(struct mptcp_sock *msk)
1214 : : {
1215 [ + ]: 910 : return READ_ONCE(msk->pm.addr_signal) & BIT(MPTCP_ADD_ADDR_ECHO);
1216 : : }
1217 : :
1218 : 453612 : static inline bool mptcp_pm_should_rm_signal(struct mptcp_sock *msk)
1219 : : {
1220 [ + ][ + + ]: 3475484 : return READ_ONCE(msk->pm.addr_signal) & BIT(MPTCP_RM_ADDR_SIGNAL);
[ + + ]
1221 : : }
1222 : :
1223 : 42 : static inline bool mptcp_pm_is_userspace(const struct mptcp_sock *msk)
1224 : : {
1225 [ + ][ + + + ]: 4456 : return READ_ONCE(msk->pm.pm_type) == MPTCP_PM_TYPE_USERSPACE;
[ + - + +
+ ][ + ]
[ + + + ][ +
- + + + ]
1226 : : }
1227 : :
1228 : 22 : static inline bool mptcp_pm_is_kernel(const struct mptcp_sock *msk)
1229 : : {
1230 [ + ][ - - ]: 1112 : return READ_ONCE(msk->pm.pm_type) == MPTCP_PM_TYPE_KERNEL;
[ - - ]
1231 : : }
1232 : :
1233 : : bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, int *size, int remaining,
1234 : : struct mptcp_addr_info *addr, bool *echo,
1235 : : bool *drop_ts);
1236 : : bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining,
1237 : : struct mptcp_rm_list *rm_list, int *len);
1238 : : int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc);
1239 : : bool mptcp_pm_is_backup(struct mptcp_sock *msk, struct sock_common *skc);
1240 : : int mptcp_pm_nl_dump_addr(struct sk_buff *msg,
1241 : : struct netlink_callback *cb);
1242 : : int mptcp_userspace_pm_dump_addr(struct sk_buff *msg,
1243 : : struct netlink_callback *cb);
1244 : : int mptcp_pm_nl_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,
1245 : : struct genl_info *info);
1246 : : int mptcp_userspace_pm_get_addr(u8 id, struct mptcp_pm_addr_entry *addr,
1247 : : struct genl_info *info);
1248 : :
1249 : 72 : static inline u8 subflow_get_local_id(const struct mptcp_subflow_context *subflow)
1250 : : {
1251 : 1216 : int local_id = READ_ONCE(subflow->local_id);
1252 : :
1253 : 1216 : if (local_id < 0)
1254 : : return 0;
1255 : : return local_id;
1256 : : }
1257 : :
1258 : : void __init mptcp_pm_kernel_register(void);
1259 : : void __init mptcp_pm_userspace_register(void);
1260 : : void __init mptcp_pm_nl_init(void);
1261 : : void mptcp_pm_worker(struct mptcp_sock *msk);
1262 : : void __mptcp_pm_kernel_worker(struct mptcp_sock *msk);
1263 : : u8 mptcp_pm_get_endp_signal_max(const struct mptcp_sock *msk);
1264 : : u8 mptcp_pm_get_endp_subflow_max(const struct mptcp_sock *msk);
1265 : : u8 mptcp_pm_get_endp_laminar_max(const struct mptcp_sock *msk);
1266 : : u8 mptcp_pm_get_endp_fullmesh_max(const struct mptcp_sock *msk);
1267 : : u8 mptcp_pm_get_limit_add_addr_accepted(const struct mptcp_sock *msk);
1268 : : u8 mptcp_pm_get_limit_extra_subflows(const struct mptcp_sock *msk);
1269 : :
1270 : : /* called under PM lock */
1271 : 941 : static inline void __mptcp_pm_close_subflow(struct mptcp_sock *msk)
1272 : : {
1273 [ + - ]: 1882 : if (!WARN_ON_ONCE(msk->pm.extra_subflows == 0) &&
1274 : 941 : --msk->pm.extra_subflows < mptcp_pm_get_limit_extra_subflows(msk))
1275 : 941 : WRITE_ONCE(msk->pm.accept_subflow, true);
1276 : 941 : }
1277 : :
1278 : 81 : static inline void mptcp_pm_close_subflow(struct mptcp_sock *msk)
1279 : : {
1280 : 81 : spin_lock_bh(&msk->pm.lock);
1281 : 81 : __mptcp_pm_close_subflow(msk);
1282 : 81 : spin_unlock_bh(&msk->pm.lock);
1283 : 81 : }
1284 : :
1285 : 1297 : static inline bool mptcp_pm_add_addr_c_flag_case(struct mptcp_sock *msk)
1286 : : {
1287 [ + ]: 1084 : return READ_ONCE(msk->pm.remote_deny_join_id0) &&
1288 [ + + ][ + + ]: 39 : msk->pm.local_addr_used == 0 &&
[ # ][ # ]
1289 [ + - ][ + - ]: 1304 : mptcp_pm_get_limit_add_addr_accepted(msk) == 0 &&
[ + - ][ + - ]
1290 [ # ][ # ]: 5 : msk->pm.extra_subflows < mptcp_pm_get_limit_extra_subflows(msk);
1291 : : }
1292 : :
1293 : : void mptcp_sockopt_sync_locked(struct mptcp_sock *msk, struct sock *ssk);
1294 : :
1295 : 0 : static inline struct mptcp_ext *mptcp_get_ext(const struct sk_buff *skb)
1296 : : {
1297 [ + - ]: 4262956 : return (struct mptcp_ext *)skb_ext_find(skb, SKB_EXT_MPTCP);
[ - - - ]
[ - + + + ]
[ - + - - ]
[ + - + -
- ][ - - +
+ + - - ]
1298 : : }
1299 : :
1300 : : void mptcp_diag_subflow_init(struct tcp_ulp_ops *ops);
1301 : :
1302 : 11151416 : static inline bool __mptcp_check_fallback(const struct mptcp_sock *msk)
1303 : : {
1304 [ + - - ]: 11151416 : return test_bit(MPTCP_FALLBACK_DONE, &msk->flags);
1305 : : }
1306 : :
1307 : 1158301 : static inline bool mptcp_check_fallback(const struct sock *sk)
1308 : : {
1309 : 1158301 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
1310 [ + ]: 1158301 : struct mptcp_sock *msk = mptcp_sk(subflow->conn);
1311 : :
1312 : 1158301 : return __mptcp_check_fallback(msk);
1313 : : }
1314 : :
1315 : 1066 : static inline bool __mptcp_has_initial_subflow(const struct mptcp_sock *msk)
1316 : : {
1317 : 1066 : struct sock *ssk = READ_ONCE(msk->first);
1318 : :
1319 [ - + + ]: 2132 : return ssk && ((1 << inet_sk_state_load(ssk)) &
[ - + ]
1320 : : (TCPF_ESTABLISHED | TCPF_SYN_SENT |
1321 : : TCPF_SYN_RECV | TCPF_LISTEN));
1322 : : }
1323 : :
1324 : : bool __mptcp_try_fallback(struct mptcp_sock *msk, int fb_mib);
1325 : :
1326 : 184 : static inline bool mptcp_try_fallback(struct sock *ssk, int fb_mib)
1327 : : {
1328 : 184 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
1329 : 184 : struct sock *sk = subflow->conn;
1330 : 184 : struct mptcp_sock *msk;
1331 : :
1332 [ + ]: 184 : msk = mptcp_sk(sk);
1333 [ + ][ + ]: 184 : if (!__mptcp_try_fallback(msk, fb_mib))
1334 : : return false;
1335 [ + + - ]: 172 : if (READ_ONCE(msk->snd_data_fin_enable) && !(ssk->sk_shutdown & SEND_SHUTDOWN)) {
[ + - ]
1336 : 0 : gfp_t saved_allocation = ssk->sk_allocation;
1337 : :
1338 : : /* we are in a atomic (BH) scope, override ssk default for data
1339 : : * fin allocation
1340 : : */
1341 : 0 : ssk->sk_allocation = GFP_ATOMIC;
1342 : 0 : ssk->sk_shutdown |= SEND_SHUTDOWN;
1343 : 0 : tcp_shutdown(ssk, SEND_SHUTDOWN);
1344 : 0 : ssk->sk_allocation = saved_allocation;
1345 : : }
1346 : : return true;
1347 : : }
1348 : :
1349 : 42 : static inline void mptcp_early_fallback(struct mptcp_sock *msk,
1350 : : struct mptcp_subflow_context *subflow,
1351 : : int fb_mib)
1352 : : {
1353 : 42 : subflow->request_mptcp = 0;
1354 [ + ]: 42 : WARN_ON_ONCE(!__mptcp_try_fallback(msk, fb_mib));
1355 : 42 : }
1356 : :
1357 : 89071 : static inline bool mptcp_check_infinite_map(struct sk_buff *skb)
1358 : : {
1359 : 89071 : struct mptcp_ext *mpext;
1360 : :
1361 [ + ][ + ]: 89071 : mpext = skb ? mptcp_get_ext(skb) : NULL;
1362 [ + + ][ - + ]: 16697 : if (mpext && mpext->infinite_map)
1363 : 1 : return true;
1364 : :
1365 : : return false;
1366 : : }
1367 : :
1368 : 0 : static inline bool is_active_ssk(struct mptcp_subflow_context *subflow)
1369 : : {
1370 [ - - ]: 6 : return (subflow->request_mptcp || subflow->request_join);
1371 : : }
1372 : :
1373 : 1798 : static inline bool subflow_simultaneous_connect(struct sock *sk)
1374 : : {
1375 : 1798 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
1376 : :
1377 : : /* Note that the sk state implies !subflow->conn_finished. */
1378 [ + ]: 1798 : return sk->sk_state == TCP_SYN_RECV && is_active_ssk(subflow);
1379 : : }
1380 : :
1381 : : #ifdef CONFIG_SYN_COOKIES
1382 : : void subflow_init_req_cookie_join_save(const struct mptcp_subflow_request_sock *subflow_req,
1383 : : struct sk_buff *skb);
1384 : : bool mptcp_token_join_cookie_init_state(struct mptcp_subflow_request_sock *subflow_req,
1385 : : struct sk_buff *skb);
1386 : : void __init mptcp_join_cookie_init(void);
1387 : : #else
1388 : : static inline void
1389 : : subflow_init_req_cookie_join_save(const struct mptcp_subflow_request_sock *subflow_req,
1390 : : struct sk_buff *skb) {}
1391 : : static inline bool
1392 : : mptcp_token_join_cookie_init_state(struct mptcp_subflow_request_sock *subflow_req,
1393 : : struct sk_buff *skb)
1394 : : {
1395 : : return false;
1396 : : }
1397 : :
1398 : : static inline void mptcp_join_cookie_init(void) {}
1399 : : #endif
1400 : :
1401 : : #endif /* __MPTCP_PROTOCOL_H */
|