local_termination.sh 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. ALL_TESTS="standalone vlan_unaware_bridge vlan_aware_bridge test_vlan \
  4. vlan_over_vlan_unaware_bridged_port vlan_over_vlan_aware_bridged_port \
  5. vlan_over_vlan_unaware_bridge vlan_over_vlan_aware_bridge"
  6. NUM_NETIFS=2
  7. PING_COUNT=1
  8. REQUIRE_MTOOLS=yes
  9. source lib.sh
  10. H1_IPV4="192.0.2.1"
  11. H2_IPV4="192.0.2.2"
  12. H1_IPV6="2001:db8:1::1"
  13. H2_IPV6="2001:db8:1::2"
  14. BRIDGE_ADDR="00:00:de:ad:be:ee"
  15. MACVLAN_ADDR="00:00:de:ad:be:ef"
  16. UNKNOWN_UC_ADDR1="de:ad:be:ef:ee:03"
  17. UNKNOWN_UC_ADDR2="de:ad:be:ef:ee:04"
  18. UNKNOWN_UC_ADDR3="de:ad:be:ef:ee:05"
  19. JOINED_IPV4_MC_ADDR="225.1.2.3"
  20. UNKNOWN_IPV4_MC_ADDR1="225.1.2.4"
  21. UNKNOWN_IPV4_MC_ADDR2="225.1.2.5"
  22. UNKNOWN_IPV4_MC_ADDR3="225.1.2.6"
  23. JOINED_IPV6_MC_ADDR="ff2e::0102:0304"
  24. UNKNOWN_IPV6_MC_ADDR1="ff2e::0102:0305"
  25. UNKNOWN_IPV6_MC_ADDR2="ff2e::0102:0306"
  26. UNKNOWN_IPV6_MC_ADDR3="ff2e::0102:0307"
  27. JOINED_MACV4_MC_ADDR="01:00:5e:01:02:03"
  28. UNKNOWN_MACV4_MC_ADDR1="01:00:5e:01:02:04"
  29. UNKNOWN_MACV4_MC_ADDR2="01:00:5e:01:02:05"
  30. UNKNOWN_MACV4_MC_ADDR3="01:00:5e:01:02:06"
  31. JOINED_MACV6_MC_ADDR="33:33:01:02:03:04"
  32. UNKNOWN_MACV6_MC_ADDR1="33:33:01:02:03:05"
  33. UNKNOWN_MACV6_MC_ADDR2="33:33:01:02:03:06"
  34. UNKNOWN_MACV6_MC_ADDR3="33:33:01:02:03:07"
  35. PTP_1588_L2_SYNC=" \
  36. 01:1b:19:00:00:00 00:00:de:ad:be:ef 88:f7 00 02 \
  37. 00 2c 00 00 02 00 00 00 00 00 00 00 00 00 00 00 \
  38. 00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 00 00 \
  39. 00 00 00 00 00 00 00 00 00 00"
  40. PTP_1588_L2_FOLLOW_UP=" \
  41. 01:1b:19:00:00:00 00:00:de:ad:be:ef 88:f7 08 02 \
  42. 00 2c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
  43. 00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 02 00 \
  44. 00 00 66 83 c5 f1 17 97 ed f0"
  45. PTP_1588_L2_PDELAY_REQ=" \
  46. 01:80:c2:00:00:0e 00:00:de:ad:be:ef 88:f7 02 02 \
  47. 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
  48. 00 00 3e 37 63 ff fe cf 17 0e 00 01 00 06 05 7f \
  49. 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
  50. 00 00 00 00"
  51. PTP_1588_IPV4_SYNC=" \
  52. 01:00:5e:00:01:81 00:00:de:ad:be:ef 08:00 45 00 \
  53. 00 48 0a 9a 40 00 01 11 cb 88 c0 00 02 01 e0 00 \
  54. 01 81 01 3f 01 3f 00 34 a3 c8 00 02 00 2c 00 00 \
  55. 02 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 37 \
  56. 63 ff fe cf 17 0e 00 01 00 00 00 00 00 00 00 00 \
  57. 00 00 00 00 00 00"
  58. PTP_1588_IPV4_FOLLOW_UP="
  59. 01:00:5e:00:01:81 00:00:de:ad:be:ef 08:00 45 00 \
  60. 00 48 0a 9b 40 00 01 11 cb 87 c0 00 02 01 e0 00 \
  61. 01 81 01 40 01 40 00 34 a3 c8 08 02 00 2c 00 00 \
  62. 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 37 \
  63. 63 ff fe cf 17 0e 00 01 00 00 02 00 00 00 66 83 \
  64. c6 0f 1d 9a 61 87"
  65. PTP_1588_IPV4_PDELAY_REQ=" \
  66. 01:00:5e:00:00:6b 00:00:de:ad:be:ef 08:00 45 00 \
  67. 00 52 35 a9 40 00 01 11 a1 85 c0 00 02 01 e0 00 \
  68. 00 6b 01 3f 01 3f 00 3e a2 bc 02 02 00 36 00 00 \
  69. 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3e 37 \
  70. 63 ff fe cf 17 0e 00 01 00 01 05 7f 00 00 00 00 \
  71. 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
  72. PTP_1588_IPV6_SYNC=" \
  73. 33:33:00:00:01:81 00:00:de:ad:be:ef 86:dd 60 06 \
  74. 7c 2f 00 36 11 01 20 01 0d b8 00 01 00 00 00 00 \
  75. 00 00 00 00 00 01 ff 0e 00 00 00 00 00 00 00 00 \
  76. 00 00 00 00 01 81 01 3f 01 3f 00 36 2e 92 00 02 \
  77. 00 2c 00 00 02 00 00 00 00 00 00 00 00 00 00 00 \
  78. 00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 00 00 \
  79. 00 00 00 00 00 00 00 00 00 00 00 00"
  80. PTP_1588_IPV6_FOLLOW_UP=" \
  81. 33:33:00:00:01:81 00:00:de:ad:be:ef 86:dd 60 0a \
  82. 00 bc 00 36 11 01 20 01 0d b8 00 01 00 00 00 00 \
  83. 00 00 00 00 00 01 ff 0e 00 00 00 00 00 00 00 00 \
  84. 00 00 00 00 01 81 01 40 01 40 00 36 2e 92 08 02 \
  85. 00 2c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
  86. 00 00 3e 37 63 ff fe cf 17 0e 00 01 00 00 02 00 \
  87. 00 00 66 83 c6 2a 32 09 bd 74 00 00"
  88. PTP_1588_IPV6_PDELAY_REQ=" \
  89. 33:33:00:00:00:6b 00:00:de:ad:be:ef 86:dd 60 0c \
  90. 5c fd 00 40 11 01 fe 80 00 00 00 00 00 00 3c 37 \
  91. 63 ff fe cf 17 0e ff 02 00 00 00 00 00 00 00 00 \
  92. 00 00 00 00 00 6b 01 3f 01 3f 00 40 b4 54 02 02 \
  93. 00 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
  94. 00 00 3e 37 63 ff fe cf 17 0e 00 01 00 01 05 7f \
  95. 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \
  96. 00 00 00 00 00 00"
  97. # Disable promisc to ensure we don't receive unknown MAC DA packets
  98. export TCPDUMP_EXTRA_FLAGS="-pl"
  99. h1=${NETIFS[p1]}
  100. h2=${NETIFS[p2]}
  101. send_raw()
  102. {
  103. local if_name=$1; shift
  104. local pkt="$1"; shift
  105. local smac=$(mac_get $if_name)
  106. pkt="${pkt/00:00:de:ad:be:ef/$smac}"
  107. $MZ -q $if_name "$pkt"
  108. }
  109. send_uc_ipv4()
  110. {
  111. local if_name=$1
  112. local dmac=$2
  113. ip neigh add $H2_IPV4 lladdr $dmac dev $if_name
  114. ping_do $if_name $H2_IPV4
  115. ip neigh del $H2_IPV4 dev $if_name
  116. }
  117. check_rcv()
  118. {
  119. local if_name=$1; shift
  120. local type=$1; shift
  121. local pattern=$1; shift
  122. local should_receive=$1; shift
  123. local test_name="$1"; shift
  124. local should_fail=
  125. [ $should_receive = true ] && should_fail=0 || should_fail=1
  126. RET=0
  127. tcpdump_show $if_name | grep -q "$pattern"
  128. check_err_fail "$should_fail" "$?" "reception"
  129. log_test "$test_name: $type"
  130. }
  131. mc_route_prepare()
  132. {
  133. local if_name=$1
  134. local vrf_name=$(master_name_get $if_name)
  135. ip route add 225.100.1.0/24 dev $if_name vrf $vrf_name
  136. ip -6 route add ff2e::/64 dev $if_name vrf $vrf_name
  137. }
  138. mc_route_destroy()
  139. {
  140. local if_name=$1
  141. local vrf_name=$(master_name_get $if_name)
  142. ip route del 225.100.1.0/24 dev $if_name vrf $vrf_name
  143. ip -6 route del ff2e::/64 dev $if_name vrf $vrf_name
  144. }
  145. run_test()
  146. {
  147. local send_if_name=$1; shift
  148. local rcv_if_name=$1; shift
  149. local skip_ptp=$1; shift
  150. local no_unicast_flt=$1; shift
  151. local test_name="$1"; shift
  152. local smac=$(mac_get $send_if_name)
  153. local rcv_dmac=$(mac_get $rcv_if_name)
  154. local should_receive
  155. tcpdump_start $rcv_if_name
  156. mc_route_prepare $send_if_name
  157. mc_route_prepare $rcv_if_name
  158. send_uc_ipv4 $send_if_name $rcv_dmac
  159. send_uc_ipv4 $send_if_name $MACVLAN_ADDR
  160. send_uc_ipv4 $send_if_name $UNKNOWN_UC_ADDR1
  161. ip link set dev $rcv_if_name promisc on
  162. send_uc_ipv4 $send_if_name $UNKNOWN_UC_ADDR2
  163. mc_send $send_if_name $UNKNOWN_IPV4_MC_ADDR2
  164. mc_send $send_if_name $UNKNOWN_IPV6_MC_ADDR2
  165. ip link set dev $rcv_if_name promisc off
  166. mc_join $rcv_if_name $JOINED_IPV4_MC_ADDR
  167. mc_send $send_if_name $JOINED_IPV4_MC_ADDR
  168. mc_leave
  169. mc_join $rcv_if_name $JOINED_IPV6_MC_ADDR
  170. mc_send $send_if_name $JOINED_IPV6_MC_ADDR
  171. mc_leave
  172. mc_send $send_if_name $UNKNOWN_IPV4_MC_ADDR1
  173. mc_send $send_if_name $UNKNOWN_IPV6_MC_ADDR1
  174. ip link set dev $rcv_if_name allmulticast on
  175. send_uc_ipv4 $send_if_name $UNKNOWN_UC_ADDR3
  176. mc_send $send_if_name $UNKNOWN_IPV4_MC_ADDR3
  177. mc_send $send_if_name $UNKNOWN_IPV6_MC_ADDR3
  178. ip link set dev $rcv_if_name allmulticast off
  179. mc_route_destroy $rcv_if_name
  180. mc_route_destroy $send_if_name
  181. if [ $skip_ptp = false ]; then
  182. ip maddress add 01:1b:19:00:00:00 dev $rcv_if_name
  183. send_raw $send_if_name "$PTP_1588_L2_SYNC"
  184. send_raw $send_if_name "$PTP_1588_L2_FOLLOW_UP"
  185. ip maddress del 01:1b:19:00:00:00 dev $rcv_if_name
  186. ip maddress add 01:80:c2:00:00:0e dev $rcv_if_name
  187. send_raw $send_if_name "$PTP_1588_L2_PDELAY_REQ"
  188. ip maddress del 01:80:c2:00:00:0e dev $rcv_if_name
  189. mc_join $rcv_if_name 224.0.1.129
  190. send_raw $send_if_name "$PTP_1588_IPV4_SYNC"
  191. send_raw $send_if_name "$PTP_1588_IPV4_FOLLOW_UP"
  192. mc_leave
  193. mc_join $rcv_if_name 224.0.0.107
  194. send_raw $send_if_name "$PTP_1588_IPV4_PDELAY_REQ"
  195. mc_leave
  196. mc_join $rcv_if_name ff0e::181
  197. send_raw $send_if_name "$PTP_1588_IPV6_SYNC"
  198. send_raw $send_if_name "$PTP_1588_IPV6_FOLLOW_UP"
  199. mc_leave
  200. mc_join $rcv_if_name ff02::6b
  201. send_raw $send_if_name "$PTP_1588_IPV6_PDELAY_REQ"
  202. mc_leave
  203. fi
  204. sleep 1
  205. tcpdump_stop $rcv_if_name
  206. check_rcv $rcv_if_name "Unicast IPv4 to primary MAC address" \
  207. "$smac > $rcv_dmac, ethertype IPv4 (0x0800)" \
  208. true "$test_name"
  209. check_rcv $rcv_if_name "Unicast IPv4 to macvlan MAC address" \
  210. "$smac > $MACVLAN_ADDR, ethertype IPv4 (0x0800)" \
  211. true "$test_name"
  212. [ $no_unicast_flt = true ] && should_receive=true || should_receive=false
  213. check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address" \
  214. "$smac > $UNKNOWN_UC_ADDR1, ethertype IPv4 (0x0800)" \
  215. $should_receive "$test_name"
  216. check_rcv $rcv_if_name "Unicast IPv4 to unknown MAC address, promisc" \
  217. "$smac > $UNKNOWN_UC_ADDR2, ethertype IPv4 (0x0800)" \
  218. true "$test_name"
  219. [ $no_unicast_flt = true ] && should_receive=true || should_receive=false
  220. check_rcv $rcv_if_name \
  221. "Unicast IPv4 to unknown MAC address, allmulti" \
  222. "$smac > $UNKNOWN_UC_ADDR3, ethertype IPv4 (0x0800)" \
  223. $should_receive "$test_name"
  224. check_rcv $rcv_if_name "Multicast IPv4 to joined group" \
  225. "$smac > $JOINED_MACV4_MC_ADDR, ethertype IPv4 (0x0800)" \
  226. true "$test_name"
  227. xfail \
  228. check_rcv $rcv_if_name \
  229. "Multicast IPv4 to unknown group" \
  230. "$smac > $UNKNOWN_MACV4_MC_ADDR1, ethertype IPv4 (0x0800)" \
  231. false "$test_name"
  232. check_rcv $rcv_if_name "Multicast IPv4 to unknown group, promisc" \
  233. "$smac > $UNKNOWN_MACV4_MC_ADDR2, ethertype IPv4 (0x0800)" \
  234. true "$test_name"
  235. check_rcv $rcv_if_name "Multicast IPv4 to unknown group, allmulti" \
  236. "$smac > $UNKNOWN_MACV4_MC_ADDR3, ethertype IPv4 (0x0800)" \
  237. true "$test_name"
  238. check_rcv $rcv_if_name "Multicast IPv6 to joined group" \
  239. "$smac > $JOINED_MACV6_MC_ADDR, ethertype IPv6 (0x86dd)" \
  240. true "$test_name"
  241. xfail \
  242. check_rcv $rcv_if_name "Multicast IPv6 to unknown group" \
  243. "$smac > $UNKNOWN_MACV6_MC_ADDR1, ethertype IPv6 (0x86dd)" \
  244. false "$test_name"
  245. check_rcv $rcv_if_name "Multicast IPv6 to unknown group, promisc" \
  246. "$smac > $UNKNOWN_MACV6_MC_ADDR2, ethertype IPv6 (0x86dd)" \
  247. true "$test_name"
  248. check_rcv $rcv_if_name "Multicast IPv6 to unknown group, allmulti" \
  249. "$smac > $UNKNOWN_MACV6_MC_ADDR3, ethertype IPv6 (0x86dd)" \
  250. true "$test_name"
  251. if [ $skip_ptp = false ]; then
  252. check_rcv $rcv_if_name "1588v2 over L2 transport, Sync" \
  253. "ethertype PTP (0x88f7).* PTPv2.* msg type : sync msg" \
  254. true "$test_name"
  255. check_rcv $rcv_if_name "1588v2 over L2 transport, Follow-Up" \
  256. "ethertype PTP (0x88f7).* PTPv2.* msg type : follow up msg" \
  257. true "$test_name"
  258. check_rcv $rcv_if_name "1588v2 over L2 transport, Peer Delay Request" \
  259. "ethertype PTP (0x88f7).* PTPv2.* msg type : peer delay req msg" \
  260. true "$test_name"
  261. check_rcv $rcv_if_name "1588v2 over IPv4, Sync" \
  262. "ethertype IPv4 (0x0800).* PTPv2.* msg type : sync msg" \
  263. true "$test_name"
  264. check_rcv $rcv_if_name "1588v2 over IPv4, Follow-Up" \
  265. "ethertype IPv4 (0x0800).* PTPv2.* msg type : follow up msg" \
  266. true "$test_name"
  267. check_rcv $rcv_if_name "1588v2 over IPv4, Peer Delay Request" \
  268. "ethertype IPv4 (0x0800).* PTPv2.* msg type : peer delay req msg" \
  269. true "$test_name"
  270. check_rcv $rcv_if_name "1588v2 over IPv6, Sync" \
  271. "ethertype IPv6 (0x86dd).* PTPv2.* msg type : sync msg" \
  272. true "$test_name"
  273. check_rcv $rcv_if_name "1588v2 over IPv6, Follow-Up" \
  274. "ethertype IPv6 (0x86dd).* PTPv2.* msg type : follow up msg" \
  275. true "$test_name"
  276. check_rcv $rcv_if_name "1588v2 over IPv6, Peer Delay Request" \
  277. "ethertype IPv6 (0x86dd).* PTPv2.* msg type : peer delay req msg" \
  278. true "$test_name"
  279. fi
  280. tcpdump_cleanup $rcv_if_name
  281. }
  282. h1_create()
  283. {
  284. simple_if_init $h1 $H1_IPV4/24 $H1_IPV6/64
  285. }
  286. h1_destroy()
  287. {
  288. simple_if_fini $h1 $H1_IPV4/24 $H1_IPV6/64
  289. }
  290. h2_create()
  291. {
  292. simple_if_init $h2 $H2_IPV4/24 $H2_IPV6/64
  293. }
  294. h2_destroy()
  295. {
  296. simple_if_fini $h2 $H2_IPV4/24 $H2_IPV6/64
  297. }
  298. h1_vlan_create()
  299. {
  300. simple_if_init $h1
  301. vlan_create $h1 100 v$h1 $H1_IPV4/24 $H1_IPV6/64
  302. }
  303. h1_vlan_destroy()
  304. {
  305. vlan_destroy $h1 100
  306. simple_if_fini $h1
  307. }
  308. h2_vlan_create()
  309. {
  310. simple_if_init $h2
  311. vlan_create $h2 100 v$h2 $H2_IPV4/24 $H2_IPV6/64
  312. }
  313. h2_vlan_destroy()
  314. {
  315. vlan_destroy $h2 100
  316. simple_if_fini $h2
  317. }
  318. bridge_create()
  319. {
  320. local vlan_filtering=$1
  321. ip link add br0 type bridge vlan_filtering $vlan_filtering
  322. ip link set br0 address $BRIDGE_ADDR
  323. ip link set br0 up
  324. ip link set $h2 master br0
  325. ip link set $h2 up
  326. }
  327. bridge_destroy()
  328. {
  329. ip link del br0
  330. }
  331. macvlan_create()
  332. {
  333. local lower=$1
  334. ip link add link $lower name macvlan0 type macvlan mode private
  335. ip link set macvlan0 address $MACVLAN_ADDR
  336. ip link set macvlan0 up
  337. }
  338. macvlan_destroy()
  339. {
  340. ip link del macvlan0
  341. }
  342. standalone()
  343. {
  344. local no_unicast_flt=true
  345. local skip_ptp=false
  346. if [ $(has_unicast_flt $h2) = yes ]; then
  347. no_unicast_flt=false
  348. fi
  349. h1_create
  350. h2_create
  351. macvlan_create $h2
  352. run_test $h1 $h2 $skip_ptp $no_unicast_flt "$h2"
  353. macvlan_destroy
  354. h2_destroy
  355. h1_destroy
  356. }
  357. test_bridge()
  358. {
  359. local no_unicast_flt=true
  360. local vlan_filtering=$1
  361. local skip_ptp=true
  362. h1_create
  363. bridge_create $vlan_filtering
  364. simple_if_init br0 $H2_IPV4/24 $H2_IPV6/64
  365. macvlan_create br0
  366. run_test $h1 br0 $skip_ptp $no_unicast_flt \
  367. "vlan_filtering=$vlan_filtering bridge"
  368. macvlan_destroy
  369. simple_if_fini br0 $H2_IPV4/24 $H2_IPV6/64
  370. bridge_destroy
  371. h1_destroy
  372. }
  373. vlan_unaware_bridge()
  374. {
  375. test_bridge 0
  376. }
  377. vlan_aware_bridge()
  378. {
  379. test_bridge 1
  380. }
  381. test_vlan()
  382. {
  383. local no_unicast_flt=true
  384. local skip_ptp=false
  385. if [ $(has_unicast_flt $h2) = yes ]; then
  386. no_unicast_flt=false
  387. fi
  388. h1_vlan_create
  389. h2_vlan_create
  390. macvlan_create $h2.100
  391. run_test $h1.100 $h2.100 $skip_ptp $no_unicast_flt "VLAN upper"
  392. macvlan_destroy
  393. h2_vlan_destroy
  394. h1_vlan_destroy
  395. }
  396. vlan_over_bridged_port()
  397. {
  398. local no_unicast_flt=true
  399. local vlan_filtering=$1
  400. local skip_ptp=false
  401. # br_manage_promisc() will not force a single vlan_filtering port to
  402. # promiscuous mode, so we should still expect unicast filtering to take
  403. # place if the device can do it.
  404. if [ $(has_unicast_flt $h2) = yes ] && [ $vlan_filtering = 1 ]; then
  405. no_unicast_flt=false
  406. fi
  407. h1_vlan_create
  408. h2_vlan_create
  409. bridge_create $vlan_filtering
  410. macvlan_create $h2.100
  411. run_test $h1.100 $h2.100 $skip_ptp $no_unicast_flt \
  412. "VLAN over vlan_filtering=$vlan_filtering bridged port"
  413. macvlan_destroy
  414. bridge_destroy
  415. h2_vlan_destroy
  416. h1_vlan_destroy
  417. }
  418. vlan_over_vlan_unaware_bridged_port()
  419. {
  420. vlan_over_bridged_port 0
  421. }
  422. vlan_over_vlan_aware_bridged_port()
  423. {
  424. vlan_over_bridged_port 1
  425. }
  426. vlan_over_bridge()
  427. {
  428. local no_unicast_flt=true
  429. local vlan_filtering=$1
  430. local skip_ptp=true
  431. h1_vlan_create
  432. bridge_create $vlan_filtering
  433. simple_if_init br0
  434. vlan_create br0 100 vbr0 $H2_IPV4/24 $H2_IPV6/64
  435. macvlan_create br0.100
  436. if [ $vlan_filtering = 1 ]; then
  437. bridge vlan add dev $h2 vid 100 master
  438. bridge vlan add dev br0 vid 100 self
  439. fi
  440. run_test $h1.100 br0.100 $skip_ptp $no_unicast_flt \
  441. "VLAN over vlan_filtering=$vlan_filtering bridge"
  442. if [ $vlan_filtering = 1 ]; then
  443. bridge vlan del dev br0 vid 100 self
  444. bridge vlan del dev $h2 vid 100 master
  445. fi
  446. macvlan_destroy
  447. vlan_destroy br0 100
  448. simple_if_fini br0
  449. bridge_destroy
  450. h1_vlan_destroy
  451. }
  452. vlan_over_vlan_unaware_bridge()
  453. {
  454. vlan_over_bridge 0
  455. }
  456. vlan_over_vlan_aware_bridge()
  457. {
  458. vlan_over_bridge 1
  459. }
  460. cleanup()
  461. {
  462. pre_cleanup
  463. ip link set $h2 down
  464. ip link set $h1 down
  465. vrf_cleanup
  466. }
  467. setup_prepare()
  468. {
  469. vrf_prepare
  470. # setup_wait() needs this
  471. ip link set $h1 up
  472. ip link set $h2 up
  473. }
  474. trap cleanup EXIT
  475. setup_prepare
  476. setup_wait
  477. tests_run
  478. exit $EXIT_STATUS