📄 test_routing1.sh
字号:
coord target $HOST $PORT3 coord initialise attach peer3 coord peer3 establish AS $PEER3_AS \ holdtime $HOLDTIME \ id 10.10.10.3 \ keepalive false coord peer3 assert established PACKET_A="packet update origin 2 aspath $PEER2_AS,1 nexthop $NH1 nlri 10.10.10.0/24 nlri 20.20.20.20/24" PACKET_B="packet update origin 2 aspath $PEER1_AS,1,2 nexthop $NH2 nlri 10.10.10.0/24 nlri 20.20.20.20/24" PACKET_C="packet update origin 2 aspath $PEER2_AS,1,2,3 nexthop $NH3 nlri 10.10.10.0/24 nlri 20.20.20.20/24" coord peer1 send $PACKET_B sleep 2 coord peer1 trie sent lookup 10.10.10.0/24 \ aspath "$PEER1_AS,1,2" coord peer2 trie recv lookup 10.10.10.0/24 \ aspath "65008,$PEER1_AS,1,2" coord peer3 trie recv lookup 10.10.10.0/24 \ aspath "$PEER1_AS,1,2" coord peer2 send $PACKET_C sleep 2# coord peer1 trie sent lookup 10.10.10.0/24 \# aspath "$PEER1_AS,1,2" coord peer2 trie sent lookup 10.10.10.0/24 \ aspath "$PEER2_AS,1,2,3" coord peer3 trie recv lookup 10.10.10.0/24 \ aspath "$PEER1_AS,1,2" coord peer2 send $PACKET_A sleep 2 coord peer1 trie recv lookup 10.10.10.0/24 \ aspath "65008,$PEER2_AS,1" coord peer2 trie sent lookup 10.10.10.0/24 \ aspath "$PEER2_AS,1" coord peer3 trie recv lookup 10.10.10.0/24 \ aspath "$PEER2_AS,1" # At the end of the test we expect all the peerings to still be established. coord peer1 assert established coord peer2 assert established coord peer3 assert established}test4(){# Route A is better than route B which is better than route C.# 1) Add a route (B) via peer1# 2) Add a route (A) via peer2 echo "TEST4 - Add a route on one peer add a better route on another peer." coord reset coord target $HOST $PORT1 coord initialise attach peer1 coord peer1 establish AS $PEER1_AS \ holdtime $HOLDTIME \ id 10.10.10.1 \ keepalive false coord peer1 assert established coord target $HOST $PORT2 coord initialise attach peer2 coord peer2 establish AS $PEER2_AS \ holdtime $HOLDTIME \ id 10.10.10.2 \ keepalive false coord peer2 assert established coord target $HOST $PORT3 coord initialise attach peer3 coord peer3 establish AS $PEER3_AS \ holdtime $HOLDTIME \ id 10.10.10.3 \ keepalive false coord peer3 assert established LONG_AS_PATH="$PEER1_AS,2,3,4,5" PACKET_A="packet update origin 2 aspath $PEER2_AS nexthop $NH1 nlri 10.10.10.0/24 nlri 20.20.20.20/24" PACKET_B="packet update origin 2 aspath $LONG_AS_PATH nexthop $NH2 nlri 10.10.10.0/24 nlri 20.20.20.20/24" coord peer1 send $PACKET_B sleep 2 coord peer1 trie sent lookup 10.10.10.0/24 \ aspath $LONG_AS_PATH coord peer2 trie recv lookup 10.10.10.0/24 \ aspath "65008,$LONG_AS_PATH" coord peer3 trie recv lookup 10.10.10.0/24 \ aspath $LONG_AS_PATH coord peer2 send $PACKET_A sleep 2 coord peer1 trie recv lookup 10.10.10.0/24 \ aspath "65008,$PEER2_AS" coord peer2 trie sent lookup 10.10.10.0/24 \ aspath "$PEER2_AS" coord peer3 trie recv lookup 10.10.10.0/24 \ aspath "$PEER2_AS" # At the end of the test we expect all the peerings to still be established. coord peer1 assert established coord peer2 assert established coord peer3 assert established}test5(){# Route A is better than route B which is better than route C.# 1) Add a route (B) via peer1# 2) Add a route (A) via peer1 echo "TEST5 - Add a route on one peer then add a better route" coord reset coord target $HOST $PORT1 coord initialise attach peer1 coord peer1 establish AS $PEER1_AS \ holdtime $HOLDTIME \ id 10.10.10.1 \ keepalive false coord peer1 assert established coord target $HOST $PORT2 coord initialise attach peer2 coord peer2 establish AS $PEER2_AS \ holdtime $HOLDTIME \ id 10.10.10.2 \ keepalive false coord peer2 assert established coord target $HOST $PORT3 coord initialise attach peer3 coord peer3 establish AS $PEER3_AS \ holdtime $HOLDTIME \ id 10.10.10.3 \ keepalive false coord peer3 assert established LONG_AS_PATH="$PEER1_AS,1,2,3,4,5" PACKET_A="packet update origin 2 aspath $PEER1_AS nexthop $NH1 nlri 10.10.10.0/24 nlri 20.20.20.20/24" PACKET_B="packet update origin 2 aspath $LONG_AS_PATH nexthop $NH2 nlri 10.10.10.0/24 nlri 20.20.20.20/24" coord peer1 send $PACKET_B sleep 2 coord peer1 trie sent lookup 10.10.10.0/24 \ aspath $LONG_AS_PATH coord peer2 trie recv lookup 10.10.10.0/24 \ aspath "$AS,$LONG_AS_PATH" coord peer3 trie recv lookup 10.10.10.0/24 \ aspath $LONG_AS_PATH coord peer1 send $PACKET_A sleep 2 coord peer1 trie sent lookup 10.10.10.0/24 \ aspath "$PEER1_AS" coord peer2 trie recv lookup 10.10.10.0/24 \ aspath "$AS,$PEER1_AS" coord peer3 trie recv lookup 10.10.10.0/24 \ aspath "$PEER1_AS" # At the end of the test we expect all the peerings to still be established. coord peer1 assert established coord peer2 assert established coord peer3 assert established}test6(){ echo "TEST6 On an EBGP peering send an update with a local preference"# Sending an update with a local preference is wrong, but it shouldn't cause# any problems. We test that when the update is propogated that the bad local# preference is removed and replaced with a local preference of 100. Which# is the recommended default. Note we are also testing that peer2 does not# receive the med from peer1. coord reset coord target $HOST $PORT1 coord initialise attach peer1 coord peer1 establish AS $PEER1_AS \ holdtime 0 \ id 10.10.10.1 \ keepalive false coord peer1 assert established coord target $HOST $PORT2 coord initialise attach peer2 coord peer2 establish AS $PEER2_AS \ holdtime 0 \ id 10.10.10.2 \ keepalive false coord peer2 assert established coord target $HOST $PORT3 coord initialise attach peer3 coord peer3 establish AS $PEER3_AS \ holdtime 0 \ id 10.10.10.3 \ keepalive false coord peer3 assert established local LOCAL_NH=$NH1 packet() { local PACKET="packet update origin 2 aspath $1 nexthop $2 nlri 10.10.10.0/24" echo $PACKET } local MED=50 coord peer1 expect $(packet $PEER1_AS $LOCAL_NH) med $MED coord peer2 expect $(packet $AS,$PEER1_AS $NEXT_HOP) med 0 coord peer3 expect $(packet $PEER1_AS $LOCAL_NH) localpref 100 coord peer1 send $(packet $PEER1_AS $LOCAL_NH) med $MED localpref 17 sleep 2 coord peer1 assert queue 1 coord peer2 assert queue 0 coord peer3 assert queue 0 coord peer1 trie sent lookup 10.10.10.0/24 aspath $PEER1_AS coord peer2 trie recv lookup 10.10.10.0/24 aspath $AS,$PEER1_AS coord peer3 trie recv lookup 10.10.10.0/24 aspath $PEER1_AS# At the end of the test we expect all the peerings to still be established. coord peer1 assert established coord peer2 assert established coord peer3 assert established}test7(){ echo "TEST7 On an I-BGP peering send an update with an empty aspath" coord reset coord target $HOST $PORT1 coord initialise attach peer1 coord peer1 establish AS $PEER1_AS \ holdtime 0 \ id 10.10.10.1 \ keepalive false coord peer1 assert established coord target $HOST $PORT2 coord initialise attach peer2 coord peer2 establish AS $PEER2_AS \ holdtime 0 \ id 10.10.10.2 \ keepalive false coord peer2 assert established coord target $HOST $PORT3 coord initialise attach peer3 coord peer3 establish AS $PEER3_AS \ holdtime 0 \ id 10.10.10.3 \ keepalive false coord peer3 assert established PACKET="packet update origin 1 aspath empty nexthop $NH1 nlri 10.10.10.0/24" coord peer3 send $PACKET sleep 2 coord peer1 assert established coord peer2 assert established coord peer3 assert established}test8(){ echo "TEST8: " echo " 1) Send the same route from all peers" echo " 2) The route from peer1 is the winner" echo " 3) Now introduce a worse route from peer1" # At the time of writing the delete route generated by the # introduction of the worse route would be met by outrage from the # RIB which denied any knowledge of this route. BGP adds a route # to the IBGP table and then proceeds to try and delete it from # the EBP table. coord reset coord target $HOST $PORT1 coord initialise attach peer1 coord peer1 establish AS $PEER1_AS \ holdtime 0 \ id 10.10.10.1 \ keepalive false coord peer1 assert established coord target $HOST $PORT2 coord initialise attach peer2 coord peer2 establish AS $PEER2_AS \ holdtime 0 \ id 10.10.10.2 \ keepalive false coord peer2 assert established coord target $HOST $PORT3 coord initialise attach peer3 coord peer3 establish AS $PEER3_AS \ holdtime 0 \ id 10.10.10.3 \ keepalive false coord peer3 assert established PACKET="packet update origin 1 aspath empty nexthop $NH3 nlri 10.10.10.0/24" coord peer3 send $PACKET PACKET="packet update origin 1 aspath $PEER1_AS nexthop $NH1 nlri 10.10.10.0/24" coord peer1 send $PACKET PACKET="packet update origin 1 aspath $PEER2_AS nexthop $NH3 nlri 10.10.10.0/24" coord peer2 send $PACKET PACKET="packet update origin 1 aspath $PEER1_AS,$PEER1_AS nexthop $NH1 nlri 10.10.10.0/24" coord peer1 send $PACKET sleep 2 coord peer1 assert established coord peer2 assert established coord peer3 assert established}TESTS_NOT_FIXED=''TESTS='test1 test1_ipv6 test2 test2_ipv6 test3 test4 test5 test6 test7 test8'# 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://peer2/common/0.1/get_target_name ./test_peer -s peer3 = $CXRL finder://peer3/common/0.1/get_target_name ./coord = $CXRL finder://coord/common/0.1/get_target_nameEOF trap '' 0 exit $?fiif [ $CONFIGURE = "yes" ]then configure_bgp configure_ribfifor i in $TESTSdo# 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 $idone# Local Variables:# mode: shell-script# sh-indentation: 4# End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -