if-route-addlarge.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/sh
  2. # SPDX-License-Identifier: GPL-2.0-or-later
  3. # Copyright (c) 2017-2018 Petr Vorel <pvorel@suse.cz>
  4. # Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
  5. # Copyright (c) International Business Machines Corp., 2005
  6. # Author: Mitsuru Chinen <mitch@jp.ibm.com>
  7. IF_CMD='route'
  8. . if-lib.sh
  9. CHECK_INTERVAL=${CHECK_INTERVAL:-$(($ROUTE_TOTAL / 20))}
  10. test_body()
  11. {
  12. local cmd="$CMD"
  13. local iface=$(tst_iface)
  14. local inet="inet$TST_IPV6"
  15. local opt_rt=
  16. if [ "$TST_IPV6" ]; then
  17. opt_rt="/64"
  18. elif [ "$cmd" = "ip" ]; then
  19. opt_rt='/32'
  20. fi
  21. tst_res TINFO "'$cmd' add IPv$TST_IPVER $ROUTE_TOTAL routes"
  22. if ! restore_ipaddr; then
  23. tst_res TBROK "Failed to set default IP addresses"
  24. return
  25. fi
  26. local x=1
  27. local y=1
  28. local cnt=1
  29. [ "$TST_IPV6" ] && local xymax=65535 || xymax=254
  30. if [ $ROUTE_TOTAL -gt $((xymax * xymax)) ]; then
  31. tst_res TWARN "set ROUTE_TOTAL to $xymax * $xymax"
  32. ROUTE_TOTAL=$((xymax * xymax))
  33. fi
  34. while [ $cnt -le $ROUTE_TOTAL ]; do
  35. make_background_tcp_traffic
  36. if [ "$TST_IPV6" ]; then
  37. local hex_x=$(printf '%x' $x)
  38. local hex_y=$(printf '%x' $y)
  39. local new_rt=${IPV6_NET32_UNUSED}:$hex_x:$hex_y::
  40. else
  41. local new_rt=${IPV4_NET16_UNUSED}.$x.$y
  42. fi
  43. case $cmd in
  44. route) route -A $inet add ${new_rt}${opt_rt} dev $iface ;;
  45. ip) ip route add ${new_rt}${opt_rt} dev $iface ;;
  46. esac
  47. if [ $? -ne 0 ]; then
  48. tst_res TFAIL "Can't add route $new_rt to $iface"
  49. return
  50. fi
  51. check_connectivity_interval $cnt || return
  52. cnt=$(($cnt + 1))
  53. y=$(($y + 1))
  54. if [ $y -gt $xymax ]; then
  55. y=1
  56. x=$(($x + 1))
  57. if [ $x -gt $xymax ]; then
  58. tst_brk TBROK "Too large $ROUTE_TOTAL"
  59. fi
  60. fi
  61. done
  62. tst_res TPASS "Test is finished correctly"
  63. }
  64. tst_run