📄 test_peering2.sh
字号:
coord peer2 send packet update \ origin 2 \ aspath "$PEER2_AS" \ nexthop 10.10.10.10 \ nlri 10.10.10.0/24 sleep 1 coord peer1 assert established coord peer2 assert established reset}test9(){ echo "TEST9 (Simple route propogation test - searching for memory leak):" echo " 1) Bring up peering (peer1)" echo " 2) Bring up a second peering (peer2) and introduce a route" echo " 3) Tear down both peerings" reset coord peer2 establish AS $PEER2_AS holdtime 0 id 192.150.187.102 coord peer2 assert established coord peer1 establish AS $PEER1_AS holdtime 0 id 192.150.187.101 coord peer1 assert established # Inject a route coord peer2 send packet update \ origin 2 \ aspath "$PEER2_AS" \ nexthop 10.10.10.10 \ nlri 10.10.10.0/24 sleep 1 coord peer1 assert established coord peer2 assert established reset}test10(){ echo "TEST10 (Verify that a router ID of 0.0.0.0 doesn't cause a problem):" echo " 1) Bring up peering (peer1)" reset coord peer2 connect sleep 2 coord peer2 expect packet notify $OPENMSGERROR $BADBGPIDENT coord peer2 send packet \ open \ asnum $PEER2_AS \ bgpid 0.0.0.0 \ holdtime 0 sleep 2 coord peer2 assert queue 0 reset}test11(){ echo "TEST11 (Behave sanely when two peers use the same router ID):" echo " 1) Bring up peering (peer1)" echo " 2) Bring up a second peering (peer2)" echo " 3) Tear down both peerings" reset coord peer2 establish AS $PEER2_AS holdtime 0 id 1.1.1.1 coord peer2 assert established coord peer1 establish AS $PEER1_AS holdtime 0 id 1.1.1.1 coord peer1 assert established sleep 1 coord peer1 assert established coord peer2 assert established reset}test12(){ echo "TEST12 (Behave sanely when a peer reuses a router ID):" echo " 1) Bring up peering (peer1)" echo " 2) Tear down the peering (peer1)" echo " 2) Bring up a second peering (peer2) with the same router ID" echo " 3) Tear down peering (peer2)" reset coord peer2 establish AS $PEER2_AS holdtime 0 id 1.1.1.1 coord peer2 assert established # Reset the connection and reuse the ID on the other peer,should be legal. reset coord peer1 establish AS $PEER1_AS holdtime 0 id 1.1.1.1 coord peer1 assert established sleep 1 coord peer1 assert established reset}test13(){ TFILE=$1 echo "TEST13" echo " 1) Inject a saved peering - $TFILE" echo " 2) Change next-hop resolution" echo " 3) Drop peering" echo " 4) Used to cause BGP to fail" # Reset the peers reset VIF0="vif0" IF1=172.16.1.1 GW1=172.16.1.2 NH1=192.150.187.2 register_rib "rib" new_vif $VIF0 add_vif_addr4 $VIF0 $IF1 $IF1/24 coord peer2 establish AS $PEER2_AS holdtime 0 id 192.150.187.102 coord peer2 assert established sleep 2 NOBLOCK=true coord peer2 send dump mrtd update $TFILE bgp_peer_unchanged peer2 coord peer2 assert established add_igp_table4 is-is isis isis true false add_route4 is-is true false $NH1/24 $GW1 10 # Reset the connection reset # Establish the new connection. coord peer2 establish AS $PEER2_AS holdtime 0 id 192.150.187.102 coord peer2 assert established}test14(){ echo "TEST14 (Simple route propogation test with RIB resolving next hop):" echo " 1) Bring up peering (peer1)" echo " 2) Bring up a second peering (peer2)" echo " 3) Introduce a route on (peer1) the IBGP peering" echo " 4) Verify that the route appears on (peer2) the EBGP peering" echo " 5) Tear down both peerings" reset VIF0="vif0" IF1=172.16.1.1 GW1=172.16.1.2 NH1=192.150.187.2 register_rib "rib" new_vif $VIF0 add_vif_addr4 $VIF0 $IF1 $IF1/24 IGP_METRIC=10 add_igp_table4 is-is isis isis true false add_route4 is-is true false $NH1/24 $GW1 $IGP_METRIC coord peer1 establish AS $PEER1_AS holdtime 0 id 192.150.187.101 coord peer1 assert established coord peer2 establish AS $PEER2_AS holdtime 0 id 192.150.187.102 coord peer2 assert established coord peer2 expect packet update \ origin 2 \ aspath 65008,1000 \ med $IGP_METRIC \ nexthop $NEXT_HOP \ nlri 10.10.10.0/24 # Inject a route coord peer1 send packet update \ origin 2 \ aspath 1000 \ localpref 100 \ nexthop $NH1 \ nlri 10.10.10.0/24 sleep 2 coord peer2 assert queue 0 coord peer1 assert established coord peer2 assert established reset}test15(){ TFILE=$1 echo "TEST15:" echo " 1) Start injecting a saved feed (peer1 I-BGP) - $TFILE" echo " 2) Wait until the whole feed has been sent" echo " 3) Bring up a second peering (peer3 E-BGP)" echo " 4) Verify all sent packets arrived" echo " 5) Verify all received packets were sent" # Reset the peers reset # Establish the EBGP peering. coord peer1 establish AS $PEER1_AS holdtime 0 id 192.150.187.101 coord peer1 assert established # Save the traffic that we send on peer1 SENT=${TMPDIR}/peer1_sent.text.$EXT rm -f $SENT coord peer1 dump sent text ipv4 traffic $SENT # send in the saved file UPDATES= NOBLOCK=true coord peer1 send dump mrtd update $TFILE $UPDATES # Wait for the whole feed to be sent it may not all have arrived at BGP bgp_peer_unchanged peer1 # XXXX # Put a big delay here if you want all the packets to have been processed # by BGP. # Save the traffic that we receive on peer3 useful for debugging RECV=${TMPDIR}/peer3_recv.text.$EXT rm -f $RECV coord peer3 dump recv text ipv4 traffic $RECV # Bring up a second peering and wait for all the updates to arrive coord peer3 establish AS $PEER3_AS holdtime 0 id 192.150.187.103 # Wait for the whole feed to be received bgp_peer_unchanged peer3 # Check all the sent packets and verify that they arrived at peer3 XRLS=${TMPDIR}/xrls.$EXT echo "Building lookup list in $XRLS" cat $SENT | $PYTHON $srcdir/lookup.py --peer peer3 \ --trie recv \ --add 65008 > $XRLS echo "Performing lookup" $CALLXRL -f $XRLS # Check all the received packets and verify that they were sent by peer1 XRLS=${TMPDIR}/xrls.$EXT echo "Building lookup list in $XRLS" cat $RECV | $PYTHON $srcdir/lookup.py --peer peer1 \ --trie sent \ --remove 65008 > $XRLS echo "Performing lookup" $CALLXRL -f $XRLS # Make sure that the peer1 connection is still established coord peer1 assert established coord peer3 assert established rm -f $SENT $RECV $XRLS}test16(){ TFILE=$1 echo "TEST16:" echo " 1) Start injecting a saved feed (peer2 E-BGP) - $TFILE" echo " 2) Wait until the whole feed has been sent" echo " 3) Bring up a second peering (peer1 I-BGP) " echo " 4) Verify all sent packets arrived" echo " 5) Verify all received packets were sent" # Reset the peers reset # Establish the EBGP peering. coord peer2 establish AS $PEER2_AS holdtime 0 id 192.150.187.102 coord peer2 assert established # Save the traffic that we send on peer2 SENT=${TMPDIR}/peer2_sent.text.$EXT rm -f $SENT coord peer2 dump sent text ipv4 traffic $SENT # send in the saved file UPDATES= NOBLOCK=true coord peer2 send dump mrtd update $TFILE $UPDATES # Wait for the whole feed to be sent it may not all have arrived at BGP bgp_peer_unchanged peer2 # XXXX # Put a big delay here if you want all the packets to have been processed # by BGP. # Save the traffic that we receive on peer1 useful for debugging RECV=${TMPDIR}/peer1_recv.text.$EXT rm -f $RECV coord peer1 dump recv text ipv4 traffic $RECV # Bring up a second peering and wait for all the updates to arrive coord peer1 establish AS $PEER1_AS holdtime 0 id 192.150.187.101 # Wait for the whole feed to arrive bgp_peer_unchanged peer1 # Check all the sent packets and verify that they arrived at peer1 XRLS=${TMPDIR}/xrls.$EXT echo "Building lookup list in $XRLS" cat $SENT | $PYTHON $srcdir/lookup.py --peer peer1 \ --trie recv > $XRLS echo "Performing lookup" $CALLXRL -f $XRLS # Check all the received packets and verify that they were sent by peer2 XRLS=${TMPDIR}/xrls.$EXT echo "Building lookup list in $XRLS" cat $RECV | $PYTHON $srcdir/lookup.py --peer peer2 \ --trie sent \ --remove 65008 > $XRLS echo "Performing lookup" $CALLXRL -f $XRLS # Make sure that the peer1 connection is still established coord peer1 assert established coord peer2 assert established rm -f $SENT $RECV $XRLS}test17(){ echo "TEST17:" echo " 1) Run test15 thrice" test15 $* test15 $* test15 $*}test_work_in_progress(){ TFILE=$1 echo "TEST:" echo " 1) Start injecting a saved feed (peer1 I-BGP) - $TFILE" echo " 2) Wait until the whole feed has been sent" echo " 3) Bring up a second peering (peer3 E-BGP)" echo " 4) Verify all sent packets arrived" echo " 5) Verify all received packets were sent" # Reset the peers reset # Establish the EBGP peering. coord peer1 establish AS $PEER1_AS holdtime 0 id 192.150.187.101 coord peer1 assert established # Save the traffic that we send on peer1 SENT=${TMPDIR}/peer1_sent.text.$EXT rm -f $SENT coord peer1 dump sent text ipv4 traffic $SENT # send in the saved file UPDATES= NOBLOCK=true coord peer1 send dump mrtd update $TFILE $UPDATES # Wait for the whole feed to be sent it may not all have arrived at BGP bgp_peer_unchanged peer1 # XXXX # Put a big delay here if you want all the packets to have been processed # by BGP. for i in 1 2 do # Drop receive peering the first time round we are not connected coord peer3 disconnect # Save the traffic that we receive on peer3 useful for debugging RECV=${TMPDIR}/peer3_recv.text.$EXT rm -f $RECV coord peer3 dump recv text ipv4 traffic $RECV # Bring up a second peering and wait for all the updates to arrive coord peer3 establish AS $PEER3_AS holdtime 0 id 192.150.187.103 # Wait for the whole feed to be received bgp_peer_unchanged peer3 # Check all the sent packets and verify that they arrived at peer3 XRLS=${TMPDIR}/xrls.$EXT cat $SENT | $PYTHON $srcdir/lookup.py --peer peer3 \ --trie recv \ --add 65008 > $XRLS $CALLXRL -f $XRLS # Check all the received packets and verify that they were sent by peer1 XRLS=${TMPDIR}/xrls.$EXT cat $RECV | $PYTHON $srcdir/lookup.py --peer peer1 \ --trie sent \ --remove 65008 > $XRLS $CALLXRL -f $XRLS # Make sure that the peer1 connection is still established coord peer1 assert established coord peer3 assert established done # Stop saving received packets coord peer3 dump recv text ipv4 traffic for i in 1 2 3 4 5 6 7 8 9 10 do # drop feed peering coord peer1 disconnect # Establish the EBGP peering. coord peer1 establish AS $PEER1_AS holdtime 0 id 192.150.187.101 coord peer1 assert established # Save the traffic that we send on peer1 SENT=${TMPDIR}/peer1_sent.text.$EXT rm -f $SENT coord peer1 dump sent text ipv4 traffic $SENT # send in the saved file UPDATES= NOBLOCK=true coord peer1 send dump mrtd update $TFILE $UPDATES # Wait for the whole feed to be sent it may not all have arrived at BGP bgp_peer_unchanged peer1 # Wait for the whole feed to be received bgp_peer_unchanged peer3 # Check all the sent packets and verify that they arrived at peer3 XRLS=${TMPDIR}/xrls.$EXT cat $SENT | $PYTHON $srcdir/lookup.py --peer peer3 \ --trie recv \ --add 65008 > $XRLS $CALLXRL -f $XRLS # Make sure that the peer1 connection is still established coord peer1 assert established coord peer3 assert established done rm -f $SENT $RECV $XRLS}TESTS_NOT_FIXED=''TESTS='test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 test11 test12 test13 test14 test15 test16 test17'# Sanity check that python is present on the host system.PYTHON=${PYTHON:=python}python_version=$(${PYTHON} -V 2>&1)if [ "X${python_version}" = "X" ]; then exit 2else export PYTHONfi# Include command line. ${srcdir}/args.shif [ $START_PROGRAMS = "yes" ]then CXRL="$CALLXRL -r 10" runit $QUIET $VERBOSE -c "$0 -s -c $*" <<EOF ../../libxipc/xorp_finder ../../fea/xorp_fea_dummy = $CXRL finder://fea/common/0.1/get_target_name ../../rib/xorp_rib = $CXRL finder://rib/common/0.1/get_target_name ../xorp_bgp = $CXRL finder://bgp/common/0.1/get_target_name ./test_peer -s peer1 = $CXRL finder://peer1/common/0.1/get_target_name ./test_peer -s peer2 = $CXRL finder://peer1/common/0.1/get_target_name ./test_peer -s peer3 = $CXRL finder://peer1/common/0.1/get_target_name ./coord = $CXRL finder://coord/common/0.1/get_target_nameEOF trap '' 0 exit $?fiif [ $CONFIGURE = "yes" ]then configure_bgpfifor i in $TESTSdo for t in ${TFILE:-$TRAFFIC_FILES} do if [ -f $t ] then# Temporary fix to let TCP sockets created by call_xrl pass through TIME_WAIT TIME_WAIT=`time_wait_seconds` echo "Waiting $TIME_WAIT seconds for TCP TIME_WAIT state timeout" sleep $TIME_WAIT $i $t else echo "Traffic file $t missing." fi donedone# Local Variables:# mode: shell-script# sh-indentation: 4# End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -