carlos / platform Public

egress: the kernel proof's live windows share one deadline set at the write (#328)

Both addresses of a revoke get one 2 s deadline taken right after the
set-property call, and an observation counts only if its probe completed
before it. The open check uses the same rule.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 6b32e92ec215090a0b30ac8ac78065721faa4b13 parent 5ce107d
1 file changed, +19 −10
  • internal/host/egress_kernel_rootrunner_linux_test.go +19 −10
diff --git a/internal/host/egress_kernel_rootrunner_linux_test.go b/internal/host/egress_kernel_rootrunner_linux_test.go
index d55583fa9..c2befbe7c 100644
--- a/internal/host/egress_kernel_rootrunner_linux_test.go
+++ b/internal/host/egress_kernel_rootrunner_linux_test.go
@@ -346,16 +346,25 @@ func TestRootEgressKernelProof(t *testing.T) {
t.Fatal("tenant probe", addr, resp.Status)
return false
}
- // within polls every 100 ms for up to 2 s until reach(addr) == want.
- within := func(c *http.Client, addr string, want bool) bool {
+ // within polls every 100 ms until every addr has been seen with
+ // reach(addr) == want. One deadline is shared by all the addresses, and
+ // an observation counts only if its probe completed before it.
+ within := func(deadline time.Time, c *http.Client, want bool, addrs ...string) bool {
t.Helper()
- deadline := time.Now().Add(2 * time.Second)
+ pending := append([]string(nil), addrs...)
for {
- if reach(c, addr) == want {
- return true
+ var still []string
+ for _, addr := range pending {
+ got := reach(c, addr)
+ if time.Now().After(deadline) {
+ return false
+ }
+ if got != want {
+ still = append(still, addr)
+ }
}
- if time.Now().After(deadline) {
- return false
+ if pending = still; len(pending) == 0 {
+ return true
}
time.Sleep(100 * time.Millisecond)
}
@@ -381,7 +390,7 @@ func TestRootEgressKernelProof(t *testing.T) {
// Step 2: reset the slice's allow while the child runs.
mustCtl("set-property", "--runtime", slice, "IPAddressAllow=")
- revoked := within(a, open20, false) && within(a, open6, false)
+ revoked := within(time.Now().Add(2*time.Second), a, false, open20, open6)
verdict("revoke live", revoked)
if !revoked {
t.Error("step 2: 10.0.5.20 or fd00:5::20 still reachable 2 s after the slice's allow was reset")
@@ -396,14 +405,14 @@ func TestRootEgressKernelProof(t *testing.T) {
// Close it by restarting, so step 3 still measures "open live".
mustCtl("restart", units[0])
serving(units[0], a)
- if !within(a, open20, false) {
+ if !within(time.Now().Add(2*time.Second), a, false, open20) {
t.Fatal("step 2: 10.0.5.20 still reachable after a restart under an empty slice allow")
}
}
// Step 3: re-open 10.0.5.20 while the child runs.
mustCtl("set-property", "--runtime", slice, "IPAddressAllow=", "IPAddressAllow=10.0.5.20/32")
- opened := within(a, open20, true)
+ opened := within(time.Now().Add(2*time.Second), a, true, open20)
verdict("open live", opened)
if !opened {
t.Error("step 3: 10.0.5.20 not reachable 2 s after the slice's allow named it")