test: cover the remaining nat_enospc sources — pool dry + hash-add ENOSPC#83
Merged
Conversation
…OSPC The existing enospc test only exercised the "every port reserved" source. The other two sources in nat_learning_port_reuse were untested (flagged in the coverage analysis of PR #73-#75): free-ring exhaustion inside nat_slot_alloc, and rte_hash_add_key_data failure for each hash. New cases in unit_test/pppd/nat_test.c (22 assertions): - test_pool_dry_enospc: drains the free ring (with one expired flow left behind), then a new learn must fail with nat_enospc+1 while the emergency GC inside nat_slot_alloc demonstrably runs (expired flow's keys deleted, nat_gc_reclaimed+1) yet cannot return the slot in-call because the RCU defer queue needs reader quiescence. After an explicit quiesce+reclaim the slot returns and the same flow learns successfully. - test_reverse_hash_full_enospc / test_forward_hash_full_enospc: the real hashes (262144-entry cuckoo, multi-writer) have no deterministic fill-to-fail point, so these use a small hand-built fixture (8-entry single-writer hashes → exactly 8 adds succeed, the 9th fails with ENOSPC) driving the same nat_learning_port_reuse code: - reverse full: every candidate port fails, one enospc after the full port wrap, the never-published slot returns to the ring on every iteration (no slot leak), no forward-key pollution. - forward full: reverse key gets unpublished (WAN side cannot reach the dead slot), flow fails immediately with one enospc, and the slot goes to deferred reclaim rather than straight back to the ring. Existing cases untouched. make test 1426/1426; e2e 73/73 PASS 0 SKIP. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nat_enospchas three sources innat_learning_port_reuse(); only the "every port reserved" one was tested. This PR covers the other two flagged in the PR #73–#75 coverage analysis: free-ring exhaustion insidenat_slot_alloc()(pool dry) andrte_hash_add_key_data()ENOSPC on each of the two hashes. Test-only change; no production code touched.New cases in
unit_test/pppd/nat_test.c(22 assertions)test_pool_dry_enospc(real fixture)nat_enospcnat_slot_allocdemonstrably runs: the expired flow's keys are deleted (nat_gc_reclaimed+1, reverse lookup misses) — but the slot cannot come back in-call because the RCU defer queue needs reader quiescence firsttest_reverse_hash_full_enospc/test_forward_hash_full_enospc(small deterministic fixture)The real hashes (262144-entry cuckoo, multi-writer + LF) have no deterministic fill-to-fail point — filling them to failure would make the test flaky. These cases build a small hand-assembled fixture (8-entry, single-writer hashes: key slots == entries exactly, so the 9th add fails with ENOSPC deterministically) and drive the very same
nat_learning_port_reuse()code path:nat_enospc; the never-published slot returns to the ring on every failed iteration (no slot leak across 64k+ attempts), and the forward hash stays unpollutednat_enospc, and the slot goes to deferred reclaim rather than straight back to the free ring (a reader may already hold the published entry)Existing cases untouched.
Testing
make test: 1426/1426 passe2e_test/run_e2e_test.sh: 73 PASS / 0 FAIL / 0 SKIP