mc_cmds.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #! /bin/sh
  2. # Copyright (c) 2015-2017 Oracle and/or its affiliates. All Rights Reserved.
  3. # Copyright (c) International Business Machines Corp., 2000
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License as
  7. # published by the Free Software Foundation; either version 2 of
  8. # the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it would be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write the Free Software Foundation,
  17. # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. #
  19. # TEST DESCRIPTION :
  20. # To determine the stability of the IP Multicast product
  21. # and to verify the accuracy and usability of IP Multicast
  22. # related publications associated with changes and/or
  23. # additions to command level interfaces for this implementations
  24. # of IP Multicast.
  25. #
  26. # Robbie Williamson (robbiew@us.ibm.com)
  27. TCID=mc_cmds
  28. TST_TOTAL=1
  29. TST_USE_LEGACY_API=1
  30. . tst_net.sh
  31. knob="net.ipv4.icmp_echo_ignore_broadcasts"
  32. knob_changed=
  33. setup()
  34. {
  35. val=$(sysctl -n $knob)
  36. if [ "$val" -ne 0 ]; then
  37. ROD sysctl -q ${knob}=0
  38. knob_changed=1
  39. fi
  40. tst_tmpdir
  41. }
  42. do_test()
  43. {
  44. local ip_fixed_version=170220
  45. ip addr show $(tst_iface) | grep -q 'MULTICAST' || \
  46. tst_brkm TFAIL "Multicast not listed for $(tst_iface)"
  47. ip maddr show $(tst_iface) | grep -q '224.0.0.1'
  48. if [ $? -ne 0 ]; then
  49. [ `ip -V | cut -d's' -f3` -lt $ip_fixed_version ] && \
  50. tst_resm TINFO "'ip maddr show $(tst_iface)' failed"\
  51. "(caused by old ip version, fixed in"\
  52. "$ip_fixed_version)" || \
  53. tst_resm TWARN "'ip maddr show $(tst_iface)' failed"
  54. tst_resm TINFO "parsing 'ip maddr show' command"
  55. ip maddr show | sed -ne "/\s$(tst_iface)/,/^[0-9]/p" | \
  56. grep -q 224.0.0.1 || \
  57. tst_brkm TFAIL "$(tst_iface) not joined 224.0.0.1"
  58. fi
  59. tst_resm TINFO "Ping all-host-groups over specified interface"
  60. ping -c2 -I $(tst_ipaddr) 224.0.0.1 > ping_out.log
  61. if [ $? -ne 0 ]; then
  62. tst_resm TINFO "Trying to ping with $(tst_iface)"\
  63. "with the -I option instead of IP address"
  64. ping -c2 -I $(tst_iface) 224.0.0.1 > ping_out.log || \
  65. tst_brkm TFAIL "No response from MC hosts to ping -c2 "\
  66. "-I $(tst_ipaddr) 224.0.0.1"
  67. fi
  68. grep -q $(tst_ipaddr) ping_out.log
  69. if [ $? -ne 0 ]; then
  70. cat ping_out.log
  71. tst_brkm TFAIL "Local host did not respond to ping -c2 "\
  72. "-I $(tst_iface) 224.0.0.1"
  73. fi
  74. tst_resm TPASS "Test Successful"
  75. tst_exit
  76. }
  77. do_cleanup()
  78. {
  79. [ "$knob_changed" ] && sysctl -q ${knob}=1
  80. tst_rmdir
  81. }
  82. setup
  83. TST_CLEANUP=do_cleanup
  84. do_test