Skip to content

test: cover tcp_conntrack seq wraparound + exhaustive FSM index scan#82

Merged
w180112 merged 1 commit into
masterfrom
test/tcp-conntrack-wrap-fsm-scan
Jul 9, 2026
Merged

test: cover tcp_conntrack seq wraparound + exhaustive FSM index scan#82
w180112 merged 1 commit into
masterfrom
test/tcp-conntrack-wrap-fsm-scan

Conversation

@w180112

@w180112 w180112 commented Jul 9, 2026

Copy link
Copy Markdown
Member

Summary

Two residual tcp_conntrack gaps from the test-coverage analysis of the PR #72/#75 conntrack work: the seq/ack window tests only exercised deltas far from the 32-bit wrap point, and the constructor-built O(1) FSM dispatch index was never verified against the full state × event space. Test-only change; no production code touched.

New cases in unit_test/pppd/tcp_conntrack_test.c (19 assertions)

test_seq_wraparound (8)

  • tcp_conntrack_seq_update advances max_seq_end/max_ack across the 0xFFFFFFFF → 0 boundary (wrap-aware signed compare: unsigned distance ~4G, signed delta tiny positive)
  • Monotonicity across the wrap: once the baseline crosses 0, a stale pre-wrap seq/ack (huge unsigned value, negative signed delta) cannot roll the max back
  • The explicit == 0 seed guard fires for an ISN ≥ 2³¹ — without it the ISN looks "older than zero" under signed math and the baseline would never advance
  • tcp_conntrack_seq_valid accepts in-window seq and ack just past the wrap, and still enforces the 16 MB seq slack and 0xFFFF ack slack across the wrap (both drop sides verified)

test_fsm_index_full_scan (11)

  • Mirrors tcp_conntrack_tbl as an expected-next-state matrix and drives tcp_conntrack_fsm through all 10 × 6 (state, event) combinations:
    • every defined row must land on the table's next_state
    • every undefined combo must keep the current state and return SUCCESS (no state may hit the no-rows ERROR contract, since every state has at least one row)
  • One assertion per state (with first-mismatch detail) plus a return-value sweep — future table edits or constructor index-build drift get caught here immediately
  • ACK rows are driven LAN-side; the WAN-side MID_STREAM → ESTABLISHED promotion is handler-driven and already covered by the existing promotion tests

Existing cases untouched.

Testing

  • make test: 1404/1404 pass
  • e2e_test/run_e2e_test.sh: 73 PASS / 0 FAIL / 0 SKIP

Two residual gaps from the test-coverage analysis of PR #72/#75's
conntrack work (existing tests only exercised seq deltas far from the
wrap point, and the constructor-built dispatch index was never scanned
against the full state x event space):

- test_seq_wraparound (8 assertions): tcp_conntrack_seq_update advances
  max_seq_end/max_ack across the 0xFFFFFFFF→0 boundary via the
  wrap-aware signed compare; stale pre-wrap seq/ack cannot roll the max
  back after the baseline crosses 0; the explicit ==0 seed guard fires
  for an ISN >= 2^31 (which looks "older than zero" under signed math).
  tcp_conntrack_seq_valid accepts in-window seq/ack just past the wrap
  (unsigned distance ~4G, signed delta tiny) and still drops seq >16MB
  and ack >0xFFFF past the wrap.

- test_fsm_index_full_scan (11 assertions): mirrors tcp_conntrack_tbl
  as an expected-next-state matrix and drives tcp_conntrack_fsm through
  all 10x6 (state, event) combinations — defined rows must land on the
  table's next_state, undefined rows must keep the state and return
  SUCCESS (no state may hit the no-rows ERROR contract since every
  state has rows). Catches future table edits or index-build drift.

Existing cases untouched. make test 1404/1404; e2e 73/73 PASS 0 SKIP.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@w180112 w180112 closed this Jul 9, 2026
@w180112 w180112 reopened this Jul 9, 2026
@w180112 w180112 merged commit c991549 into master Jul 9, 2026
13 checks passed
@w180112 w180112 deleted the test/tcp-conntrack-wrap-fsm-scan branch July 9, 2026 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant