~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/forwarding/local_termination.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php