📄 test_peering1.sh
字号:
asnum $PEER1_AS \ bgpid 0.0.0.0 \ holdtime 0 sleep 2 coord peer1 assert queue 0} test42(){ echo "TEST42 - Send an update message that has a short length field." echo " 1) Establish a connection" echo " 2) Send an update with a short length 22" echo " 3) Should return a notify Bad Message Length" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $MSGHEADERERR $BADMESSLEN 0 22 coord peer1 send packet corrupt 17 22 \ update \ origin 2 \ aspath "[$PEER2_AS],[$PEER2_AS]" \ nlri 10.10.10.0/24 \ nexthop 20.20.20.20 sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}test43(){ echo "TEST43 - Send an notify message that has a short length field." echo " 1) Establish a connection" echo " 2) Send a notify with a short length 20" echo " 3) Should return a notify Bad Message Length" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $MSGHEADERERR $BADMESSLEN 0 20 coord peer1 send packet corrupt 17 20 notify $CEASE sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}test44(){ echo "TEST44 - Send an update message with an origin with bad flags." echo " 1) Establish a connection" echo " 2) Send an update with an origin with bad flags" echo " 3) Should return an UPDATE Message Error Attribute" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $ATTRFLAGS 0 1 1 1 coord peer1 send packet \ update \ pathattr 0,1,1,1 \ aspath "[$PEER2_AS],[$PEER2_AS]" \ nexthop 20.20.20.20 \ nlri 10.10.10.0/24 sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}test45(){ echo "TEST45 - Send an update message with an aspath with bad flags." echo " 1) Establish a connection" echo " 2) Send an update with an aspath with bad flags" echo " 3) Should return an UPDATE Message Error Attribute" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $ATTRFLAGS 0 2 4 2 1 253 232 # 0 - Attribute Flags (BAD) # 2 - Attribute Type Code (AS_PATH) # 4 - Attribute Length # 2 - Path Segment Type (AS_SEQUENCE) # 1 - Path Segment Length (One AS) # 253 - Path Segment Value (65000 / 256) # 232 - Path Segment Value (65000 % 256) coord peer1 send packet \ update \ origin 2 \ pathattr 0,2,4,2,1,253,232 \ nexthop 20.20.20.20 \ nlri 10.10.10.0/24 sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}test46(){ echo "TEST46 - Send an update message with a nexthop with bad flags." echo " 1) Establish a connection" echo " 2) Send an update with a nexthop with bad flags" echo " 3) Should return an UPDATE Message Error Attribute" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $ATTRFLAGS 0 3 4 20 20 20 20 # 0 - Attribute Flags (BAD) # 3 - Attribute Type Code (NEXT_HOP) # 4 - Attribute Length # 20 - Value # 20 - Value # 20 - Value # 20 - Value coord peer1 send packet \ update \ origin 2 \ pathattr 0,3,4,20,20,20,20 \ nlri 10.10.10.0/24 sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}test47(){ echo "TEST47 - Send an update message with a med with bad flags." echo " 1) Establish a connection" echo " 2) Send an update with a med with bad flags" echo " 3) Should return an UPDATE Message Error Attribute" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $ATTRFLAGS 0 4 4 20 20 20 20 # 0 - Attribute Flags (BAD) # 4 - Attribute Type Code (MULTI_EXIT_DISC) # 4 - Attribute Length # 20 - Value # 20 - Value # 20 - Value # 20 - Value coord peer1 send packet \ update \ origin 2 \ aspath "[$PEER2_AS],[$PEER2_AS]" \ pathattr 0,4,4,20,20,20,20 \ nlri 10.10.10.0/24 sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}test48(){ echo "TEST48 - Send an update message with a LOCAL_PREF with bad flags." echo " 1) Establish a connection" echo " 2) Send an update with a LOCAL_PREF with bad flags" echo " 3) Should return an UPDATE Message Error Attribute" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $ATTRFLAGS 0 5 4 20 20 20 20 # 0 - Attribute Flags (BAD) # 5 - Attribute Type Code (LOCAL_PREF) # 4 - Attribute Length # 20 - Value # 20 - Value # 20 - Value # 20 - Value coord peer1 send packet \ update \ origin 2 \ aspath "[$PEER2_AS],[$PEER2_AS]" \ pathattr 0,5,4,20,20,20,20 \ nlri 10.10.10.0/24 sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}test49(){ echo "TEST49 - An update message with an ATOMIC_AGGREGATE with bad flags." echo " 1) Establish a connection" echo " 2) Send an update with a ATOMIC_AGGREGATE with bad flags" echo " 3) Should return an UPDATE Message Error Attribute" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $ATTRFLAGS 0 6 0 # 0 - Attribute Flags (BAD) # 6 - Attribute Type Code (ATOMIC_AGGREGATE) # 0 - Attribute Length coord peer1 send packet \ update \ origin 2 \ aspath "[$PEER2_AS],[$PEER2_AS]" \ pathattr 0,6,0 \ nlri 10.10.10.0/24 sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}test50(){ echo "TEST50 - An update message with an AGGREGATOR with bad flags." echo " 1) Establish a connection" echo " 2) Send an update with a AGGREGATOR with bad flags" echo " 3) Should return an UPDATE Message Error Attribute" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $ATTRFLAGS \ 0 7 6 1 1 20 20 20 20 # 0 - Attribute Flags (BAD) # 7 - Attribute Type Code (ATOMIC_AGGREGATE) # 6 - Attribute Length # 1 - Last AS # 1 - Last AS # 20 - IP address # 20 - IP address # 20 - IP address # 20 - IP address coord peer1 send packet \ update \ origin 2 \ aspath "[$PEER2_AS],[$PEER2_AS]" \ pathattr 0,7,6,1,1,20,20,20,20 \ nlri 10.10.10.0/24 sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}test51(){ echo "TEST51 - An update message with an origin with an illegal value." echo " 1) Establish a connection" echo " 2) Send an update with an origin with an illegal value" echo " 3) Should return an UPDATE Message Error Attribute" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $INVALORGATTR 64 1 1 5 # 0x40 - Attribute Flags # 1 - Attribute Type Code (ORIGIN) # 1 - Attribute Length # 5 - Attribute value (ILLEGAL) coord peer1 send packet \ update \ pathattr 64,1,1,5 \ aspath "[$PEER2_AS],[$PEER2_AS]" \ nexthop 20.20.20.20 \ nlri 10.10.10.0/24 sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}test52(){ echo "TEST52 - An update message with an invalid nexthop" echo " 1) Establish a connection" echo " 2) Send an update with a nexthop with an illegal value" echo " 3) Should return an UPDATE Message Error Attribute" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $INVALNHATTR \ 64 3 4 255 255 255 255 # 64 - Attribute Flags # 3 - Attribute Type Code (NEXT_HOP) # 4 - Attribute Length # 255 - Value # 255 - Value # 255 - Value # 255 - Value coord peer1 send packet \ update \ origin 2 \ pathattr 64,3,4,255,255,255,255 \ nlri 10.10.10.0/24 sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}test53(){ echo "TEST53 - A NLRI that is syntactically incorrect" echo " 1) Establish a connection" echo " 2) Should return an UPDATE Message Error Attribute" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $INVALNETFIELD # Make the number of bits 54 coord peer1 send packet corrupt 45 54\ update \ origin 2 \ aspath "[$PEER2_AS],[$PEER2_AS]" \ nexthop 20.20.20.20 \ nlri 10.10.10.0/24 sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}test54(){ echo "TEST54 - A mandatory unknown path attribute." echo " 1) Establish a connection" echo " 2) Should get an Unrecognized Well-known Attribute" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $UNRECOGWATTR 0 255 1 0 coord peer1 send packet \ update \ origin 2 \ aspath "[$PEER2_AS],[$PEER2_AS]" \ nexthop 20.20.20.20 \ nlri 10.10.10.0/24 \ pathattr 0,255,1,0 sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}test55(){ echo "TEST55 - Send an AS_PATH with confederation segments." echo " 1) Establish a connection" echo " 2) Should get a Malformed AS_PATH" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $MALASPATH coord peer1 send packet \ update \ origin 2 \ aspath "[$PEER2_AS],($PEER2_AS)" \ nexthop 20.20.20.20 \ nlri 10.10.10.0/24 sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}test56(){ echo "TEST56 - Routes originated by BGP sent to an I-BGP peer:" echo " 1) Should have a local pref added." echo " 2) Should have an empty aspath." echo " 3) Should honour the next hop?" coord reset coord target $HOST $PORT1 coord initialise attach peer1 coord peer1 expect packet open asnum $AS bgpid $ID holdtime $HOLDTIME \ afi 1 safi 1 coord peer1 expect packet keepalive coord peer1 expect packet update \ origin 0 \ nexthop 20.20.20.20 \ aspath empty \ localpref 100 \ nlri 10.10.10.0/24 # Introduce a route originate_route4 10.10.10.0/24 20.20.20.20 true false coord peer1 establish AS $PEER1_AS holdtime 0 id 192.150.187.100 sleep 2 coord peer1 trie recv lookup 10.10.10.0/24 aspath empty coord peer1 assert queue 0 coord peer1 assert established}test56_ipv6(){ echo "TEST56 (IPv6) - Routes originated by BGP sent to an I-BGP peer:" echo " 1) Should have a local pref added." echo " 2) Should have an empty aspath." echo " 3) Should honour the next hop?" coord reset coord target $HOST $PORT3 coord initialise attach peer1 coord peer1 expect packet open asnum $AS bgpid $ID holdtime $HOLDTIME \ afi 2 safi 1 coord peer1 expect packet keepalive coord peer1 expect packet update \ origin 0 \ nexthop6 20:20:20:20:20:20:20:20 \ aspath empty \ localpref 100 \ nlri6 2000::/3 # Introduce a route originate_route6 2000::/3 20:20:20:20:20:20:20:20 true false coord peer1 establish AS $PEER3_AS holdtime 0 id 192.150.187.100 ipv6 true sleep 2 coord peer1 trie recv lookup 2000::/3 aspath empty coord peer1 assert queue 0 coord peer1 assert established}test57(){ echo "TEST57 - Send an ORIGINATOR_ID on an E-BGP peering." echo " 1) Establish a connection" echo " 2) Should get a Malformed AS_PATH" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $MALATTRLIST coord peer1 send packet \ update \ origin 2 \ aspath "[$PEER2_AS],[$PEER2_AS]" \ nexthop 20.20.20.20 \ nlri 10.10.10.0/24 \ originatorid 1.2.3.4 sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}test58(){ echo "TEST58 - Send CLUSTER_LIST on an E-BGP peering." echo " 1) Establish a connection" echo " 2) Should get a Malformed AS_PATH" coord reset coord target $HOST $PORT2 coord initialise attach peer1 coord peer1 establish AS $PEER2_AS holdtime 0 id 192.150.187.100 coord peer1 expect packet notify $UPDATEMSGERR $MALATTRLIST coord peer1 send packet \ update \ origin 2 \ aspath "[$PEER2_AS],[$PEER2_AS]" \ nexthop 20.20.20.20 \ nlri 10.10.10.0/24 \ clusterlist 1.2.3.4 sleep 2 coord peer1 assert queue 0 sleep 2 coord peer1 assert idle}TESTS_NOT_FIXED=''TESTS='test1 test2 test3 test4 test5 test6 test7 test8 test8_ipv6 test9 test10 test11 test12 test12_ipv6 test13 test14 test15 test16 test17 test18 test19 test20 test20_ipv6 test21 test22 test23 test24 test25 test26 test27 test27_ipv6 test28 test28_ipv6 test29 test30 test31 test32 test33 test34 test35 test36 test37 test38 test39 test40 test41 test42 test43 test44 test45 test46 test47 test48 test49 test50 test51 test52 test53 test54 test55 test56 test56_ipv6 test57 test58'# 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 ./coord = $CXRL finder://coord/common/0.1/get_target_nameEOF trap '' 0 exit $?fiif [ $CONFIGURE = "yes" ]then configure_bgpfifor 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 + -