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 : : #define pr_fmt(fmt) "MPTCP: " fmt
8 : :
9 : : #include <linux/kernel.h>
10 : : #include <crypto/sha2.h>
11 : : #include <net/tcp.h>
12 : : #include <net/mptcp.h>
13 : : #include "protocol.h"
14 : : #include "mib.h"
15 : :
16 : : #include <trace/events/mptcp.h>
17 : :
18 : : static bool mptcp_cap_flag_sha256(u8 flags)
19 : : {
20 : : return (flags & MPTCP_CAP_FLAG_MASK) == MPTCP_CAP_HMAC_SHA256;
21 : : }
22 : :
23 : 2381725 : static void mptcp_parse_option(const struct sk_buff *skb,
24 : : const unsigned char *ptr, int opsize,
25 : : struct mptcp_options_received *mp_opt)
26 : : {
27 : 2381725 : u8 subtype = *ptr >> 4;
28 : 2381725 : int expected_opsize;
29 : 2381725 : u16 subopt;
30 : 2381725 : u8 version;
31 : 2381725 : u8 flags;
32 : 2381725 : u8 i;
33 : :
34 [ + + + + : 2381725 : switch (subtype) {
+ + + + +
- ]
35 : 7666 : case MPTCPOPT_MP_CAPABLE:
36 : : /* strict size checking */
37 [ + + ]: 7666 : if (!(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)) {
38 [ + + ]: 4450 : if (skb->len > tcp_hdr(skb)->doff << 2)
39 : : expected_opsize = TCPOLEN_MPTCP_MPC_ACK_DATA;
40 : : else
41 : 3243 : expected_opsize = TCPOLEN_MPTCP_MPC_ACK;
42 : 4450 : subopt = OPTION_MPTCP_MPC_ACK;
43 : : } else {
44 [ + + ]: 3216 : if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_ACK) {
45 : : expected_opsize = TCPOLEN_MPTCP_MPC_SYNACK;
46 : : subopt = OPTION_MPTCP_MPC_SYNACK;
47 : : } else {
48 : : expected_opsize = TCPOLEN_MPTCP_MPC_SYN;
49 : : subopt = OPTION_MPTCP_MPC_SYN;
50 : : }
51 : : }
52 : :
53 : : /* Only the MPC + ACK can be used with a RM_ADDR */
54 : 4450 : if (subopt == OPTION_MPTCP_MPC_ACK) {
55 [ + - ]: 4450 : if ((mp_opt->suboptions & ~OPTION_MPTCP_RM_ADDR) != 0)
56 : : break;
57 [ + - ]: 3216 : } else if (mp_opt->suboptions != 0) {
58 : : break;
59 : : }
60 : :
61 : : /* Cfr RFC 8684 Section 3.3.0:
62 : : * If a checksum is present but its use had
63 : : * not been negotiated in the MP_CAPABLE handshake, the receiver MUST
64 : : * close the subflow with a RST, as it is not behaving as negotiated.
65 : : * If a checksum is not present when its use has been negotiated, the
66 : : * receiver MUST close the subflow with a RST, as it is considered
67 : : * broken
68 : : * We parse even option with mismatching csum presence, so that
69 : : * later in subflow_data_ready we can trigger the reset.
70 : : */
71 [ + + ]: 7666 : if (opsize != expected_opsize &&
72 : 123 : (expected_opsize != TCPOLEN_MPTCP_MPC_ACK_DATA ||
73 [ + + ]: 123 : opsize != TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM))
74 : : break;
75 : :
76 : : /* try to be gentle vs future versions on the initial syn */
77 : 7654 : version = *ptr++ & MPTCP_VERSION_MASK;
78 [ + + ]: 7654 : if (opsize != TCPOLEN_MPTCP_MPC_SYN) {
79 [ + + ]: 5932 : if (version != MPTCP_SUPPORTED_VERSION)
80 : : break;
81 [ + - ]: 1722 : } else if (version < MPTCP_SUPPORTED_VERSION) {
82 : : break;
83 : : }
84 : :
85 : 7648 : flags = *ptr++;
86 [ + + + + ]: 7648 : if (!mptcp_cap_flag_sha256(flags) ||
87 : : (flags & MPTCP_CAP_EXTENSIBILITY))
88 : : break;
89 : :
90 : : /* RFC 6824, Section 3.1:
91 : : * "For the Checksum Required bit (labeled "A"), if either
92 : : * host requires the use of checksums, checksums MUST be used.
93 : : * In other words, the only way for checksums not to be used
94 : : * is if both hosts in their SYNs set A=0."
95 : : */
96 : 7612 : if ((flags & MPTCP_CAP_CHECKSUM_REQD) &&
97 [ + + ]: 7612 : opsize < TCPOLEN_MPTCP_MPC_ACK_DATA)
98 : 476 : mp_opt->suboptions |= OPTION_MPTCP_CSUMREQD;
99 : :
100 : 7612 : mp_opt->deny_join_id0 = !!(flags & MPTCP_CAP_DENY_JOIN_ID0);
101 : :
102 : 7612 : mp_opt->suboptions |= subopt;
103 [ + + ]: 7612 : if (opsize >= TCPOLEN_MPTCP_MPC_SYNACK) {
104 [ + + ]: 5902 : mp_opt->sndr_key = get_unaligned_be64(ptr);
105 : 5902 : ptr += 8;
106 : : }
107 [ + + ]: 5902 : if (opsize >= TCPOLEN_MPTCP_MPC_ACK) {
108 [ + + ]: 4432 : mp_opt->rcvr_key = get_unaligned_be64(ptr);
109 : 4432 : ptr += 8;
110 : : }
111 [ + + ]: 4432 : if (opsize >= TCPOLEN_MPTCP_MPC_ACK_DATA) {
112 : : /* Section 3.1.:
113 : : * "the data parameters in a MP_CAPABLE are semantically
114 : : * equivalent to those in a DSS option and can be used
115 : : * interchangeably."
116 : : */
117 : 1207 : mp_opt->suboptions |= OPTION_MPTCP_DSS;
118 : 1207 : mp_opt->use_map = 1;
119 : 1207 : mp_opt->mpc_map = 1;
120 [ + + ]: 1207 : mp_opt->data_len = get_unaligned_be16(ptr);
121 : 1207 : ptr += 2;
122 : : }
123 [ + + ]: 1207 : if (opsize == TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM) {
124 : 111 : mp_opt->csum = get_unaligned((__force __sum16 *)ptr);
125 : 111 : mp_opt->suboptions |= OPTION_MPTCP_CSUMREQD;
126 : 111 : ptr += 2;
127 : : }
128 [ - + - - ]: 7612 : pr_debug("MP_CAPABLE version=%x, flags=%x, optlen=%d sndr=%llu, rcvr=%llu len=%d csum=%u\n",
129 : : version, flags, opsize, mp_opt->sndr_key,
130 : : mp_opt->rcvr_key, mp_opt->data_len, mp_opt->csum);
131 : : break;
132 : :
133 : 2475 : case MPTCPOPT_MP_JOIN:
134 : : /* Can be used with a restricted number of other options */
135 [ + - ]: 2475 : if ((mp_opt->suboptions & ~(OPTION_MPTCP_RM_ADDR |
136 : : OPTION_MPTCP_PRIO)) != 0)
137 : : break;
138 : :
139 [ + + ]: 2475 : if (opsize == TCPOLEN_MPTCP_MPJ_SYN) {
140 : 628 : mp_opt->suboptions |= OPTION_MPTCP_MPJ_SYN;
141 : 628 : mp_opt->backup = *ptr++ & MPTCPOPT_BACKUP;
142 : 628 : mp_opt->join_id = *ptr++;
143 [ - + ]: 628 : mp_opt->token = get_unaligned_be32(ptr);
144 : 628 : ptr += 4;
145 : 628 : mp_opt->nonce = get_unaligned_be32(ptr);
146 : 628 : ptr += 4;
147 [ - + - - ]: 628 : pr_debug("MP_JOIN bkup=%u, id=%u, token=%u, nonce=%u\n",
148 : : mp_opt->backup, mp_opt->join_id,
149 : : mp_opt->token, mp_opt->nonce);
150 [ + + ]: 1847 : } else if (opsize == TCPOLEN_MPTCP_MPJ_SYNACK) {
151 : 594 : mp_opt->suboptions |= OPTION_MPTCP_MPJ_SYNACK;
152 : 594 : mp_opt->backup = *ptr++ & MPTCPOPT_BACKUP;
153 : 594 : mp_opt->join_id = *ptr++;
154 [ - + ]: 594 : mp_opt->thmac = get_unaligned_be64(ptr);
155 : 594 : ptr += 8;
156 [ - + ]: 594 : mp_opt->nonce = get_unaligned_be32(ptr);
157 : 594 : ptr += 4;
158 [ - + - - ]: 594 : pr_debug("MP_JOIN bkup=%u, id=%u, thmac=%llu, nonce=%u\n",
159 : : mp_opt->backup, mp_opt->join_id,
160 : : mp_opt->thmac, mp_opt->nonce);
161 [ + - ]: 1253 : } else if (opsize == TCPOLEN_MPTCP_MPJ_ACK) {
162 : 1253 : mp_opt->suboptions |= OPTION_MPTCP_MPJ_ACK;
163 : 1253 : ptr += 2;
164 : 1253 : memcpy(mp_opt->hmac, ptr, MPTCPOPT_HMAC_LEN);
165 [ - + - - ]: 1253 : pr_debug("MP_JOIN hmac\n");
166 : : }
167 : : break;
168 : :
169 : 2370053 : case MPTCPOPT_DSS:
170 : : /* Can be used with a restricted number of other options */
171 [ + - ]: 2370053 : if ((mp_opt->suboptions & ~(OPTION_MPTCP_ADD_ADDR |
172 : : OPTION_MPTCP_RM_ADDR |
173 : : OPTION_MPTCP_PRIO |
174 : : OPTION_MPTCP_FASTCLOSE |
175 : : OPTION_MPTCP_FAIL)) != 0)
176 : : break;
177 : :
178 [ - + - - ]: 2370053 : pr_debug("DSS\n");
179 : 2370053 : ptr++;
180 : :
181 : 2370053 : flags = (*ptr++) & MPTCP_DSS_FLAG_MASK;
182 : 2370053 : mp_opt->dsn64 = (flags & MPTCP_DSS_DSN64) != 0;
183 : 2370053 : mp_opt->use_map = (flags & MPTCP_DSS_HAS_MAP) != 0;
184 : 2370053 : mp_opt->ack64 = (flags & MPTCP_DSS_ACK64) != 0;
185 : 2370053 : mp_opt->use_ack = (flags & MPTCP_DSS_HAS_ACK);
186 : :
187 : 2370053 : expected_opsize = TCPOLEN_MPTCP_DSS_BASE;
188 : :
189 [ + - ]: 2370053 : if (mp_opt->use_ack) {
190 [ + + ]: 2370053 : if (mp_opt->ack64)
191 : : expected_opsize += TCPOLEN_MPTCP_DSS_ACK64;
192 : : else
193 : 267348 : expected_opsize += TCPOLEN_MPTCP_DSS_ACK32;
194 : : }
195 : :
196 [ + + ]: 2370053 : if (mp_opt->use_map) {
197 : 1479591 : mp_opt->data_fin = (flags & MPTCP_DSS_DATA_FIN) != 0;
198 [ + + ]: 1479591 : if (mp_opt->dsn64)
199 : 1479549 : expected_opsize += TCPOLEN_MPTCP_DSS_MAP64;
200 : : else
201 : 42 : expected_opsize += TCPOLEN_MPTCP_DSS_MAP32;
202 : : }
203 : :
204 [ - + - - ]: 2370053 : pr_debug("data_fin=%d dsn64=%d use_map=%d ack64=%d use_ack=%d\n",
205 : : mp_opt->data_fin, mp_opt->dsn64,
206 : : mp_opt->use_map, mp_opt->ack64,
207 : : mp_opt->use_ack);
208 : :
209 : : /* Always parse any csum presence combination, we will enforce
210 : : * RFC 8684 Section 3.3.0 checks later in subflow_data_ready
211 : : */
212 [ + + ]: 2370053 : if (opsize != expected_opsize &&
213 [ - + ]: 238018 : opsize != expected_opsize + TCPOLEN_MPTCP_DSS_CHECKSUM) {
214 : 0 : mp_opt->dsn64 = 0;
215 : 0 : mp_opt->use_map = 0;
216 : 0 : mp_opt->ack64 = 0;
217 : 0 : mp_opt->use_ack = 0;
218 : 0 : mp_opt->data_fin = 0;
219 : 0 : break;
220 : : }
221 : :
222 : 2370053 : mp_opt->suboptions |= OPTION_MPTCP_DSS;
223 [ + - ]: 2370053 : if (mp_opt->use_ack) {
224 [ + + ]: 2370053 : if (mp_opt->ack64) {
225 : 2102705 : mp_opt->data_ack = get_unaligned_be64(ptr);
226 : 2102705 : ptr += 8;
227 : : } else {
228 : 267348 : mp_opt->data_ack = get_unaligned_be32(ptr);
229 : 267348 : ptr += 4;
230 : : }
231 : :
232 [ - + - - ]: 2370053 : pr_debug("data_ack=%llu\n", mp_opt->data_ack);
233 : : }
234 : :
235 [ + + ]: 2370053 : if (mp_opt->use_map) {
236 [ + + ]: 1479591 : if (mp_opt->dsn64) {
237 : 1479549 : mp_opt->data_seq = get_unaligned_be64(ptr);
238 : 1479549 : ptr += 8;
239 : : } else {
240 : 42 : mp_opt->data_seq = get_unaligned_be32(ptr);
241 : 42 : ptr += 4;
242 : : }
243 : :
244 [ + + ]: 1479591 : mp_opt->subflow_seq = get_unaligned_be32(ptr);
245 : 1479591 : ptr += 4;
246 : :
247 [ + + ]: 1479591 : mp_opt->data_len = get_unaligned_be16(ptr);
248 : 1479591 : ptr += 2;
249 : :
250 [ + + ]: 1479591 : if (opsize == expected_opsize + TCPOLEN_MPTCP_DSS_CHECKSUM) {
251 : 238018 : mp_opt->suboptions |= OPTION_MPTCP_CSUMREQD;
252 : 238018 : mp_opt->csum = get_unaligned((__force __sum16 *)ptr);
253 : 238018 : ptr += 2;
254 : : }
255 : :
256 [ - + - - ]: 1479591 : pr_debug("data_seq=%llu subflow_seq=%u data_len=%u csum=%d:%u\n",
257 : : mp_opt->data_seq, mp_opt->subflow_seq,
258 : : mp_opt->data_len, !!(mp_opt->suboptions & OPTION_MPTCP_CSUMREQD),
259 : : mp_opt->csum);
260 : : }
261 : :
262 : : break;
263 : :
264 : 837 : case MPTCPOPT_ADD_ADDR:
265 : : /* Can be used with a restricted number of other options */
266 [ + - ]: 837 : if ((mp_opt->suboptions & ~(OPTIONS_MPTCP_DSS |
267 : : OPTION_MPTCP_RM_ADDR |
268 : : OPTION_MPTCP_PRIO)) != 0)
269 : : break;
270 : :
271 : 837 : mp_opt->echo = (*ptr++) & MPTCP_ADDR_ECHO;
272 [ + + ]: 837 : if (!mp_opt->echo) {
273 : 423 : if (opsize == TCPOLEN_MPTCP_ADD_ADDR ||
274 [ + + ]: 423 : opsize == TCPOLEN_MPTCP_ADD_ADDR_PORT)
275 : 329 : mp_opt->addr.family = AF_INET;
276 : : #if IS_ENABLED(CONFIG_MPTCP_IPV6)
277 : 94 : else if (opsize == TCPOLEN_MPTCP_ADD_ADDR6 ||
278 [ + - ]: 94 : opsize == TCPOLEN_MPTCP_ADD_ADDR6_PORT)
279 : 94 : mp_opt->addr.family = AF_INET6;
280 : : #endif
281 : : else
282 : : break;
283 : : } else {
284 : 414 : if (opsize == TCPOLEN_MPTCP_ADD_ADDR_BASE ||
285 [ + + ]: 414 : opsize == TCPOLEN_MPTCP_ADD_ADDR_BASE_PORT)
286 : 316 : mp_opt->addr.family = AF_INET;
287 : : #if IS_ENABLED(CONFIG_MPTCP_IPV6)
288 : 98 : else if (opsize == TCPOLEN_MPTCP_ADD_ADDR6_BASE ||
289 [ + - ]: 98 : opsize == TCPOLEN_MPTCP_ADD_ADDR6_BASE_PORT)
290 : 98 : mp_opt->addr.family = AF_INET6;
291 : : #endif
292 : : else
293 : : break;
294 : : }
295 : :
296 : 837 : mp_opt->suboptions |= OPTION_MPTCP_ADD_ADDR;
297 : 837 : mp_opt->addr.id = *ptr++;
298 : 837 : mp_opt->addr.port = 0;
299 : 837 : mp_opt->ahmac = 0;
300 [ + + ]: 837 : if (mp_opt->addr.family == AF_INET) {
301 : 645 : memcpy((u8 *)&mp_opt->addr.addr.s_addr, (u8 *)ptr, 4);
302 : 645 : ptr += 4;
303 : 645 : if (opsize == TCPOLEN_MPTCP_ADD_ADDR_PORT ||
304 [ + + ]: 645 : opsize == TCPOLEN_MPTCP_ADD_ADDR_BASE_PORT) {
305 : 74 : mp_opt->addr.port = htons(get_unaligned_be16(ptr));
306 : 74 : ptr += 2;
307 : : }
308 : : }
309 : : #if IS_ENABLED(CONFIG_MPTCP_IPV6)
310 : : else {
311 : 192 : memcpy(mp_opt->addr.addr6.s6_addr, (u8 *)ptr, 16);
312 : 192 : ptr += 16;
313 : 192 : if (opsize == TCPOLEN_MPTCP_ADD_ADDR6_PORT ||
314 [ + + ]: 192 : opsize == TCPOLEN_MPTCP_ADD_ADDR6_BASE_PORT) {
315 : 22 : mp_opt->addr.port = htons(get_unaligned_be16(ptr));
316 : 22 : ptr += 2;
317 : : }
318 : : }
319 : : #endif
320 [ + + ]: 837 : if (!mp_opt->echo) {
321 : 423 : mp_opt->ahmac = get_unaligned_be64(ptr);
322 : 423 : ptr += 8;
323 : : }
324 [ - + - - : 837 : pr_debug("ADD_ADDR%s: id=%d, ahmac=%llu, echo=%d, port=%d\n",
- - ]
325 : : (mp_opt->addr.family == AF_INET6) ? "6" : "",
326 : : mp_opt->addr.id, mp_opt->ahmac, mp_opt->echo, ntohs(mp_opt->addr.port));
327 : : break;
328 : :
329 : 108 : case MPTCPOPT_RM_ADDR:
330 : : /* Can be used with a restricted number of other options */
331 [ + - ]: 108 : if ((mp_opt->suboptions & ~(OPTION_MPTCP_MPC_ACK |
332 : : OPTIONS_MPTCP_MPJ |
333 : : OPTIONS_MPTCP_DSS |
334 : : OPTION_MPTCP_ADD_ADDR |
335 : : OPTION_MPTCP_PRIO)) != 0)
336 : : break;
337 : :
338 [ + - ]: 108 : if (opsize < TCPOLEN_MPTCP_RM_ADDR_BASE + 1 ||
339 : : opsize > TCPOLEN_MPTCP_RM_ADDR_BASE + MPTCP_RM_IDS_MAX)
340 : : break;
341 : :
342 : 108 : ptr++;
343 : :
344 : 108 : mp_opt->suboptions |= OPTION_MPTCP_RM_ADDR;
345 : 108 : mp_opt->rm_list.nr = opsize - TCPOLEN_MPTCP_RM_ADDR_BASE;
346 [ + + ]: 224 : for (i = 0; i < mp_opt->rm_list.nr; i++)
347 : 116 : mp_opt->rm_list.ids[i] = *ptr++;
348 [ - + - - ]: 108 : pr_debug("RM_ADDR: rm_list_nr=%d\n", mp_opt->rm_list.nr);
349 : : break;
350 : :
351 : 46 : case MPTCPOPT_MP_PRIO:
352 : : /* Can be used with a restricted number of other options */
353 [ + - ]: 46 : if ((mp_opt->suboptions & ~(OPTIONS_MPTCP_MPJ |
354 : : OPTIONS_MPTCP_DSS |
355 : : OPTION_MPTCP_ADD_ADDR |
356 : : OPTION_MPTCP_RM_ADDR)) != 0)
357 : : break;
358 : :
359 [ + + ]: 46 : if (opsize != TCPOLEN_MPTCP_PRIO)
360 : : break;
361 : :
362 : 40 : mp_opt->suboptions |= OPTION_MPTCP_PRIO;
363 : 40 : mp_opt->backup = *ptr++ & MPTCP_PRIO_BKUP;
364 [ - + - - ]: 40 : pr_debug("MP_PRIO: prio=%d\n", mp_opt->backup);
365 : : break;
366 : :
367 : 263 : case MPTCPOPT_MP_FASTCLOSE:
368 : : /* Can be used with a restricted number of other options */
369 [ + - ]: 263 : if ((mp_opt->suboptions & ~(OPTIONS_MPTCP_DSS |
370 : : OPTION_MPTCP_RST)) != 0)
371 : : break;
372 : :
373 [ + - ]: 263 : if (opsize != TCPOLEN_MPTCP_FASTCLOSE)
374 : : break;
375 : :
376 : 263 : ptr += 2;
377 [ - + ]: 263 : mp_opt->rcvr_key = get_unaligned_be64(ptr);
378 : 263 : ptr += 8;
379 : 263 : mp_opt->suboptions |= OPTION_MPTCP_FASTCLOSE;
380 [ - + - - ]: 263 : pr_debug("MP_FASTCLOSE: recv_key=%llu\n", mp_opt->rcvr_key);
381 : : break;
382 : :
383 : 271 : case MPTCPOPT_RST:
384 : : /* Can be used with a restricted number of other options */
385 [ + - ]: 271 : if ((mp_opt->suboptions & ~(OPTION_MPTCP_FAIL |
386 : : OPTION_MPTCP_FASTCLOSE)) != 0)
387 : : break;
388 : :
389 [ + - ]: 271 : if (opsize != TCPOLEN_MPTCP_RST)
390 : : break;
391 : :
392 [ + + ]: 271 : if (!(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_RST))
393 : : break;
394 : :
395 : 259 : mp_opt->suboptions |= OPTION_MPTCP_RST;
396 : 259 : flags = *ptr++;
397 : 259 : mp_opt->reset_transient = flags & MPTCP_RST_TRANSIENT;
398 : 259 : mp_opt->reset_reason = *ptr;
399 [ - + - - ]: 259 : pr_debug("MP_RST: transient=%u reason=%u\n",
400 : : mp_opt->reset_transient, mp_opt->reset_reason);
401 : : break;
402 : :
403 : 6 : case MPTCPOPT_MP_FAIL:
404 : : /* Can be used with a restricted number of other options */
405 [ + - ]: 6 : if ((mp_opt->suboptions & ~(OPTIONS_MPTCP_DSS |
406 : : OPTION_MPTCP_RST)) != 0)
407 : : break;
408 : :
409 [ + - ]: 6 : if (opsize != TCPOLEN_MPTCP_FAIL)
410 : : break;
411 : :
412 : 6 : ptr += 2;
413 : 6 : mp_opt->suboptions |= OPTION_MPTCP_FAIL;
414 [ - + ]: 6 : mp_opt->fail_seq = get_unaligned_be64(ptr);
415 [ - + - - ]: 6 : pr_debug("MP_FAIL: data_seq=%llu\n", mp_opt->fail_seq);
416 : : break;
417 : :
418 : : default:
419 : : break;
420 : : }
421 : 2381725 : }
422 : :
423 : 2381912 : void mptcp_get_options(const struct sk_buff *skb,
424 : : struct mptcp_options_received *mp_opt)
425 : : {
426 : 2381912 : const struct tcphdr *th = tcp_hdr(skb);
427 : 2381912 : const unsigned char *ptr;
428 : 2381912 : int length;
429 : :
430 : : /* Ensure that casting the whole status to u32 is efficient and safe */
431 : 2381912 : BUILD_BUG_ON(sizeof_field(struct mptcp_options_received, status) != sizeof(u32));
432 : 2381912 : BUILD_BUG_ON(!IS_ALIGNED(offsetof(struct mptcp_options_received, status),
433 : : sizeof(u32)));
434 : 2381912 : *(u32 *)&mp_opt->status = 0;
435 : :
436 : 2381912 : length = (th->doff * 4) - sizeof(struct tcphdr);
437 : 2381912 : ptr = (const unsigned char *)(th + 1);
438 : :
439 [ + + ]: 14458253 : while (length > 0) {
440 : 12076341 : int opcode = *ptr++;
441 : 12076341 : int opsize;
442 : :
443 [ + + - ]: 12076341 : switch (opcode) {
444 : : case TCPOPT_EOL:
445 : : return;
446 : 7280982 : case TCPOPT_NOP: /* Ref: RFC 793 section 3.1 */
447 : 7280982 : length--;
448 : 7280982 : continue;
449 : 4795359 : default:
450 [ + - ]: 4795359 : if (length < 2)
451 : : return;
452 : 4795359 : opsize = *ptr++;
453 [ + - ]: 4795359 : if (opsize < 2) /* "silly options" */
454 : : return;
455 [ + - ]: 4795359 : if (opsize > length)
456 : : return; /* don't parse partial options */
457 [ + + ]: 4795359 : if (opcode == TCPOPT_MPTCP)
458 : 2381725 : mptcp_parse_option(skb, ptr, opsize, mp_opt);
459 : 4795359 : ptr += opsize - 2;
460 : 4795359 : length -= opsize;
461 : : }
462 : : }
463 : : }
464 : :
465 : 2478 : bool mptcp_syn_options(struct sock *sk, const struct sk_buff *skb,
466 : : unsigned int *size, struct mptcp_out_options *opts)
467 : : {
468 [ + + ]: 2478 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
469 : :
470 : : /* we will use snd_isn to detect first pkt [re]transmission
471 : : * in mptcp_established_options_mp()
472 : : */
473 : 2478 : subflow->snd_isn = TCP_SKB_CB(skb)->end_seq;
474 [ + + ]: 2478 : if (subflow->request_mptcp) {
475 [ + + ]: 1745 : if (unlikely(subflow_simultaneous_connect(sk))) {
476 [ - + ]: 6 : WARN_ON_ONCE(!mptcp_try_fallback(sk, MPTCP_MIB_SIMULTCONNFALLBACK));
477 : :
478 : : /* Ensure mptcp_finish_connect() will not process the
479 : : * MPC handshake.
480 : : */
481 : 6 : subflow->request_mptcp = 0;
482 : 6 : return false;
483 : : }
484 : :
485 : 1739 : opts->suboptions = OPTION_MPTCP_MPC_SYN;
486 : 1739 : opts->csum_reqd = mptcp_is_checksum_enabled(sock_net(sk));
487 : 1739 : opts->allow_join_id0 = mptcp_allow_join_id0(sock_net(sk));
488 : 1739 : *size = TCPOLEN_MPTCP_MPC_SYN;
489 : 1739 : return true;
490 [ + + ]: 733 : } else if (subflow->request_join) {
491 [ - + - - ]: 703 : pr_debug("remote_token=%u, nonce=%u\n", subflow->remote_token,
492 : : subflow->local_nonce);
493 : 703 : opts->suboptions = OPTION_MPTCP_MPJ_SYN;
494 : 703 : opts->join_id = subflow->local_id;
495 : 703 : opts->token = subflow->remote_token;
496 : 703 : opts->nonce = subflow->local_nonce;
497 : 703 : opts->backup = subflow->request_bkup;
498 : 703 : *size = TCPOLEN_MPTCP_MPJ_SYN;
499 : 703 : return true;
500 : : }
501 : : return false;
502 : : }
503 : :
504 : 1198 : static void clear_3rdack_retransmission(struct sock *sk)
505 : : {
506 : 1198 : struct inet_connection_sock *icsk = inet_csk(sk);
507 : :
508 : 1198 : sk_stop_timer(sk, &icsk->icsk_delack_timer);
509 : 1198 : icsk->icsk_ack.ato = 0;
510 : 1198 : icsk->icsk_ack.pending &= ~(ICSK_ACK_SCHED | ICSK_ACK_TIMER);
511 : 1198 : }
512 : :
513 : 4177403 : static bool mptcp_established_options_mp(struct sock *sk, struct sk_buff *skb,
514 : : bool snd_data_fin_enable, int *size,
515 : : struct mptcp_out_options *opts)
516 : : {
517 [ - + ]: 4177403 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
518 [ - + ]: 4177403 : struct mptcp_sock *msk = mptcp_sk(subflow->conn);
519 : 4177403 : struct mptcp_ext *mpext;
520 : 4177403 : unsigned int data_len;
521 : 4177403 : u8 len;
522 : :
523 : : /* When skb is not available, we better over-estimate the emitted
524 : : * options len. A full DSS option (28 bytes) is longer than
525 : : * TCPOLEN_MPTCP_MPC_ACK_DATA(22) or TCPOLEN_MPTCP_MPJ_ACK(24), so
526 : : * tell the caller to defer the estimate to
527 : : * mptcp_established_options_dss(), which will reserve enough space.
528 : : */
529 [ + + ]: 4177403 : if (!skb)
530 : : return false;
531 : :
532 : : /* MPC/MPJ needed only on 3rd ack packet, DATA_FIN and TCP shutdown take precedence */
533 [ - + + + : 1903476 : if (READ_ONCE(subflow->fully_established) || snd_data_fin_enable ||
+ + ]
[ + + + + ]
534 [ + + ]: 4355 : subflow->snd_isn != TCP_SKB_CB(skb)->seq ||
535 [ + + ]: 3118 : sk->sk_state != TCP_ESTABLISHED)
536 : : return false;
537 : :
538 [ + + ]: 3118 : if (subflow->mp_capable) {
539 [ + + ]: 2511 : mpext = mptcp_get_ext(skb);
540 [ + + ]: 1776 : data_len = mpext ? mpext->data_len : 0;
541 : :
542 : : /* we will check ops->data_len in mptcp_write_options() to
543 : : * discriminate between TCPOLEN_MPTCP_MPC_ACK_DATA and
544 : : * TCPOLEN_MPTCP_MPC_ACK
545 : : */
546 : 2511 : opts->data_len = data_len;
547 : 2511 : opts->suboptions = OPTION_MPTCP_MPC_ACK;
548 : 2511 : opts->sndr_key = subflow->local_key;
549 : 2511 : opts->rcvr_key = subflow->remote_key;
550 [ - + ]: 2511 : opts->csum_reqd = READ_ONCE(msk->csum_enabled);
551 : 2511 : opts->allow_join_id0 = mptcp_allow_join_id0(sock_net(sk));
552 : :
553 : : /* Section 3.1.
554 : : * The MP_CAPABLE option is carried on the SYN, SYN/ACK, and ACK
555 : : * packets that start the first subflow of an MPTCP connection,
556 : : * as well as the first packet that carries data
557 : : */
558 [ + + ]: 2511 : if (data_len > 0) {
559 : 1040 : len = TCPOLEN_MPTCP_MPC_ACK_DATA;
560 [ + + ]: 1040 : if (opts->csum_reqd) {
561 : : /* we need to propagate more info to csum the pseudo hdr */
562 : 102 : opts->data_seq = mpext->data_seq;
563 : 102 : opts->subflow_seq = mpext->subflow_seq;
564 : 102 : opts->csum = mpext->csum;
565 : 102 : len += TCPOLEN_MPTCP_DSS_CHECKSUM;
566 : : }
567 : 1040 : *size = ALIGN(len, 4);
568 : : } else {
569 : 1471 : *size = TCPOLEN_MPTCP_MPC_ACK;
570 : : }
571 : :
572 [ - + - - ]: 2511 : pr_debug("subflow=%p, local_key=%llu, remote_key=%llu map_len=%d\n",
573 : : subflow, subflow->local_key, subflow->remote_key,
574 : : data_len);
575 : :
576 : 2511 : return true;
577 [ + + ]: 607 : } else if (subflow->mp_join) {
578 : 607 : opts->suboptions = OPTION_MPTCP_MPJ_ACK;
579 : 607 : memcpy(opts->hmac, subflow->hmac, MPTCPOPT_HMAC_LEN);
580 : 607 : *size = TCPOLEN_MPTCP_MPJ_ACK;
581 [ - + - - ]: 607 : pr_debug("subflow=%p\n", subflow);
582 : :
583 : : /* we can use the full delegate action helper only from BH context
584 : : * If we are in process context - sk is flushing the backlog at
585 : : * socket lock release time - just set the appropriate flag, will
586 : : * be handled by the release callback
587 : : */
588 [ + + ]: 607 : if (sock_owned_by_user(sk))
589 : 517 : set_bit(MPTCP_DELEGATE_ACK, &subflow->delegated_status);
590 : : else
591 : 90 : mptcp_subflow_delegate(subflow, MPTCP_DELEGATE_ACK);
592 : 607 : return true;
593 : : }
594 : : return false;
595 : : }
596 : :
597 : 31832 : static void mptcp_write_data_fin(struct mptcp_subflow_context *subflow,
598 : : struct sk_buff *skb, struct mptcp_ext *ext)
599 : : {
600 : : /* The write_seq value has already been incremented, so the actual
601 : : * sequence number for the DATA_FIN is one less.
602 : : */
603 [ - + ]: 31832 : u64 data_fin_tx_seq = READ_ONCE(mptcp_sk(subflow->conn)->write_seq) - 1;
604 : :
605 [ + + - + ]: 31832 : if (!ext->use_map || !skb->len) {
606 : : /* RFC6824 requires a DSS mapping with specific values
607 : : * if DATA_FIN is set but no data payload is mapped
608 : : */
609 : 14580 : ext->data_fin = 1;
610 : 14580 : ext->use_map = 1;
611 : 14580 : ext->dsn64 = 1;
612 : 14580 : ext->data_seq = data_fin_tx_seq;
613 : 14580 : ext->subflow_seq = 0;
614 : 14580 : ext->data_len = 1;
615 [ + + ]: 17252 : } else if (ext->data_seq + ext->data_len == data_fin_tx_seq) {
616 : : /* If there's an existing DSS mapping and it is the
617 : : * final mapping, DATA_FIN consumes 1 additional byte of
618 : : * mapping space.
619 : : */
620 : 1621 : ext->data_fin = 1;
621 : 1621 : ext->data_len++;
622 : : }
623 : 31832 : }
624 : :
625 : 4174285 : static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb,
626 : : bool snd_data_fin_enable, int *size,
627 : : struct mptcp_out_options *opts)
628 : : {
629 [ - + ]: 4174285 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
630 [ - + ]: 4174285 : struct mptcp_sock *msk = mptcp_sk(subflow->conn);
631 [ - + ]: 4174285 : struct tcp_sock *tp = tcp_sk(sk);
632 : 4174285 : unsigned int dss_size = 0;
633 : 4174285 : struct mptcp_ext *mpext;
634 : 4174285 : unsigned int ack_size;
635 : 4174285 : bool ret = false;
636 : :
637 : : /* Zero `use_ack` and `use_map` flags with one shot. */
638 : 4174285 : memset(&opts->ext_copy.flags, 0, sizeof(opts->ext_copy.flags));
639 [ - + ]: 4174285 : opts->csum_reqd = READ_ONCE(msk->csum_enabled);
640 [ + + ]: 4174285 : mpext = skb ? mptcp_get_ext(skb) : NULL;
641 : :
642 [ + + - + : 1900358 : if (!skb || (mpext && mpext->use_map) || snd_data_fin_enable) {
+ + ]
643 : 3222966 : unsigned int map_size = TCPOLEN_MPTCP_DSS_BASE + TCPOLEN_MPTCP_DSS_MAP64;
644 : :
645 [ + + ]: 3222966 : if (mpext) {
646 [ + + ]: 934459 : if (opts->csum_reqd)
647 : 185909 : map_size += TCPOLEN_MPTCP_DSS_CHECKSUM;
648 : :
649 : 934459 : opts->ext_copy = *mpext;
650 : : }
651 : :
652 : 3222966 : dss_size = map_size;
653 [ + + ]: 3222966 : if (skb && snd_data_fin_enable)
654 : 31832 : mptcp_write_data_fin(subflow, skb, &opts->ext_copy);
655 : 3222966 : opts->suboptions = OPTION_MPTCP_DSS;
656 : 3222966 : ret = true;
657 : : }
658 : :
659 : : /* passive sockets msk will set the 'can_ack' after accept(), even
660 : : * if the first subflow may have the already the remote key handy
661 : : */
662 [ - + + + ]: 4174285 : if (!READ_ONCE(msk->can_ack)) {
[ + + ]
663 : 33 : *size = ALIGN(dss_size, 4);
664 : 33 : return ret;
665 : : }
666 : :
667 [ - + + + ]: 4174252 : if (READ_ONCE(msk->use_64bit_ack)) {
[ + + ]
668 : 3797238 : ack_size = TCPOLEN_MPTCP_DSS_ACK64;
669 : 3797238 : opts->ext_copy.ack64 = 1;
670 : : } else {
671 : 377014 : ack_size = TCPOLEN_MPTCP_DSS_ACK32;
672 : 377014 : opts->ext_copy.ack64 = 0;
673 : : }
674 : 4174252 : opts->ext_copy.use_ack = 1;
675 : 4174252 : opts->suboptions = OPTION_MPTCP_DSS;
676 : :
677 : : /* Add kind/length/subtype/flag overhead if mapping is not populated */
678 [ + + ]: 4174252 : if (dss_size == 0)
679 : 951319 : ack_size += TCPOLEN_MPTCP_DSS_BASE;
680 : :
681 : : /* The caller is __tcp_transmit_skb(), and will compute the new rcv
682 : : * wnd soon: ensure that the window can shrink.
683 : : */
684 [ + + ]: 4174252 : if (skb)
685 : 1900358 : tp->rcv_wnd = tp->rcv_nxt - tp->rcv_wup;
686 : :
687 : 4174252 : dss_size += ack_size;
688 : :
689 : 4174252 : *size = ALIGN(dss_size, 4);
690 : 4174252 : return true;
691 : : }
692 : :
693 : 914 : static u64 add_addr_generate_hmac(u64 key1, u64 key2,
694 : : struct mptcp_addr_info *addr)
695 : : {
696 : 914 : u16 port = ntohs(addr->port);
697 : 914 : u8 hmac[SHA256_DIGEST_SIZE];
698 : 914 : u8 msg[19];
699 : 914 : int i = 0;
700 : :
701 : 914 : msg[i++] = addr->id;
702 [ + + ]: 914 : if (addr->family == AF_INET) {
703 : 706 : memcpy(&msg[i], &addr->addr.s_addr, 4);
704 : 706 : i += 4;
705 : : }
706 : : #if IS_ENABLED(CONFIG_MPTCP_IPV6)
707 [ + - ]: 208 : else if (addr->family == AF_INET6) {
708 : 208 : memcpy(&msg[i], &addr->addr6.s6_addr, 16);
709 : 208 : i += 16;
710 : : }
711 : : #endif
712 : 914 : msg[i++] = port >> 8;
713 : 914 : msg[i++] = port & 0xFF;
714 : :
715 : 914 : mptcp_crypto_hmac_sha(key1, key2, msg, i, hmac);
716 : :
717 : 914 : return get_unaligned_be64(&hmac[SHA256_DIGEST_SIZE - sizeof(u64)]);
718 : : }
719 : :
720 : 4177399 : static bool mptcp_established_options_add_addr(struct sock *sk,
721 : : struct sk_buff *skb, int *size,
722 : : unsigned int remaining,
723 : : bool has_ts,
724 : : struct mptcp_out_options *opts)
725 : : {
726 [ - + ]: 4177399 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
727 [ - + ]: 4177399 : struct mptcp_sock *msk = mptcp_sk(subflow->conn);
728 : 4177399 : struct mptcp_addr_info addr;
729 : 4177399 : bool drop_ts = has_ts;
730 : 4177399 : bool echo;
731 : :
732 : : /* add addr will strip the existing options, be sure to avoid breaking
733 : : * MPC/MPJ handshakes
734 : : */
735 [ + + ]: 4177399 : if (!mptcp_pm_should_add_signal(msk) ||
736 [ + - + + ]: 913 : (opts->suboptions & (OPTION_MPTCP_MPJ_ACK | OPTION_MPTCP_MPC_ACK)) ||
737 [ + + + + ]: 1820 : !skb || !skb_is_tcp_pure_ack(skb) ||
738 : 909 : !mptcp_pm_add_addr_signal(msk, size, remaining, &addr, &echo,
739 : : &drop_ts))
740 : 4176498 : return false;
741 : :
742 [ - + - - ]: 901 : pr_debug("drop other suboptions\n");
743 : 901 : opts->suboptions = OPTION_MPTCP_ADD_ADDR;
744 [ - + ]: 901 : opts->drop_ts = drop_ts;
745 : 901 : opts->addr = addr;
746 [ - + + + ]: 901 : if (!echo) {
[ + + ]
747 [ + - ]: 491 : MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_ADDADDRTX);
748 : 491 : opts->ahmac = add_addr_generate_hmac(READ_ONCE(msk->local_key),
749 : 491 : READ_ONCE(msk->remote_key),
750 : : &opts->addr);
751 : : } else {
752 [ + - ]: 410 : MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_ECHOADDTX);
753 : 410 : opts->ahmac = 0;
754 : : }
755 [ - + - - : 901 : pr_debug("addr_id=%d, ahmac=%llu, echo=%d, port=%d\n",
- - ]
[ - + - - ]
756 : : opts->addr.id, opts->ahmac, echo, ntohs(opts->addr.port));
757 : :
758 : : return true;
759 : : }
760 : :
761 : 4176498 : static bool mptcp_established_options_rm_addr(struct sock *sk, int *size,
762 : : unsigned int remaining,
763 : : struct mptcp_out_options *opts)
764 : : {
765 [ - + ]: 4176498 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
766 [ - + ]: 4176498 : struct mptcp_sock *msk = mptcp_sk(subflow->conn);
767 : 4176498 : struct mptcp_rm_list rm_list;
768 : 4176498 : int i;
769 : :
770 [ + + - + ]: 4176612 : if (!mptcp_pm_should_rm_signal(msk) ||
771 : 114 : !(mptcp_pm_rm_addr_signal(msk, remaining, &rm_list, size)))
772 : 4176384 : return false;
773 : :
774 : 114 : opts->suboptions |= OPTION_MPTCP_RM_ADDR;
775 : 114 : opts->rm_list = rm_list;
776 : :
777 [ + + ]: 236 : for (i = 0; i < opts->rm_list.nr; i++)
778 [ - + - - ]: 122 : pr_debug("rm_list_ids[%d]=%d\n", i, opts->rm_list.ids[i]);
779 : 114 : MPTCP_ADD_STATS(sock_net(sk), MPTCP_MIB_RMADDRTX, opts->rm_list.nr);
780 : 114 : return true;
781 : : }
782 : :
783 : 4177399 : static bool mptcp_established_options_mp_prio(struct sock *sk, int *size,
784 : : unsigned int remaining,
785 : : struct mptcp_out_options *opts)
786 : : {
787 [ + + ]: 4177399 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
788 : :
789 : : /* can't send MP_PRIO with MPC, as they share the same option space:
790 : : * 'backup'. Also it makes no sense at all
791 : : */
792 [ + + + - ]: 4177399 : if (!subflow->send_mp_prio || (opts->suboptions & OPTIONS_MPTCP_MPC))
793 : : return false;
794 : :
795 : : /* account for the trailing 'nop' option */
796 [ + - ]: 28 : if (remaining < TCPOLEN_MPTCP_PRIO_ALIGN)
797 : : return false;
798 : :
799 : 28 : *size = TCPOLEN_MPTCP_PRIO_ALIGN;
800 : 28 : opts->suboptions |= OPTION_MPTCP_PRIO;
801 : 28 : opts->backup = subflow->request_bkup;
802 : :
803 [ - + - - ]: 28 : pr_debug("prio=%d\n", opts->backup);
804 : :
805 : : return true;
806 : : }
807 : :
808 : 502 : static noinline bool mptcp_established_options_rst(struct sock *sk,
809 : : int *size,
810 : : unsigned int remaining,
811 : : struct mptcp_out_options *opts)
812 : : {
813 [ + - ]: 502 : const struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
814 : :
815 [ + - ]: 502 : if (remaining < TCPOLEN_MPTCP_RST)
816 : : return false;
817 : :
818 : 502 : *size = TCPOLEN_MPTCP_RST;
819 : 502 : opts->suboptions |= OPTION_MPTCP_RST;
820 : 502 : opts->reset_transient = subflow->reset_transient;
821 : 502 : opts->reset_reason = subflow->reset_reason;
822 [ + - ]: 502 : MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPRSTTX);
823 : :
824 : : return true;
825 : : }
826 : :
827 : 502 : static bool mptcp_established_options_fastclose(struct sock *sk, int *size,
828 : : unsigned int remaining,
829 : : struct mptcp_out_options *opts)
830 : : {
831 [ - + ]: 502 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
832 [ - + ]: 502 : struct mptcp_sock *msk = mptcp_sk(subflow->conn);
833 : :
834 [ + + ]: 502 : if (likely(!subflow->send_fastclose))
835 : : return false;
836 : :
837 [ + - ]: 446 : if (remaining < TCPOLEN_MPTCP_FASTCLOSE)
838 : : return false;
839 : :
840 : 446 : *size = TCPOLEN_MPTCP_FASTCLOSE;
841 : 446 : opts->suboptions |= OPTION_MPTCP_FASTCLOSE;
842 : 446 : opts->rcvr_key = READ_ONCE(msk->remote_key);
843 : :
844 [ - + - - ]: 446 : pr_debug("FASTCLOSE key=%llu\n", opts->rcvr_key);
845 [ + - ]: 446 : MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPFASTCLOSETX);
846 : : return true;
847 : : }
848 : :
849 : 4174341 : static bool mptcp_established_options_mp_fail(struct sock *sk, int *size,
850 : : unsigned int remaining,
851 : : struct mptcp_out_options *opts)
852 : : {
853 [ + + ]: 4174341 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
854 : :
855 [ + + ]: 4174341 : if (likely(!subflow->send_mp_fail))
856 : : return false;
857 : :
858 [ + - ]: 6 : if (remaining < TCPOLEN_MPTCP_FAIL)
859 : : return false;
860 : :
861 : 6 : *size = TCPOLEN_MPTCP_FAIL;
862 : 6 : opts->suboptions |= OPTION_MPTCP_FAIL;
863 : 6 : opts->fail_seq = subflow->map_seq;
864 : :
865 [ - + - - ]: 6 : pr_debug("MP_FAIL fail_seq=%llu\n", opts->fail_seq);
866 [ + - ]: 6 : MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPFAILTX);
867 : :
868 : : return true;
869 : : }
870 : :
871 : 4285744 : int mptcp_established_options(struct sock *sk, struct sk_buff *skb,
872 : : unsigned int remaining, bool has_ts,
873 : : struct mptcp_out_options *opts)
874 : : {
875 [ - + ]: 4285744 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
876 [ - + ]: 4285744 : struct mptcp_sock *msk = mptcp_sk(subflow->conn);
877 : 4285744 : int total_size = 0;
878 : 4285744 : bool snd_data_fin;
879 : 4285744 : bool ret = false;
880 : 4285744 : int opt_size = 0;
881 : :
882 : 4285744 : opts->suboptions = 0;
883 : :
884 : : /* Force later mptcp_write_options(), but do not use any actual
885 : : * option space.
886 : : */
887 [ + + + + ]: 4285744 : if (unlikely(__mptcp_check_fallback(msk) && !mptcp_check_infinite_map(skb)))
888 : : return 0;
889 : :
890 [ + + + + ]: 4177905 : if (unlikely(skb && TCP_SKB_CB(skb)->tcp_flags & TCPHDR_RST)) {
891 [ + + + + ]: 558 : if (mptcp_established_options_fastclose(sk, &opt_size, remaining, opts) ||
892 : 56 : mptcp_established_options_mp_fail(sk, &opt_size, remaining, opts)) {
893 : 448 : total_size += opt_size;
894 : 448 : remaining -= opt_size;
895 : : }
896 : : /* MP_RST can be used with MP_FASTCLOSE and MP_FAIL if there is room */
897 [ + - ]: 502 : if (mptcp_established_options_rst(sk, &opt_size, remaining, opts)) {
898 : 502 : total_size += opt_size;
899 : 502 : remaining -= opt_size;
900 : : }
901 : 502 : return total_size;
902 : : }
903 : :
904 [ + + ]: 4177403 : snd_data_fin = mptcp_data_fin_enabled(msk);
905 [ + + ]: 4177403 : if (mptcp_established_options_mp(sk, skb, snd_data_fin, &opt_size, opts))
906 : : ret = true;
907 [ + - ]: 4174285 : else if (mptcp_established_options_dss(sk, skb, snd_data_fin, &opt_size, opts)) {
908 : 4174285 : int mp_fail_size;
909 : :
910 : 4174285 : ret = true;
911 [ + + ]: 4174285 : if (mptcp_established_options_mp_fail(sk, &mp_fail_size,
912 : : remaining - opt_size, opts)) {
913 : 4 : total_size += opt_size + mp_fail_size;
914 : 4 : remaining -= opt_size - mp_fail_size;
915 : 4 : return total_size;
916 : : }
917 : : }
918 : :
919 : : /* we reserved enough space for the above options, and exceeding the
920 : : * TCP option space would be fatal
921 : : */
922 [ - + - + ]: 4177399 : if (WARN_ON_ONCE(opt_size > remaining))
923 : : return -1;
924 : :
925 : 4177399 : total_size += opt_size;
926 : 4177399 : remaining -= opt_size;
927 [ + + ]: 4177399 : if (mptcp_established_options_add_addr(sk, skb, &opt_size, remaining,
928 : : has_ts, opts)) {
929 : 901 : total_size += opt_size;
930 : 901 : remaining -= opt_size;
931 : 901 : ret = true;
932 [ + + ]: 4176498 : } else if (mptcp_established_options_rm_addr(sk, &opt_size, remaining, opts)) {
933 : 114 : total_size += opt_size;
934 : 114 : remaining -= opt_size;
935 : 114 : ret = true;
936 : : }
937 : :
938 [ + + ]: 4177399 : if (mptcp_established_options_mp_prio(sk, &opt_size, remaining, opts)) {
939 : 28 : total_size += opt_size;
940 : 28 : remaining -= opt_size;
941 : 28 : ret = true;
942 : : }
943 : :
944 [ - + ]: 4177399 : return ret ? total_size : -1;
945 : : }
946 : :
947 : 2436 : bool mptcp_synack_options(const struct request_sock *req, unsigned int *size,
948 : : struct mptcp_out_options *opts)
949 : : {
950 : 2436 : struct mptcp_subflow_request_sock *subflow_req = mptcp_subflow_rsk(req);
951 : :
952 [ + + ]: 2436 : if (subflow_req->mp_capable) {
953 : 1654 : opts->suboptions = OPTION_MPTCP_MPC_SYNACK;
954 : 1654 : opts->sndr_key = subflow_req->local_key;
955 : 1654 : opts->csum_reqd = subflow_req->csum_reqd;
956 : 1654 : opts->allow_join_id0 = subflow_req->allow_join_id0;
957 : 1654 : *size = TCPOLEN_MPTCP_MPC_SYNACK;
958 [ - + - - ]: 1654 : pr_debug("subflow_req=%p, local_key=%llu\n",
959 : : subflow_req, subflow_req->local_key);
960 : 1654 : return true;
961 [ + + ]: 782 : } else if (subflow_req->mp_join) {
962 : 622 : opts->suboptions = OPTION_MPTCP_MPJ_SYNACK;
963 : 622 : opts->backup = subflow_req->request_bkup;
964 : 622 : opts->join_id = subflow_req->local_id;
965 : 622 : opts->thmac = subflow_req->thmac;
966 : 622 : opts->nonce = subflow_req->local_nonce;
967 [ - + - - ]: 622 : pr_debug("req=%p, bkup=%u, id=%u, thmac=%llu, nonce=%u\n",
968 : : subflow_req, opts->backup, opts->join_id,
969 : : opts->thmac, opts->nonce);
970 : 622 : *size = TCPOLEN_MPTCP_MPJ_SYNACK;
971 : 622 : return true;
972 : : }
973 : : return false;
974 : : }
975 : :
976 : 2374894 : static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk,
977 : : struct mptcp_subflow_context *subflow,
978 : : struct sk_buff *skb,
979 : : struct mptcp_options_received *mp_opt)
980 : : {
981 : : /* here we can process OoO, in-window pkts, only in-sequence 4th ack
982 : : * will make the subflow fully established
983 : : */
984 [ - + + + ]: 2374894 : if (likely(READ_ONCE(subflow->fully_established))) {
[ + + ]
985 : : /* on passive sockets, check for 3rd ack retransmission
986 : : * note that msk is always set by subflow_syn_recv_sock()
987 : : * for mp_join subflows
988 : : */
989 [ + + ]: 2372790 : if (TCP_SKB_CB(skb)->seq == subflow->ssn_offset + 1 &&
990 [ + + + + ]: 252905 : TCP_SKB_CB(skb)->end_seq == TCP_SKB_CB(skb)->seq &&
991 [ + + ]: 73917 : subflow->mp_join && (mp_opt->suboptions & OPTIONS_MPTCP_MPJ) &&
992 [ + - ]: 613 : !subflow->request_join)
993 : 613 : tcp_send_ack(ssk);
994 : 2372790 : goto check_notify;
995 : : }
996 : :
997 : : /* we must process OoO packets before the first subflow is fully
998 : : * established. OoO packets are instead a protocol violation
999 : : * for MP_JOIN subflows as the peer must not send any data
1000 : : * before receiving the forth ack - cfr. RFC 8684 section 3.2.
1001 : : */
1002 [ + + ]: 2104 : if (TCP_SKB_CB(skb)->seq != subflow->ssn_offset + 1) {
1003 [ - + ]: 56 : if (subflow->mp_join)
1004 : 0 : goto reset;
1005 [ - + - - ]: 56 : if (subflow->is_mptfo && mp_opt->suboptions & OPTION_MPTCP_MPC_ACK)
1006 : 0 : goto set_fully_established;
1007 : 56 : return subflow->mp_capable;
1008 : : }
1009 : :
1010 [ + + ]: 2048 : if (subflow->remote_key_valid &&
1011 [ + + - + : 2004 : (((mp_opt->suboptions & OPTION_MPTCP_DSS) && mp_opt->use_ack) ||
+ + ]
1012 : 99 : ((mp_opt->suboptions & OPTION_MPTCP_ADD_ADDR) &&
1013 [ + + + - ]: 99 : (!mp_opt->echo || subflow->mp_join)))) {
1014 : : /* subflows are fully established as soon as we get any
1015 : : * additional ack, including ADD_ADDR.
1016 : : */
1017 : 1990 : goto set_fully_established;
1018 : : }
1019 : :
1020 : : /* If the first established packet does not contain MP_CAPABLE + data
1021 : : * then fallback to TCP. Fallback scenarios requires a reset for
1022 : : * MP_JOIN subflows.
1023 : : */
1024 [ + + ]: 58 : if (!(mp_opt->suboptions & OPTIONS_MPTCP_MPC)) {
1025 [ + + ]: 14 : if (subflow->mp_join)
1026 : 8 : goto reset;
1027 : 6 : subflow->mp_capable = 0;
1028 [ - + ]: 6 : if (!mptcp_try_fallback(ssk, MPTCP_MIB_MPCAPABLEDATAFALLBACK)) {
1029 [ # # ]: 0 : MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_FALLBACKFAILED);
1030 : 0 : goto reset;
1031 : : }
1032 : : return false;
1033 : : }
1034 : :
1035 [ - + + - ]: 44 : if (unlikely(!READ_ONCE(msk->pm.server_side)))
[ + - ]
1036 : : /* DO-NOT-MERGE: use WARN i/o pr_warn: only for MPTCP export */
1037 : 0 : WARN_ONCE(1, "bogus mpc option on established client sk");
1038 : :
1039 : 44 : set_fully_established:
1040 [ - + ]: 2034 : if (mp_opt->deny_join_id0)
1041 : 0 : WRITE_ONCE(msk->pm.remote_deny_join_id0, true);
1042 : :
1043 : 2034 : mptcp_data_lock((struct sock *)msk);
1044 : 2034 : __mptcp_subflow_fully_established(msk, subflow, mp_opt);
1045 : 2034 : mptcp_data_unlock((struct sock *)msk);
1046 : :
1047 : 2374824 : check_notify:
1048 : : /* if the subflow is not already linked into the conn_list, we can't
1049 : : * notify the PM: this subflow is still on the listener queue
1050 : : * and the PM possibly acquiring the subflow lock could race with
1051 : : * the listener close
1052 : : */
1053 [ + + + - ]: 2374824 : if (likely(subflow->pm_notified) || list_empty(&subflow->node))
1054 : : return true;
1055 : :
1056 : 2646 : subflow->pm_notified = 1;
1057 [ + + ]: 2646 : if (subflow->mp_join) {
1058 : 1198 : clear_3rdack_retransmission(ssk);
1059 : 1198 : mptcp_pm_subflow_established(msk);
1060 : : } else {
1061 : 1448 : mptcp_pm_fully_established(msk, ssk);
1062 : : }
1063 : : return true;
1064 : :
1065 : 8 : reset:
1066 : 8 : mptcp_subflow_reset(ssk);
1067 : 8 : return false;
1068 : : }
1069 : :
1070 : 283290 : u64 __mptcp_expand_seq(u64 old_seq, u64 cur_seq)
1071 : : {
1072 : 283290 : u32 old_seq32, cur_seq32;
1073 : :
1074 : 283290 : old_seq32 = (u32)old_seq;
1075 : 283290 : cur_seq32 = (u32)cur_seq;
1076 : 283290 : cur_seq = (old_seq & GENMASK_ULL(63, 32)) + cur_seq32;
1077 [ + + - + ]: 283290 : if (unlikely(cur_seq32 < old_seq32 && before(old_seq32, cur_seq32)))
1078 : 0 : return cur_seq + (1LL << 32);
1079 : :
1080 : : /* reverse wrap could happen, too */
1081 [ + + - + ]: 283290 : if (unlikely(cur_seq32 > old_seq32 && after(old_seq32, cur_seq32)))
1082 : 0 : return cur_seq - (1LL << 32);
1083 : : return cur_seq;
1084 : : }
1085 : :
1086 : 0 : static void __mptcp_snd_una_update(struct mptcp_sock *msk, u64 new_snd_una)
1087 : : {
1088 : 692792 : msk->bytes_acked += new_snd_una - msk->snd_una;
1089 : 692792 : WRITE_ONCE(msk->snd_una, new_snd_una);
1090 : : }
1091 : :
1092 : 2371252 : static void rwin_update(struct mptcp_sock *msk, struct sock *ssk,
1093 : : struct sk_buff *skb)
1094 : : {
1095 [ - + ]: 2371252 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk);
1096 [ - + ]: 2371252 : struct tcp_sock *tp = tcp_sk(ssk);
1097 : 2371252 : u64 mptcp_rcv_wnd;
1098 : :
1099 : : /* Avoid touching extra cachelines if TCP is going to accept this
1100 : : * skb without filling the TCP-level window even with a possibly
1101 : : * outdated mptcp-level rwin.
1102 : : */
1103 [ + - + + ]: 2371252 : if (!skb->len || skb->len < tcp_receive_window(tp))
1104 : : return;
1105 : :
1106 [ - + ]: 24206 : mptcp_rcv_wnd = atomic64_read(&msk->rcv_wnd_sent);
1107 [ - + ]: 24206 : if (!after64(mptcp_rcv_wnd, subflow->rcv_wnd_sent))
1108 : : return;
1109 : :
1110 : : /* Some other subflow grew the mptcp-level rwin since rcv_wup,
1111 : : * resync.
1112 : : */
1113 : 0 : tp->rcv_wnd += mptcp_rcv_wnd - subflow->rcv_wnd_sent;
1114 [ # # ]: 0 : tcp_update_max_rcv_wnd_seq(tp);
1115 : 0 : subflow->rcv_wnd_sent = mptcp_rcv_wnd;
1116 : : }
1117 : :
1118 : 2370053 : static void ack_update_msk(struct mptcp_sock *msk,
1119 : : struct sock *ssk,
1120 : : struct mptcp_options_received *mp_opt)
1121 : : {
1122 : 2370053 : u64 new_wnd_end, new_snd_una, snd_nxt = READ_ONCE(msk->snd_nxt);
1123 : 2370053 : struct sock *sk = (struct sock *)msk;
1124 : 2370053 : u64 old_snd_una;
1125 : :
1126 : 2370053 : mptcp_data_lock(sk);
1127 : :
1128 : : /* avoid ack expansion on update conflict, to reduce the risk of
1129 : : * wrongly expanding to a future ack sequence number, which is way
1130 : : * more dangerous than missing an ack
1131 : : */
1132 : 2370053 : old_snd_una = msk->snd_una;
1133 [ + + ]: 2370053 : new_snd_una = mptcp_expand_seq(old_snd_una, mp_opt->data_ack, mp_opt->ack64);
1134 : :
1135 : : /* ACK for data not even sent yet? Ignore.*/
1136 [ + + ]: 2370053 : if (unlikely(after64(new_snd_una, snd_nxt)))
1137 : 116 : new_snd_una = old_snd_una;
1138 : :
1139 [ - + ]: 2370053 : new_wnd_end = new_snd_una + tcp_sk(ssk)->snd_wnd;
1140 : :
1141 [ + + ]: 2370053 : if (after64(new_wnd_end, msk->wnd_end))
1142 : 671364 : WRITE_ONCE(msk->wnd_end, new_wnd_end);
1143 : :
1144 : : /* this assumes mptcp_incoming_options() is invoked after tcp_ack() */
1145 [ + + ]: 2370053 : if (after64(msk->wnd_end, snd_nxt))
1146 : 2178965 : __mptcp_check_push(sk, ssk);
1147 : :
1148 [ + + ]: 2370053 : if (after64(new_snd_una, old_snd_una)) {
1149 : 666837 : __mptcp_snd_una_update(msk, new_snd_una);
1150 : 666837 : __mptcp_data_acked(sk);
1151 : : }
1152 : 2370053 : msk->last_ack_recv = tcp_jiffies32;
1153 : 2370053 : mptcp_data_unlock(sk);
1154 : :
1155 : 2370053 : trace_ack_update_msk(mp_opt->data_ack,
1156 : : old_snd_una, new_snd_una,
1157 : 2370053 : new_wnd_end, READ_ONCE(msk->wnd_end));
1158 : 2370053 : }
1159 : :
1160 : 15446 : bool mptcp_update_rcv_data_fin(struct mptcp_sock *msk, u64 data_fin_seq, bool use_64bit)
1161 : : {
1162 : : /* Skip if DATA_FIN was already received.
1163 : : * If updating simultaneously with the recvmsg loop, values
1164 : : * should match. If they mismatch, the peer is misbehaving and
1165 : : * we will prefer the most recent information.
1166 : : */
1167 [ - + + + ]: 15446 : if (READ_ONCE(msk->rcv_data_fin))
[ + + ]
1168 : : return false;
1169 : :
1170 [ + + ]: 3183 : WRITE_ONCE(msk->rcv_data_fin_seq,
1171 : : mptcp_expand_seq(READ_ONCE(msk->ack_seq), data_fin_seq, use_64bit));
1172 : 3183 : WRITE_ONCE(msk->rcv_data_fin, 1);
1173 : :
1174 : 3183 : return true;
1175 : : }
1176 : :
1177 : 837 : static bool add_addr_hmac_valid(struct mptcp_sock *msk,
1178 : : struct mptcp_options_received *mp_opt)
1179 : : {
1180 : 837 : u64 hmac = 0;
1181 : :
1182 [ + + ]: 837 : if (mp_opt->echo)
1183 : : return true;
1184 : :
1185 : 423 : hmac = add_addr_generate_hmac(READ_ONCE(msk->remote_key),
1186 : 423 : READ_ONCE(msk->local_key),
1187 : : &mp_opt->addr);
1188 : :
1189 [ - + - - ]: 423 : pr_debug("msk=%p, ahmac=%llu, mp_opt->ahmac=%llu\n",
1190 : : msk, hmac, mp_opt->ahmac);
1191 : :
1192 : 423 : return hmac == mp_opt->ahmac;
1193 : : }
1194 : :
1195 : : /* Return false in case of error (or subflow has been reset),
1196 : : * else return true.
1197 : : */
1198 : 2400889 : bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)
1199 : : {
1200 [ - + ]: 2400889 : struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
1201 [ - + ]: 2400889 : struct mptcp_sock *msk = mptcp_sk(subflow->conn);
1202 : 2400889 : struct mptcp_options_received mp_opt;
1203 : 2400889 : struct mptcp_ext *mpext;
1204 : :
1205 [ + + ]: 2400889 : if (__mptcp_check_fallback(msk)) {
1206 : : /* Keep it simple and unconditionally trigger send data cleanup and
1207 : : * pending queue spooling. We will need to acquire the data lock
1208 : : * for more accurate checks, and once the lock is acquired, such
1209 : : * helpers are cheap.
1210 : : */
1211 : 25995 : mptcp_data_lock(subflow->conn);
1212 [ + + ]: 25995 : if (sk_stream_memory_free(sk))
1213 : 25986 : __mptcp_check_push(subflow->conn, sk);
1214 : :
1215 : : /* on fallback we just need to ignore the msk-level snd_una, as
1216 : : * this is really plain TCP
1217 : : */
1218 : 25995 : __mptcp_snd_una_update(msk, READ_ONCE(msk->snd_nxt));
1219 : :
1220 : 25995 : __mptcp_data_acked(subflow->conn);
1221 : 25995 : mptcp_data_unlock(subflow->conn);
1222 : 25995 : return true;
1223 : : }
1224 : :
1225 : 2374894 : mptcp_get_options(skb, &mp_opt);
1226 : :
1227 : : /* The subflow can be in close state only if check_fully_established()
1228 : : * just sent a reset. If so, tell the caller to ignore the current packet.
1229 : : */
1230 [ + + ]: 2374894 : if (!check_fully_established(msk, sk, subflow, skb, &mp_opt))
1231 : 64 : return sk->sk_state != TCP_CLOSE;
1232 : :
1233 [ + + ]: 2374830 : if (unlikely(mp_opt.suboptions != OPTION_MPTCP_DSS)) {
1234 [ + + ]: 242969 : if ((mp_opt.suboptions & OPTION_MPTCP_FASTCLOSE) &&
1235 [ + + ]: 263 : READ_ONCE(msk->local_key) == mp_opt.rcvr_key) {
1236 : 253 : WRITE_ONCE(msk->rcv_fastclose, true);
1237 : 253 : mptcp_schedule_work((struct sock *)msk);
1238 [ + - ]: 253 : MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPFASTCLOSERX);
1239 : : }
1240 : :
1241 [ + + + - ]: 243806 : if ((mp_opt.suboptions & OPTION_MPTCP_ADD_ADDR) &&
1242 : 837 : add_addr_hmac_valid(msk, &mp_opt)) {
1243 [ + + ]: 837 : if (!mp_opt.echo) {
1244 : 423 : mptcp_pm_add_addr_received(sk, &mp_opt.addr);
1245 [ + - ]: 423 : MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_ADDADDR);
1246 : : } else {
1247 : 414 : mptcp_pm_add_addr_echoed(msk, &mp_opt.addr);
1248 [ + - ]: 414 : MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_ECHOADD);
1249 : : }
1250 : :
1251 [ + + ]: 837 : if (mp_opt.addr.port)
1252 [ + - ]: 96 : MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_PORTADD);
1253 : : }
1254 : :
1255 [ + + ]: 242969 : if (mp_opt.suboptions & OPTION_MPTCP_RM_ADDR)
1256 : 108 : mptcp_pm_rm_addr_received(msk, &mp_opt.rm_list);
1257 : :
1258 [ + + ]: 242969 : if (mp_opt.suboptions & OPTION_MPTCP_PRIO) {
1259 : 40 : mptcp_pm_mp_prio_received(sk, mp_opt.backup);
1260 [ + - ]: 40 : MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPPRIORX);
1261 : : }
1262 : :
1263 [ + + ]: 242969 : if (mp_opt.suboptions & OPTION_MPTCP_FAIL) {
1264 : 6 : mptcp_pm_mp_fail_received(sk, mp_opt.fail_seq);
1265 [ + - ]: 6 : MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPFAILRX);
1266 : : }
1267 : :
1268 [ + + ]: 242969 : if (mp_opt.suboptions & OPTION_MPTCP_RST) {
1269 : 249 : subflow->reset_seen = 1;
1270 : 249 : subflow->reset_reason = mp_opt.reset_reason;
1271 : 249 : subflow->reset_transient = mp_opt.reset_transient;
1272 [ + - ]: 249 : MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPRSTRX);
1273 : : }
1274 : :
1275 [ + + ]: 242969 : if (!(mp_opt.suboptions & OPTION_MPTCP_DSS))
1276 : : return true;
1277 : : }
1278 : :
1279 : : /* we can't wait for recvmsg() to update the ack_seq, otherwise
1280 : : * monodirectional flows will stuck
1281 : : */
1282 [ + + ]: 2371252 : if (mp_opt.use_ack)
1283 : 2370053 : ack_update_msk(msk, sk, &mp_opt);
1284 : 2371252 : rwin_update(msk, sk, skb);
1285 : :
1286 : : /* Zero-data-length packets are dropped by the caller and not
1287 : : * propagated to the MPTCP layer, so the skb extension does not
1288 : : * need to be allocated or populated. DATA_FIN information, if
1289 : : * present, needs to be updated here before the skb is freed.
1290 : : */
1291 [ + + ]: 2371252 : if (TCP_SKB_CB(skb)->seq == TCP_SKB_CB(skb)->end_seq) {
1292 [ + + + - : 912821 : if (mp_opt.data_fin && mp_opt.data_len == 1 &&
+ + ]
1293 : 12679 : mptcp_update_rcv_data_fin(msk, mp_opt.data_seq, mp_opt.dsn64))
1294 : 2974 : mptcp_schedule_work((struct sock *)msk);
1295 : :
1296 : 900142 : return true;
1297 : : }
1298 : :
1299 : 1471110 : mpext = skb_ext_add(skb, SKB_EXT_MPTCP);
1300 [ + - ]: 1471110 : if (!mpext)
1301 : : return false;
1302 : :
1303 : 1471110 : memset(mpext, 0, sizeof(*mpext));
1304 : :
1305 [ + + ]: 1471110 : if (likely(mp_opt.use_map)) {
1306 [ + + ]: 1468075 : if (mp_opt.mpc_map) {
1307 : : /* this is an MP_CAPABLE carrying MPTCP data
1308 : : * we know this map the first chunk of data
1309 : : */
1310 : 1199 : mptcp_crypto_key_sha(subflow->remote_key, NULL,
1311 : : &mpext->data_seq);
1312 : 1199 : mpext->data_seq++;
1313 : 1199 : mpext->subflow_seq = 1;
1314 : 1199 : mpext->dsn64 = 1;
1315 : 1199 : mpext->mpc_map = 1;
1316 : 1199 : mpext->data_fin = 0;
1317 : : } else {
1318 : 1466876 : mpext->data_seq = mp_opt.data_seq;
1319 : 1466876 : mpext->subflow_seq = mp_opt.subflow_seq;
1320 : 1466876 : mpext->dsn64 = mp_opt.dsn64;
1321 : 1466876 : mpext->data_fin = mp_opt.data_fin;
1322 : : }
1323 : 1468075 : mpext->data_len = mp_opt.data_len;
1324 : 1468075 : mpext->use_map = 1;
1325 : 1468075 : mpext->csum_reqd = !!(mp_opt.suboptions & OPTION_MPTCP_CSUMREQD);
1326 : :
1327 [ + + ]: 1468075 : if (mpext->csum_reqd)
1328 : 236311 : mpext->csum = mp_opt.csum;
1329 : : }
1330 : :
1331 : : return true;
1332 : : }
1333 : :
1334 : 1899457 : static u64 mptcp_set_rwin(struct mptcp_sock *msk, struct tcp_sock *tp,
1335 : : struct tcphdr *th, u64 ack_seq)
1336 : : {
1337 : 1899457 : const struct sock *ssk = (const struct sock *)tp;
1338 : 1899457 : u64 rcv_wnd_old, rcv_wnd_new;
1339 : 1899457 : u32 new_win;
1340 : 1899457 : u64 win;
1341 : :
1342 : 1899457 : rcv_wnd_new = ack_seq + tp->rcv_wnd;
1343 : :
1344 [ + + ]: 1899457 : rcv_wnd_old = atomic64_read(&msk->rcv_wnd_sent);
1345 [ + + ]: 1899457 : if (after64(rcv_wnd_new, rcv_wnd_old)) {
1346 : 70 : u64 rcv_wnd;
1347 : :
1348 : 756243 : for (;;) {
1349 : 756313 : rcv_wnd = atomic64_cmpxchg(&msk->rcv_wnd_sent, rcv_wnd_old, rcv_wnd_new);
1350 : :
1351 [ + + ]: 756243 : if (rcv_wnd == rcv_wnd_old)
1352 : : break;
1353 : :
1354 : 14 : rcv_wnd_old = rcv_wnd;
1355 [ + + ]: 14 : if (before64(rcv_wnd_new, rcv_wnd_old)) {
1356 [ + - ]: 2 : MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_RCVWNDCONFLICTUPDATE);
1357 : 2 : goto raise_win;
1358 : : }
1359 [ - + ]: 82 : MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_RCVWNDCONFLICT);
1360 : : }
1361 : 756229 : goto update_wspace;
1362 : : }
1363 : :
1364 [ + + ]: 1143226 : if (rcv_wnd_new != rcv_wnd_old) {
1365 : 361483 : raise_win:
1366 : : /* The msk-level rcv wnd is after the tcp level one,
1367 : : * sync the latter.
1368 : : */
1369 : 361485 : rcv_wnd_new = rcv_wnd_old;
1370 : 361485 : win = rcv_wnd_old - ack_seq;
1371 : 361485 : new_win = min_t(u64, win, U32_MAX);
1372 : 361485 : tp->rcv_wnd = new_win;
1373 [ + + ]: 361485 : tcp_update_max_rcv_wnd_seq(tp);
1374 : :
1375 : : /* Make sure we do not exceed the maximum possible
1376 : : * scaled window.
1377 : : */
1378 [ - + ]: 361485 : if (unlikely(th->syn))
1379 : 0 : new_win = min(new_win, 65535U) << tp->rx_opt.rcv_wscale;
1380 [ - + ]: 361485 : if (!tp->rx_opt.rcv_wscale &&
[ - + - - ]
1381 [ # # ]: 0 : READ_ONCE(sock_net(ssk)->ipv4.sysctl_tcp_workaround_signed_windows))
1382 : 0 : new_win = min(new_win, MAX_TCP_WINDOW);
1383 : : else
1384 : 361485 : new_win = min(new_win, (65535U << tp->rx_opt.rcv_wscale));
1385 : :
1386 : : /* RFC1323 scaling applied */
1387 : 361485 : new_win >>= tp->rx_opt.rcv_wscale;
1388 : 361485 : th->window = htons(new_win);
1389 [ + - ]: 361485 : MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_RCVWNDSHARED);
1390 : : }
1391 : :
1392 : 781743 : update_wspace:
1393 : 1899457 : WRITE_ONCE(msk->old_wspace, tp->rcv_wnd);
1394 : 1899457 : return rcv_wnd_new;
1395 : : }
1396 : :
1397 : 27911 : static void mptcp_track_rwin(struct tcp_sock *tp)
1398 : : {
1399 : 27911 : const struct sock *ssk = (const struct sock *)tp;
1400 : 27911 : struct mptcp_subflow_context *subflow;
1401 : 27911 : struct mptcp_sock *msk;
1402 : :
1403 [ + - ]: 27911 : if (!ssk)
1404 : : return;
1405 : :
1406 [ - + ]: 27911 : subflow = mptcp_subflow_ctx(ssk);
1407 [ - + ]: 27911 : msk = mptcp_sk(subflow->conn);
1408 : 27911 : WRITE_ONCE(msk->old_wspace, tp->rcv_wnd);
1409 : : }
1410 : :
1411 : 281651 : __sum16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum sum)
1412 : : {
1413 : 281651 : struct csum_pseudo_header header;
1414 : 281651 : __wsum csum;
1415 : :
1416 : : /* cfr RFC 8684 3.3.1.:
1417 : : * the data sequence number used in the pseudo-header is
1418 : : * always the 64-bit value, irrespective of what length is used in the
1419 : : * DSS option itself.
1420 : : */
1421 : 281651 : header.data_seq = cpu_to_be64(data_seq);
1422 : 281651 : header.subflow_seq = htonl(subflow_seq);
1423 : 281651 : header.data_len = htons(data_len);
1424 : 281651 : header.csum = 0;
1425 : :
1426 : 281651 : csum = csum_partial(&header, sizeof(header), sum);
1427 : 281651 : return csum_fold(csum);
1428 : : }
1429 : :
1430 : 187766 : static __sum16 mptcp_make_csum(const struct mptcp_ext *mpext)
1431 : : {
1432 : 375532 : return __mptcp_make_csum(mpext->data_seq, mpext->subflow_seq, mpext->data_len,
1433 : 187766 : ~csum_unfold(mpext->csum));
1434 : : }
1435 : :
1436 : 0 : static void put_len_csum(u16 len, __sum16 csum, void *data)
1437 : : {
1438 : 187870 : __sum16 *sumptr = data + 2;
1439 : 187870 : __be16 *ptr = data;
1440 : :
1441 : 187870 : put_unaligned_be16(len, ptr);
1442 : :
1443 : 187870 : put_unaligned(csum, sumptr);
1444 : 187870 : }
1445 : :
1446 : 1936607 : void mptcp_write_options(struct tcphdr *th, __be32 *ptr, struct tcp_sock *tp,
1447 : : struct mptcp_out_options *opts)
1448 : : {
1449 : 1936607 : const struct sock *ssk = (const struct sock *)tp;
1450 : 1936607 : struct mptcp_subflow_context *subflow;
1451 : :
1452 : : /* Which options can be used together?
1453 : : *
1454 : : * X: mutually exclusive
1455 : : * O: often used together
1456 : : * C: can be used together in some cases
1457 : : * P: could be used together but we prefer not to (optimisations)
1458 : : *
1459 : : * Opt: | MPC | MPJ | DSS | ADD | RM | PRIO | FAIL | FC |
1460 : : * ------|------|------|------|------|------|------|------|------|
1461 : : * MPC |------|------|------|------|------|------|------|------|
1462 : : * MPJ | X |------|------|------|------|------|------|------|
1463 : : * DSS | X | X |------|------|------|------|------|------|
1464 : : * ADD | X | X | P |------|------|------|------|------|
1465 : : * RM | C | C | C | P |------|------|------|------|
1466 : : * PRIO | X | C | C | C | C |------|------|------|
1467 : : * FAIL | X | X | C | X | X | X |------|------|
1468 : : * FC | X | X | P | X | X | X | X |------|
1469 : : * RST | X | X | X | X | X | X | O | O |
1470 : : * ------|------|------|------|------|------|------|------|------|
1471 : : *
1472 : : * The same applies in mptcp_established_options() function.
1473 : : */
1474 [ + + ]: 1936607 : if (likely(OPTION_MPTCP_DSS & opts->suboptions)) {
1475 : 1899457 : struct mptcp_ext *mpext = &opts->ext_copy;
1476 : 1899457 : u8 len = TCPOLEN_MPTCP_DSS_BASE;
1477 : 1899457 : u8 flags = 0;
1478 : :
1479 [ + - ]: 1899457 : if (mpext->use_ack) {
1480 : 1899457 : flags = MPTCP_DSS_HAS_ACK;
1481 [ + + ]: 1899457 : if (mpext->ack64) {
1482 : : len += TCPOLEN_MPTCP_DSS_ACK64;
1483 : : flags |= MPTCP_DSS_ACK64;
1484 : : } else {
1485 : 80483 : len += TCPOLEN_MPTCP_DSS_ACK32;
1486 : : }
1487 : : }
1488 : :
1489 [ + + ]: 1899457 : if (mpext->use_map) {
1490 : 949039 : len += TCPOLEN_MPTCP_DSS_MAP64;
1491 : :
1492 : : /* Use only 64-bit mapping flags for now, add
1493 : : * support for optional 32-bit mappings later.
1494 : : */
1495 : 949039 : flags |= MPTCP_DSS_HAS_MAP | MPTCP_DSS_DSN64;
1496 [ + + ]: 949039 : if (mpext->data_fin)
1497 : 16201 : flags |= MPTCP_DSS_DATA_FIN;
1498 : :
1499 [ + + ]: 949039 : if (opts->csum_reqd)
1500 : 187768 : len += TCPOLEN_MPTCP_DSS_CHECKSUM;
1501 : : }
1502 : :
1503 [ + - ]: 1899457 : *ptr++ = mptcp_option(MPTCPOPT_DSS, len, 0, flags);
1504 : :
1505 [ + - ]: 1899457 : if (mpext->use_ack) {
1506 : 1899457 : struct mptcp_sock *msk;
1507 : 1899457 : u64 ack_seq;
1508 : :
1509 : : /* DSS option is set only by mptcp_established_options,
1510 : : * the caller is __tcp_transmit_skb() and ssk is always
1511 : : * not NULL.
1512 : : */
1513 [ - + ]: 1899457 : subflow = mptcp_subflow_ctx(ssk);
1514 [ - + ]: 1899457 : msk = mptcp_sk(subflow->conn);
1515 : 1899457 : ack_seq = READ_ONCE(msk->ack_seq);
1516 [ + + ]: 1899457 : if (mpext->ack64) {
1517 : 1818974 : put_unaligned_be64(ack_seq, ptr);
1518 : 1818974 : ptr += 2;
1519 : : } else {
1520 : 80483 : put_unaligned_be32(ack_seq, ptr);
1521 : 80483 : ptr += 1;
1522 : : }
1523 : 1899457 : subflow->rcv_wnd_sent = mptcp_set_rwin(msk, tp, th,
1524 : : ack_seq);
1525 : : }
1526 : :
1527 [ + + ]: 1899457 : if (mpext->use_map) {
1528 [ + + ]: 949039 : put_unaligned_be64(mpext->data_seq, ptr);
1529 : 949039 : ptr += 2;
1530 [ + + ]: 949039 : put_unaligned_be32(mpext->subflow_seq, ptr);
1531 : 949039 : ptr += 1;
1532 [ + + ]: 949039 : if (opts->csum_reqd) {
1533 : : /* data_len == 0 is reserved for the infinite mapping,
1534 : : * the checksum will also be set to 0.
1535 : : */
1536 : 187768 : put_len_csum(mpext->data_len,
1537 [ + + ]: 187768 : (mpext->data_len ? mptcp_make_csum(mpext) : 0),
1538 : : ptr);
1539 : : } else {
1540 : 761271 : put_unaligned_be32(mpext->data_len << 16 |
1541 : 761271 : TCPOPT_NOP << 8 | TCPOPT_NOP, ptr);
1542 : : }
1543 : 949039 : ptr += 1;
1544 : : }
1545 : :
1546 : : /* We might need to add MP_FAIL options in rare cases */
1547 [ + + ]: 1899457 : if (unlikely(OPTION_MPTCP_FAIL & opts->suboptions))
1548 : 4 : goto mp_fail;
1549 [ + + ]: 37150 : } else if (OPTIONS_MPTCP_MPC & opts->suboptions) {
1550 : 5904 : u8 len, flag = MPTCP_CAP_HMAC_SHA256;
1551 : :
1552 [ + + ]: 5904 : if (OPTION_MPTCP_MPC_SYN & opts->suboptions) {
1553 : : len = TCPOLEN_MPTCP_MPC_SYN;
1554 [ + + ]: 4165 : } else if (OPTION_MPTCP_MPC_SYNACK & opts->suboptions) {
1555 : : len = TCPOLEN_MPTCP_MPC_SYNACK;
1556 [ + + ]: 2511 : } else if (opts->data_len) {
1557 : 1040 : len = TCPOLEN_MPTCP_MPC_ACK_DATA;
1558 [ + + ]: 1040 : if (opts->csum_reqd)
1559 : 102 : len += TCPOLEN_MPTCP_DSS_CHECKSUM;
1560 : : } else {
1561 : : len = TCPOLEN_MPTCP_MPC_ACK;
1562 : : }
1563 : :
1564 [ + + ]: 5904 : if (opts->csum_reqd)
1565 : 477 : flag |= MPTCP_CAP_CHECKSUM_REQD;
1566 : :
1567 [ + + ]: 5904 : if (!opts->allow_join_id0)
1568 : 36 : flag |= MPTCP_CAP_DENY_JOIN_ID0;
1569 : :
1570 [ + + ]: 5904 : *ptr++ = mptcp_option(MPTCPOPT_MP_CAPABLE, len,
1571 : : MPTCP_SUPPORTED_VERSION,
1572 : : flag);
1573 : :
1574 : 5904 : if (!((OPTION_MPTCP_MPC_SYNACK | OPTION_MPTCP_MPC_ACK) &
1575 [ + + ]: 5904 : opts->suboptions))
1576 : 1739 : goto mp_capable_done;
1577 : :
1578 [ + + ]: 4165 : put_unaligned_be64(opts->sndr_key, ptr);
1579 : 4165 : ptr += 2;
1580 [ + + ]: 4165 : if (!((OPTION_MPTCP_MPC_ACK) & opts->suboptions))
1581 : 1654 : goto mp_capable_done;
1582 : :
1583 [ + + ]: 2511 : put_unaligned_be64(opts->rcvr_key, ptr);
1584 : 2511 : ptr += 2;
1585 [ + + ]: 2511 : if (!opts->data_len)
1586 : 1471 : goto mp_capable_done;
1587 : :
1588 [ + + ]: 1040 : if (opts->csum_reqd) {
1589 : 102 : put_len_csum(opts->data_len,
1590 : 102 : __mptcp_make_csum(opts->data_seq,
1591 : : opts->subflow_seq,
1592 : : opts->data_len,
1593 : 102 : ~csum_unfold(opts->csum)),
1594 : : ptr);
1595 : : } else {
1596 : 938 : put_unaligned_be32(opts->data_len << 16 |
1597 : 938 : TCPOPT_NOP << 8 | TCPOPT_NOP, ptr);
1598 : : }
1599 : 1040 : ptr += 1;
1600 : :
1601 : : /* MPC is additionally mutually exclusive with MP_PRIO */
1602 : 1040 : goto mp_capable_done;
1603 [ + + ]: 31246 : } else if (OPTIONS_MPTCP_MPJ & opts->suboptions) {
1604 [ + + ]: 1932 : if (OPTION_MPTCP_MPJ_SYN & opts->suboptions) {
1605 : 703 : *ptr++ = mptcp_option(MPTCPOPT_MP_JOIN,
1606 : : TCPOLEN_MPTCP_MPJ_SYN,
1607 : 703 : opts->backup, opts->join_id);
1608 : 703 : put_unaligned_be32(opts->token, ptr);
1609 : 703 : ptr += 1;
1610 : 703 : put_unaligned_be32(opts->nonce, ptr);
1611 : 703 : ptr += 1;
1612 [ + + ]: 1229 : } else if (OPTION_MPTCP_MPJ_SYNACK & opts->suboptions) {
1613 : 622 : *ptr++ = mptcp_option(MPTCPOPT_MP_JOIN,
1614 : : TCPOLEN_MPTCP_MPJ_SYNACK,
1615 : 622 : opts->backup, opts->join_id);
1616 : 622 : put_unaligned_be64(opts->thmac, ptr);
1617 : 622 : ptr += 2;
1618 : 622 : put_unaligned_be32(opts->nonce, ptr);
1619 : 622 : ptr += 1;
1620 : : } else {
1621 : 607 : *ptr++ = mptcp_option(MPTCPOPT_MP_JOIN,
1622 : : TCPOLEN_MPTCP_MPJ_ACK, 0, 0);
1623 : 607 : memcpy(ptr, opts->hmac, MPTCPOPT_HMAC_LEN);
1624 : 607 : ptr += 5;
1625 : : }
1626 [ + + ]: 29314 : } else if (OPTION_MPTCP_ADD_ADDR & opts->suboptions) {
1627 : 901 : u8 len = TCPOLEN_MPTCP_ADD_ADDR_BASE;
1628 : 901 : u8 echo = MPTCP_ADDR_ECHO;
1629 : :
1630 : : #if IS_ENABLED(CONFIG_MPTCP_IPV6)
1631 [ + + ]: 901 : if (opts->addr.family == AF_INET6)
1632 : 208 : len = TCPOLEN_MPTCP_ADD_ADDR6_BASE;
1633 : : #endif
1634 : :
1635 [ + + ]: 901 : if (opts->addr.port)
1636 : 96 : len += TCPOLEN_MPTCP_PORT_LEN;
1637 : :
1638 [ + + ]: 901 : if (opts->ahmac) {
1639 : 491 : len += sizeof(opts->ahmac);
1640 : 491 : echo = 0;
1641 : : }
1642 : :
1643 : 901 : *ptr++ = mptcp_option(MPTCPOPT_ADD_ADDR,
1644 [ + + ]: 901 : len, echo, opts->addr.id);
1645 [ + + ]: 901 : if (opts->addr.family == AF_INET) {
1646 : 693 : memcpy((u8 *)ptr, (u8 *)&opts->addr.addr.s_addr, 4);
1647 : 693 : ptr += 1;
1648 : : }
1649 : : #if IS_ENABLED(CONFIG_MPTCP_IPV6)
1650 [ + - ]: 208 : else if (opts->addr.family == AF_INET6) {
1651 : 208 : memcpy((u8 *)ptr, opts->addr.addr6.s6_addr, 16);
1652 : 208 : ptr += 4;
1653 : : }
1654 : : #endif
1655 : :
1656 [ + + ]: 901 : if (!opts->addr.port) {
1657 [ + + ]: 805 : if (opts->ahmac) {
1658 : 437 : put_unaligned_be64(opts->ahmac, ptr);
1659 : 437 : ptr += 2;
1660 : : }
1661 : : } else {
1662 : 96 : u16 port = ntohs(opts->addr.port);
1663 : :
1664 [ + + ]: 96 : if (opts->ahmac) {
1665 : 54 : u8 *bptr = (u8 *)ptr;
1666 : :
1667 : 54 : put_unaligned_be16(port, bptr);
1668 : 54 : bptr += 2;
1669 : 54 : put_unaligned_be64(opts->ahmac, bptr);
1670 : 54 : bptr += 8;
1671 : 54 : put_unaligned_be16(TCPOPT_NOP << 8 |
1672 : : TCPOPT_NOP, bptr);
1673 : :
1674 : 54 : ptr += 3;
1675 : : } else {
1676 : 42 : put_unaligned_be32(port << 16 |
1677 : 42 : TCPOPT_NOP << 8 |
1678 : : TCPOPT_NOP, ptr);
1679 : 42 : ptr += 1;
1680 : : }
1681 : : }
1682 [ + + ]: 28413 : } else if (unlikely(OPTION_MPTCP_FASTCLOSE & opts->suboptions)) {
1683 : : /* FASTCLOSE is mutually exclusive with others except RST */
1684 : 446 : *ptr++ = mptcp_option(MPTCPOPT_MP_FASTCLOSE,
1685 : : TCPOLEN_MPTCP_FASTCLOSE,
1686 : : 0, 0);
1687 [ + - ]: 446 : put_unaligned_be64(opts->rcvr_key, ptr);
1688 : 446 : ptr += 2;
1689 : :
1690 [ + - ]: 446 : if (OPTION_MPTCP_RST & opts->suboptions)
1691 : 446 : goto mp_rst;
1692 : : return;
1693 [ + + ]: 27967 : } else if (unlikely(OPTION_MPTCP_FAIL & opts->suboptions)) {
1694 : 2 : mp_fail:
1695 : : /* MP_FAIL is mutually exclusive with others except RST */
1696 [ + + ]: 6 : subflow = mptcp_subflow_ctx(ssk);
1697 : 6 : subflow->send_mp_fail = 0;
1698 : :
1699 : 6 : *ptr++ = mptcp_option(MPTCPOPT_MP_FAIL,
1700 : : TCPOLEN_MPTCP_FAIL,
1701 : : 0, 0);
1702 [ + + ]: 6 : put_unaligned_be64(opts->fail_seq, ptr);
1703 : 6 : ptr += 2;
1704 : :
1705 [ + + ]: 6 : if (OPTION_MPTCP_RST & opts->suboptions)
1706 : 2 : goto mp_rst;
1707 : : return;
1708 [ + + ]: 27965 : } else if (unlikely(OPTION_MPTCP_RST & opts->suboptions)) {
1709 : 54 : mp_rst:
1710 : 502 : *ptr++ = mptcp_option(MPTCPOPT_RST,
1711 : : TCPOLEN_MPTCP_RST,
1712 : 502 : opts->reset_transient,
1713 : 502 : opts->reset_reason);
1714 : 502 : return;
1715 [ + - ]: 27911 : } else if (unlikely(!opts->suboptions)) {
1716 : : /* Fallback to TCP */
1717 : 27911 : mptcp_track_rwin(tp);
1718 : 27911 : return;
1719 : : }
1720 : :
1721 [ + + ]: 1902286 : if (OPTION_MPTCP_PRIO & opts->suboptions) {
1722 [ + - ]: 28 : subflow = mptcp_subflow_ctx(ssk);
1723 : 28 : subflow->send_mp_prio = 0;
1724 : :
1725 : 28 : *ptr++ = mptcp_option(MPTCPOPT_MP_PRIO,
1726 : : TCPOLEN_MPTCP_PRIO,
1727 [ + - ]: 28 : opts->backup, TCPOPT_NOP);
1728 : :
1729 [ + - ]: 28 : MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_MPPRIOTX);
1730 : : }
1731 : :
1732 : 1902258 : mp_capable_done:
1733 [ + + ]: 1908190 : if (OPTION_MPTCP_RM_ADDR & opts->suboptions) {
1734 : 114 : u8 i = 1;
1735 : :
1736 : 114 : *ptr++ = mptcp_option(MPTCPOPT_RM_ADDR,
1737 : 114 : TCPOLEN_MPTCP_RM_ADDR_BASE + opts->rm_list.nr,
1738 : 114 : 0, opts->rm_list.ids[0]);
1739 : :
1740 [ + + ]: 118 : while (i < opts->rm_list.nr) {
1741 : 4 : u8 id1, id2, id3, id4;
1742 : :
1743 : 4 : id1 = opts->rm_list.ids[i];
1744 [ + - ]: 4 : id2 = i + 1 < opts->rm_list.nr ? opts->rm_list.ids[i + 1] : TCPOPT_NOP;
1745 [ - + ]: 4 : id3 = i + 2 < opts->rm_list.nr ? opts->rm_list.ids[i + 2] : TCPOPT_NOP;
1746 [ - + ]: 4 : id4 = i + 3 < opts->rm_list.nr ? opts->rm_list.ids[i + 3] : TCPOPT_NOP;
1747 : 4 : put_unaligned_be32(id1 << 24 | id2 << 16 | id3 << 8 | id4, ptr);
1748 : 4 : ptr += 1;
1749 : 4 : i += 4;
1750 : : }
1751 : : }
1752 : : }
1753 : :
1754 : 16 : __be32 mptcp_get_reset_option(const struct sk_buff *skb)
1755 : : {
1756 [ + - ]: 16 : const struct mptcp_ext *ext = mptcp_get_ext(skb);
1757 : 16 : u8 flags, reason;
1758 : :
1759 [ + - ]: 16 : if (ext) {
1760 : 16 : flags = ext->reset_transient;
1761 : 16 : reason = ext->reset_reason;
1762 : :
1763 : 16 : return mptcp_option(MPTCPOPT_RST, TCPOLEN_MPTCP_RST,
1764 : : flags, reason);
1765 : : }
1766 : :
1767 : : return htonl(0u);
1768 : : }
1769 : : EXPORT_SYMBOL_GPL(mptcp_get_reset_option);
|