Wave icon indicating copy to clipboard operation
Wave copied to clipboard

Expose datagram truncation instead of losing recvmsg result flags

Open LunaStev opened this issue 2 months ago • 0 comments

The Linux vectored receive provider constructs a local NativeMessage, calls recvmsg, and returns only the byte count. The kernel-written message.flags are discarded. udp_recv_vectored then returns an ordinary successful NetIoResult, which has no truncation field.

For a datagram larger than the combined receive buffers, Linux reports MSG_TRUNC in the output flags. Once that flag is discarded, a caller cannot distinguish a complete datagram that exactly filled the buffers from the prefix of a larger datagram whose tail was discarded. The public single-buffer UDP receive helpers also expose only the count/error outcome.

This is a request for an observable portable result, not a claim that a returned byte count by itself violates recvmsg behavior.

Code evidence:

Acceptance:

  • [ ] Preserve native truncation information through the provider boundary and expose it via a reviewed result/API extension or an explicit truncation error.
  • [ ] Keep the number of bytes actually stored distinct from the original datagram size when a backend can report both.
  • [ ] Cover smaller-than-buffer, exactly-full, oversized and zero-length datagrams over loopback, with one and several receive slices.
  • [ ] Define equivalent observable behavior for supported native Windows/BSD providers without making TCP EOF semantics depend on datagram flags.
  • [ ] Preserve bounded caller-owned storage and do not retry a truncated datagram as if its discarded tail were another stream read.

Reference: Linux recvmsg output flags. Related #515 replaces Linux vector libc wrappers, but does not cover lost result flags; #509 concerns zero-length TCP reads, and #508 concerns error-code classification.

Audit status: static source inspection against canonical master ea74c2dafc31da876e5561f2d176ba719f5a0458 on 2026-09-10. No compiler build, test execution, implementation change or local reproduction was performed for this report. The examples describe the source-derived behavior to verify when implementing the fix.

LunaStev avatar Sep 10 '26 12:09 LunaStev