bridge_vlan_aware.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding"
  4. NUM_NETIFS=4
  5. CHECK_TC="yes"
  6. source lib.sh
  7. h1_create()
  8. {
  9. simple_if_init $h1 192.0.2.1/24 2001:db8:1::1/64
  10. }
  11. h1_destroy()
  12. {
  13. simple_if_fini $h1 192.0.2.1/24 2001:db8:1::1/64
  14. }
  15. h2_create()
  16. {
  17. simple_if_init $h2 192.0.2.2/24 2001:db8:1::2/64
  18. }
  19. h2_destroy()
  20. {
  21. simple_if_fini $h2 192.0.2.2/24 2001:db8:1::2/64
  22. }
  23. switch_create()
  24. {
  25. # 10 Seconds ageing time.
  26. ip link add dev br0 type bridge vlan_filtering 1 ageing_time 1000 \
  27. mcast_snooping 0
  28. ip link set dev $swp1 master br0
  29. ip link set dev $swp2 master br0
  30. ip link set dev br0 up
  31. ip link set dev $swp1 up
  32. ip link set dev $swp2 up
  33. }
  34. switch_destroy()
  35. {
  36. ip link set dev $swp2 down
  37. ip link set dev $swp1 down
  38. ip link del dev br0
  39. }
  40. setup_prepare()
  41. {
  42. h1=${NETIFS[p1]}
  43. swp1=${NETIFS[p2]}
  44. swp2=${NETIFS[p3]}
  45. h2=${NETIFS[p4]}
  46. vrf_prepare
  47. h1_create
  48. h2_create
  49. switch_create
  50. }
  51. cleanup()
  52. {
  53. pre_cleanup
  54. switch_destroy
  55. h2_destroy
  56. h1_destroy
  57. vrf_cleanup
  58. }
  59. ping_ipv4()
  60. {
  61. ping_test $h1 192.0.2.2
  62. }
  63. ping_ipv6()
  64. {
  65. ping6_test $h1 2001:db8:1::2
  66. }
  67. learning()
  68. {
  69. learning_test "br0" $swp1 $h1 $h2
  70. }
  71. flooding()
  72. {
  73. flood_test $swp2 $h1 $h2
  74. }
  75. trap cleanup EXIT
  76. setup_prepare
  77. setup_wait
  78. tests_run
  79. exit $EXIT_STATUS