diff options
| author | Calvin Morrison <calvin@pobox.com> | 2026-08-18 23:20:19 -0400 |
|---|---|---|
| committer | Calvin Morrison <calvin@pobox.com> | 2026-08-18 23:20:19 -0400 |
| commit | 1d2e70b303ee08c17a7f59fa8a1e667b709e9dc2 (patch) | |
| tree | 73ef021cd5d5880d8ce3cafd980485c34a422b99 /fw/test | |
| parent | e03c1bb3df2e70f5fb707f5c7a7081022ed31d8c (diff) | |
fw: read the interface tables a line at a time, and test card mode at all
learnaddr, reclaim and takecard each read a status or route file into a
fixed 1024-byte buffer and split it into at most eight lines. I called
this a defect that could lose the default route. It could not: routes
come out sorted, and 0.0.0.0 sorts first, so the default route is on
the first line of the table and both limits are reached long after it
has been found. The report was wrong about the consequence.
The limits are still worth removing, and one thing in there was a real
mistake: learnaddr and takecard looked for the device name anywhere in
the status text, addresses included, rather than in the field that
holds it. An interface whose address contained the name of the device
being looked for would have matched. Contrived, but there is no reason
to be searching a blob for something that has a place of its own. Bio
reads line by line, the device is matched against the device field, and
nothing has a length limit any more.
More to the point, none of this had ever been run. Card mode is
outside the suite because taking the machine's card away is how you
end up with no network -- but a second card that nothing is using can
be taken safely. The suite now binds #l1 into /net, puts it in an IP
stack of its own with an address and a default route, and hands it to
fw with no -a and no -g:
fw: /net/ether1 has 10.9.9.1/120, gateway 10.9.9.254
fw: took /net/ether1 away from .../ipifc/0
fw: protected .../ipifc/0 addr 10.9.9.1 /120
fw: default route via 10.9.9.254
Six checks on that: the address and gateway are read off the interface
rather than repeated on the command line, the card is taken, what
replaces it is a pkt interface at the card's mtu holding the same
address, and the route the card carried is put back. Skipped when
there is no spare card, which is why it says so rather than passing
quietly. 72 pass.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'fw/test')
| -rwxr-xr-x | fw/test/fwtest.rc | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/fw/test/fwtest.rc b/fw/test/fwtest.rc index 8a5a085..0325bfd 100755 --- a/fw/test/fwtest.rc +++ b/fw/test/fwtest.rc @@ -46,7 +46,7 @@ mkdir -p $mtpt # The stacks the packet checks build for themselves. Fixed numbers are # fine because they are unbound again at the end of each block, and the # last check proves it. -stacks=(20 21 22 23 24 25) +stacks=(20 21 22 23 24 25 26) # A port of our own. Conversations outlive the run that made them - a # devip Conv is never freed - so a fixed port makes one run's leftovers @@ -502,6 +502,55 @@ echo '== a fragmented datagram crosses' stopfw $nA $nB } +echo '== a card' +# Card mode has never been tested, because taking the machine's card +# away is how you end up with no network. A second card that nothing +# is using can be taken safely: bound into a stack of our own, given an +# address there, and handed to fw. Everything up to the wire is then +# real - reading the address off the interface, taking the card, +# putting a pkt interface in its place, restoring the route. +@{ + rfork n + bind -a '#l1' /net >[2]/dev/null + spare=no + if(test -e /net/ether1) + if(~ `{grep -c ether1 /net/ipifc/*/status >[2]/dev/null | awk '{n += $1} END {print n+0}'} 0) + spare=yes + if(~ $spare no) + echo ' skip no spare card to take' + if not { + mkdir -p $tmp/nC + bind -a '#I26' $tmp/nC + @{ + conv=`{cat /fd/0} + echo -n 'bind ether /net/ether1' >[1=0] + echo -n 'add 10.9.9.1 255.255.255.0' >[1=0] + } <>[0] $tmp/nC/ipifc/clone + echo -n 'add 0.0.0.0 0.0.0.0 10.9.9.254' > $tmp/nC/iproute + + # no -a and no -g: both come off the interface it is taking + # over, which is the whole point of not having to repeat them + $fw -n $tmp/nC -e /net/ether1 -m $mtpt $tmp/empty.ndb >[2] $tmp/carderr + sleep 2 + + r=`{grep -c '/net/ether1 has 10.9.9.1/120, gateway 10.9.9.254' $tmp/carderr} + check 'the address and gateway are read off the card' 1 $"r + r=`{grep -c 'took /net/ether1 away' $tmp/carderr} + check 'and the card is taken from the stack' 1 $"r + + r=`{sed 1q $tmp/nC/ipifc/0/status | awk '{print $2}'} + check 'what the stack has now is a pkt interface' pkt0 $"r + r=`{sed 1q $tmp/nC/ipifc/0/status | awk '{print $4}'} + check 'at the mtu of the card it replaced' 1500 $"r + r=`{sed -n 2p $tmp/nC/ipifc/0/status | awk '{print $1}'} + check 'keeping the address' 10.9.9.1 $"r + 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 + + stopfw $tmp/nC + } +} + echo '== fwstart' if(test -f $lib/fwstart) @{ |
