net/ipv4/inet_timewait_sock.c
Source file repositories/reference/linux-study-clean/net/ipv4/inet_timewait_sock.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv4/inet_timewait_sock.c- Extension
.c- Size
- 10792 bytes
- Lines
- 361
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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
linux/kernel.hlinux/slab.hlinux/module.hnet/inet_hashtables.hnet/inet_timewait_sock.hnet/ip.hnet/tcp.hnet/psp.h
Detected Declarations
function inet_twsk_putfunction inet_twsk_killfunction inet_twsk_freefunction inet_twsk_putfunction inet_twsk_schedulefunction inet_twsk_hashdance_schedulefunction tw_timer_handlerfunction inet_twsk_deschedule_putfunction __inet_twsk_schedulefunction inet_twsk_purgefunction sk_nulls_for_each_rcuexport inet_twsk_putexport inet_twsk_deschedule_put
Annotated Snippet
sk_nulls_for_each_rcu(sk, node, &head->chain) {
int state = inet_sk_state_load(sk);
if ((1 << state) & ~(TCPF_TIME_WAIT |
TCPF_NEW_SYN_RECV))
continue;
if (check_net(sock_net(sk)))
continue;
if (unlikely(!refcount_inc_not_zero(&sk->sk_refcnt)))
continue;
if (check_net(sock_net(sk))) {
sock_gen_put(sk);
goto restart;
}
rcu_read_unlock();
local_bh_disable();
if (state == TCP_TIME_WAIT) {
inet_twsk_deschedule_put(inet_twsk(sk));
} else {
struct request_sock *req = inet_reqsk(sk);
inet_csk_reqsk_queue_drop_and_put(req->rsk_listener,
req);
}
local_bh_enable();
goto restart_rcu;
}
/* If the nulls value we got at the end of this lookup is
* not the expected one, we must restart lookup.
* We probably met an item that was moved to another chain.
*/
if (get_nulls_value(node) != slot)
goto restart;
rcu_read_unlock();
}
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/module.h`, `net/inet_hashtables.h`, `net/inet_timewait_sock.h`, `net/ip.h`, `net/tcp.h`, `net/psp.h`.
- Detected declarations: `function inet_twsk_put`, `function inet_twsk_kill`, `function inet_twsk_free`, `function inet_twsk_put`, `function inet_twsk_schedule`, `function inet_twsk_hashdance_schedule`, `function tw_timer_handler`, `function inet_twsk_deschedule_put`, `function __inet_twsk_schedule`, `function inet_twsk_purge`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.