forwarding.sh (d3373029e29b8aebb412f99efbd03cd4fbb853d9) | forwarding.sh (0e7ed5d666d8668d57146be5729c42832a7f8bb1) |
---|---|
1#!/bin/sh 2#- 3# Copyright (c) 2012 Cisco Systems, Inc. 4# All rights reserved. 5# 6# This software was developed by Bjoern Zeeb under contract to 7# Cisco Systems, Inc.. 8# --- 208 unchanged lines hidden (view full) --- 217 return 1 218 ;; 219 esac 220 return 0 221} 222 223reachability_check() 224{ | 1#!/bin/sh 2#- 3# Copyright (c) 2012 Cisco Systems, Inc. 4# All rights reserved. 5# 6# This software was developed by Bjoern Zeeb under contract to 7# Cisco Systems, Inc.. 8# --- 208 unchanged lines hidden (view full) --- 217 return 1 218 ;; 219 esac 220 return 0 221} 222 223reachability_check() 224{ |
225 local _i _rc | 225 local _i rc |
226 227 # Try to reach all control addresses on other nodes. 228 # We need to loop for a while as we cannot expect all to be up 229 # the very same moment. 230 i=1 | 226 227 # Try to reach all control addresses on other nodes. 228 # We need to loop for a while as we cannot expect all to be up 229 # the very same moment. 230 i=1 |
231 _rc=42 232 while test ${_rc} -ne 0 -a ${i} -le ${WAITS}; do | 231 rc=42 232 while test ${rc} -ne 0 -a ${i} -le ${WAITS}; do |
233 print_debug "${i}/${WAITS} trying to ping6 control addresses." | 233 print_debug "${i}/${WAITS} trying to ping6 control addresses." |
234 _rc=0 | 234 rc=0 |
235 set +e 236 case ${node} in 237 left) _reachability_check ${MIDDLELEFTADDR} | 235 set +e 236 case ${node} in 237 left) _reachability_check ${MIDDLELEFTADDR} |
238 _rc=$((_rc + $?)) | 238 rc=$((rc + $?)) |
239 _reachability_check ${MIDDLERIGHTADDR} | 239 _reachability_check ${MIDDLERIGHTADDR} |
240 _rc=$((_rc + $?)) | 240 rc=$((rc + $?)) |
241 _reachability_check ${RIGHTADDR} | 241 _reachability_check ${RIGHTADDR} |
242 _rc=$((_rc + $?)) | 242 rc=$((rc + $?)) |
243 ;; 244 middle) _reachability_check ${LEFTADDR} | 243 ;; 244 middle) _reachability_check ${LEFTADDR} |
245 _rc=$((_rc + $?)) | 245 rc=$((rc + $?)) |
246 _reachability_check ${RIGHTADDR} | 246 _reachability_check ${RIGHTADDR} |
247 _rc=$((_rc + $?)) | 247 rc=$((rc + $?)) |
248 ;; 249 right) _reachability_check ${MIDDLERIGHTADDR} | 248 ;; 249 right) _reachability_check ${MIDDLERIGHTADDR} |
250 _rc=$((_rc + $?)) | 250 rc=$((rc + $?)) |
251 _reachability_check ${MIDDLELEFTADDR} | 251 _reachability_check ${MIDDLELEFTADDR} |
252 _rc=$((_rc + $?)) | 252 rc=$((rc + $?)) |
253 _reachability_check ${LEFTADDR} | 253 _reachability_check ${LEFTADDR} |
254 _rc=$((_rc + $?)) | 254 rc=$((rc + $?)) |
255 ;; 256 esac 257 set -e 258 sleep 1 259 i=$((i + 1)) 260 done 261} 262 --- 122 unchanged lines hidden (view full) --- 385 testno=$((testno + 1)) 386 i=$((i + 1)) 387 done 388 set -e 389} 390 391test_ulp_reflect_one() 392{ | 255 ;; 256 esac 257 set -e 258 sleep 1 259 i=$((i + 1)) 260 done 261} 262 --- 122 unchanged lines hidden (view full) --- 385 testno=$((testno + 1)) 386 i=$((i + 1)) 387 done 388 set -e 389} 390 391test_ulp_reflect_one() 392{ |
393 local _txt _opts _port _fib | 393 local _txt _opts port fib |
394 _txt="$1" 395 _opts="$2" | 394 _txt="$1" 395 _opts="$2" |
396 _port=$3 397 _fib=$4 | 396 port=$3 397 fib=$4 |
398 | 398 |
399 print_debug "./reflect -p $((_port + 1 + _fib)) -t ${_txt}" "${_opts}" 400 ./reflect -p $((_port + 1 + _fib)) -t ${_txt} ${_opts} | 399 print_debug "./reflect -p $((port + 1 + fib)) -t ${_txt}" "${_opts}" 400 ./reflect -p $((port + 1 + fib)) -t ${_txt} ${_opts} |
401 print_debug "reflect '${_txt}' terminated without error." 402} 403 404test_ulp_reflect_multiple() 405{ 406 local _maxfibs _txt _opts i _jobs _p 407 _maxfibs=$1 408 _txt="$2" --- 49 unchanged lines hidden (view full) --- 458 break 459 fi 460 done 461 return 0 462} 463 464test_ulp() 465{ | 401 print_debug "reflect '${_txt}' terminated without error." 402} 403 404test_ulp_reflect_multiple() 405{ 406 local _maxfibs _txt _opts i _jobs _p 407 _maxfibs=$1 408 _txt="$2" --- 49 unchanged lines hidden (view full) --- 458 break 459 fi 460 done 461 return 0 462} 463 464test_ulp() 465{ |
466 local _maxfibs _msg _addr _port _fib i _txt testno _rc _reply 467 _maxfibs=$1 | 466 local maxfibs _msg _addr port fib i _txt testno _rc _reply 467 maxfibs=$1 |
468 _msg="$2" 469 _addr=$3 | 468 _msg="$2" 469 _addr=$3 |
470 _port=$4 471 _fib=$5 | 470 port=$4 471 fib=$5 |
472 | 472 |
473 printf "1..%d\n" $((${_maxfibs} * 2)) | 473 printf "1..%d\n" $((${maxfibs} * 2)) |
474 testno=1 475 i=0 | 474 testno=1 475 i=0 |
476 while test ${i} -lt ${_maxfibs}; do | 476 while test ${i} -lt ${maxfibs}; do |
477 | 477 |
478 if test ${i} -eq $((${_maxfibs} - 1)); then | 478 if test ${i} -eq $((${maxfibs} - 1)); then |
479 # Last one; signal DONE. 480 _txt="DONE ${_msg}_${i}" 481 else 482 _txt="DONE ${_msg}_${i}" 483 fi 484 485 eval _rc="\${rc_${i}}" 486 487 # Test TCP. | 479 # Last one; signal DONE. 480 _txt="DONE ${_msg}_${i}" 481 else 482 _txt="DONE ${_msg}_${i}" 483 fi 484 485 eval _rc="\${rc_${i}}" 486 487 # Test TCP. |
488 nc_send_recv ${_maxfibs} "${_txt}" "${_txt}" ${_addr} \ 489 $((${_port} + 1 + _fib)) "" | 488 nc_send_recv ${maxfibs} "${_txt}" "${_txt}" ${_addr} \ 489 $((${port} + 1 + fib)) "" |
490 check_rc $? ${_rc} ${testno} "${_msg}_${i}_tcp" \ | 490 check_rc $? ${_rc} ${testno} "${_msg}_${i}_tcp" \ |
491 "[${_addr}]:$((${_port} + 1 + _fib)) ${_reply}" | 491 "[${_addr}]:$((${port} + 1 + fib)) ${_reply}" |
492 testno=$((testno + 1)) 493 sleep 1 494 495 # Test UDP. | 492 testno=$((testno + 1)) 493 sleep 1 494 495 # Test UDP. |
496 nc_send_recv ${_maxfibs} "${_txt}" "${_txt}" ${_addr} \ 497 $((${_port} + 1 + _fib)) "-u" | 496 nc_send_recv ${maxfibs} "${_txt}" "${_txt}" ${_addr} \ 497 $((${port} + 1 + fib)) "-u" |
498 check_rc $? ${_rc} ${testno} "${_msg}_${i}_udp" \ | 498 check_rc $? ${_rc} ${testno} "${_msg}_${i}_udp" \ |
499 "[${_addr}]:$((${_port} + 1 + _fib)) ${_reply}" | 499 "[${_addr}]:$((${port} + 1 + fib)) ${_reply}" |
500 sleep 1 501 502 i=$((i + 1)) 503 testno=$((testno + 1)) 504 done 505} 506 507setup_ipfw_count() 508{ | 500 sleep 1 501 502 i=$((i + 1)) 503 testno=$((testno + 1)) 504 done 505} 506 507setup_ipfw_count() 508{ |
509 local i _port _maxfib _p _fib _ofib 510 _port=$1 511 _maxfib=$2 | 509 local i port maxfib _p _fib _ofib 510 port=$1 511 maxfib=$2 |
512 _fib=$3 513 _ofib=$4 514 515 i=0 | 512 _fib=$3 513 _ofib=$4 514 515 i=0 |
516 while test ${i} -lt ${_maxfib}; do | 516 while test ${i} -lt ${maxfib}; do |
517 518 case ${_ofib} in | 517 518 case ${_ofib} in |
519 -1) _p=$((_port + 1 + i)) ;; 520 *) _p=$((_port + 1 + _maxfib - 1 - i)) ;; | 519 -1) _p=$((port + 1 + i)) ;; 520 *) _p=$((port + 1 + maxfib - 1 - i)) ;; |
521 esac 522 523 # Only count ICMP6 echo replies. 524 ipfw add $((10000 + i)) count ipv6-icmp from any to any \ 525 icmp6types 129 fib ${i} via ${IFACE} out > /dev/null 526 ipfw add $((10000 + i)) count tcp from any to any \ 527 src-port ${_p} fib ${i} via ${IFACE} out > /dev/null 528 ipfw add $((10000 + i)) count udp from any to any \ 529 src-port ${_p} fib ${i} via ${IFACE} out > /dev/null 530 531 # Only count ICMP6 echo requests. 532 ipfw add $((20000 + i)) count ipv6-icmp from any to any \ 533 icmp6types 128 fib ${i} via ${IFACEFAR} out > /dev/null 534 ipfw add $((20000 + i)) count tcp from any to any \ | 521 esac 522 523 # Only count ICMP6 echo replies. 524 ipfw add $((10000 + i)) count ipv6-icmp from any to any \ 525 icmp6types 129 fib ${i} via ${IFACE} out > /dev/null 526 ipfw add $((10000 + i)) count tcp from any to any \ 527 src-port ${_p} fib ${i} via ${IFACE} out > /dev/null 528 ipfw add $((10000 + i)) count udp from any to any \ 529 src-port ${_p} fib ${i} via ${IFACE} out > /dev/null 530 531 # Only count ICMP6 echo requests. 532 ipfw add $((20000 + i)) count ipv6-icmp from any to any \ 533 icmp6types 128 fib ${i} via ${IFACEFAR} out > /dev/null 534 ipfw add $((20000 + i)) count tcp from any to any \ |
535 dst-port $((${_port} + 1 + i)) fib ${i} \ | 535 dst-port $((${port} + 1 + i)) fib ${i} \ |
536 via ${IFACEFAR} out > /dev/null 537 ipfw add $((20000 + i)) count udp from any to any \ | 536 via ${IFACEFAR} out > /dev/null 537 ipfw add $((20000 + i)) count udp from any to any \ |
538 dst-port $((${_port} + 1 + i)) fib ${i} \ | 538 dst-port $((${port} + 1 + i)) fib ${i} \ |
539 via ${IFACEFAR} out > /dev/null 540 541 i=$((i + 1)) 542 done 543} 544 545report_ipfw_count() 546{ | 539 via ${IFACEFAR} out > /dev/null 540 541 i=$((i + 1)) 542 done 543} 544 545report_ipfw_count() 546{ |
547 local _fib _o i _rstr _c _req _p _opts | 547 local _fib _o i _rstr _c _req _p _opts base |
548 _o="$2" 549 550 case ${DEBUG} in 551 ''|0) ;; 552 *) ipfw show ;; 553 esac 554 555 _rstr="RESULTS " | 548 _o="$2" 549 550 case ${DEBUG} in 551 ''|0) ;; 552 *) ipfw show ;; 553 esac 554 555 _rstr="RESULTS " |
556 for _base in 10000 20000; do | 556 for base in 10000 20000; do |
557 for _o in i t u; do | 557 for _o in i t u; do |
558 case ${_base} in | 558 case ${base} in |
559 10000) _rstr="${_rstr}\nLEFT " ;; 560 20000) _rstr="${_rstr}\nRIGHT " ;; 561 esac 562 case ${_o} in 563 i) _rstr="${_rstr}ICMP6 " ;; 564 t) _rstr="${_rstr}TCP " ;; 565 u) _rstr="${_rstr}UDP " ;; 566 esac 567 i=0 568 while test ${i} -lt ${RT_NUMFIBS}; do 569 570 case "${_o}" in | 559 10000) _rstr="${_rstr}\nLEFT " ;; 560 20000) _rstr="${_rstr}\nRIGHT " ;; 561 esac 562 case ${_o} in 563 i) _rstr="${_rstr}ICMP6 " ;; 564 t) _rstr="${_rstr}TCP " ;; 565 u) _rstr="${_rstr}UDP " ;; 566 esac 567 i=0 568 while test ${i} -lt ${RT_NUMFIBS}; do 569 570 case "${_o}" in |
571 i) _c=`ipfw show $((${_base} + i)) | \ | 571 i) _c=`ipfw show $((${base} + i)) | \ |
572 awk '/ ipv6-icmp / { print $2 }'` ;; | 572 awk '/ ipv6-icmp / { print $2 }'` ;; |
573 t) _c=`ipfw show $((${_base} + i)) | \ | 573 t) _c=`ipfw show $((${base} + i)) | \ |
574 awk '/ tcp / { print $2 }'` ;; | 574 awk '/ tcp / { print $2 }'` ;; |
575 u) _c=`ipfw show $((${_base} + i)) | \ | 575 u) _c=`ipfw show $((${base} + i)) | \ |
576 awk '/ udp / { print $2 }'` ;; 577 esac 578 _rstr="${_rstr}${i} ${_c}," 579 580 i=$((i + 1)) 581 done 582 done 583 i=0 584 while test ${i} -lt ${RT_NUMFIBS}; do | 576 awk '/ udp / { print $2 }'` ;; 577 esac 578 _rstr="${_rstr}${i} ${_c}," 579 580 i=$((i + 1)) 581 done 582 done 583 i=0 584 while test ${i} -lt ${RT_NUMFIBS}; do |
585 ipfw delete $((${_base} + i)) > /dev/null 2>&1 || true | 585 ipfw delete $((${base} + i)) > /dev/null 2>&1 || true |
586 i=$((i + 1)) 587 done 588 done 589 590 # We do not care about the request. 591 _req=`printf "${_rstr}" | nc -6 -l $((${CTRLPORT} - 1))` 592 print_debug "$? -- ${_req} -- ${_rstr}" 593} --- 395 unchanged lines hidden (view full) --- 989 right) _fwd_fib_symmetric_right ${_n} ${_maxfib} ;; 990 esac 991} 992 993################################################################################ 994 995_fwd_fib_asymmetric_results() 996{ | 586 i=$((i + 1)) 587 done 588 done 589 590 # We do not care about the request. 591 _req=`printf "${_rstr}" | nc -6 -l $((${CTRLPORT} - 1))` 592 print_debug "$? -- ${_req} -- ${_rstr}" 593} --- 395 unchanged lines hidden (view full) --- 989 right) _fwd_fib_symmetric_right ${_n} ${_maxfib} ;; 990 esac 991} 992 993################################################################################ 994 995_fwd_fib_asymmetric_results() 996{ |
997 local _n _fib _maxfib i _edge _type _rc | 997 local _n fib maxfib i _edge _type _rc |
998 _n="$1" | 998 _n="$1" |
999 _fib=$2 1000 _maxfib=$3 | 999 fib=$2 1000 maxfib=$3 |
1001 1002 i=0 | 1001 1002 i=0 |
1003 while test ${i} -lt ${_maxfib}; do | 1003 while test ${i} -lt ${maxfib}; do |
1004 _edge="RIGHT" 1005 for _type in "ICMP6" "TCP" "UDP"; do 1006 1007 case ${i} in | 1004 _edge="RIGHT" 1005 for _type in "ICMP6" "TCP" "UDP"; do 1006 1007 case ${i} in |
1008 ${_fib}) eval rc_${_n}_${_edge}_${_type}_${i}=1 | 1008 ${fib}) eval rc_${_n}_${_edge}_${_type}_${i}=1 |
1009 #print_debug \ 1010 # "rc_${_n}_${_edge}_${_type}_${i}=1" 1011 ;; 1012 *) eval rc_${_n}_${_edge}_${_type}_${i}=0 1013 #print_debug \ 1014 # "rc_${_n}_${_edge}_${_type}_${i}=0" 1015 ;; 1016 esac 1017 1018 done 1019 i=$((i + 1)) 1020 done | 1009 #print_debug \ 1010 # "rc_${_n}_${_edge}_${_type}_${i}=1" 1011 ;; 1012 *) eval rc_${_n}_${_edge}_${_type}_${i}=0 1013 #print_debug \ 1014 # "rc_${_n}_${_edge}_${_type}_${i}=0" 1015 ;; 1016 esac 1017 1018 done 1019 i=$((i + 1)) 1020 done |
1021 _fib=$((_maxfib - 1 - _fib)) | 1021 fib=$((maxfib - 1 - fib)) |
1022 i=0 | 1022 i=0 |
1023 while test ${i} -lt ${_maxfib}; do | 1023 while test ${i} -lt ${maxfib}; do |
1024 _edge="LEFT" 1025 for _type in "ICMP6" "TCP" "UDP"; do 1026 1027 case ${i} in | 1024 _edge="LEFT" 1025 for _type in "ICMP6" "TCP" "UDP"; do 1026 1027 case ${i} in |
1028 ${_fib}) eval rc_${_n}_${_edge}_${_type}_${i}=1 | 1028 ${fib}) eval rc_${_n}_${_edge}_${_type}_${i}=1 |
1029 #print_debug \ 1030 # "rc_${_n}_${_edge}_${_type}_${i}=1" 1031 ;; 1032 *) eval rc_${_n}_${_edge}_${_type}_${i}=0 1033 #print_debug \ 1034 # "rc_${_n}_${_edge}_${_type}_${i}=0" 1035 ;; 1036 esac --- 31 unchanged lines hidden (view full) --- 1068 _fwd_fib_asymmetric_results "${_n}_${i}" ${i} ${_maxfib} 1069 fetch_ipfw_count "${_n}_${i}" 1070 i=$((i + 1)) 1071 done 1072} 1073 1074_fwd_fib_asymmetric_middle_ifconfig() 1075{ | 1029 #print_debug \ 1030 # "rc_${_n}_${_edge}_${_type}_${i}=1" 1031 ;; 1032 *) eval rc_${_n}_${_edge}_${_type}_${i}=0 1033 #print_debug \ 1034 # "rc_${_n}_${_edge}_${_type}_${i}=0" 1035 ;; 1036 esac --- 31 unchanged lines hidden (view full) --- 1068 _fwd_fib_asymmetric_results "${_n}_${i}" ${i} ${_maxfib} 1069 fetch_ipfw_count "${_n}_${i}" 1070 i=$((i + 1)) 1071 done 1072} 1073 1074_fwd_fib_asymmetric_middle_ifconfig() 1075{ |
1076 local _n _maxfib i | 1076 local _n maxfib i |
1077 _n="$1" | 1077 _n="$1" |
1078 _maxfib=$2 | 1078 maxfib=$2 |
1079 1080 i=0 | 1079 1080 i=0 |
1081 while test ${i} -lt ${_maxfib}; do | 1081 while test ${i} -lt ${maxfib}; do |
1082 ifconfig ${IFACE} fib ${i} | 1082 ifconfig ${IFACE} fib ${i} |
1083 ifconfig ${IFACEFAR} fib $((${_maxfib} - 1 - ${i})) 1084 setup_ipfw_count ${CTRLPORT} ${_maxfib} ${i} \ 1085 $((${_maxfib} - 1 - ${i})) | 1083 ifconfig ${IFACEFAR} fib $((${maxfib} - 1 - ${i})) 1084 setup_ipfw_count ${CTRLPORT} ${maxfib} ${i} \ 1085 $((${maxfib} - 1 - ${i})) |
1086 wait_remote_ready "START_${_n}_${i}" 1087 ipfw -q zero > /dev/null 1088 # Nothing to do for the middle node testing the default. 1089 sleep 1 1090 wait_remote_ready "STOP_${_n}_${i}" 1091 report_ipfw_count 1092 i=$((i + 1)) 1093 done 1094} 1095 1096_fwd_fib_asymmetric_middle_ipfw() 1097{ | 1086 wait_remote_ready "START_${_n}_${i}" 1087 ipfw -q zero > /dev/null 1088 # Nothing to do for the middle node testing the default. 1089 sleep 1 1090 wait_remote_ready "STOP_${_n}_${i}" 1091 report_ipfw_count 1092 i=$((i + 1)) 1093 done 1094} 1095 1096_fwd_fib_asymmetric_middle_ipfw() 1097{ |
1098 local _n _maxfib i j _port | 1098 local _n maxfib i j _port |
1099 _n="$1" | 1099 _n="$1" |
1100 _maxfib=$2 | 1100 maxfib=$2 |
1101 1102 i=0 | 1101 1102 i=0 |
1103 while test ${i} -lt ${_maxfib}; do | 1103 while test ${i} -lt ${maxfib}; do |
1104 1105 _port=$((CTRLPORT + 1 + i)) 1106 ipfw add 100 setfib ${i} ipv6-icmp from any to any \ 1107 icmp6types 128 via ${IFACE} in > /dev/null 1108 ipfw add 100 setfib ${i} tcp from any to any \ 1109 dst-port ${_port} via ${IFACE} in > /dev/null 1110 ipfw add 100 setfib ${i} udp from any to any \ 1111 dst-port ${_port} via ${IFACE} in > /dev/null 1112 | 1104 1105 _port=$((CTRLPORT + 1 + i)) 1106 ipfw add 100 setfib ${i} ipv6-icmp from any to any \ 1107 icmp6types 128 via ${IFACE} in > /dev/null 1108 ipfw add 100 setfib ${i} tcp from any to any \ 1109 dst-port ${_port} via ${IFACE} in > /dev/null 1110 ipfw add 100 setfib ${i} udp from any to any \ 1111 dst-port ${_port} via ${IFACE} in > /dev/null 1112 |
1113 j=$((${_maxfib} - 1 - ${i})) | 1113 j=$((${maxfib} - 1 - ${i})) |
1114 ipfw add 100 setfib ${j} ipv6-icmp from any to any \ 1115 icmp6types 129 via ${IFACEFAR} in > /dev/null 1116 ipfw add 100 setfib ${j} tcp from any to any \ 1117 src-port ${_port} via ${IFACEFAR} in > /dev/null 1118 ipfw add 100 setfib ${j} udp from any to any \ 1119 src-port ${_port} via ${IFACEFAR} in > /dev/null 1120 | 1114 ipfw add 100 setfib ${j} ipv6-icmp from any to any \ 1115 icmp6types 129 via ${IFACEFAR} in > /dev/null 1116 ipfw add 100 setfib ${j} tcp from any to any \ 1117 src-port ${_port} via ${IFACEFAR} in > /dev/null 1118 ipfw add 100 setfib ${j} udp from any to any \ 1119 src-port ${_port} via ${IFACEFAR} in > /dev/null 1120 |
1121 setup_ipfw_count ${CTRLPORT} ${_maxfib} ${i} ${j} | 1121 setup_ipfw_count ${CTRLPORT} ${maxfib} ${i} ${j} |
1122 wait_remote_ready "START_${_n}_${i}" 1123 ipfw -q zero > /dev/null 1124 # Nothing to do for the middle node testing the default. 1125 sleep 1 1126 wait_remote_ready "STOP_${_n}_${i}" 1127 report_ipfw_count 1128 1129 ipfw delete 100 > /dev/null --- 523 unchanged lines hidden --- | 1122 wait_remote_ready "START_${_n}_${i}" 1123 ipfw -q zero > /dev/null 1124 # Nothing to do for the middle node testing the default. 1125 sleep 1 1126 wait_remote_ready "STOP_${_n}_${i}" 1127 report_ipfw_count 1128 1129 ipfw delete 100 > /dev/null --- 523 unchanged lines hidden --- |