Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * INET An implementation of the TCP/IP protocol suite for the LINUX |
| 3 | * operating system. INET is implemented using the BSD Socket |
| 4 | * interface as the means of communication with the user level. |
| 5 | * |
| 6 | * Implementation of the Transmission Control Protocol(TCP). |
| 7 | * |
Jesper Juhl | 02c30a8 | 2005-05-05 16:16:16 -0700 | [diff] [blame] | 8 | * Authors: Ross Biro |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> |
| 10 | * Mark Evans, <evansmp@uhura.aston.ac.uk> |
| 11 | * Corey Minyard <wf-rch!minyard@relay.EU.net> |
| 12 | * Florian La Roche, <flla@stud.uni-sb.de> |
| 13 | * Charles Hedrick, <hedrick@klinzhai.rutgers.edu> |
| 14 | * Linus Torvalds, <torvalds@cs.helsinki.fi> |
| 15 | * Alan Cox, <gw4pts@gw4pts.ampr.org> |
| 16 | * Matthew Dillon, <dillon@apollo.west.oic.com> |
| 17 | * Arnt Gulbrandsen, <agulbra@nvg.unit.no> |
| 18 | * Jorge Cwik, <jorge@laser.satlink.net> |
| 19 | */ |
| 20 | |
| 21 | #include <linux/module.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 22 | #include <linux/gfp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <net/tcp.h> |
| 24 | |
Wei Yongjun | 5547720 | 2018-07-25 06:06:07 +0000 | [diff] [blame] | 25 | static u32 tcp_retransmit_stamp(const struct sock *sk) |
Jon Maxwell | a7fa377 | 2018-07-19 11:14:43 +1000 | [diff] [blame] | 26 | { |
| 27 | u32 start_ts = tcp_sk(sk)->retrans_stamp; |
| 28 | |
| 29 | if (unlikely(!start_ts)) { |
| 30 | struct sk_buff *head = tcp_rtx_queue_head(sk); |
| 31 | |
| 32 | if (!head) |
| 33 | return 0; |
| 34 | start_ts = tcp_skb_timestamp(head); |
| 35 | } |
| 36 | return start_ts; |
| 37 | } |
| 38 | |
Jon Maxwell | b701a99 | 2018-07-19 11:14:44 +1000 | [diff] [blame] | 39 | static u32 tcp_clamp_rto_to_user_timeout(const struct sock *sk) |
| 40 | { |
| 41 | struct inet_connection_sock *icsk = inet_csk(sk); |
| 42 | u32 elapsed, start_ts; |
Eric Dumazet | 9efdda4 | 2018-11-24 09:12:24 -0800 | [diff] [blame^] | 43 | s32 remaining; |
Jon Maxwell | b701a99 | 2018-07-19 11:14:44 +1000 | [diff] [blame] | 44 | |
| 45 | start_ts = tcp_retransmit_stamp(sk); |
| 46 | if (!icsk->icsk_user_timeout || !start_ts) |
| 47 | return icsk->icsk_rto; |
| 48 | elapsed = tcp_time_stamp(tcp_sk(sk)) - start_ts; |
Eric Dumazet | 9efdda4 | 2018-11-24 09:12:24 -0800 | [diff] [blame^] | 49 | remaining = icsk->icsk_user_timeout - elapsed; |
| 50 | if (remaining <= 0) |
Jon Maxwell | b701a99 | 2018-07-19 11:14:44 +1000 | [diff] [blame] | 51 | return 1; /* user timeout has passed; fire ASAP */ |
Eric Dumazet | 9efdda4 | 2018-11-24 09:12:24 -0800 | [diff] [blame^] | 52 | |
| 53 | return min_t(u32, icsk->icsk_rto, msecs_to_jiffies(remaining)); |
Jon Maxwell | b701a99 | 2018-07-19 11:14:44 +1000 | [diff] [blame] | 54 | } |
| 55 | |
Richard Sailer | c380d37 | 2016-07-16 04:04:34 +0200 | [diff] [blame] | 56 | /** |
| 57 | * tcp_write_err() - close socket and save error info |
| 58 | * @sk: The socket the error has appeared on. |
| 59 | * |
| 60 | * Returns: Nothing (void) |
| 61 | */ |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | static void tcp_write_err(struct sock *sk) |
| 64 | { |
| 65 | sk->sk_err = sk->sk_err_soft ? : ETIMEDOUT; |
| 66 | sk->sk_error_report(sk); |
| 67 | |
Soheil Hassas Yeganeh | e05836a | 2018-03-06 17:15:12 -0500 | [diff] [blame] | 68 | tcp_write_queue_purge(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | tcp_done(sk); |
Eric Dumazet | 02a1d6e | 2016-04-27 16:44:39 -0700 | [diff] [blame] | 70 | __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONTIMEOUT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | } |
| 72 | |
Richard Sailer | c380d37 | 2016-07-16 04:04:34 +0200 | [diff] [blame] | 73 | /** |
| 74 | * tcp_out_of_resources() - Close socket if out of resources |
| 75 | * @sk: pointer to current socket |
| 76 | * @do_reset: send a last packet with reset flag |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | * |
Richard Sailer | c380d37 | 2016-07-16 04:04:34 +0200 | [diff] [blame] | 78 | * Do not allow orphaned sockets to eat all our resources. |
| 79 | * This is direct violation of TCP specs, but it is required |
| 80 | * to prevent DoS attacks. It is called when a retransmission timeout |
| 81 | * or zero probe timeout occurs on orphaned socket. |
| 82 | * |
Dan Streetman | 4ee806d | 2018-01-18 16:14:26 -0500 | [diff] [blame] | 83 | * Also close if our net namespace is exiting; in that case there is no |
| 84 | * hope of ever communicating again since all netns interfaces are already |
| 85 | * down (or about to be down), and we need to release our dst references, |
| 86 | * which have been moved to the netns loopback interface, so the namespace |
| 87 | * can finish exiting. This condition is only possible if we are a kernel |
| 88 | * socket, as those do not hold references to the namespace. |
| 89 | * |
Richard Sailer | c380d37 | 2016-07-16 04:04:34 +0200 | [diff] [blame] | 90 | * Criteria is still not confirmed experimentally and may change. |
| 91 | * We kill the socket, if: |
| 92 | * 1. If number of orphaned sockets exceeds an administratively configured |
| 93 | * limit. |
| 94 | * 2. If we have strong memory pressure. |
Dan Streetman | 4ee806d | 2018-01-18 16:14:26 -0500 | [diff] [blame] | 95 | * 3. If our net namespace is exiting. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | */ |
Yuchung Cheng | b248230 | 2014-09-29 13:20:38 -0700 | [diff] [blame] | 97 | static int tcp_out_of_resources(struct sock *sk, bool do_reset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | { |
| 99 | struct tcp_sock *tp = tcp_sk(sk); |
David S. Miller | ad1af0f | 2010-08-25 02:27:49 -0700 | [diff] [blame] | 100 | int shift = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 102 | /* If peer does not open window for long time, or did not transmit |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | * anything for long time, penalize it. */ |
Eric Dumazet | d635fbe | 2017-05-16 14:00:03 -0700 | [diff] [blame] | 104 | if ((s32)(tcp_jiffies32 - tp->lsndtime) > 2*TCP_RTO_MAX || !do_reset) |
David S. Miller | ad1af0f | 2010-08-25 02:27:49 -0700 | [diff] [blame] | 105 | shift++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | |
| 107 | /* If some dubious ICMP arrived, penalize even more. */ |
| 108 | if (sk->sk_err_soft) |
David S. Miller | ad1af0f | 2010-08-25 02:27:49 -0700 | [diff] [blame] | 109 | shift++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
Arun Sharma | efcdbf2 | 2012-01-30 14:16:06 -0800 | [diff] [blame] | 111 | if (tcp_check_oom(sk, shift)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | /* Catch exceptional cases, when connection requires reset. |
| 113 | * 1. Last segment was sent recently. */ |
Eric Dumazet | d635fbe | 2017-05-16 14:00:03 -0700 | [diff] [blame] | 114 | if ((s32)(tcp_jiffies32 - tp->lsndtime) <= TCP_TIMEWAIT_LEN || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | /* 2. Window is closed. */ |
| 116 | (!tp->snd_wnd && !tp->packets_out)) |
Yuchung Cheng | b248230 | 2014-09-29 13:20:38 -0700 | [diff] [blame] | 117 | do_reset = true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | if (do_reset) |
| 119 | tcp_send_active_reset(sk, GFP_ATOMIC); |
| 120 | tcp_done(sk); |
Eric Dumazet | 02a1d6e | 2016-04-27 16:44:39 -0700 | [diff] [blame] | 121 | __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | return 1; |
| 123 | } |
Dan Streetman | 4ee806d | 2018-01-18 16:14:26 -0500 | [diff] [blame] | 124 | |
| 125 | if (!check_net(sock_net(sk))) { |
| 126 | /* Not possible to send reset; just close */ |
| 127 | tcp_done(sk); |
| 128 | return 1; |
| 129 | } |
| 130 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | return 0; |
| 132 | } |
| 133 | |
Richard Sailer | c380d37 | 2016-07-16 04:04:34 +0200 | [diff] [blame] | 134 | /** |
| 135 | * tcp_orphan_retries() - Returns maximal number of retries on an orphaned socket |
| 136 | * @sk: Pointer to the current socket. |
| 137 | * @alive: bool, socket alive state |
| 138 | */ |
Richard Sailer | 7533ce3 | 2015-10-09 02:41:37 +0200 | [diff] [blame] | 139 | static int tcp_orphan_retries(struct sock *sk, bool alive) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | { |
Nikolay Borisov | c402d9b | 2016-02-03 09:46:55 +0200 | [diff] [blame] | 141 | int retries = sock_net(sk)->ipv4.sysctl_tcp_orphan_retries; /* May be zero. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
| 143 | /* We know from an ICMP that something is wrong. */ |
| 144 | if (sk->sk_err_soft && !alive) |
| 145 | retries = 0; |
| 146 | |
| 147 | /* However, if socket sent something recently, select some safe |
| 148 | * number of retries. 8 corresponds to >100 seconds with minimal |
| 149 | * RTO of 200msec. */ |
| 150 | if (retries == 0 && alive) |
| 151 | retries = 8; |
| 152 | return retries; |
| 153 | } |
| 154 | |
Eric Dumazet | ce55dd3 | 2007-12-21 01:50:43 -0800 | [diff] [blame] | 155 | static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk) |
| 156 | { |
Eric Dumazet | d0f3684 | 2017-11-03 06:09:17 -0700 | [diff] [blame] | 157 | const struct net *net = sock_net(sk); |
| 158 | int mss; |
Fan Du | b0f9ca5 | 2015-02-10 09:53:16 +0800 | [diff] [blame] | 159 | |
Eric Dumazet | ce55dd3 | 2007-12-21 01:50:43 -0800 | [diff] [blame] | 160 | /* Black hole detection */ |
Eric Dumazet | d0f3684 | 2017-11-03 06:09:17 -0700 | [diff] [blame] | 161 | if (!net->ipv4.sysctl_tcp_mtu_probing) |
| 162 | return; |
David S. Miller | 829942c | 2007-12-21 04:29:16 -0800 | [diff] [blame] | 163 | |
Eric Dumazet | d0f3684 | 2017-11-03 06:09:17 -0700 | [diff] [blame] | 164 | if (!icsk->icsk_mtup.enabled) { |
| 165 | icsk->icsk_mtup.enabled = 1; |
| 166 | icsk->icsk_mtup.probe_timestamp = tcp_jiffies32; |
| 167 | } else { |
| 168 | mss = tcp_mtu_to_mss(sk, icsk->icsk_mtup.search_low) >> 1; |
| 169 | mss = min(net->ipv4.sysctl_tcp_base_mss, mss); |
| 170 | mss = max(mss, 68 - tcp_sk(sk)->tcp_header_len); |
| 171 | icsk->icsk_mtup.search_low = tcp_mss_to_mtu(sk, mss); |
Eric Dumazet | ce55dd3 | 2007-12-21 01:50:43 -0800 | [diff] [blame] | 172 | } |
Eric Dumazet | d0f3684 | 2017-11-03 06:09:17 -0700 | [diff] [blame] | 173 | tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); |
Eric Dumazet | ce55dd3 | 2007-12-21 01:50:43 -0800 | [diff] [blame] | 174 | } |
| 175 | |
Richard Sailer | c380d37 | 2016-07-16 04:04:34 +0200 | [diff] [blame] | 176 | |
| 177 | /** |
| 178 | * retransmits_timed_out() - returns true if this connection has timed out |
| 179 | * @sk: The current socket |
| 180 | * @boundary: max number of retransmissions |
| 181 | * @timeout: A custom timeout value. |
| 182 | * If set to 0 the default timeout is calculated and used. |
| 183 | * Using TCP_RTO_MIN and the number of unsuccessful retransmits. |
Richard Sailer | c380d37 | 2016-07-16 04:04:34 +0200 | [diff] [blame] | 184 | * |
| 185 | * The default "timeout" value this function can calculate and use |
| 186 | * is equivalent to the timeout of a TCP Connection |
| 187 | * after "boundary" unsuccessful, exponentially backed-off |
Eric Dumazet | ce682ef | 2017-05-23 12:38:35 -0700 | [diff] [blame] | 188 | * retransmissions with an initial RTO of TCP_RTO_MIN. |
Damian Lukowski | 2f7de57 | 2009-12-07 06:06:16 +0000 | [diff] [blame] | 189 | */ |
| 190 | static bool retransmits_timed_out(struct sock *sk, |
Jerry Chu | dca43c7 | 2010-08-27 19:13:28 +0000 | [diff] [blame] | 191 | unsigned int boundary, |
Eric Dumazet | ce682ef | 2017-05-23 12:38:35 -0700 | [diff] [blame] | 192 | unsigned int timeout) |
Damian Lukowski | 2f7de57 | 2009-12-07 06:06:16 +0000 | [diff] [blame] | 193 | { |
Eric Dumazet | ce682ef | 2017-05-23 12:38:35 -0700 | [diff] [blame] | 194 | const unsigned int rto_base = TCP_RTO_MIN; |
Eric Dumazet | 9a568de | 2017-05-16 14:00:14 -0700 | [diff] [blame] | 195 | unsigned int linear_backoff_thresh, start_ts; |
Damian Lukowski | 2f7de57 | 2009-12-07 06:06:16 +0000 | [diff] [blame] | 196 | |
| 197 | if (!inet_csk(sk)->icsk_retransmits) |
| 198 | return false; |
| 199 | |
Jon Maxwell | a7fa377 | 2018-07-19 11:14:43 +1000 | [diff] [blame] | 200 | start_ts = tcp_retransmit_stamp(sk); |
| 201 | if (!start_ts) |
| 202 | return false; |
Damian Lukowski | 2f7de57 | 2009-12-07 06:06:16 +0000 | [diff] [blame] | 203 | |
Jerry Chu | dca43c7 | 2010-08-27 19:13:28 +0000 | [diff] [blame] | 204 | if (likely(timeout == 0)) { |
David S. Miller | 21a180c | 2010-10-04 11:56:38 -0700 | [diff] [blame] | 205 | linear_backoff_thresh = ilog2(TCP_RTO_MAX/rto_base); |
Damian Lukowski | 2f7de57 | 2009-12-07 06:06:16 +0000 | [diff] [blame] | 206 | |
Jerry Chu | dca43c7 | 2010-08-27 19:13:28 +0000 | [diff] [blame] | 207 | if (boundary <= linear_backoff_thresh) |
David S. Miller | 21a180c | 2010-10-04 11:56:38 -0700 | [diff] [blame] | 208 | timeout = ((2 << boundary) - 1) * rto_base; |
Jerry Chu | dca43c7 | 2010-08-27 19:13:28 +0000 | [diff] [blame] | 209 | else |
David S. Miller | 21a180c | 2010-10-04 11:56:38 -0700 | [diff] [blame] | 210 | timeout = ((2 << linear_backoff_thresh) - 1) * rto_base + |
Jerry Chu | dca43c7 | 2010-08-27 19:13:28 +0000 | [diff] [blame] | 211 | (boundary - linear_backoff_thresh) * TCP_RTO_MAX; |
Jon Maxwell | 9bcc66e | 2018-07-19 11:14:42 +1000 | [diff] [blame] | 212 | timeout = jiffies_to_msecs(timeout); |
Jerry Chu | dca43c7 | 2010-08-27 19:13:28 +0000 | [diff] [blame] | 213 | } |
Eric Dumazet | 9efdda4 | 2018-11-24 09:12:24 -0800 | [diff] [blame^] | 214 | return (s32)(tcp_time_stamp(tcp_sk(sk)) - start_ts - timeout) >= 0; |
Damian Lukowski | 2f7de57 | 2009-12-07 06:06:16 +0000 | [diff] [blame] | 215 | } |
| 216 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | /* A write timeout has occurred. Process the after effects. */ |
| 218 | static int tcp_write_timeout(struct sock *sk) |
| 219 | { |
John Heffner | 5d424d5 | 2006-03-20 17:53:41 -0800 | [diff] [blame] | 220 | struct inet_connection_sock *icsk = inet_csk(sk); |
Yuchung Cheng | c968601 | 2013-10-29 10:09:05 -0700 | [diff] [blame] | 221 | struct tcp_sock *tp = tcp_sk(sk); |
Nikolay Borisov | 6fa2516 | 2016-02-03 09:46:49 +0200 | [diff] [blame] | 222 | struct net *net = sock_net(sk); |
Eric Dumazet | ce682ef | 2017-05-23 12:38:35 -0700 | [diff] [blame] | 223 | bool expired, do_reset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | int retry_until; |
| 225 | |
| 226 | if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) { |
Yuchung Cheng | c968601 | 2013-10-29 10:09:05 -0700 | [diff] [blame] | 227 | if (icsk->icsk_retransmits) { |
Eric Dumazet | b6c6712 | 2010-04-08 23:03:29 +0000 | [diff] [blame] | 228 | dst_negative_advice(sk); |
Lawrence Brakmo | 3acf3ec | 2016-09-27 19:03:37 -0700 | [diff] [blame] | 229 | } else if (!tp->syn_data && !tp->syn_fastopen) { |
| 230 | sk_rethink_txhash(sk); |
Yuchung Cheng | c968601 | 2013-10-29 10:09:05 -0700 | [diff] [blame] | 231 | } |
Nikolay Borisov | 6fa2516 | 2016-02-03 09:46:49 +0200 | [diff] [blame] | 232 | retry_until = icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_syn_retries; |
Eric Dumazet | ce682ef | 2017-05-23 12:38:35 -0700 | [diff] [blame] | 233 | expired = icsk->icsk_retransmits >= retry_until; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | } else { |
Eric Dumazet | ce682ef | 2017-05-23 12:38:35 -0700 | [diff] [blame] | 235 | if (retransmits_timed_out(sk, net->ipv4.sysctl_tcp_retries1, 0)) { |
John Heffner | 5d424d5 | 2006-03-20 17:53:41 -0800 | [diff] [blame] | 236 | /* Black hole detection */ |
Eric Dumazet | ce55dd3 | 2007-12-21 01:50:43 -0800 | [diff] [blame] | 237 | tcp_mtu_probing(icsk, sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | |
Eric Dumazet | b6c6712 | 2010-04-08 23:03:29 +0000 | [diff] [blame] | 239 | dst_negative_advice(sk); |
Lawrence Brakmo | 3acf3ec | 2016-09-27 19:03:37 -0700 | [diff] [blame] | 240 | } else { |
| 241 | sk_rethink_txhash(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | } |
| 243 | |
Nikolay Borisov | c6214a9 | 2016-02-03 09:46:54 +0200 | [diff] [blame] | 244 | retry_until = net->ipv4.sysctl_tcp_retries2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | if (sock_flag(sk, SOCK_DEAD)) { |
Richard Sailer | 7533ce3 | 2015-10-09 02:41:37 +0200 | [diff] [blame] | 246 | const bool alive = icsk->icsk_rto < TCP_RTO_MAX; |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 247 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | retry_until = tcp_orphan_retries(sk, alive); |
Damian Lukowski | 6fa12c8 | 2009-08-26 00:16:34 +0000 | [diff] [blame] | 249 | do_reset = alive || |
Eric Dumazet | ce682ef | 2017-05-23 12:38:35 -0700 | [diff] [blame] | 250 | !retransmits_timed_out(sk, retry_until, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | |
Damian Lukowski | 6fa12c8 | 2009-08-26 00:16:34 +0000 | [diff] [blame] | 252 | if (tcp_out_of_resources(sk, do_reset)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | return 1; |
| 254 | } |
Eric Dumazet | ce682ef | 2017-05-23 12:38:35 -0700 | [diff] [blame] | 255 | expired = retransmits_timed_out(sk, retry_until, |
| 256 | icsk->icsk_user_timeout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | } |
Yuchung Cheng | 7268586 | 2017-12-12 13:10:40 -0800 | [diff] [blame] | 258 | tcp_fastopen_active_detect_blackhole(sk, expired); |
Lawrence Brakmo | f89013f | 2018-01-25 16:14:11 -0800 | [diff] [blame] | 259 | |
| 260 | if (BPF_SOCK_OPS_TEST_FLAG(tp, BPF_SOCK_OPS_RTO_CB_FLAG)) |
| 261 | tcp_call_bpf_3arg(sk, BPF_SOCK_OPS_RTO_CB, |
| 262 | icsk->icsk_retransmits, |
| 263 | icsk->icsk_rto, (int)expired); |
| 264 | |
Eric Dumazet | ce682ef | 2017-05-23 12:38:35 -0700 | [diff] [blame] | 265 | if (expired) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | /* Has it gone just too far? */ |
| 267 | tcp_write_err(sk); |
| 268 | return 1; |
| 269 | } |
Lawrence Brakmo | f89013f | 2018-01-25 16:14:11 -0800 | [diff] [blame] | 270 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | return 0; |
| 272 | } |
| 273 | |
Eric Dumazet | c10d931 | 2016-04-29 14:16:47 -0700 | [diff] [blame] | 274 | /* Called with BH disabled */ |
Eric Dumazet | 6f458df | 2012-07-20 05:45:50 +0000 | [diff] [blame] | 275 | void tcp_delack_timer_handler(struct sock *sk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | { |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 277 | struct inet_connection_sock *icsk = inet_csk(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | |
David S. Miller | 9993e7d | 2008-01-10 21:56:38 -0800 | [diff] [blame] | 279 | sk_mem_reclaim_partial(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | |
Eric Dumazet | 02b2faa | 2017-03-03 14:08:21 -0800 | [diff] [blame] | 281 | if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) || |
| 282 | !(icsk->icsk_ack.pending & ICSK_ACK_TIMER)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | goto out; |
| 284 | |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 285 | if (time_after(icsk->icsk_ack.timeout, jiffies)) { |
| 286 | sk_reset_timer(sk, &icsk->icsk_delack_timer, icsk->icsk_ack.timeout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | goto out; |
| 288 | } |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 289 | icsk->icsk_ack.pending &= ~ICSK_ACK_TIMER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 291 | if (inet_csk_ack_scheduled(sk)) { |
| 292 | if (!icsk->icsk_ack.pingpong) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | /* Delayed ACK missed: inflate ATO. */ |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 294 | icsk->icsk_ack.ato = min(icsk->icsk_ack.ato << 1, icsk->icsk_rto); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | } else { |
| 296 | /* Delayed ACK missed: leave pingpong mode and |
| 297 | * deflate ATO. |
| 298 | */ |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 299 | icsk->icsk_ack.pingpong = 0; |
| 300 | icsk->icsk_ack.ato = TCP_ATO_MIN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | } |
Eric Dumazet | 4688eb7 | 2017-12-12 18:22:52 -0800 | [diff] [blame] | 302 | tcp_mstamp_refresh(tcp_sk(sk)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | tcp_send_ack(sk); |
Eric Dumazet | 02a1d6e | 2016-04-27 16:44:39 -0700 | [diff] [blame] | 304 | __NET_INC_STATS(sock_net(sk), LINUX_MIB_DELAYEDACKS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | |
| 307 | out: |
Eric Dumazet | b8da51e | 2015-05-15 12:39:27 -0700 | [diff] [blame] | 308 | if (tcp_under_memory_pressure(sk)) |
Hideo Aoki | 3ab224b | 2007-12-31 00:11:19 -0800 | [diff] [blame] | 309 | sk_mem_reclaim(sk); |
Eric Dumazet | 6f458df | 2012-07-20 05:45:50 +0000 | [diff] [blame] | 310 | } |
| 311 | |
Richard Sailer | c380d37 | 2016-07-16 04:04:34 +0200 | [diff] [blame] | 312 | |
| 313 | /** |
| 314 | * tcp_delack_timer() - The TCP delayed ACK timeout handler |
| 315 | * @data: Pointer to the current socket. (gets casted to struct sock *) |
| 316 | * |
| 317 | * This function gets (indirectly) called when the kernel timer for a TCP packet |
| 318 | * of this socket expires. Calls tcp_delack_timer_handler() to do the actual work. |
| 319 | * |
| 320 | * Returns: Nothing (void) |
| 321 | */ |
Kees Cook | 59f379f | 2017-10-16 17:29:19 -0700 | [diff] [blame] | 322 | static void tcp_delack_timer(struct timer_list *t) |
Eric Dumazet | 6f458df | 2012-07-20 05:45:50 +0000 | [diff] [blame] | 323 | { |
Kees Cook | 59f379f | 2017-10-16 17:29:19 -0700 | [diff] [blame] | 324 | struct inet_connection_sock *icsk = |
| 325 | from_timer(icsk, t, icsk_delack_timer); |
| 326 | struct sock *sk = &icsk->icsk_inet.sk; |
Eric Dumazet | 6f458df | 2012-07-20 05:45:50 +0000 | [diff] [blame] | 327 | |
| 328 | bh_lock_sock(sk); |
| 329 | if (!sock_owned_by_user(sk)) { |
| 330 | tcp_delack_timer_handler(sk); |
| 331 | } else { |
Kees Cook | 59f379f | 2017-10-16 17:29:19 -0700 | [diff] [blame] | 332 | icsk->icsk_ack.blocked = 1; |
Eric Dumazet | 02a1d6e | 2016-04-27 16:44:39 -0700 | [diff] [blame] | 333 | __NET_INC_STATS(sock_net(sk), LINUX_MIB_DELAYEDACKLOCKED); |
Eric Dumazet | 6f458df | 2012-07-20 05:45:50 +0000 | [diff] [blame] | 334 | /* deleguate our work to tcp_release_cb() */ |
Eric Dumazet | 7aa5470 | 2016-12-03 11:14:57 -0800 | [diff] [blame] | 335 | if (!test_and_set_bit(TCP_DELACK_TIMER_DEFERRED, &sk->sk_tsq_flags)) |
Eric Dumazet | 144d56e | 2012-08-20 00:22:46 +0000 | [diff] [blame] | 336 | sock_hold(sk); |
Eric Dumazet | 6f458df | 2012-07-20 05:45:50 +0000 | [diff] [blame] | 337 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | bh_unlock_sock(sk); |
| 339 | sock_put(sk); |
| 340 | } |
| 341 | |
| 342 | static void tcp_probe_timer(struct sock *sk) |
| 343 | { |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 344 | struct inet_connection_sock *icsk = inet_csk(sk); |
Eric Dumazet | 75c119a | 2017-10-05 22:21:27 -0700 | [diff] [blame] | 345 | struct sk_buff *skb = tcp_send_head(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | struct tcp_sock *tp = tcp_sk(sk); |
| 347 | int max_probes; |
Yuchung Cheng | b248230 | 2014-09-29 13:20:38 -0700 | [diff] [blame] | 348 | u32 start_ts; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | |
Eric Dumazet | 75c119a | 2017-10-05 22:21:27 -0700 | [diff] [blame] | 350 | if (tp->packets_out || !skb) { |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 351 | icsk->icsk_probes_out = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | return; |
| 353 | } |
| 354 | |
Yuchung Cheng | b248230 | 2014-09-29 13:20:38 -0700 | [diff] [blame] | 355 | /* RFC 1122 4.2.2.17 requires the sender to stay open indefinitely as |
| 356 | * long as the receiver continues to respond probes. We support this by |
| 357 | * default and reset icsk_probes_out with incoming ACKs. But if the |
| 358 | * socket is orphaned or the user specifies TCP_USER_TIMEOUT, we |
| 359 | * kill the socket when the retry count and the time exceeds the |
| 360 | * corresponding system limit. We also implement similar policy when |
| 361 | * we use RTO to probe window in tcp_retransmit_timer(). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | */ |
Eric Dumazet | 75c119a | 2017-10-05 22:21:27 -0700 | [diff] [blame] | 363 | start_ts = tcp_skb_timestamp(skb); |
Yuchung Cheng | b248230 | 2014-09-29 13:20:38 -0700 | [diff] [blame] | 364 | if (!start_ts) |
Eric Dumazet | 5f6188a | 2018-10-15 09:37:52 -0700 | [diff] [blame] | 365 | skb->skb_mstamp_ns = tp->tcp_clock_cache; |
Yuchung Cheng | b248230 | 2014-09-29 13:20:38 -0700 | [diff] [blame] | 366 | else if (icsk->icsk_user_timeout && |
Jon Maxwell | 9bcc66e | 2018-07-19 11:14:42 +1000 | [diff] [blame] | 367 | (s32)(tcp_time_stamp(tp) - start_ts) > icsk->icsk_user_timeout) |
Yuchung Cheng | b248230 | 2014-09-29 13:20:38 -0700 | [diff] [blame] | 368 | goto abort; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 369 | |
Nikolay Borisov | c6214a9 | 2016-02-03 09:46:54 +0200 | [diff] [blame] | 370 | max_probes = sock_net(sk)->ipv4.sysctl_tcp_retries2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | if (sock_flag(sk, SOCK_DEAD)) { |
Richard Sailer | 7533ce3 | 2015-10-09 02:41:37 +0200 | [diff] [blame] | 372 | const bool alive = inet_csk_rto_backoff(icsk, TCP_RTO_MAX) < TCP_RTO_MAX; |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 373 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | max_probes = tcp_orphan_retries(sk, alive); |
Yuchung Cheng | b248230 | 2014-09-29 13:20:38 -0700 | [diff] [blame] | 375 | if (!alive && icsk->icsk_backoff >= max_probes) |
| 376 | goto abort; |
| 377 | if (tcp_out_of_resources(sk, true)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | return; |
| 379 | } |
| 380 | |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 381 | if (icsk->icsk_probes_out > max_probes) { |
Yuchung Cheng | b248230 | 2014-09-29 13:20:38 -0700 | [diff] [blame] | 382 | abort: tcp_write_err(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 383 | } else { |
| 384 | /* Only send another probe if we didn't close things up. */ |
| 385 | tcp_send_probe0(sk); |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | /* |
Jerry Chu | 8336886 | 2012-08-31 12:29:12 +0000 | [diff] [blame] | 390 | * Timer for Fast Open socket to retransmit SYNACK. Note that the |
| 391 | * sk here is the child socket, not the parent (listener) socket. |
| 392 | */ |
| 393 | static void tcp_fastopen_synack_timer(struct sock *sk) |
| 394 | { |
| 395 | struct inet_connection_sock *icsk = inet_csk(sk); |
| 396 | int max_retries = icsk->icsk_syn_retries ? : |
Nikolay Borisov | 7c083ec | 2016-02-03 09:46:50 +0200 | [diff] [blame] | 397 | sock_net(sk)->ipv4.sysctl_tcp_synack_retries + 1; /* add one more retry for fastopen */ |
Jerry Chu | 8336886 | 2012-08-31 12:29:12 +0000 | [diff] [blame] | 398 | struct request_sock *req; |
| 399 | |
| 400 | req = tcp_sk(sk)->fastopen_rsk; |
Eric Dumazet | 42cb80a | 2015-03-22 10:22:19 -0700 | [diff] [blame] | 401 | req->rsk_ops->syn_ack_timeout(req); |
Jerry Chu | 8336886 | 2012-08-31 12:29:12 +0000 | [diff] [blame] | 402 | |
Eric Dumazet | e6c022a | 2012-10-27 23:16:46 +0000 | [diff] [blame] | 403 | if (req->num_timeout >= max_retries) { |
Jerry Chu | 8336886 | 2012-08-31 12:29:12 +0000 | [diff] [blame] | 404 | tcp_write_err(sk); |
| 405 | return; |
| 406 | } |
| 407 | /* XXX (TFO) - Unlike regular SYN-ACK retransmit, we ignore error |
| 408 | * returned from rtx_syn_ack() to make it more persistent like |
| 409 | * regular retransmit because if the child socket has been accepted |
| 410 | * it's not good to give up too easily. |
| 411 | */ |
Eric Dumazet | e6c022a | 2012-10-27 23:16:46 +0000 | [diff] [blame] | 412 | inet_rtx_syn_ack(sk, req); |
| 413 | req->num_timeout++; |
Yuchung Cheng | 7e32b44 | 2016-09-21 16:16:15 -0700 | [diff] [blame] | 414 | icsk->icsk_retransmits++; |
Jerry Chu | 8336886 | 2012-08-31 12:29:12 +0000 | [diff] [blame] | 415 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, |
Eric Dumazet | e6c022a | 2012-10-27 23:16:46 +0000 | [diff] [blame] | 416 | TCP_TIMEOUT_INIT << req->num_timeout, TCP_RTO_MAX); |
Jerry Chu | 8336886 | 2012-08-31 12:29:12 +0000 | [diff] [blame] | 417 | } |
| 418 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | |
Richard Sailer | c380d37 | 2016-07-16 04:04:34 +0200 | [diff] [blame] | 420 | /** |
| 421 | * tcp_retransmit_timer() - The TCP retransmit timeout handler |
| 422 | * @sk: Pointer to the current socket. |
| 423 | * |
| 424 | * This function gets called when the kernel timer for a TCP packet |
| 425 | * of this socket expires. |
| 426 | * |
| 427 | * It handles retransmission, timer adjustment and other necesarry measures. |
| 428 | * |
| 429 | * Returns: Nothing (void) |
| 430 | */ |
Damian Lukowski | f1ecd5d | 2009-08-26 00:16:31 +0000 | [diff] [blame] | 431 | void tcp_retransmit_timer(struct sock *sk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | { |
| 433 | struct tcp_sock *tp = tcp_sk(sk); |
Nikolay Borisov | ae5c3f4 | 2016-02-03 09:46:53 +0200 | [diff] [blame] | 434 | struct net *net = sock_net(sk); |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 435 | struct inet_connection_sock *icsk = inet_csk(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 436 | |
Jerry Chu | 8336886 | 2012-08-31 12:29:12 +0000 | [diff] [blame] | 437 | if (tp->fastopen_rsk) { |
Jerry Chu | 37561f6 | 2012-10-22 11:26:36 +0000 | [diff] [blame] | 438 | WARN_ON_ONCE(sk->sk_state != TCP_SYN_RECV && |
| 439 | sk->sk_state != TCP_FIN_WAIT1); |
Jerry Chu | 8336886 | 2012-08-31 12:29:12 +0000 | [diff] [blame] | 440 | tcp_fastopen_synack_timer(sk); |
| 441 | /* Before we receive ACK to our SYN-ACK don't retransmit |
| 442 | * anything else (e.g., data or FIN segments). |
| 443 | */ |
| 444 | return; |
| 445 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | if (!tp->packets_out) |
| 447 | goto out; |
| 448 | |
Eric Dumazet | 75c119a | 2017-10-05 22:21:27 -0700 | [diff] [blame] | 449 | WARN_ON(tcp_rtx_queue_empty(sk)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | |
Nandita Dukkipati | 9b717a8 | 2013-03-11 10:00:44 +0000 | [diff] [blame] | 451 | tp->tlp_high_seq = 0; |
| 452 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | if (!tp->snd_wnd && !sock_flag(sk, SOCK_DEAD) && |
| 454 | !((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV))) { |
| 455 | /* Receiver dastardly shrinks window. Our retransmits |
| 456 | * become zero probes, but we should not timeout this |
| 457 | * connection. If the socket is an orphan, time it out, |
| 458 | * we cannot allow such beasts to hang infinitely. |
| 459 | */ |
YOSHIFUJI Hideaki | 569508c | 2008-04-14 04:09:36 -0700 | [diff] [blame] | 460 | struct inet_sock *inet = inet_sk(sk); |
| 461 | if (sk->sk_family == AF_INET) { |
Joe Perches | ba7a46f | 2014-11-11 10:59:17 -0800 | [diff] [blame] | 462 | net_dbg_ratelimited("Peer %pI4:%u/%u unexpectedly shrunk window %u:%u (repaired)\n", |
| 463 | &inet->inet_daddr, |
| 464 | ntohs(inet->inet_dport), |
| 465 | inet->inet_num, |
| 466 | tp->snd_una, tp->snd_nxt); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | } |
Eric Dumazet | dfd56b8 | 2011-12-10 09:48:31 +0000 | [diff] [blame] | 468 | #if IS_ENABLED(CONFIG_IPV6) |
YOSHIFUJI Hideaki | 569508c | 2008-04-14 04:09:36 -0700 | [diff] [blame] | 469 | else if (sk->sk_family == AF_INET6) { |
Joe Perches | ba7a46f | 2014-11-11 10:59:17 -0800 | [diff] [blame] | 470 | net_dbg_ratelimited("Peer %pI6:%u/%u unexpectedly shrunk window %u:%u (repaired)\n", |
| 471 | &sk->sk_v6_daddr, |
| 472 | ntohs(inet->inet_dport), |
| 473 | inet->inet_num, |
| 474 | tp->snd_una, tp->snd_nxt); |
YOSHIFUJI Hideaki | 569508c | 2008-04-14 04:09:36 -0700 | [diff] [blame] | 475 | } |
| 476 | #endif |
Eric Dumazet | 70eabf0 | 2017-05-16 14:00:07 -0700 | [diff] [blame] | 477 | if (tcp_jiffies32 - tp->rcv_tstamp > TCP_RTO_MAX) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 | tcp_write_err(sk); |
| 479 | goto out; |
| 480 | } |
Neal Cardwell | 5ae344c | 2014-08-04 19:12:29 -0400 | [diff] [blame] | 481 | tcp_enter_loss(sk); |
Eric Dumazet | 75c119a | 2017-10-05 22:21:27 -0700 | [diff] [blame] | 482 | tcp_retransmit_skb(sk, tcp_rtx_queue_head(sk), 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | __sk_dst_reset(sk); |
| 484 | goto out_reset_timer; |
| 485 | } |
| 486 | |
| 487 | if (tcp_write_timeout(sk)) |
| 488 | goto out; |
| 489 | |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 490 | if (icsk->icsk_retransmits == 0) { |
Pavel Emelyanov | 40b215e | 2008-07-03 01:05:41 -0700 | [diff] [blame] | 491 | int mib_idx; |
| 492 | |
Ilpo Järvinen | c60ce4e | 2010-10-14 01:52:09 +0000 | [diff] [blame] | 493 | if (icsk->icsk_ca_state == TCP_CA_Recovery) { |
Ilpo Järvinen | bc079e9 | 2009-02-28 04:44:34 +0000 | [diff] [blame] | 494 | if (tcp_is_sack(tp)) |
| 495 | mib_idx = LINUX_MIB_TCPSACKRECOVERYFAIL; |
| 496 | else |
| 497 | mib_idx = LINUX_MIB_TCPRENORECOVERYFAIL; |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 498 | } else if (icsk->icsk_ca_state == TCP_CA_Loss) { |
Pavel Emelyanov | 40b215e | 2008-07-03 01:05:41 -0700 | [diff] [blame] | 499 | mib_idx = LINUX_MIB_TCPLOSSFAILURES; |
Ilpo Järvinen | c60ce4e | 2010-10-14 01:52:09 +0000 | [diff] [blame] | 500 | } else if ((icsk->icsk_ca_state == TCP_CA_Disorder) || |
| 501 | tp->sacked_out) { |
| 502 | if (tcp_is_sack(tp)) |
| 503 | mib_idx = LINUX_MIB_TCPSACKFAILURES; |
| 504 | else |
| 505 | mib_idx = LINUX_MIB_TCPRENOFAILURES; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | } else { |
Pavel Emelyanov | 40b215e | 2008-07-03 01:05:41 -0700 | [diff] [blame] | 507 | mib_idx = LINUX_MIB_TCPTIMEOUTS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | } |
Eric Dumazet | 02a1d6e | 2016-04-27 16:44:39 -0700 | [diff] [blame] | 509 | __NET_INC_STATS(sock_net(sk), mib_idx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | } |
| 511 | |
Neal Cardwell | 5ae344c | 2014-08-04 19:12:29 -0400 | [diff] [blame] | 512 | tcp_enter_loss(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | |
Eric Dumazet | 75c119a | 2017-10-05 22:21:27 -0700 | [diff] [blame] | 514 | if (tcp_retransmit_skb(sk, tcp_rtx_queue_head(sk), 1) > 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | /* Retransmission failed because of local congestion, |
| 516 | * do not backoff. |
| 517 | */ |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 518 | if (!icsk->icsk_retransmits) |
| 519 | icsk->icsk_retransmits = 1; |
| 520 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, |
Arnaldo Carvalho de Melo | 3f421ba | 2005-08-09 20:11:08 -0700 | [diff] [blame] | 521 | min(icsk->icsk_rto, TCP_RESOURCE_PROBE_INTERVAL), |
| 522 | TCP_RTO_MAX); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | goto out; |
| 524 | } |
| 525 | |
| 526 | /* Increase the timeout each time we retransmit. Note that |
| 527 | * we do not increase the rtt estimate. rto is initialized |
| 528 | * from rtt, but increases here. Jacobson (SIGCOMM 88) suggests |
| 529 | * that doubling rto each time is the least we can get away with. |
| 530 | * In KA9Q, Karn uses this for the first few times, and then |
| 531 | * goes to quadratic. netBSD doubles, but only goes up to *64, |
| 532 | * and clamps at 1 to 64 sec afterwards. Note that 120 sec is |
| 533 | * defined in the protocol as the maximum possible RTT. I guess |
| 534 | * we'll have to use something other than TCP to talk to the |
| 535 | * University of Mars. |
| 536 | * |
| 537 | * PAWS allows us longer timeouts and large windows, so once |
| 538 | * implemented ftp to mars will work nicely. We will have to fix |
| 539 | * the 120 second clamps though! |
| 540 | */ |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 541 | icsk->icsk_backoff++; |
| 542 | icsk->icsk_retransmits++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | |
| 544 | out_reset_timer: |
Andreas Petlund | 36e31b0a | 2010-02-18 02:47:01 +0000 | [diff] [blame] | 545 | /* If stream is thin, use linear timeouts. Since 'icsk_backoff' is |
| 546 | * used to reset timer, set to 0. Recalculate 'icsk_rto' as this |
| 547 | * might be increased if the stream oscillates between thin and thick, |
| 548 | * thus the old value might already be too high compared to the value |
| 549 | * set by 'tcp_set_rto' in tcp_input.c which resets the rto without |
| 550 | * backoff. Limit to TCP_THIN_LINEAR_RETRIES before initiating |
| 551 | * exponential backoff behaviour to avoid continue hammering |
| 552 | * linear-timeout retransmissions into a black hole |
| 553 | */ |
| 554 | if (sk->sk_state == TCP_ESTABLISHED && |
Eric Dumazet | 2c04ac8 | 2017-10-26 21:54:58 -0700 | [diff] [blame] | 555 | (tp->thin_lto || net->ipv4.sysctl_tcp_thin_linear_timeouts) && |
Andreas Petlund | 36e31b0a | 2010-02-18 02:47:01 +0000 | [diff] [blame] | 556 | tcp_stream_is_thin(tp) && |
| 557 | icsk->icsk_retransmits <= TCP_THIN_LINEAR_RETRIES) { |
| 558 | icsk->icsk_backoff = 0; |
| 559 | icsk->icsk_rto = min(__tcp_set_rto(tp), TCP_RTO_MAX); |
| 560 | } else { |
| 561 | /* Use normal (exponential) backoff */ |
| 562 | icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX); |
| 563 | } |
Jon Maxwell | b701a99 | 2018-07-19 11:14:44 +1000 | [diff] [blame] | 564 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, |
| 565 | tcp_clamp_rto_to_user_timeout(sk), TCP_RTO_MAX); |
Eric Dumazet | ce682ef | 2017-05-23 12:38:35 -0700 | [diff] [blame] | 566 | if (retransmits_timed_out(sk, net->ipv4.sysctl_tcp_retries1 + 1, 0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | __sk_dst_reset(sk); |
| 568 | |
| 569 | out:; |
| 570 | } |
| 571 | |
Richard Sailer | c380d37 | 2016-07-16 04:04:34 +0200 | [diff] [blame] | 572 | /* Called with bottom-half processing disabled. |
| 573 | Called by tcp_write_timer() */ |
Eric Dumazet | 6f458df | 2012-07-20 05:45:50 +0000 | [diff] [blame] | 574 | void tcp_write_timer_handler(struct sock *sk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | { |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 576 | struct inet_connection_sock *icsk = inet_csk(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | int event; |
| 578 | |
Eric Dumazet | 02b2faa | 2017-03-03 14:08:21 -0800 | [diff] [blame] | 579 | if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) || |
| 580 | !icsk->icsk_pending) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | goto out; |
| 582 | |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 583 | if (time_after(icsk->icsk_timeout, jiffies)) { |
| 584 | sk_reset_timer(sk, &icsk->icsk_retransmit_timer, icsk->icsk_timeout); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | goto out; |
| 586 | } |
| 587 | |
Eric Dumazet | 9a568de | 2017-05-16 14:00:14 -0700 | [diff] [blame] | 588 | tcp_mstamp_refresh(tcp_sk(sk)); |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 589 | event = icsk->icsk_pending; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | |
| 591 | switch (event) { |
Yuchung Cheng | 57dde7f | 2017-01-12 22:11:33 -0800 | [diff] [blame] | 592 | case ICSK_TIME_REO_TIMEOUT: |
| 593 | tcp_rack_reo_timeout(sk); |
| 594 | break; |
Nandita Dukkipati | 6ba8a3b | 2013-03-11 10:00:43 +0000 | [diff] [blame] | 595 | case ICSK_TIME_LOSS_PROBE: |
| 596 | tcp_send_loss_probe(sk); |
| 597 | break; |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 598 | case ICSK_TIME_RETRANS: |
Nandita Dukkipati | 6ba8a3b | 2013-03-11 10:00:43 +0000 | [diff] [blame] | 599 | icsk->icsk_pending = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | tcp_retransmit_timer(sk); |
| 601 | break; |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 602 | case ICSK_TIME_PROBE0: |
Nandita Dukkipati | 6ba8a3b | 2013-03-11 10:00:43 +0000 | [diff] [blame] | 603 | icsk->icsk_pending = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | tcp_probe_timer(sk); |
| 605 | break; |
| 606 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | |
| 608 | out: |
Hideo Aoki | 3ab224b | 2007-12-31 00:11:19 -0800 | [diff] [blame] | 609 | sk_mem_reclaim(sk); |
Eric Dumazet | 6f458df | 2012-07-20 05:45:50 +0000 | [diff] [blame] | 610 | } |
| 611 | |
Kees Cook | 59f379f | 2017-10-16 17:29:19 -0700 | [diff] [blame] | 612 | static void tcp_write_timer(struct timer_list *t) |
Eric Dumazet | 6f458df | 2012-07-20 05:45:50 +0000 | [diff] [blame] | 613 | { |
Kees Cook | 59f379f | 2017-10-16 17:29:19 -0700 | [diff] [blame] | 614 | struct inet_connection_sock *icsk = |
| 615 | from_timer(icsk, t, icsk_retransmit_timer); |
| 616 | struct sock *sk = &icsk->icsk_inet.sk; |
Eric Dumazet | 6f458df | 2012-07-20 05:45:50 +0000 | [diff] [blame] | 617 | |
| 618 | bh_lock_sock(sk); |
| 619 | if (!sock_owned_by_user(sk)) { |
| 620 | tcp_write_timer_handler(sk); |
| 621 | } else { |
Richard Sailer | c380d37 | 2016-07-16 04:04:34 +0200 | [diff] [blame] | 622 | /* delegate our work to tcp_release_cb() */ |
Eric Dumazet | 7aa5470 | 2016-12-03 11:14:57 -0800 | [diff] [blame] | 623 | if (!test_and_set_bit(TCP_WRITE_TIMER_DEFERRED, &sk->sk_tsq_flags)) |
Eric Dumazet | 144d56e | 2012-08-20 00:22:46 +0000 | [diff] [blame] | 624 | sock_hold(sk); |
Eric Dumazet | 6f458df | 2012-07-20 05:45:50 +0000 | [diff] [blame] | 625 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | bh_unlock_sock(sk); |
| 627 | sock_put(sk); |
| 628 | } |
| 629 | |
Eric Dumazet | 42cb80a | 2015-03-22 10:22:19 -0700 | [diff] [blame] | 630 | void tcp_syn_ack_timeout(const struct request_sock *req) |
Octavian Purdila | 72659ec | 2010-01-17 19:09:39 -0800 | [diff] [blame] | 631 | { |
Eric Dumazet | 42cb80a | 2015-03-22 10:22:19 -0700 | [diff] [blame] | 632 | struct net *net = read_pnet(&inet_rsk(req)->ireq_net); |
| 633 | |
Eric Dumazet | 02a1d6e | 2016-04-27 16:44:39 -0700 | [diff] [blame] | 634 | __NET_INC_STATS(net, LINUX_MIB_TCPTIMEOUTS); |
Octavian Purdila | 72659ec | 2010-01-17 19:09:39 -0800 | [diff] [blame] | 635 | } |
| 636 | EXPORT_SYMBOL(tcp_syn_ack_timeout); |
| 637 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | void tcp_set_keepalive(struct sock *sk, int val) |
| 639 | { |
| 640 | if ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) |
| 641 | return; |
| 642 | |
| 643 | if (val && !sock_flag(sk, SOCK_KEEPOPEN)) |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 644 | inet_csk_reset_keepalive_timer(sk, keepalive_time_when(tcp_sk(sk))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | else if (!val) |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 646 | inet_csk_delete_keepalive_timer(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | } |
Ursula Braun | 4b9d07a | 2017-01-09 16:55:12 +0100 | [diff] [blame] | 648 | EXPORT_SYMBOL_GPL(tcp_set_keepalive); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | |
| 650 | |
Kees Cook | 59f379f | 2017-10-16 17:29:19 -0700 | [diff] [blame] | 651 | static void tcp_keepalive_timer (struct timer_list *t) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | { |
Kees Cook | 59f379f | 2017-10-16 17:29:19 -0700 | [diff] [blame] | 653 | struct sock *sk = from_timer(sk, t, sk_timer); |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 654 | struct inet_connection_sock *icsk = inet_csk(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | struct tcp_sock *tp = tcp_sk(sk); |
Flavio Leitner | 6c37e5d | 2010-04-26 18:33:27 +0000 | [diff] [blame] | 656 | u32 elapsed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | |
| 658 | /* Only process if socket is not in use. */ |
| 659 | bh_lock_sock(sk); |
| 660 | if (sock_owned_by_user(sk)) { |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 661 | /* Try again later. */ |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 662 | inet_csk_reset_keepalive_timer (sk, HZ/20); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | goto out; |
| 664 | } |
| 665 | |
| 666 | if (sk->sk_state == TCP_LISTEN) { |
Eric Dumazet | fa76ce73 | 2015-03-19 19:04:20 -0700 | [diff] [blame] | 667 | pr_err("Hmm... keepalive on a LISTEN ???\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | goto out; |
| 669 | } |
| 670 | |
Eric Dumazet | 4688eb7 | 2017-12-12 18:22:52 -0800 | [diff] [blame] | 671 | tcp_mstamp_refresh(tp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | if (sk->sk_state == TCP_FIN_WAIT2 && sock_flag(sk, SOCK_DEAD)) { |
| 673 | if (tp->linger2 >= 0) { |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 674 | const int tmo = tcp_fin_time(sk) - TCP_TIMEWAIT_LEN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | |
| 676 | if (tmo > 0) { |
| 677 | tcp_time_wait(sk, TCP_FIN_WAIT2, tmo); |
| 678 | goto out; |
| 679 | } |
| 680 | } |
| 681 | tcp_send_active_reset(sk, GFP_ATOMIC); |
| 682 | goto death; |
| 683 | } |
| 684 | |
Eric Dumazet | 2dda640 | 2017-08-02 23:10:46 -0700 | [diff] [blame] | 685 | if (!sock_flag(sk, SOCK_KEEPOPEN) || |
| 686 | ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 687 | goto out; |
| 688 | |
| 689 | elapsed = keepalive_time_when(tp); |
| 690 | |
| 691 | /* It is alive without keepalive 8) */ |
Eric Dumazet | 75c119a | 2017-10-05 22:21:27 -0700 | [diff] [blame] | 692 | if (tp->packets_out || !tcp_write_queue_empty(sk)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 693 | goto resched; |
| 694 | |
Flavio Leitner | 6c37e5d | 2010-04-26 18:33:27 +0000 | [diff] [blame] | 695 | elapsed = keepalive_time_elapsed(tp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | |
| 697 | if (elapsed >= keepalive_time_when(tp)) { |
Jerry Chu | dca43c7 | 2010-08-27 19:13:28 +0000 | [diff] [blame] | 698 | /* If the TCP_USER_TIMEOUT option is enabled, use that |
| 699 | * to determine when to timeout instead. |
| 700 | */ |
| 701 | if ((icsk->icsk_user_timeout != 0 && |
Jon Maxwell | 9bcc66e | 2018-07-19 11:14:42 +1000 | [diff] [blame] | 702 | elapsed >= msecs_to_jiffies(icsk->icsk_user_timeout) && |
Jerry Chu | dca43c7 | 2010-08-27 19:13:28 +0000 | [diff] [blame] | 703 | icsk->icsk_probes_out > 0) || |
| 704 | (icsk->icsk_user_timeout == 0 && |
| 705 | icsk->icsk_probes_out >= keepalive_probes(tp))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | tcp_send_active_reset(sk, GFP_ATOMIC); |
| 707 | tcp_write_err(sk); |
| 708 | goto out; |
| 709 | } |
Eric Dumazet | e520af4 | 2015-05-06 14:26:25 -0700 | [diff] [blame] | 710 | if (tcp_write_wakeup(sk, LINUX_MIB_TCPKEEPALIVE) <= 0) { |
Arnaldo Carvalho de Melo | 6687e98 | 2005-08-10 04:03:31 -0300 | [diff] [blame] | 711 | icsk->icsk_probes_out++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | elapsed = keepalive_intvl_when(tp); |
| 713 | } else { |
| 714 | /* If keepalive was lost due to local congestion, |
| 715 | * try harder. |
| 716 | */ |
| 717 | elapsed = TCP_RESOURCE_PROBE_INTERVAL; |
| 718 | } |
| 719 | } else { |
| 720 | /* It is tp->rcv_tstamp + keepalive_time_when(tp) */ |
| 721 | elapsed = keepalive_time_when(tp) - elapsed; |
| 722 | } |
| 723 | |
Hideo Aoki | 3ab224b | 2007-12-31 00:11:19 -0800 | [diff] [blame] | 724 | sk_mem_reclaim(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | |
| 726 | resched: |
Arnaldo Carvalho de Melo | 463c84b | 2005-08-09 20:10:42 -0700 | [diff] [blame] | 727 | inet_csk_reset_keepalive_timer (sk, elapsed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | goto out; |
| 729 | |
YOSHIFUJI Hideaki | e905a9e | 2007-02-09 23:24:47 +0900 | [diff] [blame] | 730 | death: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 731 | tcp_done(sk); |
| 732 | |
| 733 | out: |
| 734 | bh_unlock_sock(sk); |
| 735 | sock_put(sk); |
| 736 | } |
Eric Dumazet | 6f458df | 2012-07-20 05:45:50 +0000 | [diff] [blame] | 737 | |
Eric Dumazet | 5d9f426 | 2018-05-17 14:47:26 -0700 | [diff] [blame] | 738 | static enum hrtimer_restart tcp_compressed_ack_kick(struct hrtimer *timer) |
| 739 | { |
| 740 | struct tcp_sock *tp = container_of(timer, struct tcp_sock, compressed_ack_timer); |
| 741 | struct sock *sk = (struct sock *)tp; |
| 742 | |
| 743 | bh_lock_sock(sk); |
| 744 | if (!sock_owned_by_user(sk)) { |
Eric Dumazet | 86de592 | 2018-11-20 05:53:59 -0800 | [diff] [blame] | 745 | if (tp->compressed_ack > TCP_FASTRETRANS_THRESH) |
Eric Dumazet | 5d9f426 | 2018-05-17 14:47:26 -0700 | [diff] [blame] | 746 | tcp_send_ack(sk); |
| 747 | } else { |
| 748 | if (!test_and_set_bit(TCP_DELACK_TIMER_DEFERRED, |
| 749 | &sk->sk_tsq_flags)) |
| 750 | sock_hold(sk); |
| 751 | } |
| 752 | bh_unlock_sock(sk); |
| 753 | |
| 754 | sock_put(sk); |
| 755 | |
| 756 | return HRTIMER_NORESTART; |
| 757 | } |
| 758 | |
Eric Dumazet | 6f458df | 2012-07-20 05:45:50 +0000 | [diff] [blame] | 759 | void tcp_init_xmit_timers(struct sock *sk) |
| 760 | { |
| 761 | inet_csk_init_xmit_timers(sk, &tcp_write_timer, &tcp_delack_timer, |
| 762 | &tcp_keepalive_timer); |
Eric Dumazet | fb420d5 | 2018-09-28 10:28:44 -0700 | [diff] [blame] | 763 | hrtimer_init(&tcp_sk(sk)->pacing_timer, CLOCK_MONOTONIC, |
Eric Dumazet | 73a6bab | 2018-05-10 14:59:43 -0700 | [diff] [blame] | 764 | HRTIMER_MODE_ABS_PINNED_SOFT); |
Eric Dumazet | 218af59 | 2017-05-16 04:24:36 -0700 | [diff] [blame] | 765 | tcp_sk(sk)->pacing_timer.function = tcp_pace_kick; |
Eric Dumazet | 5d9f426 | 2018-05-17 14:47:26 -0700 | [diff] [blame] | 766 | |
| 767 | hrtimer_init(&tcp_sk(sk)->compressed_ack_timer, CLOCK_MONOTONIC, |
| 768 | HRTIMER_MODE_REL_PINNED_SOFT); |
| 769 | tcp_sk(sk)->compressed_ack_timer.function = tcp_compressed_ack_kick; |
Eric Dumazet | 6f458df | 2012-07-20 05:45:50 +0000 | [diff] [blame] | 770 | } |