Repository navigation
faults/network: add network partition fault - #8
Open
alexmchughdev wants to merge 1 commit into
Open
alexmchughdev wants to merge 1 commit into
alexmchughdev wants to merge 1 commit into
Conversation
Third network fault for Phase 2. iptables-based, not netem-based, so this introduces an IPTables abstraction (parallel to TC) and a per-fault chain isolation pattern documented in ADR-0003. Each partition Apply creates a dedicated SCORPIUS_PART_<8hex> chain, populates DROP rules, and inserts jumps from OUTPUT and/or INPUT. Revert deletes the jumps, flushes, and deletes the chain. The agent never reads or modifies user-installed rules, so revert is unconditional and Verify is meaningful. Address takes an IPv4 host or CIDR (IPv6 is a Phase 6 item). Optional parameters: direction (in/out/both, default both), protocol (tcp/udp/ icmp), and port. Port requires tcp or udp protocol. CLI: scorpius inject network-partition --address ... [--protocol ...] [--port ...] [--direction ...] plus the shared duration/audit/ watchdog flags. iptables invocations all pass -w 5 to wait on the xtables lock instead of failing fast under contention.
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
Stage 2 of Phase 2 (v0.2.0). Third network fault, first iptables-based
one. Introduces:
chain-per-fault isolation pattern. Per-fault chain
(
SCORPIUS_PART_<8hex>) holds all DROP rules; jumps are insertedinto the default chains. Revert never touches user rules.
internal/faults/network/iptables.go—IPTablesinterface andexecIPTablesimpl, parallel in shape to the existing TCabstraction. Every invocation passes
-w 5so we wait politelyfor the xtables lock.
internal/faults/network/partition.go—Partitionfault. Applyis fully transactional: any failure mid-build rolls back the
partial chain and any jumps already installed.
validation, rollback paths, idempotent revert, leftover-chain
detection, and the watchdog heartbeat.
//go:build integrationthat exercisea real
iptablesagainst TEST-NET-1 (192.0.2.0/24, RFC 5737) sothe rules cannot affect anything real even if they leak.
CLI:
scorpius inject network-partition --address <ipv4-or-cidr> [--protocol tcp|udp|icmp] [--port N] [--direction in|out|both].IPv4 only in v0.2.0; ip6tables parity is a v1.0 hardening item.
Test plan
go vet ./...go build -tags integration ./...go test -race -count=1 ./...(unit suite, all green)sudo go test -race -count=1 -tags integration ./internal/faults/network/on a host withiptables(uses 192.0.2.x targets so safe to run anywhere; expected post-merge before tagging v0.2.0)