21 #include <linux/module.h>
35 static void tcp_write_err(
struct sock *
sk)
86 static int tcp_orphan_retries(
struct sock *sk,
int alive)
97 if (retries == 0 && alive)
105 if (sysctl_tcp_mtu_probing) {
114 mss =
min(sysctl_tcp_base_mss, mss);
127 static bool retransmits_timed_out(
struct sock *sk,
128 unsigned int boundary,
129 unsigned int timeout,
132 unsigned int linear_backoff_thresh, start_ts;
135 if (!inet_csk(sk)->icsk_retransmits)
139 start_ts =
TCP_SKB_CB(tcp_write_queue_head(sk))->when;
141 start_ts = tcp_sk(sk)->retrans_stamp;
143 if (
likely(timeout == 0)) {
146 if (boundary <= linear_backoff_thresh)
147 timeout = ((2 << boundary) - 1) * rto_base;
149 timeout = ((2 << linear_backoff_thresh) - 1) * rto_base +
156 static int tcp_write_timeout(
struct sock *sk)
164 dst_negative_advice(sk);
168 if (retransmits_timed_out(sk, sysctl_tcp_retries1, 0, 0)) {
170 tcp_mtu_probing(icsk, sk);
172 dst_negative_advice(sk);
179 retry_until = tcp_orphan_retries(sk, alive);
181 !retransmits_timed_out(sk, retry_until, 0, 0);
183 if (tcp_out_of_resources(sk, do_reset))
188 if (retransmits_timed_out(sk, retry_until,
202 sk_mem_reclaim_partial(sk);
213 if (!skb_queue_empty(&tp->
ucopy.prequeue)) {
218 while ((skb = __skb_dequeue(&tp->
ucopy.prequeue)) !=
NULL)
219 sk_backlog_rcv(sk, skb);
221 tp->
ucopy.memory = 0;
224 if (inet_csk_ack_scheduled(sk)) {
240 if (sk_under_memory_pressure(sk))
244 static void tcp_delack_timer(
unsigned long data)
246 struct sock *sk = (
struct sock *)data;
252 inet_csk(sk)->icsk_ack.blocked = 1;
262 static void tcp_probe_timer(
struct sock *sk)
293 max_probes = tcp_orphan_retries(sk, alive);
295 if (tcp_out_of_resources(sk, alive || icsk->
icsk_probes_out <= max_probes))
311 static void tcp_fastopen_synack_timer(
struct sock *sk)
318 req = tcp_sk(sk)->fastopen_rsk;
319 req->
rsk_ops->syn_ack_timeout(sk, req);
321 if (req->
retrans >= max_retries) {
352 tcp_fastopen_synack_timer(sk);
361 WARN_ON(tcp_write_queue_empty(sk));
371 if (sk->sk_family ==
AF_INET) {
377 #if IS_ENABLED(CONFIG_IPV6)
378 else if (sk->sk_family ==
AF_INET6) {
393 goto out_reset_timer;
396 if (tcp_write_timeout(sk))
469 tcp_stream_is_thin(tp) &&
513 static void tcp_write_timer(
unsigned long data)
515 struct sock *sk = (
struct sock *)data;
533 static void tcp_synack_timer(
struct sock *sk)
557 static void tcp_keepalive_timer (
unsigned long data)
559 struct sock *sk = (
struct sock *) data;
573 tcp_synack_timer(sk);
593 elapsed = keepalive_time_when(tp);
599 elapsed = keepalive_time_elapsed(tp);
601 if (elapsed >= keepalive_time_when(tp)) {
616 elapsed = keepalive_intvl_when(tp);
625 elapsed = keepalive_time_when(tp) - elapsed;
645 &tcp_keepalive_timer);