Skip to content

Commit ed65721

Browse files
committed
net: P5-C — atomic cutover from TcpConnection to Pcb enum-of-structs
Delete TcpConnection, TcpConnectionTable, TCP_TABLE, TcpInputResult, and the five process_* handler functions. tcp_input now locks PCB_TABLE and dispatches through Pcb::on_segment, returning Actions that callers drain for segments, timer ops, and socket wake-ups. Architecture: buffers live in a parallel static array (PcbTable.buffers[64]) separate from the small Pcb structs (PcbTable.slots[Option<Pcb>; 64]), matching Linux's sk_buff separation and preventing stack overflow on construct/drop of the ~75 KB TcpBufferPair. Key changes: - All lifecycle/query/data-path functions take ConnId, drop tcp_ prefix - TcpState kept as derived read-only view via PcbState::tcp_state() - SegmentBuilder: delete &TcpConnection methods, rename _raw to canon - socket.rs: ConnId threading, socket_notify_tcp_activity takes &Actions - sync_socket_state uses observed_socket_state() directly - tcp_socket shim deleted from lib.rs - Keepalive scheduling wired into tcp_input glue - RttEstimator gains consecutive_timeouts for retransmit-max detection - with_data_state! macro + with_pcb closure API for test ergonomics - All 24 files updated, 2351/2351 tests green (1 deleted: empty defaults) Grep audits: TcpInputResult=0, TcpConnection=0, tcp_get_connection=0, tcp::tcp_=0, pub mod tcp_socket=0 in code.
1 parent 761e09b commit ed65721

24 files changed

Lines changed: 1947 additions & 2774 deletions

drivers/src/virtio_net.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,11 +653,11 @@ fn dispatch_rx_frame(state: &mut VirtioNetState, frame: &[u8]) {
653653
let options = &ip_payload[tcp::TCP_HEADER_LEN..hdr_len];
654654
let payload = &ip_payload[hdr_len..];
655655
let now_ms = slopos_utils::clock::uptime_ms();
656-
let result = tcp::tcp_input(src_ip, dst_ip, &hdr, options, payload, now_ms);
657-
if let Some(seg) = result.response {
658-
let _ = socket::socket_send_tcp_segment(&seg, &[]);
656+
let actions = tcp::input(src_ip, dst_ip, &hdr, options, payload, now_ms);
657+
for seg in actions.segments() {
658+
let _ = socket::socket_send_tcp_segment(seg, &[]);
659659
}
660-
socket::socket_notify_tcp_activity(&result);
660+
socket::socket_notify_tcp_activity(&actions);
661661
}
662662
p if p == net::IpProtocol::Udp.as_u8() => {
663663
if let Some((src_port, dst_port, udp_payload)) = parse_udp_header(ip_payload) {

net/src/ipv4.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ fn dispatch_tcp(src_ip: [u8; 4], dst_ip: [u8; 4], pkt: &PacketBuf, checksum_rx:
213213
// 2-tuple (listener). The actual state machine processing still goes
214214
// through tcp_input() which uses TcpConnectionTable internally.
215215
{
216-
use super::tcp_socket::TCP_DEMUX;
216+
use super::tcp::listener::TCP_DEMUX;
217217
use super::types::{Ipv4Addr, Port};
218218

219219
let demux = TCP_DEMUX.lock();
@@ -242,12 +242,12 @@ fn dispatch_tcp(src_ip: [u8; 4], dst_ip: [u8; 4], pkt: &PacketBuf, checksum_rx:
242242
}
243243
}
244244

245-
let result = tcp::tcp_input(src_ip, dst_ip, &hdr, options, payload, now_ms);
245+
let actions = tcp::input(src_ip, dst_ip, &hdr, options, payload, now_ms);
246246

247-
if let Some(seg) = result.response {
248-
let _ = socket::socket_send_tcp_segment(&seg, &[]);
247+
for seg in actions.segments() {
248+
let _ = socket::socket_send_tcp_segment(seg, &[]);
249249
}
250-
socket::socket_notify_tcp_activity(&result);
250+
socket::socket_notify_tcp_activity(&actions);
251251
}
252252

253253
/// Dispatch a UDP datagram to the socket layer, with DNS interception.

net/src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,6 @@ pub mod route;
3232
pub mod socket;
3333
pub mod socket_file_ops;
3434
pub mod tcp;
35-
/// Compatibility shim for the former top-level `net::tcp_socket` module.
36-
///
37-
/// The real implementation moved to `tcp::listener` under P2.4 of the TCP
38-
/// overhaul. Existing call sites (socket.rs, tests) keep working through
39-
/// this glob re-export; future work will update them to import from
40-
/// `tcp::listener` directly.
41-
pub mod tcp_socket {
42-
pub use crate::tcp::listener::*;
43-
}
4435
pub mod timer;
4536
pub mod udp;
4637
pub mod unix_socket;

0 commit comments

Comments
 (0)