2 # SPDX-License-Identifier: GPL-2.0
4 # +--------------------+
9 # | 2001:db8:1::2/64 | |
13 # +------------------|-+
15 # +------------------|-+
21 # | 2001:db8:1::1/64 |
23 # +--------------------+
40 vlan_create
$h1 10 v
$h1 192.0.2.2/24 2001:db8
:1::2/64
45 vlan_destroy
$h1 10 192.0.2.2/24 2001:db8
:1::2/64
51 ip li
set dev
$swp1 up
52 vlan_create
$swp1 10 "" 192.0.2.1/24 2001:db8
:1::1/64
57 ip li
set dev
$swp1 down
90 ping_test
$h1.10
192.0.2.1
95 ping6_test
$h1.10
2001:db8
:1::1
101 local min_max
=$1; shift
103 ip
-d -j link show
$dev | jq
".[].$min_max"
106 ensure_compatible_min_max_mtu
()
108 local min_max
=$1; shift
110 local mtu
=$
(min_max_mtu_get_if
${NETIFS[p1]} $min_max)
113 for ((i
= 2; i
<= NUM_NETIFS
; ++i
)); do
114 local current_mtu
=$
(min_max_mtu_get_if
${NETIFS[p$i]} $min_max)
116 if [ $current_mtu -ne $mtu ]; then
126 local should_fail
=${1:-0}; shift
128 mtu_set
$dev $mtu 2>/dev
/null
129 check_err_fail
$should_fail $?
"Set MTU $mtu for $dev"
137 for ((i
= 1; i
<= NUM_NETIFS
; ++i
)); do
138 mtu_set_if
${NETIFS[p$i]} $mtu
139 mtu_set_if
${NETIFS[p$i]}.10 $mtu
147 for ((i
= 1; i
<= NUM_NETIFS
; ++i
)); do
148 mtu_restore
${NETIFS[p$i]}.10
149 mtu_restore
${NETIFS[p$i]}
156 local should_fail
=$1; shift
158 # Ping adds 8 bytes for ICMP header and 20 bytes for IP header
159 local ping_headers_len
=$
((20 + 8))
160 local pkt_size
=$
((mtu
- ping_headers_len
))
162 ping_do
$h1.10
192.0.2.1 "-s $pkt_size -M do"
163 check_err_fail
$should_fail $?
"Ping, packet size: $pkt_size"
169 local should_fail
=$1; shift
171 # Ping adds 8 bytes for ICMP header and 40 bytes for IPv6 header
172 local ping6_headers_len
=$
((40 + 8))
173 local pkt_size
=$
((mtu
- ping6_headers_len
))
175 ping6_do
$h1.10
2001:db8
:1::1 "-s $pkt_size -M do"
176 check_err_fail
$should_fail $?
"Ping6, packet size: $pkt_size"
179 max_mtu_config_test
()
185 for ((i
= 1; i
<= NUM_NETIFS
; ++i
)); do
186 local dev
=${NETIFS[p$i]}
187 local max_mtu
=$
(min_max_mtu_get_if
$dev "max_mtu")
191 mtu_set_if
$dev $max_mtu $should_fail
195 mtu_set_if
$dev $
((max_mtu
+ 1)) $should_fail
199 log_test
"Test maximum MTU configuration"
202 max_mtu_traffic_test
()
209 if ! ensure_compatible_min_max_mtu
"max_mtu"; then
210 log_test_xfail
"Topology has incompatible maximum MTU values"
214 max_mtu
=$
(min_max_mtu_get_if
${NETIFS[p1]} "max_mtu")
217 mtu_set_all_if
$max_mtu
218 mtu_test_ping4
$max_mtu $should_fail
219 mtu_test_ping6
$max_mtu $should_fail
223 mtu_set_all_if $
((max_mtu
- 1))
224 mtu_test_ping4
$max_mtu $should_fail
225 mtu_test_ping6
$max_mtu $should_fail
228 log_test
"Test traffic, packet size is maximum MTU"
231 min_mtu_config_test
()
237 for ((i
= 1; i
<= NUM_NETIFS
; ++i
)); do
238 local dev
=${NETIFS[p$i]}
239 local min_mtu
=$
(min_max_mtu_get_if
$dev "min_mtu")
243 mtu_set_if
$dev $min_mtu $should_fail
247 mtu_set_if
$dev $
((min_mtu
- 1)) $should_fail
251 log_test
"Test minimum MTU configuration"
254 min_mtu_traffic_test
()
261 if ! ensure_compatible_min_max_mtu
"min_mtu"; then
262 log_test_xfail
"Topology has incompatible minimum MTU values"
266 min_mtu
=$
(min_max_mtu_get_if
${NETIFS[p1]} "min_mtu")
267 mtu_set_all_if
$min_mtu
268 mtu_test_ping4
$min_mtu $should_fail
269 # Do not test minimum MTU with IPv6, as IPv6 requires higher MTU.
273 log_test
"Test traffic, packet size is minimum MTU"