2 # SPDX-License-Identifier: GPL-2.0
11 ip link
set dev
$h1 master vrf-h1
13 ip link
set dev vrf-h1 up
14 ip link
set dev
$h1 up
16 ip address add
192.0.2.2/24 dev
$h1
18 ip route add
198.51.100.0/24 vrf vrf-h1 nexthop via
192.0.2.1
19 ip route add
198.51.200.0/24 vrf vrf-h1 nexthop via
192.0.2.1
24 ip route del
198.51.200.0/24 vrf vrf-h1
25 ip route del
198.51.100.0/24 vrf vrf-h1
27 ip address del
192.0.2.2/24 dev
$h1
29 ip link
set dev
$h1 down
36 ip link
set dev
$h2 master vrf-h2
38 ip link
set dev vrf-h2 up
39 ip link
set dev
$h2 up
41 ip address add
198.51.100.2/24 dev
$h2
43 ip route add
192.0.2.0/24 vrf vrf-h2 nexthop via
198.51.100.1
44 ip route add
198.51.200.0/24 vrf vrf-h2 nexthop via
198.51.100.1
49 ip route del
198.51.200.0/24 vrf vrf-h2
50 ip route del
192.0.2.0/24 vrf vrf-h2
52 ip address del
198.51.100.2/24 dev
$h2
54 ip link
set dev
$h2 down
61 ip link
set dev
$h3 master vrf-h3
63 ip link
set dev vrf-h3 up
64 ip link
set dev
$h3 up
66 ip address add
198.51.200.2/24 dev
$h3
68 ip route add
192.0.2.0/24 vrf vrf-h3 nexthop via
198.51.200.1
69 ip route add
198.51.100.0/24 vrf vrf-h3 nexthop via
198.51.200.1
74 ip route del
198.51.100.0/24 vrf vrf-h3
75 ip route del
192.0.2.0/24 vrf vrf-h3
77 ip address del
198.51.200.2/24 dev
$h3
79 ip link
set dev
$h3 down
85 ip link
set dev
$rp1 up
86 ip link
set dev
$rp2 up
87 ip link
set dev
$rp3 up
89 ip address add
192.0.2.1/24 dev
$rp1
91 ip address add
198.51.100.1/24 dev
$rp2
92 ip address add
198.51.200.1/24 dev
$rp3
97 ip address del
198.51.200.1/24 dev
$rp3
98 ip address del
198.51.100.1/24 dev
$rp2
100 ip address del
192.0.2.1/24 dev
$rp1
102 ip link
set dev
$rp3 down
103 ip link
set dev
$rp2 down
104 ip link
set dev
$rp1 down
144 bc_forwarding_disable
()
146 sysctl_set net.ipv4.conf.all.bc_forwarding
0
147 sysctl_set net.ipv4.conf.
$rp1.bc_forwarding
0
148 sysctl_set net.ipv4.conf.
$rp2.bc_forwarding
0
151 bc_forwarding_enable
()
153 sysctl_set net.ipv4.conf.all.bc_forwarding
1
154 sysctl_set net.ipv4.conf.
$rp1.bc_forwarding
1
155 sysctl_set net.ipv4.conf.
$rp2.bc_forwarding
1
158 bc_forwarding_restore
()
160 sysctl_restore net.ipv4.conf.
$rp2.bc_forwarding
161 sysctl_restore net.ipv4.conf.
$rp1.bc_forwarding
162 sysctl_restore net.ipv4.conf.all.bc_forwarding
174 log_info
"ping $dip, expected reply from $from"
175 ip vrf
exec $
(master_name_get
$oif) \
176 $PING -I $oif $dip -c 10 -i 0.1 -w $PING_TIMEOUT -b 2>&1 \
177 |
grep "bytes from $from" > /dev
/null
178 check_err_fail
$fail $?
183 sysctl_set net.ipv4.icmp_echo_ignore_broadcasts
0
185 bc_forwarding_disable
186 log_info
"bc_forwarding disabled on r1 =>"
187 ping_test_from
$h1 198.51.100.255 192.0.2.1
188 log_test
"h1 -> net2: reply from r1 (not forwarding)"
189 ping_test_from
$h1 198.51.200.255 192.0.2.1
190 log_test
"h1 -> net3: reply from r1 (not forwarding)"
191 ping_test_from
$h1 192.0.2.255 192.0.2.1
192 log_test
"h1 -> net1: reply from r1 (not dropping)"
193 ping_test_from
$h1 255.255.255.255 192.0.2.1
194 log_test
"h1 -> 255.255.255.255: reply from r1 (not forwarding)"
196 ping_test_from
$h2 192.0.2.255 198.51.100.1
197 log_test
"h2 -> net1: reply from r1 (not forwarding)"
198 ping_test_from
$h2 198.51.200.255 198.51.100.1
199 log_test
"h2 -> net3: reply from r1 (not forwarding)"
200 ping_test_from
$h2 198.51.100.255 198.51.100.1
201 log_test
"h2 -> net2: reply from r1 (not dropping)"
202 ping_test_from
$h2 255.255.255.255 198.51.100.1
203 log_test
"h2 -> 255.255.255.255: reply from r1 (not forwarding)"
204 bc_forwarding_restore
207 log_info
"bc_forwarding enabled on r1 =>"
208 ping_test_from
$h1 198.51.100.255 198.51.100.2
209 log_test
"h1 -> net2: reply from h2 (forwarding)"
210 ping_test_from
$h1 198.51.200.255 198.51.200.2
211 log_test
"h1 -> net3: reply from h3 (forwarding)"
212 ping_test_from
$h1 192.0.2.255 192.0.2.1 1
213 log_test
"h1 -> net1: no reply (dropping)"
214 ping_test_from
$h1 255.255.255.255 192.0.2.1
215 log_test
"h1 -> 255.255.255.255: reply from r1 (not forwarding)"
217 ping_test_from
$h2 192.0.2.255 192.0.2.2
218 log_test
"h2 -> net1: reply from h1 (forwarding)"
219 ping_test_from
$h2 198.51.200.255 198.51.200.2
220 log_test
"h2 -> net3: reply from h3 (forwarding)"
221 ping_test_from
$h2 198.51.100.255 198.51.100.1 1
222 log_test
"h2 -> net2: no reply (dropping)"
223 ping_test_from
$h2 255.255.255.255 198.51.100.1
224 log_test
"h2 -> 255.255.255.255: reply from r1 (not forwarding)"
225 bc_forwarding_restore
227 sysctl_restore net.ipv4.icmp_echo_ignore_broadcasts