diff options
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) @{ |
