2 # SPDX-License-Identifier: GPL-2.0
4 # +-----------------------+ +----------------------+
5 # | H1 (vrf) | | H2 (vrf) |
7 # | | 192.0.2.1/28 | | 192.0.2.2/28 | |
8 # | | 2001:db8:1::1/64 | | 2001:db8:1::2/64 | |
9 # +----|------------------+ +------------------|---+
11 # +----|-------------------------------------------------------------------|---+
13 # | +-|-------------------------------------------------------------------|-+ |
14 # | | + $swp1 BR $swp2 + | |
15 # | +-----------------------------------------------------------------------+ |
16 # +----------------------------------------------------------------------------+
20 test_l2_miss_multicast
21 test_l2_miss_ll_multicast
22 test_l2_miss_broadcast
31 simple_if_init
$h1 192.0.2.1/28 2001:db8
:1::1/64
36 simple_if_fini
$h1 192.0.2.1/28 2001:db8
:1::1/64
41 simple_if_init
$h2 192.0.2.2/28 2001:db8
:1::2/64
46 simple_if_fini
$h2 192.0.2.2/28 2001:db8
:1::2/64
51 ip link add name br1 up
type bridge
52 ip link
set dev
$swp1 master br1
53 ip link
set dev
$swp1 up
54 ip link
set dev
$swp2 master br1
55 ip link
set dev
$swp2 up
57 tc qdisc add dev
$swp2 clsact
62 tc qdisc del dev
$swp2 clsact
64 ip link
set dev
$swp2 down
65 ip link
set dev
$swp2 nomaster
66 ip link
set dev
$swp1 down
67 ip link
set dev
$swp1 nomaster
71 test_l2_miss_unicast
()
73 local dmac
=00:01:02:03:04:05
80 tc filter add dev
$swp2 egress protocol ipv4 handle
101 pref
1 \
81 flower indev
$swp1 l2_miss
1 dst_mac
$dmac src_ip
$sip \
82 dst_ip
$dip action pass
84 tc filter add dev
$swp2 egress protocol ipv4 handle
102 pref
1 \
85 flower indev
$swp1 l2_miss
0 dst_mac
$dmac src_ip
$sip \
86 dst_ip
$dip action pass
88 # Before adding FDB entry.
89 $MZ $h1 -a own
-b $dmac -t ip
-A $sip -B $dip -c 1 -p 100 -q
91 tc_check_packets
"dev $swp2 egress" 101 1
92 check_err $?
"Unknown unicast filter was not hit before adding FDB entry"
94 tc_check_packets
"dev $swp2 egress" 102 0
95 check_err $?
"Known unicast filter was hit before adding FDB entry"
98 bridge fdb replace
$dmac dev
$swp2 master static
100 $MZ $h1 -a own
-b $dmac -t ip
-A $sip -B $dip -c 1 -p 100 -q
102 tc_check_packets
"dev $swp2 egress" 101 1
103 check_err $?
"Unknown unicast filter was hit after adding FDB entry"
105 tc_check_packets
"dev $swp2 egress" 102 1
106 check_err $?
"Known unicast filter was not hit after adding FDB entry"
108 # Deleting FDB entry.
109 bridge fdb del
$dmac dev
$swp2 master static
111 $MZ $h1 -a own
-b $dmac -t ip
-A $sip -B $dip -c 1 -p 100 -q
113 tc_check_packets
"dev $swp2 egress" 101 2
114 check_err $?
"Unknown unicast filter was not hit after deleting FDB entry"
116 tc_check_packets
"dev $swp2 egress" 102 1
117 check_err $?
"Known unicast filter was hit after deleting FDB entry"
119 tc filter del dev
$swp2 egress protocol ipv4 pref
1 handle
102 flower
120 tc filter del dev
$swp2 egress protocol ipv4 pref
1 handle
101 flower
122 log_test
"L2 miss - Unicast"
125 test_l2_miss_multicast_common
()
127 local proto
=$1; shift
136 # Unregistered multicast.
137 tc filter add dev
$swp2 egress protocol
$proto handle
101 pref
1 \
138 flower indev
$swp1 l2_miss
1 src_ip
$sip dst_ip
$dip \
140 # Registered multicast.
141 tc filter add dev
$swp2 egress protocol
$proto handle
102 pref
1 \
142 flower indev
$swp1 l2_miss
0 src_ip
$sip dst_ip
$dip \
145 # Before adding MDB entry.
146 $MZ $mode $h1 -a own
-b $dmac -t ip
-A $sip -B $dip -c 1 -p 100 -q
148 tc_check_packets
"dev $swp2 egress" 101 1
149 check_err $?
"Unregistered multicast filter was not hit before adding MDB entry"
151 tc_check_packets
"dev $swp2 egress" 102 0
152 check_err $?
"Registered multicast filter was hit before adding MDB entry"
155 bridge mdb replace dev br1 port
$swp2 grp
$dip permanent
157 $MZ $mode $h1 -a own
-b $dmac -t ip
-A $sip -B $dip -c 1 -p 100 -q
159 tc_check_packets
"dev $swp2 egress" 101 1
160 check_err $?
"Unregistered multicast filter was hit after adding MDB entry"
162 tc_check_packets
"dev $swp2 egress" 102 1
163 check_err $?
"Registered multicast filter was not hit after adding MDB entry"
165 # Deleting MDB entry.
166 bridge mdb del dev br1 port
$swp2 grp
$dip
168 $MZ $mode $h1 -a own
-b $dmac -t ip
-A $sip -B $dip -c 1 -p 100 -q
170 tc_check_packets
"dev $swp2 egress" 101 2
171 check_err $?
"Unregistered multicast filter was not hit after deleting MDB entry"
173 tc_check_packets
"dev $swp2 egress" 102 1
174 check_err $?
"Registered multicast filter was hit after deleting MDB entry"
176 tc filter del dev
$swp2 egress protocol
$proto pref
1 handle
102 flower
177 tc filter del dev
$swp2 egress protocol
$proto pref
1 handle
101 flower
179 log_test
"L2 miss - Multicast ($name)"
182 test_l2_miss_multicast_ipv4
()
187 local dmac
=01:00:5e
:01:01:01
191 test_l2_miss_multicast_common
$proto $sip $dip $dmac $mode $name
194 test_l2_miss_multicast_ipv6
()
197 local sip
=2001:db8
:1::1
199 local dmac
=33:33:00:00:00:01
203 test_l2_miss_multicast_common
$proto $sip $dip $dmac $mode $name
206 test_l2_miss_multicast
()
208 # Configure $swp2 as a multicast router port so that it will forward
209 # both registered and unregistered multicast traffic.
210 bridge link
set dev
$swp2 mcast_router
2
212 # Set the Max Response Delay to 100 centiseconds (1 second) so that the
213 # bridge will start forwarding according to its MDB soon after a
214 # multicast querier is enabled.
215 ip link
set dev br1
type bridge mcast_query_response_interval
100
217 # Forwarding according to MDB entries only takes place when the bridge
218 # detects that there is a valid querier in the network. Set the bridge
219 # as the querier and assign it a valid IPv6 link-local address to be
220 # used as the source address for MLD queries.
221 ip link
set dev br1
type bridge mcast_querier
1
222 ip
-6 address add fe80
::1/64 nodad dev br1
225 test_l2_miss_multicast_ipv4
226 test_l2_miss_multicast_ipv6
228 ip
-6 address del fe80
::1/64 dev br1
229 ip link
set dev br1
type bridge mcast_querier
0
230 ip link
set dev br1
type bridge mcast_query_response_interval
1000
231 bridge link
set dev
$swp2 mcast_router
1
234 test_l2_miss_multicast_common2
()
243 test_l2_miss_ll_multicast_common
()
245 local proto
=$1; shift
254 tc filter add dev
$swp2 egress protocol
$proto handle
101 pref
1 \
255 flower indev
$swp1 l2_miss
1 dst_mac
$dmac src_ip
$sip \
256 dst_ip
$dip action pass
258 $MZ $mode $h1 -a own
-b $dmac -t ip
-A $sip -B $dip -c 1 -p 100 -q
260 tc_check_packets
"dev $swp2 egress" 101 1
261 check_err $?
"Filter was not hit"
263 tc filter del dev
$swp2 egress protocol
$proto pref
1 handle
101 flower
265 log_test
"L2 miss - Link-local multicast ($name)"
268 test_l2_miss_ll_multicast_ipv4
()
271 local dmac
=01:00:5e
:00:00:01
277 test_l2_miss_ll_multicast_common
$proto $dmac $sip $dip $mode $name
280 test_l2_miss_ll_multicast_ipv6
()
283 local dmac
=33:33:00:00:00:01
284 local sip
=2001:db8
:1::1
289 test_l2_miss_ll_multicast_common
$proto $dmac $sip $dip $mode $name
292 test_l2_miss_ll_multicast
()
294 test_l2_miss_ll_multicast_ipv4
295 test_l2_miss_ll_multicast_ipv6
298 test_l2_miss_broadcast
()
300 local dmac
=ff
:ff
:ff
:ff
:ff
:ff
301 local smac
=00:01:02:03:04:05
305 tc filter add dev
$swp2 egress protocol all handle
101 pref
1 \
306 flower l2_miss
1 dst_mac
$dmac src_mac
$smac \
308 tc filter add dev
$swp2 egress protocol all handle
102 pref
1 \
309 flower l2_miss
0 dst_mac
$dmac src_mac
$smac \
312 $MZ $h1 -a $smac -b $dmac -c 1 -p 100 -q
314 tc_check_packets
"dev $swp2 egress" 101 0
315 check_err $?
"L2 miss filter was hit when should not"
317 tc_check_packets
"dev $swp2 egress" 102 1
318 check_err $?
"L2 no miss filter was not hit when should"
320 tc filter del dev
$swp2 egress protocol all pref
1 handle
102 flower
321 tc filter del dev
$swp2 egress protocol all pref
1 handle
101 flower
323 log_test
"L2 miss - Broadcast"