summaryrefslogtreecommitdiff
path: root/fw/test
diff options
context:
space:
mode:
Diffstat (limited to 'fw/test')
-rwxr-xr-xfw/test/fwtest.rc61
1 files changed, 61 insertions, 0 deletions
diff --git a/fw/test/fwtest.rc b/fw/test/fwtest.rc
index 3f80242..bd7423d 100755
--- a/fw/test/fwtest.rc
+++ b/fw/test/fwtest.rc
@@ -547,10 +547,71 @@ echo '== a card'
r=`{awk '$1 == "0.0.0.0" {print $3}' $tmp/nC/iproute | sed 1q}
check 'and the route that went with the card' 10.9.9.254 $"r
+ # The question a firewall has to answer about its own death:
+ # does the network come back open, or not at all. A note is
+ # a fair stand-in for a crash - what matters is the kernel
+ # closing what fw held, which happens either way. No other
+ # fw is running here; the leak checks at the end say so.
+ kill fw | rc
+ sleep 3
+ r=`{ps | awk '$NF == "fw"' | wc -l}
+ check 'killing one part kills the firewall' 0 $"r
+ r=`{awk '/4u$/ {print $1}' $tmp/nC/ipselftab}
+ check 'a dead fw leaves the stack no address' '' $"r
+ r=`{awk '$1 == "0.0.0.0" {print $3}' $tmp/nC/iproute | sed 1q}
+ check 'and no route: the network is down, not open' '' $"r
+ # "device" with nothing after it: the pkt interface is gone
+ # and the card was never given back
+ r=`{sed 1q $tmp/nC/ipifc/0/status | awk '{print $2}'}
+ check 'and nothing bound to hand the card back' maxtu $"r
+
+ # recovery, without ever passing through open. The dead fw
+ # also left its control filesystem mounted, and a corpse of a
+ # mount fails every operation on it - including the check fw
+ # makes before touching a card. So a restart has that to get
+ # past too.
+ @{ $fw -n $tmp/nC -e /net/ether1 -m $mtpt $tmp/empty.ndb } >[2]/dev/null
+ if(~ $status '')
+ r=started
+ if not
+ r=refused
+ check 'it will not restart on a guess' refused $"r
+
+ $fw -n $tmp/nC -e /net/ether1 -a 10.9.9.1/24 -g 10.9.9.254 \
+ -m $mtpt $tmp/empty.ndb >[2] $tmp/rerr
+ sleep 2
+ r=`{grep -c 'cleared '^$mtpt $tmp/rerr}
+ check 'the control mount the dead one left is cleared away' 1 $"r
+ r=`{awk '/4u$/ {print $1}' $tmp/nC/ipselftab}
+ check 'but does when told the address the card no longer has' 10.9.9.1 $"r
+ r=`{awk '$1 == "0.0.0.0" {print $3}' $tmp/nC/iproute | sed 1q}
+ check 'route and all' 10.9.9.254 $"r
+
stopfw $tmp/nC
}
}
+echo '== a dead firewall leaves a sandbox with no network either'
+@{
+ rfork n
+ $fw $tmp/empty.ndb >[2]/dev/null
+ # the drop is per process group and this block has its own, so it
+ # reaches this shell and its children and nothing else
+ echo 'chdev' '&~' 'Iluσ' > /dev/drivers
+ kill fw | rc
+ sleep 3
+ if(@{ ls /net/tcp/clone } >/dev/null >[2]/dev/null)
+ r=there
+ if not
+ r=gone
+ check 'the filtered /net dies with it' gone $"r
+ if(@{ bind -a '#I' /net } >[2]/dev/null)
+ r=allowed
+ if not
+ r=refused
+ check 'and the real one cannot be bound back in its place' refused $"r
+}
+
echo '== supervision'
# fw daemonizes, like every other Plan 9 file server: the process you
# exec posts to /srv, forks the server and exits. A supervisor watches