.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * INET An implementation of the TCP/IP protocol suite for the LINUX |
---|
3 | 4 | * operating system. INET is implemented using the BSD Socket |
---|
.. | .. |
---|
8 | 9 | * Version: @(#)tcp.h 1.0.2 04/28/93 |
---|
9 | 10 | * |
---|
10 | 11 | * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> |
---|
11 | | - * |
---|
12 | | - * This program is free software; you can redistribute it and/or |
---|
13 | | - * modify it under the terms of the GNU General Public License |
---|
14 | | - * as published by the Free Software Foundation; either version |
---|
15 | | - * 2 of the License, or (at your option) any later version. |
---|
16 | 12 | */ |
---|
17 | 13 | #ifndef _LINUX_TCP_H |
---|
18 | 14 | #define _LINUX_TCP_H |
---|
.. | .. |
---|
20 | 16 | |
---|
21 | 17 | #include <linux/skbuff.h> |
---|
22 | 18 | #include <linux/win_minmax.h> |
---|
| 19 | +#include <linux/android_kabi.h> |
---|
23 | 20 | #include <net/sock.h> |
---|
24 | 21 | #include <net/inet_connection_sock.h> |
---|
25 | 22 | #include <net/inet_timewait_sock.h> |
---|
.. | .. |
---|
62 | 59 | |
---|
63 | 60 | /* TCP Fast Open Cookie as stored in memory */ |
---|
64 | 61 | struct tcp_fastopen_cookie { |
---|
65 | | - union { |
---|
66 | | - u8 val[TCP_FASTOPEN_COOKIE_MAX]; |
---|
67 | | -#if IS_ENABLED(CONFIG_IPV6) |
---|
68 | | - struct in6_addr addr; |
---|
69 | | -#endif |
---|
70 | | - }; |
---|
| 62 | + __le64 val[DIV_ROUND_UP(TCP_FASTOPEN_COOKIE_MAX, sizeof(u64))]; |
---|
71 | 63 | s8 len; |
---|
72 | 64 | bool exp; /* In RFC6994 experimental option format */ |
---|
73 | 65 | }; |
---|
.. | .. |
---|
101 | 93 | smc_ok : 1, /* SMC seen on SYN packet */ |
---|
102 | 94 | snd_wscale : 4, /* Window scaling received from sender */ |
---|
103 | 95 | rcv_wscale : 4; /* Window scaling to send to receiver */ |
---|
| 96 | + u8 saw_unknown:1, /* Received unknown option */ |
---|
| 97 | + unused:7; |
---|
104 | 98 | u8 num_sacks; /* Number of SACK blocks */ |
---|
105 | 99 | u16 user_mss; /* mss requested by user in ioctl */ |
---|
106 | 100 | u16 mss_clamp; /* Maximal mss, negotiated at connection setup */ |
---|
.. | .. |
---|
128 | 122 | const struct tcp_request_sock_ops *af_specific; |
---|
129 | 123 | u64 snt_synack; /* first SYNACK sent time */ |
---|
130 | 124 | bool tfo_listener; |
---|
| 125 | + bool is_mptcp; |
---|
| 126 | +#if IS_ENABLED(CONFIG_MPTCP) |
---|
| 127 | + bool drop_req; |
---|
| 128 | +#endif |
---|
131 | 129 | u32 txhash; |
---|
132 | 130 | u32 rcv_isn; |
---|
133 | 131 | u32 snt_isn; |
---|
.. | .. |
---|
137 | 135 | * FastOpen it's the seq# |
---|
138 | 136 | * after data-in-SYN. |
---|
139 | 137 | */ |
---|
| 138 | + u8 syn_tos; |
---|
140 | 139 | }; |
---|
141 | 140 | |
---|
142 | 141 | static inline struct tcp_request_sock *tcp_rsk(const struct request_sock *req) |
---|
.. | .. |
---|
225 | 224 | } rack; |
---|
226 | 225 | u16 advmss; /* Advertised MSS */ |
---|
227 | 226 | u8 compressed_ack; |
---|
228 | | - u8 tlp_retrans:1, /* TLP is a retransmission */ |
---|
229 | | - unused_1:7; |
---|
| 227 | + u8 dup_ack_counter:2, |
---|
| 228 | + tlp_retrans:1, /* TLP is a retransmission */ |
---|
| 229 | + unused:5; |
---|
230 | 230 | u32 chrono_start; /* Start time in jiffies of a TCP chrono */ |
---|
231 | 231 | u32 chrono_stat[3]; /* Time in jiffies for chrono_stat stats */ |
---|
232 | 232 | u8 chrono_type:2, /* current chronograph type */ |
---|
.. | .. |
---|
234 | 234 | fastopen_connect:1, /* FASTOPEN_CONNECT sockopt */ |
---|
235 | 235 | fastopen_no_cookie:1, /* Allow send/recv SYN+data without a cookie */ |
---|
236 | 236 | is_sack_reneg:1, /* in recovery from loss with SACK reneg? */ |
---|
237 | | - unused:2; |
---|
| 237 | + fastopen_client_fail:2; /* reason why fastopen failed */ |
---|
238 | 238 | u8 nonagle : 4,/* Disable Nagle algorithm? */ |
---|
239 | 239 | thin_lto : 1,/* Use linear timeouts for thin streams */ |
---|
240 | 240 | recvmsg_inq : 1,/* Indicate # of bytes in queue upon recvmsg */ |
---|
241 | 241 | repair : 1, |
---|
242 | 242 | frto : 1;/* F-RTO (RFC5682) activated in CA_Loss */ |
---|
243 | 243 | u8 repair_queue; |
---|
244 | | - u8 syn_data:1, /* SYN includes data */ |
---|
| 244 | + u8 save_syn:2, /* Save headers of SYN packet */ |
---|
| 245 | + syn_data:1, /* SYN includes data */ |
---|
245 | 246 | syn_fastopen:1, /* SYN includes Fast Open option */ |
---|
246 | 247 | syn_fastopen_exp:1,/* SYN includes Fast Open exp. option */ |
---|
247 | 248 | syn_fastopen_ch:1, /* Active TFO re-enabling probe */ |
---|
248 | 249 | syn_data_acked:1,/* data in SYN is acked by SYN-ACK */ |
---|
249 | | - save_syn:1, /* Save headers of SYN packet */ |
---|
250 | | - is_cwnd_limited:1,/* forward progress limited by snd_cwnd? */ |
---|
251 | | - syn_smc:1; /* SYN includes SMC */ |
---|
| 250 | + is_cwnd_limited:1;/* forward progress limited by snd_cwnd? */ |
---|
252 | 251 | u32 tlp_high_seq; /* snd_nxt at the time of TLP */ |
---|
| 252 | + |
---|
| 253 | + u32 tcp_tx_delay; /* delay (in usec) added to TX packets */ |
---|
| 254 | + u64 tcp_wstamp_ns; /* departure time for next sent data packet */ |
---|
| 255 | + u64 tcp_clock_cache; /* cache last tcp_clock_ns() (see tcp_mstamp_refresh()) */ |
---|
253 | 256 | |
---|
254 | 257 | /* RTT measurement */ |
---|
255 | 258 | u64 tcp_mstamp; /* most recent packet received/sent */ |
---|
.. | .. |
---|
263 | 266 | u32 packets_out; /* Packets which are "in flight" */ |
---|
264 | 267 | u32 retrans_out; /* Retransmitted packets out */ |
---|
265 | 268 | u32 max_packets_out; /* max packets_out in last window */ |
---|
| 269 | +/* GENKSYMS hack to preserve the ABI because of f4ce91ce12a7 ("tcp: fix |
---|
| 270 | + * tcp_cwnd_validate() to not forget is_cwnd_limited") |
---|
| 271 | + */ |
---|
| 272 | +#ifndef __GENKSYMS__ |
---|
| 273 | + u32 cwnd_usage_seq; /* right edge of cwnd usage tracking flight */ |
---|
| 274 | +#else |
---|
266 | 275 | u32 max_packets_seq; /* right edge of max_packets_out flight */ |
---|
| 276 | +#endif |
---|
267 | 277 | |
---|
268 | 278 | u16 urg_data; /* Saved octet of OOB data and control flags */ |
---|
269 | 279 | u8 ecn_flags; /* ECN status bits. */ |
---|
.. | .. |
---|
361 | 371 | #define BPF_SOCK_OPS_TEST_FLAG(TP, ARG) 0 |
---|
362 | 372 | #endif |
---|
363 | 373 | |
---|
| 374 | + u16 timeout_rehash; /* Timeout-triggered rehash attempts */ |
---|
| 375 | + |
---|
| 376 | + u32 rcv_ooopack; /* Received out-of-order packets, for tcpinfo */ |
---|
| 377 | + |
---|
364 | 378 | /* Receiver side RTT estimation */ |
---|
365 | 379 | u32 rcv_rtt_last_tsecr; |
---|
366 | 380 | struct { |
---|
.. | .. |
---|
384 | 398 | u32 mtu_info; /* We received an ICMP_FRAG_NEEDED / ICMPV6_PKT_TOOBIG |
---|
385 | 399 | * while socket was owned by user. |
---|
386 | 400 | */ |
---|
| 401 | +#if IS_ENABLED(CONFIG_MPTCP) |
---|
| 402 | + bool is_mptcp; |
---|
| 403 | +#endif |
---|
| 404 | +#if IS_ENABLED(CONFIG_SMC) |
---|
| 405 | + bool syn_smc; /* SYN includes SMC */ |
---|
| 406 | +#endif |
---|
387 | 407 | |
---|
388 | 408 | #ifdef CONFIG_TCP_MD5SIG |
---|
389 | 409 | /* TCP AF-Specific parts; only used by MD5 Signature support so far */ |
---|
.. | .. |
---|
398 | 418 | /* fastopen_rsk points to request_sock that resulted in this big |
---|
399 | 419 | * socket. Used to retransmit SYNACKs etc. |
---|
400 | 420 | */ |
---|
401 | | - struct request_sock *fastopen_rsk; |
---|
402 | | - u32 *saved_syn; |
---|
| 421 | + struct request_sock __rcu *fastopen_rsk; |
---|
| 422 | + struct saved_syn *saved_syn; |
---|
| 423 | + |
---|
| 424 | + ANDROID_KABI_RESERVE(1); |
---|
403 | 425 | }; |
---|
404 | 426 | |
---|
405 | 427 | enum tsq_enum { |
---|
.. | .. |
---|
439 | 461 | u32 tw_last_oow_ack_time; |
---|
440 | 462 | |
---|
441 | 463 | int tw_ts_recent_stamp; |
---|
| 464 | + u32 tw_tx_delay; |
---|
442 | 465 | #ifdef CONFIG_TCP_MD5SIG |
---|
443 | 466 | struct tcp_md5sig_key *tw_md5_key; |
---|
444 | 467 | #endif |
---|
.. | .. |
---|
451 | 474 | |
---|
452 | 475 | static inline bool tcp_passive_fastopen(const struct sock *sk) |
---|
453 | 476 | { |
---|
454 | | - return (sk->sk_state == TCP_SYN_RECV && |
---|
455 | | - tcp_sk(sk)->fastopen_rsk != NULL); |
---|
| 477 | + return sk->sk_state == TCP_SYN_RECV && |
---|
| 478 | + rcu_access_pointer(tcp_sk(sk)->fastopen_rsk) != NULL; |
---|
456 | 479 | } |
---|
457 | 480 | |
---|
458 | 481 | static inline void fastopen_queue_tune(struct sock *sk, int backlog) |
---|
.. | .. |
---|
460 | 483 | struct request_sock_queue *queue = &inet_csk(sk)->icsk_accept_queue; |
---|
461 | 484 | int somaxconn = READ_ONCE(sock_net(sk)->core.sysctl_somaxconn); |
---|
462 | 485 | |
---|
463 | | - queue->fastopenq.max_qlen = min_t(unsigned int, backlog, somaxconn); |
---|
| 486 | + WRITE_ONCE(queue->fastopenq.max_qlen, min_t(unsigned int, backlog, somaxconn)); |
---|
464 | 487 | } |
---|
465 | 488 | |
---|
466 | 489 | static inline void tcp_move_syn(struct tcp_sock *tp, |
---|
.. | .. |
---|
476 | 499 | tp->saved_syn = NULL; |
---|
477 | 500 | } |
---|
478 | 501 | |
---|
479 | | -struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk); |
---|
| 502 | +static inline u32 tcp_saved_syn_len(const struct saved_syn *saved_syn) |
---|
| 503 | +{ |
---|
| 504 | + return saved_syn->mac_hdrlen + saved_syn->network_hdrlen + |
---|
| 505 | + saved_syn->tcp_hdrlen; |
---|
| 506 | +} |
---|
| 507 | + |
---|
| 508 | +struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk, |
---|
| 509 | + const struct sk_buff *orig_skb); |
---|
480 | 510 | |
---|
481 | 511 | static inline u16 tcp_mss_clamp(const struct tcp_sock *tp, u16 mss) |
---|
482 | 512 | { |
---|
.. | .. |
---|
491 | 521 | int tcp_skb_shift(struct sk_buff *to, struct sk_buff *from, int pcount, |
---|
492 | 522 | int shiftlen); |
---|
493 | 523 | |
---|
| 524 | +void tcp_sock_set_cork(struct sock *sk, bool on); |
---|
| 525 | +int tcp_sock_set_keepcnt(struct sock *sk, int val); |
---|
| 526 | +int tcp_sock_set_keepidle_locked(struct sock *sk, int val); |
---|
| 527 | +int tcp_sock_set_keepidle(struct sock *sk, int val); |
---|
| 528 | +int tcp_sock_set_keepintvl(struct sock *sk, int val); |
---|
| 529 | +void tcp_sock_set_nodelay(struct sock *sk); |
---|
| 530 | +void tcp_sock_set_quickack(struct sock *sk, int val); |
---|
| 531 | +int tcp_sock_set_syncnt(struct sock *sk, int val); |
---|
| 532 | +void tcp_sock_set_user_timeout(struct sock *sk, u32 val); |
---|
| 533 | + |
---|
494 | 534 | #endif /* _LINUX_TCP_H */ |
---|