mirror_vlan.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. # This test uses standard topology for testing mirroring. See mirror_topo_lib.sh
  4. # for more details.
  5. #
  6. # Test for "tc action mirred egress mirror" that mirrors to a vlan device.
  7. ALL_TESTS="
  8. test_vlan
  9. test_tagged_vlan
  10. "
  11. NUM_NETIFS=6
  12. source lib.sh
  13. source mirror_lib.sh
  14. source mirror_topo_lib.sh
  15. setup_prepare()
  16. {
  17. h1=${NETIFS[p1]}
  18. swp1=${NETIFS[p2]}
  19. swp2=${NETIFS[p3]}
  20. h2=${NETIFS[p4]}
  21. swp3=${NETIFS[p5]}
  22. h3=${NETIFS[p6]}
  23. vrf_prepare
  24. mirror_topo_create
  25. vlan_create $swp3 555
  26. vlan_create $h3 555 v$h3
  27. matchall_sink_create $h3.555
  28. vlan_create $h1 111 v$h1 192.0.2.17/28
  29. bridge vlan add dev $swp1 vid 111
  30. vlan_create $h2 111 v$h2 192.0.2.18/28
  31. bridge vlan add dev $swp2 vid 111
  32. }
  33. cleanup()
  34. {
  35. pre_cleanup
  36. vlan_destroy $h2 111
  37. vlan_destroy $h1 111
  38. vlan_destroy $h3 555
  39. vlan_destroy $swp3 555
  40. mirror_topo_destroy
  41. vrf_cleanup
  42. }
  43. test_vlan_dir()
  44. {
  45. local direction=$1; shift
  46. local forward_type=$1; shift
  47. local backward_type=$1; shift
  48. RET=0
  49. mirror_install $swp1 $direction $swp3.555 "matchall $tcflags"
  50. test_span_dir "$h3.555" "$direction" "$forward_type" "$backward_type"
  51. mirror_uninstall $swp1 $direction
  52. log_test "$direction mirror to vlan ($tcflags)"
  53. }
  54. test_vlan()
  55. {
  56. test_vlan_dir ingress 8 0
  57. test_vlan_dir egress 0 8
  58. }
  59. test_tagged_vlan_dir()
  60. {
  61. local direction=$1; shift
  62. local forward_type=$1; shift
  63. local backward_type=$1; shift
  64. RET=0
  65. mirror_install $swp1 $direction $swp3.555 "matchall $tcflags"
  66. do_test_span_vlan_dir_ips 10 "$h3.555" 111 "$direction" \
  67. 192.0.2.17 192.0.2.18
  68. do_test_span_vlan_dir_ips 0 "$h3.555" 555 "$direction" \
  69. 192.0.2.17 192.0.2.18
  70. mirror_uninstall $swp1 $direction
  71. log_test "$direction mirror tagged to vlan ($tcflags)"
  72. }
  73. test_tagged_vlan()
  74. {
  75. test_tagged_vlan_dir ingress 8 0
  76. test_tagged_vlan_dir egress 0 8
  77. }
  78. test_all()
  79. {
  80. slow_path_trap_install $swp1 ingress
  81. slow_path_trap_install $swp1 egress
  82. trap_install $h3 ingress
  83. tests_run
  84. trap_uninstall $h3 ingress
  85. slow_path_trap_uninstall $swp1 egress
  86. slow_path_trap_uninstall $swp1 ingress
  87. }
  88. trap cleanup EXIT
  89. setup_prepare
  90. setup_wait
  91. tcflags="skip_hw"
  92. test_all
  93. if ! tc_offload_check; then
  94. echo "WARN: Could not test offloaded functionality"
  95. else
  96. tcflags="skip_sw"
  97. test_all
  98. fi
  99. exit $EXIT_STATUS