net/ipv4/tcp_timer.c
Source file repositories/reference/linux-study-clean/net/ipv4/tcp_timer.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv4/tcp_timer.c- Extension
.c- Size
- 27197 bytes
- Lines
- 906
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/gfp.hnet/tcp.hnet/tcp_ecn.hnet/rstreason.h
Detected Declarations
function Protocolfunction tcp_clamp_probe0_to_user_timeoutfunction tcp_write_errfunction downfunction tcp_orphan_retriesfunction tcp_mtu_probingfunction tcp_model_timeoutfunction retransmits_timed_outfunction tcp_write_timeoutfunction tcp_delack_timer_handlerfunction tcp_delack_timerfunction tcp_probe_timerfunction tcp_retransmit_timerfunction tcp_update_rto_statsfunction tcp_fastopen_synack_timerfunction tcp_rtx_probe0_timed_outfunction tcp_retransmit_timerfunction tcp_stream_is_thinfunction READ_ONCEfunction tcp_write_timerfunction tcp_write_timerfunction tcp_syn_ack_timeoutfunction tcp_reset_keepalive_timerfunction tcp_delete_keepalive_timerfunction tcp_set_keepalivefunction tcp_keepalive_timerfunction tcp_compressed_ack_kickfunction tcp_init_xmit_timers
Annotated Snippet
if (retransmits_timed_out(sk, READ_ONCE(net->ipv4.sysctl_tcp_retries1), 0)) {
/* Black hole detection */
tcp_mtu_probing(icsk, sk);
__dst_negative_advice(sk);
}
retry_until = READ_ONCE(net->ipv4.sysctl_tcp_retries2);
if (sock_flag(sk, SOCK_DEAD)) {
const bool alive = icsk->icsk_rto < tcp_rto_max(sk);
retry_until = tcp_orphan_retries(sk, alive);
do_reset = alive ||
!retransmits_timed_out(sk, retry_until, 0);
if (tcp_out_of_resources(sk, do_reset))
return 1;
}
}
if (!expired)
expired = retransmits_timed_out(sk, retry_until,
READ_ONCE(icsk->icsk_user_timeout));
tcp_fastopen_active_detect_blackhole(sk, expired);
mptcp_active_detect_blackhole(sk, expired);
if (BPF_SOCK_OPS_TEST_FLAG(tp, BPF_SOCK_OPS_RTO_CB_FLAG))
tcp_call_bpf_3arg(sk, BPF_SOCK_OPS_RTO_CB,
icsk->icsk_retransmits,
icsk->icsk_rto, (int)expired);
if (expired) {
/* Has it gone just too far? */
tcp_write_err(sk);
return 1;
}
if (__sk_rethink_txhash_reset_dst(sk)) {
WRITE_ONCE(tp->timeout_rehash, tp->timeout_rehash + 1);
__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPTIMEOUTREHASH);
}
return 0;
}
/* Called with BH disabled */
void tcp_delack_timer_handler(struct sock *sk)
{
struct inet_connection_sock *icsk = inet_csk(sk);
struct tcp_sock *tp = tcp_sk(sk);
if ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))
return;
/* Handling the sack compression case */
if (tp->compressed_ack) {
tcp_mstamp_refresh(tp);
tcp_sack_compress_send_ack(sk);
return;
}
if (!(icsk->icsk_ack.pending & ICSK_ACK_TIMER))
return;
if (time_after(icsk_delack_timeout(icsk), jiffies)) {
sk_reset_timer(sk, &icsk->icsk_delack_timer,
icsk_delack_timeout(icsk));
return;
}
icsk->icsk_ack.pending &= ~ICSK_ACK_TIMER;
if (inet_csk_ack_scheduled(sk)) {
if (!inet_csk_in_pingpong_mode(sk)) {
/* Delayed ACK missed: inflate ATO. */
icsk->icsk_ack.ato = min_t(u32, icsk->icsk_ack.ato << 1, icsk->icsk_rto);
} else {
/* Delayed ACK missed: leave pingpong mode and
* deflate ATO.
*/
inet_csk_exit_pingpong_mode(sk);
icsk->icsk_ack.ato = TCP_ATO_MIN;
}
tcp_mstamp_refresh(tp);
tcp_send_ack(sk);
__NET_INC_STATS(sock_net(sk), LINUX_MIB_DELAYEDACKS);
}
}
/**
* tcp_delack_timer() - The TCP delayed ACK timeout handler
Annotation
- Immediate include surface: `linux/module.h`, `linux/gfp.h`, `net/tcp.h`, `net/tcp_ecn.h`, `net/rstreason.h`.
- Detected declarations: `function Protocol`, `function tcp_clamp_probe0_to_user_timeout`, `function tcp_write_err`, `function down`, `function tcp_orphan_retries`, `function tcp_mtu_probing`, `function tcp_model_timeout`, `function retransmits_timed_out`, `function tcp_write_timeout`, `function tcp_delack_timer_handler`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.