Skip to content

test(net): cover nonblocking socket read and readv semantics - #2318

Merged
fslongjin merged 1 commit into
DragonOS-Community:masterfrom
fslongjin:codex/ngc003-socket-read-nonblocking
Sep 22, 2026
Merged

fslongjin merged 1 commit into
DragonOS-Community:masterfrom
fslongjin:codex/ngc003-socket-read-nonblocking

Conversation

@fslongjin

Copy link
Copy Markdown
Member

Summary

Add eight dunitest regression cases for FIONBIO-controlled read and readv on TCP, UDP, Unix stream and Unix datagram sockets.

The nonblocking state synchronization fix merged in #2317 also resolves the nginx HTTPS handshake-success/HTTP-timeout symptom. This PR adds missing file-style read coverage; it does not introduce another kernel change or an nginx workaround.

Coverage and design

  • Enable nonblocking mode and verify shared flags through dup.
  • Require EAGAIN on an empty receive queue.
  • Read an available byte, then require EAGAIN after draining.
  • Clear FIONBIO through the alias and verify that a read waits for delayed data.
  • Reuse existing socket ownership and bounded child-process helpers, with no new dependencies.
  • Use single-byte writes rather than assuming a stream read fills its buffer.

Validation

  • Linux: 19/19 socket_nonblocking cases pass.
  • Controlled guest comparison restoring the previous nonblocking implementation: all eight new cases detect incorrect blocking and are bounded by the existing watchdog.
  • Current DragonOS: 19 socket_nonblocking, 13 socket_readv_semantics, 3 tcp_listen_poll_semantics and 40 tcp_relisten cases pass (75 total).
  • Real nginx on DragonOS: guest curl succeeds with TLS 1.2 and TLS 1.3, including certificate verification.
  • Host-to-guest HTTPS: 20 connections per TLS version, five requests per connection, concurrency four, 100ms gaps; all 200 requests pass with correct body and verified keepalive reuse.
  • The controlled old-behavior comparison completes both TLS handshakes but times out awaiting HTTP responses; a syscall snapshot captures a worker inside read. The comparison isolates the nonblocking change group, not each individual modification.
  • make kernel, FMT_CHECK=1 make fmt, and git diff --check pass.
  • Independent design and implementation review completed with no blocking findings.

The HTTPS checks cover IPv4 HTTP/1.1 with a short static response; they are not a claim of complete TLS or nginx compatibility.

Protect file-style socket reads used by TLS BIOs against divergence between FIONBIO file flags and the socket mode. The runtime synchronization fix is already present in DragonOS-Community#2317; no additional kernel or nginx workaround is needed.

Add eight parameterized cases covering TCP, UDP, Unix streams and Unix datagrams. Check empty-queue EAGAIN through a duplicated descriptor, successful reads followed by EAGAIN after draining, and restored blocking reads after FIONBIO is cleared. Reuse the existing bounded child watchdog and socket ownership helper. Send one byte to avoid assuming stream reads fill their buffers.

Validation: all 19 socket_nonblocking tests pass on Linux and DragonOS. All eight new cases detect erroneous blocking with the previous nonblocking implementation restored in a controlled guest. On current master, 75 focused guest tests and 200 TLS 1.2/1.3 HTTPS requests pass, including verified keepalive reuse. Kernel build, formatting checks, and independent plan/code review pass.
Signed-off-by: longjin <longjin@dragonos.org>
@github-actions github-actions Bot added the test Unitest/User space test label Sep 22, 2026
@fslongjin

Copy link
Copy Markdown
Member Author

@codex review

@fslongjin
fslongjin merged commit 16ad77d into DragonOS-Community:master Sep 22, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Unitest/User space test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant