net/ipv4/tcp_minisocks.c
Source file repositories/reference/linux-study-clean/net/ipv4/tcp_minisocks.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv4/tcp_minisocks.c- Extension
.c- Size
- 31806 bytes
- Lines
- 1016
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/tcp.hnet/tcp_ecn.hnet/xfrm.hnet/busy_poll.hnet/rstreason.hnet/psp.h
Detected Declarations
function Protocolfunction tcp_timewait_check_oow_rate_limitfunction twsk_rcv_nxt_updatefunction onefunction duplicatefunction tcp_time_wait_initfunction tcp_time_waitfunction tcp_twsk_destructorfunction tcp_twsk_purgefunction list_for_each_entryfunction tcp_openreq_init_rwinfunction tcp_ecn_openreq_childfunction tcp_ca_openreq_childfunction smc_check_reset_syn_reqfunction XXXfunction drawsfunction TCP_SKB_CBfunction __inet_lookup_established
Annotated Snippet
if (tmp_opt.saw_tstamp) {
if (tmp_opt.rcv_tsecr)
tmp_opt.rcv_tsecr -= tcptw->tw_ts_offset;
tmp_opt.ts_recent = READ_ONCE(tcptw->tw_ts_recent);
tmp_opt.ts_recent_stamp = ts_recent_stamp;
paws_reject = tcp_paws_reject(&tmp_opt, th->rst);
}
}
if (READ_ONCE(tw->tw_substate) == TCP_FIN_WAIT2) {
/* Just repeat all the checks of tcp_rcv_state_process() */
if (psp_drop)
goto out_put;
/* Out of window, send ACK */
if (paws_reject ||
!tcp_in_window(TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq,
rcv_nxt,
rcv_nxt + tcptw->tw_rcv_wnd))
return tcp_timewait_check_oow_rate_limit(
tw, skb, LINUX_MIB_TCPACKSKIPPEDFINWAIT2);
if (th->rst)
goto kill;
if (th->syn && !before(TCP_SKB_CB(skb)->seq, rcv_nxt))
return TCP_TW_RST;
/* Dup ACK? */
if (!th->ack ||
!after(TCP_SKB_CB(skb)->end_seq, rcv_nxt) ||
TCP_SKB_CB(skb)->end_seq == TCP_SKB_CB(skb)->seq) {
inet_twsk_put(tw);
return TCP_TW_SUCCESS;
}
/* New data or FIN. If new data arrive after half-duplex close,
* reset.
*/
if (!th->fin ||
TCP_SKB_CB(skb)->end_seq != rcv_nxt + 1)
return TCP_TW_RST;
/* FIN arrived, enter true time-wait state. */
WRITE_ONCE(tw->tw_substate, TCP_TIME_WAIT);
twsk_rcv_nxt_update(tcptw, TCP_SKB_CB(skb)->end_seq,
rcv_nxt);
if (tmp_opt.saw_tstamp) {
u64 ts = tcp_clock_ms();
WRITE_ONCE(tw->tw_entry_stamp, ts);
WRITE_ONCE(tcptw->tw_ts_recent_stamp,
div_u64(ts, MSEC_PER_SEC));
WRITE_ONCE(tcptw->tw_ts_recent,
tmp_opt.rcv_tsval);
}
inet_twsk_reschedule(tw, TCP_TIMEWAIT_LEN);
return TCP_TW_ACK;
}
/*
* Now real TIME-WAIT state.
*
* RFC 1122:
* "When a connection is [...] on TIME-WAIT state [...]
* [a TCP] MAY accept a new SYN from the remote TCP to
* reopen the connection directly, if it:
*
* (1) assigns its initial sequence number for the new
* connection to be larger than the largest sequence
* number it used on the previous connection incarnation,
* and
*
* (2) returns to TIME-WAIT state if the SYN turns out
* to be an old duplicate".
*/
if (!paws_reject &&
(TCP_SKB_CB(skb)->seq == rcv_nxt &&
(TCP_SKB_CB(skb)->seq == TCP_SKB_CB(skb)->end_seq || th->rst))) {
/* In window segment, it may be only reset or bare ack. */
if (psp_drop)
goto out_put;
if (th->rst) {
/* This is TIME_WAIT assassination, in two flavors.
Annotation
- Immediate include surface: `net/tcp.h`, `net/tcp_ecn.h`, `net/xfrm.h`, `net/busy_poll.h`, `net/rstreason.h`, `net/psp.h`.
- Detected declarations: `function Protocol`, `function tcp_timewait_check_oow_rate_limit`, `function twsk_rcv_nxt_update`, `function one`, `function duplicate`, `function tcp_time_wait_init`, `function tcp_time_wait`, `function tcp_twsk_destructor`, `function tcp_twsk_purge`, `function list_for_each_entry`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.