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