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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/net/pmtu.sh

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/selftests/net/pmtu.sh (Version linux-6.11.5) and /tools/testing/selftests/net/pmtu.sh (Version linux-4.15.18)


  1 #!/bin/bash                                       
  2 # SPDX-License-Identifier: GPL-2.0                
  3 #                                                 
  4 # Check that route PMTU values match expectati    
  5 # values are assigned correctly                   
  6 #                                                 
  7 # Tests currently implemented:                    
  8 #                                                 
  9 # - pmtu_ipv4                                     
 10 #       Set up two namespaces, A and B, with t    
 11 #       R1 and R2 (also implemented with names    
 12 #                                                 
 13 #         segment a_r1    segment b_r1            
 14 #       .--------------R1--------------.          
 15 #       A                               B         
 16 #       '--------------R2--------------'          
 17 #         segment a_r2    segment b_r2            
 18 #                                                 
 19 #       Check that PMTU exceptions with the co    
 20 #       decrease and increase the MTU of the l    
 21 #       A to R1, checking that route exception    
 22 #       this path. Also check that locked exce    
 23 #       message advertising a PMTU smaller tha    
 24 #       received                                  
 25 #                                                 
 26 # - pmtu_ipv6                                     
 27 #       Same as pmtu_ipv4, except for locked P    
 28 #                                                 
 29 # - pmtu_ipv4_dscp_icmp_exception                 
 30 #       Set up the same network topology as pm    
 31 #       routing table in A. A fib-rule is used    
 32 #       based on DSCP. Send ICMPv4 packets wit    
 33 #       verify that ECN doesn't interfere with    
 34 #                                                 
 35 # - pmtu_ipv4_dscp_udp_exception                  
 36 #       Same as pmtu_ipv4_dscp_icmp_exception,    
 37 #                                                 
 38 # - pmtu_ipv4_vxlan4_exception                    
 39 #       Set up the same network topology as pm    
 40 #       over IPv4 between A and B, routed via     
 41 #       set a MTU lower than the VXLAN MTU and    
 42 #       R1. Send IPv4 packets, exceeding the M    
 43 #       from A to B and check that the PMTU ex    
 44 #       value on A                                
 45 #                                                 
 46 # - pmtu_ipv6_vxlan4_exception                    
 47 #       Same as pmtu_ipv4_vxlan4_exception, bu    
 48 #                                                 
 49 # - pmtu_ipv4_vxlan6_exception                    
 50 #       Same as pmtu_ipv4_vxlan4_exception, bu    
 51 #                                                 
 52 # - pmtu_ipv6_vxlan6_exception                    
 53 #       Same as pmtu_ipv4_vxlan6_exception, bu    
 54 #                                                 
 55 # - pmtu_ipv4_geneve4_exception                   
 56 #       Same as pmtu_ipv4_vxlan4_exception, bu    
 57 #       VXLAN                                     
 58 #                                                 
 59 # - pmtu_ipv6_geneve4_exception                   
 60 #       Same as pmtu_ipv6_vxlan4_exception, bu    
 61 #       VXLAN                                     
 62 #                                                 
 63 # - pmtu_ipv4_geneve6_exception                   
 64 #       Same as pmtu_ipv4_vxlan6_exception, bu    
 65 #       VXLAN                                     
 66 #                                                 
 67 # - pmtu_ipv6_geneve6_exception                   
 68 #       Same as pmtu_ipv6_vxlan6_exception, bu    
 69 #       VXLAN                                     
 70 #                                                 
 71 # - pmtu_ipv{4,6}_br_vxlan{4,6}_exception         
 72 #       Set up three namespaces, A, B, and C,     
 73 #       R1. R2 is unused in these tests. A has    
 74 #       connected to B via a VXLAN endpoint, w    
 75 #       MTU on the B-R1 link is lower than oth    
 76 #                                                 
 77 #       Check that both C and A are able to co    
 78 #       tunnel, and that PMTU exceptions with     
 79 #                                                 
 80 #                         segment a_r1    segm    
 81 #                       .--------------R1-----    
 82 #          C---veth     A                         
 83 #               ' bridge                          
 84 #                   '---- - - - - - VXLAN - -     
 85 #                                                 
 86 # - pmtu_ipv{4,6}_br_geneve{4,6}_exception        
 87 #       Same as pmtu_ipv{4,6}_br_vxlan{4,6}_ex    
 88 #       instead.                                  
 89 #                                                 
 90 # - pmtu_ipv{4,6}_ovs_vxlan{4,6}_exception        
 91 #       Set up two namespaces, B, and C, with     
 92 #       and B over R1. A and R2 are unused in     
 93 #       has a veth connection to C, and is con    
 94 #       which is handled by Open vSwitch and b    
 95 #       is lower than other MTUs.                 
 96 #                                                 
 97 #       Check that C is able to communicate wi    
 98 #       that PMTU exceptions with the correct     
 99 #                                                 
100 #                         segment a_r1    segm    
101 #                       .--------------R1-----    
102 #          C---veth    init                       
103 #               '- ovs                            
104 #                   '---- - - - - - VXLAN - -     
105 #                                                 
106 # - pmtu_ipv{4,6}_ovs_geneve{4,6}_exception       
107 #       Same as pmtu_ipv{4,6}_ovs_vxlan{4,6}_e    
108 #       instead.                                  
109 #                                                 
110 # - pmtu_ipv{4,6}_fou{4,6}_exception              
111 #       Same as pmtu_ipv4_vxlan4, but using a     
112 #       (FoU) over IPv4/IPv6, instead of VXLAN    
113 #                                                 
114 # - pmtu_ipv{4,6}_fou{4,6}_exception              
115 #       Same as pmtu_ipv4_vxlan4, but using a     
116 #       encapsulation (GUE) over IPv4/IPv6, in    
117 #                                                 
118 # - pmtu_ipv{4,6}_ipv{4,6}_exception              
119 #       Same as pmtu_ipv4_vxlan4, but using a     
120 #       instead of VXLAN                          
121 #                                                 
122 # - pmtu_vti4_exception                           
123 #       Set up vti tunnel on top of veth, with    
124 #       namespaces with matching endpoints. Ch    
125 #       created if link layer MTU is not excee    
126 #       exception is created with the expected    
127 #       below for IPv6 doesn't apply here, bec    
128 #       changes alone won't affect PMTU           
129 #                                                 
130 # - pmtu_vti4_udp_exception                       
131 #       Same as pmtu_vti4_exception, but using    
132 #                                                 
133 # - pmtu_vti4_udp_routed_exception                
134 #       Set up vti tunnel on top of veth conne    
135 #       add xfrm states and policies with ESP-    
136 #       route exception is not created if link    
137 #       lower MTU on second part of routed env    
138 #       is created with the expected PMTU.        
139 #                                                 
140 # - pmtu_vti6_exception                           
141 #       Set up vti6 tunnel on top of veth, wit    
142 #       namespaces with matching endpoints. Ch    
143 #       created by exceeding link layer MTU wi    
144 #       decrease and increase MTU of tunnel, c    
145 #       changes accordingly                       
146 #                                                 
147 # - pmtu_vti6_udp_exception                       
148 #       Same as pmtu_vti6_exception, but using    
149 #                                                 
150 # - pmtu_vti6_udp_routed_exception                
151 #       Same as pmtu_vti6_udp_routed_exception    
152 #       endpoints                                 
153 #                                                 
154 # - pmtu_vti4_default_mtu                         
155 #       Set up vti4 tunnel on top of veth, in     
156 #       endpoints. Check that MTU assigned to     
157 #       lower layer (veth) minus additional lo    
158 #       minus IPv4 header length                  
159 #                                                 
160 # - pmtu_vti6_default_mtu                         
161 #       Same as above, for IPv6                   
162 #                                                 
163 # - pmtu_vti4_link_add_mtu                        
164 #       Set up vti4 interface passing MTU valu    
165 #       configured, and that link is not creat    
166 #                                                 
167 # - pmtu_vti6_link_add_mtu                        
168 #       Same as above, for IPv6                   
169 #                                                 
170 # - pmtu_vti6_link_change_mtu                     
171 #       Set up two dummy interfaces with diffe    
172 #       and check that configured MTU is used     
173 #       that MTU is properly calculated instea    
174 #       userspace                                 
175 #                                                 
176 # - cleanup_ipv4_exception                        
177 #       Similar to pmtu_ipv4_vxlan4_exception,    
178 #       exceptions on multiple CPUs and check     
179 #       happens in a timely manner                
180 #                                                 
181 # - cleanup_ipv6_exception                        
182 #       Same as above, but use IPv6 transport     
183 #                                                 
184 # - list_flush_ipv4_exception                     
185 #       Using the same topology as in pmtu_ipv    
186 #       they are shown when listing exception     
187 #                                                 
188 # - list_flush_ipv6_exception                     
189 #       Using the same topology as in pmtu_ipv    
190 #       they are shown when listing exception     
191 #                                                 
192 # - pmtu_ipv4_route_change                        
193 #       Use the same topology as in pmtu_ipv4,    
194 #       command and delete the corresponding d    
195 #       proper cleanup of the PMTU exceptions     
196 #       Device unregistration should complete     
197 #                                                 
198 # - pmtu_ipv6_route_change                        
199 #       Same as above but with IPv6               
200                                                   
201 source lib.sh                                     
202 source net_helper.sh                              
203                                                   
204 PAUSE_ON_FAIL=no                                  
205 VERBOSE=0                                         
206 TRACING=0                                         
207                                                   
208 # Some systems don't have a ping6 binary anymo    
209 which ping6 > /dev/null 2>&1 && ping6=$(which     
210                                                   
211 #               Name                              
212 tests="                                           
213         pmtu_ipv4_exception             ipv4:     
214         pmtu_ipv6_exception             ipv6:     
215         pmtu_ipv4_dscp_icmp_exception   ICMPv4    
216         pmtu_ipv4_dscp_udp_exception    UDPv4     
217         pmtu_ipv4_vxlan4_exception      IPv4 o    
218         pmtu_ipv6_vxlan4_exception      IPv6 o    
219         pmtu_ipv4_vxlan6_exception      IPv4 o    
220         pmtu_ipv6_vxlan6_exception      IPv6 o    
221         pmtu_ipv4_geneve4_exception     IPv4 o    
222         pmtu_ipv6_geneve4_exception     IPv6 o    
223         pmtu_ipv4_geneve6_exception     IPv4 o    
224         pmtu_ipv6_geneve6_exception     IPv6 o    
225         pmtu_ipv4_br_vxlan4_exception   IPv4,     
226         pmtu_ipv6_br_vxlan4_exception   IPv6,     
227         pmtu_ipv4_br_vxlan6_exception   IPv4,     
228         pmtu_ipv6_br_vxlan6_exception   IPv6,     
229         pmtu_ipv4_br_geneve4_exception  IPv4,     
230         pmtu_ipv6_br_geneve4_exception  IPv6,     
231         pmtu_ipv4_br_geneve6_exception  IPv4,     
232         pmtu_ipv6_br_geneve6_exception  IPv6,     
233         pmtu_ipv4_ovs_vxlan4_exception  IPv4,     
234         pmtu_ipv6_ovs_vxlan4_exception  IPv6,     
235         pmtu_ipv4_ovs_vxlan6_exception  IPv4,     
236         pmtu_ipv6_ovs_vxlan6_exception  IPv6,     
237         pmtu_ipv4_ovs_geneve4_exception IPv4,     
238         pmtu_ipv6_ovs_geneve4_exception IPv6,     
239         pmtu_ipv4_ovs_geneve6_exception IPv4,     
240         pmtu_ipv6_ovs_geneve6_exception IPv6,     
241         pmtu_ipv4_fou4_exception        IPv4 o    
242         pmtu_ipv6_fou4_exception        IPv6 o    
243         pmtu_ipv4_fou6_exception        IPv4 o    
244         pmtu_ipv6_fou6_exception        IPv6 o    
245         pmtu_ipv4_gue4_exception        IPv4 o    
246         pmtu_ipv6_gue4_exception        IPv6 o    
247         pmtu_ipv4_gue6_exception        IPv4 o    
248         pmtu_ipv6_gue6_exception        IPv6 o    
249         pmtu_ipv4_ipv4_exception        IPv4 o    
250         pmtu_ipv6_ipv4_exception        IPv6 o    
251         pmtu_ipv4_ipv6_exception        IPv4 o    
252         pmtu_ipv6_ipv6_exception        IPv6 o    
253         pmtu_vti6_exception             vti6:     
254         pmtu_vti4_exception             vti4:     
255         pmtu_vti6_udp_exception         vti6:     
256         pmtu_vti4_udp_exception         vti4:     
257         pmtu_vti6_udp_routed_exception  vti6:     
258         pmtu_vti4_udp_routed_exception  vti4:     
259         pmtu_vti4_default_mtu           vti4:     
260         pmtu_vti6_default_mtu           vti6:     
261         pmtu_vti4_link_add_mtu          vti4:     
262         pmtu_vti6_link_add_mtu          vti6:     
263         pmtu_vti6_link_change_mtu       vti6:     
264         cleanup_ipv4_exception          ipv4:     
265         cleanup_ipv6_exception          ipv6:     
266         list_flush_ipv4_exception       ipv4:     
267         list_flush_ipv6_exception       ipv6:     
268         pmtu_ipv4_route_change          ipv4:     
269         pmtu_ipv6_route_change          ipv6:     
270                                                   
271 # Addressing and routing for tests with router    
272 # index SEGMENT between 1 and 4, a common pref    
273 # identifier ID, which is 1 for hosts (A and B    
274 # Addresses are:                                  
275 # - IPv4: PREFIX4.SEGMENT.ID (/24)                
276 # - IPv6: PREFIX6:SEGMENT::ID (/64)               
277 prefix4="10.0"                                    
278 prefix6="fc00"                                    
279 a_r1=1                                            
280 a_r2=2                                            
281 b_r1=3                                            
282 b_r2=4                                            
283 #       ns      peer    segment                   
284 routing_addrs="                                   
285         A       R1      ${a_r1}                   
286         A       R2      ${a_r2}                   
287         B       R1      ${b_r1}                   
288         B       R2      ${b_r2}                   
289 "                                                 
290 # Traffic from A to B goes through R1 by defau    
291 # B's address on the b_r2 segment.                
292 # Traffic from B to A goes through R1.            
293 #       ns      destination             gatewa    
294 routes="                                          
295         A       default                 ${pref    
296         A       ${prefix4}.${b_r2}.1    ${pref    
297         B       default                 ${pref    
298                                                   
299         A       default                 ${pref    
300         A       ${prefix6}:${b_r2}::1   ${pref    
301         B       default                 ${pref    
302 "                                                 
303 USE_NH="no"                                       
304 #       ns      family  nh id      destination    
305 nexthops="                                        
306         A       4       41      ${prefix4}.${a    
307         A       4       42      ${prefix4}.${a    
308         B       4       41      ${prefix4}.${b    
309                                                   
310         A       6       61      ${prefix6}:${a    
311         A       6       62      ${prefix6}:${a    
312         B       6       61      ${prefix6}:${b    
313 "                                                 
314                                                   
315 # nexthop id correlates to id in nexthops conf    
316 #       ns    family    prefix                    
317 routes_nh="                                       
318         A       4       default                   
319         A       4       ${prefix4}.${b_r2}.1      
320         B       4       default                   
321                                                   
322         A       6       default                   
323         A       6       ${prefix6}:${b_r2}::1     
324         B       6       default                   
325 "                                                 
326                                                   
327 policy_mark=0x04                                  
328 rt_table=main                                     
329                                                   
330 veth4_a_addr="192.168.1.1"                        
331 veth4_b_addr="192.168.1.2"                        
332 veth4_c_addr="192.168.2.10"                       
333 veth4_mask="24"                                   
334 veth6_a_addr="fd00:1::a"                          
335 veth6_b_addr="fd00:1::b"                          
336 veth6_c_addr="fd00:2::c"                          
337 veth6_mask="64"                                   
338                                                   
339 tunnel4_a_addr="192.168.2.1"                      
340 tunnel4_b_addr="192.168.2.2"                      
341 tunnel4_mask="24"                                 
342 tunnel6_a_addr="fd00:2::a"                        
343 tunnel6_b_addr="fd00:2::b"                        
344 tunnel6_mask="64"                                 
345                                                   
346 dummy6_0_prefix="fc00:1000::"                     
347 dummy6_1_prefix="fc00:1001::"                     
348 dummy6_mask="64"                                  
349                                                   
350 err_buf=                                          
351 tcpdump_pids=                                     
352 nettest_pids=                                     
353 socat_pids=                                       
354 tmpoutfile=                                       
355                                                   
356 err() {                                           
357         err_buf="${err_buf}${1}                   
358 "                                                 
359 }                                                 
360                                                   
361 err_flush() {                                     
362         echo -n "${err_buf}"                      
363         err_buf=                                  
364 }                                                 
365                                                   
366 run_cmd() {                                       
367         cmd="$*"                                  
368                                                   
369         if [ "$VERBOSE" = "1" ]; then             
370                 printf "    COMMAND: $cmd\n"      
371         fi                                        
372                                                   
373         out="$($cmd 2>&1)"                        
374         rc=$?                                     
375         if [ "$VERBOSE" = "1" -a -n "$out" ];     
376                 echo "    $out"                   
377                 echo                              
378         fi                                        
379                                                   
380         return $rc                                
381 }                                                 
382                                                   
383 run_cmd_bg() {                                    
384         cmd="$*"                                  
385                                                   
386         if [ "$VERBOSE" = "1" ]; then             
387                 printf "    COMMAND: %s &\n" "    
388         fi                                        
389                                                   
390         $cmd 2>&1 &                               
391 }                                                 
392                                                   
393 # Find the auto-generated name for this namesp    
394 nsname() {                                        
395         eval echo \$NS_$1                         
396 }                                                 
397                                                   
398 setup_fou_or_gue() {                              
399         outer="${1}"                              
400         inner="${2}"                              
401         encap="${3}"                              
402                                                   
403         if [ "${outer}" = "4" ]; then             
404                 modprobe fou || return $ksft_s    
405                 a_addr="${prefix4}.${a_r1}.1"     
406                 b_addr="${prefix4}.${b_r1}.1"     
407                 if [ "${inner}" = "4" ]; then     
408                         type="ipip"               
409                         ipproto="4"               
410                 else                              
411                         type="sit"                
412                         ipproto="41"              
413                 fi                                
414         else                                      
415                 modprobe fou6 || return $ksft_    
416                 a_addr="${prefix6}:${a_r1}::1"    
417                 b_addr="${prefix6}:${b_r1}::1"    
418                 if [ "${inner}" = "4" ]; then     
419                         type="ip6tnl"             
420                         mode="mode ipip6"         
421                         ipproto="4 -6"            
422                 else                              
423                         type="ip6tnl"             
424                         mode="mode ip6ip6"        
425                         ipproto="41 -6"           
426                 fi                                
427         fi                                        
428                                                   
429         run_cmd ${ns_a} ip fou add port 5555 i    
430         run_cmd ${ns_a} ip link add ${encap}_a    
431                                                   
432         run_cmd ${ns_b} ip fou add port 5556 i    
433         run_cmd ${ns_b} ip link add ${encap}_b    
434                                                   
435         if [ "${inner}" = "4" ]; then             
436                 run_cmd ${ns_a} ip addr add ${    
437                 run_cmd ${ns_b} ip addr add ${    
438         else                                      
439                 run_cmd ${ns_a} ip addr add ${    
440                 run_cmd ${ns_b} ip addr add ${    
441         fi                                        
442                                                   
443         run_cmd ${ns_a} ip link set ${encap}_a    
444         run_cmd ${ns_b} ip link set ${encap}_b    
445 }                                                 
446                                                   
447 setup_fou44() {                                   
448         setup_fou_or_gue 4 4 fou                  
449 }                                                 
450                                                   
451 setup_fou46() {                                   
452         setup_fou_or_gue 4 6 fou                  
453 }                                                 
454                                                   
455 setup_fou64() {                                   
456         setup_fou_or_gue 6 4 fou                  
457 }                                                 
458                                                   
459 setup_fou66() {                                   
460         setup_fou_or_gue 6 6 fou                  
461 }                                                 
462                                                   
463 setup_gue44() {                                   
464         setup_fou_or_gue 4 4 gue                  
465 }                                                 
466                                                   
467 setup_gue46() {                                   
468         setup_fou_or_gue 4 6 gue                  
469 }                                                 
470                                                   
471 setup_gue64() {                                   
472         setup_fou_or_gue 6 4 gue                  
473 }                                                 
474                                                   
475 setup_gue66() {                                   
476         setup_fou_or_gue 6 6 gue                  
477 }                                                 
478                                                   
479 setup_ipvX_over_ipvY() {                          
480         inner=${1}                                
481         outer=${2}                                
482                                                   
483         if [ "${outer}" -eq 4 ]; then             
484                 a_addr="${prefix4}.${a_r1}.1"     
485                 b_addr="${prefix4}.${b_r1}.1"     
486                 if [ "${inner}" -eq 4 ]; then     
487                         type="ipip"               
488                         mode="ipip"               
489                 else                              
490                         type="sit"                
491                         mode="ip6ip"              
492                 fi                                
493         else                                      
494                 a_addr="${prefix6}:${a_r1}::1"    
495                 b_addr="${prefix6}:${b_r1}::1"    
496                 type="ip6tnl"                     
497                 if [ "${inner}" -eq 4 ]; then     
498                         mode="ipip6"              
499                 else                              
500                         mode="ip6ip6"             
501                 fi                                
502         fi                                        
503                                                   
504         run_cmd ${ns_a} ip link add ip_a type     
505         run_cmd ${ns_b} ip link add ip_b type     
506                                                   
507         run_cmd ${ns_a} ip link set ip_a up       
508         run_cmd ${ns_b} ip link set ip_b up       
509                                                   
510         if [ "${inner}" = "4" ]; then             
511                 run_cmd ${ns_a} ip addr add ${    
512                 run_cmd ${ns_b} ip addr add ${    
513         else                                      
514                 run_cmd ${ns_a} ip addr add ${    
515                 run_cmd ${ns_b} ip addr add ${    
516         fi                                        
517 }                                                 
518                                                   
519 setup_ip4ip4() {                                  
520         setup_ipvX_over_ipvY 4 4                  
521 }                                                 
522                                                   
523 setup_ip6ip4() {                                  
524         setup_ipvX_over_ipvY 6 4                  
525 }                                                 
526                                                   
527 setup_ip4ip6() {                                  
528         setup_ipvX_over_ipvY 4 6                  
529 }                                                 
530                                                   
531 setup_ip6ip6() {                                  
532         setup_ipvX_over_ipvY 6 6                  
533 }                                                 
534                                                   
535 setup_namespaces() {                              
536         setup_ns NS_A NS_B NS_C NS_R1 NS_R2       
537         for n in ${NS_A} ${NS_B} ${NS_C} ${NS_    
538                 # Disable DAD, so that we don'    
539                 # configured IPv6 addresses       
540                 ip netns exec ${n} sysctl -q n    
541         done                                      
542         ns_a="ip netns exec ${NS_A}"              
543         ns_b="ip netns exec ${NS_B}"              
544         ns_c="ip netns exec ${NS_C}"              
545         ns_r1="ip netns exec ${NS_R1}"            
546         ns_r2="ip netns exec ${NS_R2}"            
547 }                                                 
548                                                   
549 setup_veth() {                                    
550         run_cmd ${ns_a} ip link add veth_a typ    
551         run_cmd ${ns_a} ip link set veth_b net    
552                                                   
553         run_cmd ${ns_a} ip addr add ${veth4_a_    
554         run_cmd ${ns_b} ip addr add ${veth4_b_    
555                                                   
556         run_cmd ${ns_a} ip addr add ${veth6_a_    
557         run_cmd ${ns_b} ip addr add ${veth6_b_    
558                                                   
559         run_cmd ${ns_a} ip link set veth_a up     
560         run_cmd ${ns_b} ip link set veth_b up     
561 }                                                 
562                                                   
563 setup_vti() {                                     
564         proto=${1}                                
565         veth_a_addr="${2}"                        
566         veth_b_addr="${3}"                        
567         vti_a_addr="${4}"                         
568         vti_b_addr="${5}"                         
569         vti_mask=${6}                             
570                                                   
571         [ ${proto} -eq 6 ] && vti_type="vti6"     
572                                                   
573         run_cmd ${ns_a} ip link add vti${proto    
574         run_cmd ${ns_b} ip link add vti${proto    
575                                                   
576         run_cmd ${ns_a} ip addr add ${vti_a_ad    
577         run_cmd ${ns_b} ip addr add ${vti_b_ad    
578                                                   
579         run_cmd ${ns_a} ip link set vti${proto    
580         run_cmd ${ns_b} ip link set vti${proto    
581 }                                                 
582                                                   
583 setup_vti4() {                                    
584         setup_vti 4 ${veth4_a_addr} ${veth4_b_    
585 }                                                 
586                                                   
587 setup_vti6() {                                    
588         setup_vti 6 ${veth6_a_addr} ${veth6_b_    
589 }                                                 
590                                                   
591 setup_vti4routed() {                              
592         setup_vti 4 ${prefix4}.${a_r1}.1 ${pre    
593 }                                                 
594                                                   
595 setup_vti6routed() {                              
596         setup_vti 6 ${prefix6}:${a_r1}::1 ${pr    
597 }                                                 
598                                                   
599 setup_vxlan_or_geneve() {                         
600         type="${1}"                               
601         a_addr="${2}"                             
602         b_addr="${3}"                             
603         opts="${4}"                               
604         br_if_a="${5}"                            
605                                                   
606         if [ "${type}" = "vxlan" ]; then          
607                 opts="${opts} ttl 64 dstport 4    
608                 opts_a="local ${a_addr}"          
609                 opts_b="local ${b_addr}"          
610         else                                      
611                 opts_a=""                         
612                 opts_b=""                         
613         fi                                        
614                                                   
615         run_cmd ${ns_a} ip link add ${type}_a     
616         run_cmd ${ns_b} ip link add ${type}_b     
617                                                   
618         if [ -n "${br_if_a}" ]; then              
619                 run_cmd ${ns_a} ip addr add ${    
620                 run_cmd ${ns_a} ip addr add ${    
621                 run_cmd ${ns_a} ip link set ${    
622         else                                      
623                 run_cmd ${ns_a} ip addr add ${    
624                 run_cmd ${ns_a} ip addr add ${    
625         fi                                        
626                                                   
627         run_cmd ${ns_b} ip addr add ${tunnel4_    
628         run_cmd ${ns_b} ip addr add ${tunnel6_    
629                                                   
630         run_cmd ${ns_a} ip link set ${type}_a     
631         run_cmd ${ns_b} ip link set ${type}_b     
632 }                                                 
633                                                   
634 setup_geneve4() {                                 
635         setup_vxlan_or_geneve geneve ${prefix4    
636 }                                                 
637                                                   
638 setup_vxlan4() {                                  
639         setup_vxlan_or_geneve vxlan  ${prefix4    
640 }                                                 
641                                                   
642 setup_geneve6() {                                 
643         setup_vxlan_or_geneve geneve ${prefix6    
644 }                                                 
645                                                   
646 setup_vxlan6() {                                  
647         setup_vxlan_or_geneve vxlan  ${prefix6    
648 }                                                 
649                                                   
650 setup_bridged_geneve4() {                         
651         setup_vxlan_or_geneve geneve ${prefix4    
652 }                                                 
653                                                   
654 setup_bridged_vxlan4() {                          
655         setup_vxlan_or_geneve vxlan  ${prefix4    
656 }                                                 
657                                                   
658 setup_bridged_geneve6() {                         
659         setup_vxlan_or_geneve geneve ${prefix6    
660 }                                                 
661                                                   
662 setup_bridged_vxlan6() {                          
663         setup_vxlan_or_geneve vxlan  ${prefix6    
664 }                                                 
665                                                   
666 setup_xfrm() {                                    
667         proto=${1}                                
668         veth_a_addr="${2}"                        
669         veth_b_addr="${3}"                        
670         encap=${4}                                
671                                                   
672         run_cmd ${ns_a} ip -${proto} xfrm stat    
673         run_cmd ${ns_a} ip -${proto} xfrm stat    
674         run_cmd ${ns_a} ip -${proto} xfrm poli    
675         run_cmd ${ns_a} ip -${proto} xfrm poli    
676                                                   
677         run_cmd ${ns_b} ip -${proto} xfrm stat    
678         run_cmd ${ns_b} ip -${proto} xfrm stat    
679         run_cmd ${ns_b} ip -${proto} xfrm poli    
680         run_cmd ${ns_b} ip -${proto} xfrm poli    
681 }                                                 
682                                                   
683 setup_nettest_xfrm() {                            
684         if ! which nettest >/dev/null; then       
685                 PATH=$PWD:$PATH                   
686                 if ! which nettest >/dev/null;    
687                         echo "'nettest' comman    
688                         return 1                  
689                 fi                                
690         fi                                        
691                                                   
692         [ ${1} -eq 6 ] && proto="-6" || proto=    
693         port=${2}                                 
694                                                   
695         run_cmd_bg "${ns_a}" nettest "${proto}    
696         nettest_pids="${nettest_pids} $!"         
697                                                   
698         run_cmd_bg "${ns_b}" nettest "${proto}    
699         nettest_pids="${nettest_pids} $!"         
700 }                                                 
701                                                   
702 setup_xfrm4() {                                   
703         setup_xfrm 4 ${veth4_a_addr} ${veth4_b    
704 }                                                 
705                                                   
706 setup_xfrm6() {                                   
707         setup_xfrm 6 ${veth6_a_addr} ${veth6_b    
708 }                                                 
709                                                   
710 setup_xfrm4udp() {                                
711         setup_xfrm 4 ${veth4_a_addr} ${veth4_b    
712                 setup_nettest_xfrm 4 4500         
713 }                                                 
714                                                   
715 setup_xfrm6udp() {                                
716         setup_xfrm 6 ${veth6_a_addr} ${veth6_b    
717                 setup_nettest_xfrm 6 4500         
718 }                                                 
719                                                   
720 setup_xfrm4udprouted() {                          
721         setup_xfrm 4 ${prefix4}.${a_r1}.1 ${pr    
722                 setup_nettest_xfrm 4 4500         
723 }                                                 
724                                                   
725 setup_xfrm6udprouted() {                          
726         setup_xfrm 6 ${prefix6}:${a_r1}::1 ${p    
727                 setup_nettest_xfrm 6 4500         
728 }                                                 
729                                                   
730 setup_routing_old() {                             
731         for i in ${routes}; do                    
732                 [ "${ns}" = "" ]        && ns=    
733                 [ "${addr}" = "" ]      && add    
734                 [ "${gw}" = "" ]        && gw=    
735                                                   
736                 ns_name="$(nsname ${ns})"         
737                                                   
738                 ip -n "${ns_name}" route add "    
739                                                   
740                 ns=""; addr=""; gw=""             
741         done                                      
742 }                                                 
743                                                   
744 setup_routing_new() {                             
745         for i in ${nexthops}; do                  
746                 [ "${ns}" = "" ]        && ns=    
747                 [ "${fam}" = "" ]       && fam    
748                 [ "${nhid}" = "" ]      && nhi    
749                 [ "${gw}" = "" ]        && gw=    
750                 [ "${dev}" = "" ]       && dev    
751                                                   
752                 ns_name="$(nsname ${ns})"         
753                                                   
754                 ip -n ${ns_name} -${fam} nexth    
755                                                   
756                 ns=""; fam=""; nhid=""; gw="";    
757                                                   
758         done                                      
759                                                   
760         for i in ${routes_nh}; do                 
761                 [ "${ns}" = "" ]        && ns=    
762                 [ "${fam}" = "" ]       && fam    
763                 [ "${addr}" = "" ]      && add    
764                 [ "${nhid}" = "" ]      && nhi    
765                                                   
766                 ns_name="$(nsname ${ns})"         
767                                                   
768                 ip -n "${ns_name}" -"${fam}" r    
769                                                   
770                 ns=""; fam=""; addr=""; nhid="    
771         done                                      
772 }                                                 
773                                                   
774 setup_routing() {                                 
775         for i in ${NS_R1} ${NS_R2}; do            
776                 ip netns exec ${i} sysctl -q n    
777                 ip netns exec ${i} sysctl -q n    
778         done                                      
779                                                   
780         for i in ${routing_addrs}; do             
781                 [ "${ns}" = "" ]        && ns=    
782                 [ "${peer}" = "" ]      && pee    
783                 [ "${segment}" = "" ]   && seg    
784                                                   
785                 ns_name="$(nsname ${ns})"         
786                 peer_name="$(nsname ${peer})"     
787                 if="veth_${ns}-${peer}"           
788                 ifpeer="veth_${peer}-${ns}"       
789                                                   
790                 # Create veth links               
791                 ip link add ${if} up netns ${n    
792                 ip -n ${peer_name} link set de    
793                                                   
794                 # Add addresses                   
795                 ip -n ${ns_name}   addr add ${    
796                 ip -n ${ns_name}   addr add ${    
797                                                   
798                 ip -n ${peer_name} addr add ${    
799                 ip -n ${peer_name} addr add ${    
800                                                   
801                 ns=""; peer=""; segment=""        
802         done                                      
803                                                   
804         if [ "$USE_NH" = "yes" ]; then            
805                 setup_routing_new                 
806         else                                      
807                 setup_routing_old                 
808         fi                                        
809                                                   
810         return 0                                  
811 }                                                 
812                                                   
813 setup_policy_routing() {                          
814         setup_routing                             
815                                                   
816         ip -netns "${NS_A}" -4 rule add dsfiel    
817                 table "${rt_table}"               
818                                                   
819         # Set the IPv4 Don't Fragment bit with    
820         # have an option do to it.                
821         tc -netns "${NS_A}" qdisc replace dev     
822         tc -netns "${NS_A}" qdisc replace dev     
823         tc -netns "${NS_A}" filter add dev vet    
824                 protocol ipv4 flower ip_proto     
825                 action pedit ex munge ip df se    
826         tc -netns "${NS_A}" filter add dev vet    
827                 protocol ipv4 flower ip_proto     
828                 action pedit ex munge ip df se    
829 }                                                 
830                                                   
831 setup_bridge() {                                  
832         run_cmd ${ns_a} ip link add br0 type b    
833         run_cmd ${ns_a} ip link set br0 up        
834                                                   
835         run_cmd ${ns_c} ip link add veth_C-A t    
836         run_cmd ${ns_c} ip link set veth_A-C n    
837                                                   
838         run_cmd ${ns_a} ip link set veth_A-C u    
839         run_cmd ${ns_c} ip link set veth_C-A u    
840         run_cmd ${ns_c} ip addr add ${veth4_c_    
841         run_cmd ${ns_c} ip addr add ${veth6_c_    
842         run_cmd ${ns_a} ip link set veth_A-C m    
843 }                                                 
844                                                   
845 setup_ovs_via_internal_utility() {                
846         type="${1}"                               
847         a_addr="${2}"                             
848         b_addr="${3}"                             
849         dport="${4}"                              
850                                                   
851         run_cmd python3 ./openvswitch/ovs-dpct    
852                                                   
853         ports=$(python3 ./openvswitch/ovs-dpct    
854         br0_port=$(echo "$ports" | grep -E "\s    
855         type_a_port=$(echo "$ports" | grep ${t    
856         veth_a_port=$(echo "$ports" | grep vet    
857                                                   
858         v4_a_tun="${prefix4}.${a_r1}.1"           
859         v4_b_tun="${prefix4}.${b_r1}.1"           
860                                                   
861         v6_a_tun="${prefix6}:${a_r1}::1"          
862         v6_b_tun="${prefix6}:${b_r1}::1"          
863                                                   
864         if [ "${v4_a_tun}" = "${a_addr}" ]; th    
865                 run_cmd python3 ./openvswitch/    
866                     "recirc_id(0),in_port(${ve    
867                     "set(tunnel(tun_id=1,dst=$    
868                 run_cmd python3 ./openvswitch/    
869                     "recirc_id(0),in_port(${ve    
870                     "set(tunnel(tun_id=1,dst=$    
871                 run_cmd python3 ./openvswitch/    
872                     "recirc_id(0),tunnel(tun_i    
873                     "${veth_a_port}"              
874                 run_cmd python3 ./openvswitch/    
875                     "recirc_id(0),tunnel(tun_i    
876                     "${veth_a_port}"              
877                 run_cmd python3 ./openvswitch/    
878                     "recirc_id(0),tunnel(tun_i    
879                     "${veth_a_port}"              
880                 run_cmd python3 ./openvswitch/    
881                     "recirc_id(0),in_port(${ve    
882                     "set(tunnel(tun_id=1,dst=$    
883         else                                      
884                 run_cmd python3 ./openvswitch/    
885                     "recirc_id(0),in_port(${ve    
886                     "set(tunnel(tun_id=1,ipv6_    
887                 run_cmd python3 ./openvswitch/    
888                     "recirc_id(0),in_port(${ve    
889                     "set(tunnel(tun_id=1,ipv6_    
890                 run_cmd python3 ./openvswitch/    
891                     "recirc_id(0),tunnel(tun_i    
892                     "${veth_a_port}"              
893                 run_cmd python3 ./openvswitch/    
894                     "recirc_id(0),tunnel(tun_i    
895                     "${veth_a_port}"              
896                 run_cmd python3 ./openvswitch/    
897                     "recirc_id(0),tunnel(tun_i    
898                     "${veth_a_port}"              
899                 run_cmd python3 ./openvswitch/    
900                     "recirc_id(0),in_port(${ve    
901                     "set(tunnel(tun_id=1,ipv6_    
902         fi                                        
903 }                                                 
904                                                   
905 setup_ovs_via_vswitchd() {                        
906         type="${1}"                               
907         b_addr="${2}"                             
908                                                   
909         run_cmd ovs-vsctl add-port ovs_br0 ${t    
910                 set interface ${type}_a type=$    
911                 options:remote_ip=${b_addr} op    
912 }                                                 
913                                                   
914 setup_ovs_vxlan_or_geneve() {                     
915         type="${1}"                               
916         a_addr="${2}"                             
917         b_addr="${3}"                             
918         dport="6081"                              
919                                                   
920         if [ "${type}" = "vxlan" ]; then          
921                 dport="4789"                      
922                 opts="${opts} ttl 64 dstport 4    
923                 opts_b="local ${b_addr}"          
924         fi                                        
925                                                   
926         setup_ovs_via_internal_utility "${type    
927                                        "${dpor    
928             setup_ovs_via_vswitchd "${type}" "    
929                                                   
930         run_cmd ${ns_b} ip link add ${type}_b     
931                                                   
932         run_cmd ${ns_b} ip addr add ${tunnel4_    
933         run_cmd ${ns_b} ip addr add ${tunnel6_    
934                                                   
935         run_cmd ip link set ${type}_a up          
936         run_cmd ${ns_b} ip link set ${type}_b     
937 }                                                 
938                                                   
939 setup_ovs_geneve4() {                             
940         setup_ovs_vxlan_or_geneve geneve ${pre    
941 }                                                 
942                                                   
943 setup_ovs_vxlan4() {                              
944         setup_ovs_vxlan_or_geneve vxlan  ${pre    
945 }                                                 
946                                                   
947 setup_ovs_geneve6() {                             
948         setup_ovs_vxlan_or_geneve geneve ${pre    
949 }                                                 
950                                                   
951 setup_ovs_vxlan6() {                              
952         setup_ovs_vxlan_or_geneve vxlan  ${pre    
953 }                                                 
954                                                   
955 setup_ovs_br_internal() {                         
956         run_cmd python3 ./openvswitch/ovs-dpct    
957                 return 1                          
958 }                                                 
959                                                   
960 setup_ovs_br_vswitchd() {                         
961         run_cmd ovs-vsctl add-br ovs_br0 || re    
962 }                                                 
963                                                   
964 setup_ovs_add_if() {                              
965         ifname="${1}"                             
966         run_cmd python3 ./openvswitch/ovs-dpct    
967                 "${ifname}" || \                  
968                 run_cmd ovs-vsctl add-port ovs    
969 }                                                 
970                                                   
971 setup_ovs_bridge() {                              
972         setup_ovs_br_internal || setup_ovs_br_    
973         run_cmd ip link set ovs_br0 up            
974                                                   
975         run_cmd ${ns_c} ip link add veth_C-A t    
976         run_cmd ${ns_c} ip link set veth_A-C n    
977                                                   
978         run_cmd         ip link set veth_A-C u    
979         run_cmd ${ns_c} ip link set veth_C-A u    
980         run_cmd ${ns_c} ip addr add ${veth4_c_    
981         run_cmd ${ns_c} ip addr add ${veth6_c_    
982         setup_ovs_add_if veth_A-C                 
983                                                   
984         # Move veth_A-R1 to init                  
985         run_cmd ${ns_a} ip link set veth_A-R1     
986         run_cmd ip addr add ${prefix4}.${a_r1}    
987         run_cmd ip addr add ${prefix6}:${a_r1}    
988         run_cmd ip link set veth_A-R1 up          
989         run_cmd ip route add ${prefix4}.${b_r1    
990         run_cmd ip route add ${prefix6}:${b_r1    
991 }                                                 
992                                                   
993 setup() {                                         
994         [ "$(id -u)" -ne 0 ] && echo "  need t    
995                                                   
996         for arg do                                
997                 eval setup_${arg} || { echo "     
998         done                                      
999 }                                                 
1000                                                  
1001 trace() {                                        
1002         [ $TRACING -eq 0 ] && return             
1003                                                  
1004         for arg do                               
1005                 [ "${ns_cmd}" = "" ] && ns_cm    
1006                 ${ns_cmd} tcpdump --immediate    
1007                 tcpdump_pids="${tcpdump_pids}    
1008                 ns_cmd=                          
1009         done                                     
1010         sleep 1                                  
1011 }                                                
1012                                                  
1013 cleanup_del_ovs_internal() {                     
1014         # squelch the output of the del-if co    
1015         python3 ./openvswitch/ovs-dpctl.py de    
1016         python3 ./openvswitch/ovs-dpctl.py de    
1017         python3 ./openvswitch/ovs-dpctl.py de    
1018 }                                                
1019                                                  
1020 cleanup_del_ovs_vswitchd() {                     
1021         ovs-vsctl --if-exists del-port vxlan_    
1022         ovs-vsctl --if-exists del-br ovs_br0     
1023 }                                                
1024                                                  
1025 cleanup() {                                      
1026         for pid in ${tcpdump_pids}; do           
1027                 kill ${pid}                      
1028         done                                     
1029         tcpdump_pids=                            
1030                                                  
1031         for pid in ${nettest_pids}; do           
1032                 kill ${pid}                      
1033         done                                     
1034         nettest_pids=                            
1035                                                  
1036         for pid in ${socat_pids}; do             
1037                 kill "${pid}"                    
1038         done                                     
1039         socat_pids=                              
1040                                                  
1041         cleanup_all_ns                           
1042                                                  
1043         ip link del veth_A-C            2>/de    
1044         ip link del veth_A-R1           2>/de    
1045         cleanup_del_ovs_internal                 
1046         cleanup_del_ovs_vswitchd                 
1047         rm -f "$tmpoutfile"                      
1048 }                                                
1049                                                  
1050 mtu() {                                          
1051         ns_cmd="${1}"                            
1052         dev="${2}"                               
1053         mtu="${3}"                               
1054                                                  
1055         ${ns_cmd} ip link set dev ${dev} mtu     
1056 }                                                
1057                                                  
1058 mtu_parse() {                                    
1059         input="${1}"                             
1060                                                  
1061         next=0                                   
1062         for i in ${input}; do                    
1063                 [ ${next} -eq 1 -a "${i}" = "    
1064                 [ ${next} -eq 1 ] && echo "${    
1065                 [ ${next} -eq 2 ] && echo "lo    
1066                 [ "${i}" = "mtu" ] && next=1     
1067         done                                     
1068 }                                                
1069                                                  
1070 link_get() {                                     
1071         ns_cmd="${1}"                            
1072         name="${2}"                              
1073                                                  
1074         ${ns_cmd} ip link show dev "${name}"     
1075 }                                                
1076                                                  
1077 link_get_mtu() {                                 
1078         ns_cmd="${1}"                            
1079         name="${2}"                              
1080                                                  
1081         mtu_parse "$(link_get "${ns_cmd}" ${n    
1082 }                                                
1083                                                  
1084 route_get_dst_exception() {                      
1085         ns_cmd="${1}"                            
1086         dst="${2}"                               
1087         dsfield="${3}"                           
1088                                                  
1089         if [ -z "${dsfield}" ]; then             
1090                 dsfield=0                        
1091         fi                                       
1092                                                  
1093         ${ns_cmd} ip route get "${dst}" dsfie    
1094 }                                                
1095                                                  
1096 route_get_dst_pmtu_from_exception() {            
1097         ns_cmd="${1}"                            
1098         dst="${2}"                               
1099         dsfield="${3}"                           
1100                                                  
1101         mtu_parse "$(route_get_dst_exception     
1102 }                                                
1103                                                  
1104 check_pmtu_value() {                             
1105         expected="${1}"                          
1106         value="${2}"                             
1107         event="${3}"                             
1108                                                  
1109         [ "${expected}" = "any" ] && [ -n "${    
1110         [ "${value}" = "${expected}" ] && ret    
1111         [ -z "${value}" ] &&    err "  PMTU e    
1112         [ -z "${expected}" ] && err "  PMTU e    
1113         err "  found PMTU exception with inco    
1114         return 1                                 
1115 }                                                
1116                                                  
1117 test_pmtu_ipvX() {                               
1118         family=${1}                              
1119                                                  
1120         setup namespaces routing || return $k    
1121         trace "${ns_a}"  veth_A-R1    "${ns_r    
1122               "${ns_r1}" veth_R1-B    "${ns_b    
1123               "${ns_a}"  veth_A-R2    "${ns_r    
1124               "${ns_r2}" veth_R2-B    "${ns_b    
1125                                                  
1126         if [ ${family} -eq 4 ]; then             
1127                 ping=ping                        
1128                 dst1="${prefix4}.${b_r1}.1"      
1129                 dst2="${prefix4}.${b_r2}.1"      
1130         else                                     
1131                 ping=${ping6}                    
1132                 dst1="${prefix6}:${b_r1}::1"     
1133                 dst2="${prefix6}:${b_r2}::1"     
1134         fi                                       
1135                                                  
1136         # Set up initial MTU values              
1137         mtu "${ns_a}"  veth_A-R1 2000            
1138         mtu "${ns_r1}" veth_R1-A 2000            
1139         mtu "${ns_r1}" veth_R1-B 1400            
1140         mtu "${ns_b}"  veth_B-R1 1400            
1141                                                  
1142         mtu "${ns_a}"  veth_A-R2 2000            
1143         mtu "${ns_r2}" veth_R2-A 2000            
1144         mtu "${ns_r2}" veth_R2-B 1500            
1145         mtu "${ns_b}"  veth_B-R2 1500            
1146                                                  
1147         # Create route exceptions                
1148         run_cmd ${ns_a} ${ping} -q -M want -i    
1149         run_cmd ${ns_a} ${ping} -q -M want -i    
1150                                                  
1151         # Check that exceptions have been cre    
1152         pmtu_1="$(route_get_dst_pmtu_from_exc    
1153         check_pmtu_value "1400" "${pmtu_1}" "    
1154         pmtu_2="$(route_get_dst_pmtu_from_exc    
1155         check_pmtu_value "1500" "${pmtu_2}" "    
1156                                                  
1157         # Decrease local MTU below PMTU, chec    
1158         mtu "${ns_a}"  veth_A-R1 1300            
1159         mtu "${ns_r1}" veth_R1-A 1300            
1160         pmtu_1="$(route_get_dst_pmtu_from_exc    
1161         check_pmtu_value "1300" "${pmtu_1}" "    
1162         # Second exception shouldn't be modif    
1163         pmtu_2="$(route_get_dst_pmtu_from_exc    
1164         check_pmtu_value "1500" "${pmtu_2}" "    
1165                                                  
1166         # Increase MTU, check for PMTU increa    
1167         mtu "${ns_a}"  veth_A-R1 1700            
1168         mtu "${ns_r1}" veth_R1-A 1700            
1169         pmtu_1="$(route_get_dst_pmtu_from_exc    
1170         check_pmtu_value "1700" "${pmtu_1}" "    
1171         # Second exception shouldn't be modif    
1172         pmtu_2="$(route_get_dst_pmtu_from_exc    
1173         check_pmtu_value "1500" "${pmtu_2}" "    
1174                                                  
1175         # Skip PMTU locking tests for IPv6       
1176         [ $family -eq 6 ] && return 0            
1177                                                  
1178         # Decrease remote MTU on path via R2,    
1179         mtu "${ns_r2}" veth_R2-B 400             
1180         mtu "${ns_b}"  veth_B-R2 400             
1181         run_cmd ${ns_a} ${ping} -q -M want -i    
1182         pmtu_2="$(route_get_dst_pmtu_from_exc    
1183         check_pmtu_value "lock 552" "${pmtu_2    
1184                                                  
1185         # Decrease local MTU below PMTU          
1186         mtu "${ns_a}"  veth_A-R2 500             
1187         mtu "${ns_r2}" veth_R2-A 500             
1188         pmtu_2="$(route_get_dst_pmtu_from_exc    
1189         check_pmtu_value "500" "${pmtu_2}" "d    
1190                                                  
1191         # Increase local MTU                     
1192         mtu "${ns_a}"  veth_A-R2 1500            
1193         mtu "${ns_r2}" veth_R2-A 1500            
1194         pmtu_2="$(route_get_dst_pmtu_from_exc    
1195         check_pmtu_value "1500" "${pmtu_2}" "    
1196                                                  
1197         # Get new exception                      
1198         run_cmd ${ns_a} ${ping} -q -M want -i    
1199         pmtu_2="$(route_get_dst_pmtu_from_exc    
1200         check_pmtu_value "lock 552" "${pmtu_2    
1201 }                                                
1202                                                  
1203 test_pmtu_ipv4_exception() {                     
1204         test_pmtu_ipvX 4                         
1205 }                                                
1206                                                  
1207 test_pmtu_ipv6_exception() {                     
1208         test_pmtu_ipvX 6                         
1209 }                                                
1210                                                  
1211 test_pmtu_ipv4_dscp_icmp_exception() {           
1212         rt_table=100                             
1213                                                  
1214         setup namespaces policy_routing || re    
1215         trace "${ns_a}"  veth_A-R1    "${ns_r    
1216               "${ns_r1}" veth_R1-B    "${ns_b    
1217               "${ns_a}"  veth_A-R2    "${ns_r    
1218               "${ns_r2}" veth_R2-B    "${ns_b    
1219                                                  
1220         # Set up initial MTU values              
1221         mtu "${ns_a}"  veth_A-R1 2000            
1222         mtu "${ns_r1}" veth_R1-A 2000            
1223         mtu "${ns_r1}" veth_R1-B 1400            
1224         mtu "${ns_b}"  veth_B-R1 1400            
1225                                                  
1226         mtu "${ns_a}"  veth_A-R2 2000            
1227         mtu "${ns_r2}" veth_R2-A 2000            
1228         mtu "${ns_r2}" veth_R2-B 1500            
1229         mtu "${ns_b}"  veth_B-R2 1500            
1230                                                  
1231         len=$((2000 - 20 - 8)) # Fills MTU of    
1232                                                  
1233         dst1="${prefix4}.${b_r1}.1"              
1234         dst2="${prefix4}.${b_r2}.1"              
1235                                                  
1236         # Create route exceptions                
1237         dsfield=${policy_mark} # No ECN bit s    
1238         run_cmd "${ns_a}" ping -q -M want -Q     
1239                                                  
1240         dsfield=$(printf "%#x" $((policy_mark    
1241         run_cmd "${ns_a}" ping -q -M want -Q     
1242                                                  
1243         # Check that exceptions have been cre    
1244         pmtu_1="$(route_get_dst_pmtu_from_exc    
1245         check_pmtu_value "1400" "${pmtu_1}" "    
1246                                                  
1247         pmtu_2="$(route_get_dst_pmtu_from_exc    
1248         check_pmtu_value "1500" "${pmtu_2}" "    
1249 }                                                
1250                                                  
1251 test_pmtu_ipv4_dscp_udp_exception() {            
1252         rt_table=100                             
1253                                                  
1254         if ! which socat > /dev/null 2>&1; th    
1255                 echo "'socat' command not fou    
1256                 return $ksft_skip                
1257         fi                                       
1258                                                  
1259         setup namespaces policy_routing || re    
1260         trace "${ns_a}"  veth_A-R1    "${ns_r    
1261               "${ns_r1}" veth_R1-B    "${ns_b    
1262               "${ns_a}"  veth_A-R2    "${ns_r    
1263               "${ns_r2}" veth_R2-B    "${ns_b    
1264                                                  
1265         # Set up initial MTU values              
1266         mtu "${ns_a}"  veth_A-R1 2000            
1267         mtu "${ns_r1}" veth_R1-A 2000            
1268         mtu "${ns_r1}" veth_R1-B 1400            
1269         mtu "${ns_b}"  veth_B-R1 1400            
1270                                                  
1271         mtu "${ns_a}"  veth_A-R2 2000            
1272         mtu "${ns_r2}" veth_R2-A 2000            
1273         mtu "${ns_r2}" veth_R2-B 1500            
1274         mtu "${ns_b}"  veth_B-R2 1500            
1275                                                  
1276         len=$((2000 - 20 - 8)) # Fills MTU of    
1277                                                  
1278         dst1="${prefix4}.${b_r1}.1"              
1279         dst2="${prefix4}.${b_r2}.1"              
1280                                                  
1281         # Create route exceptions                
1282         run_cmd_bg "${ns_b}" socat UDP-LISTEN    
1283         socat_pids="${socat_pids} $!"            
1284                                                  
1285         dsfield=${policy_mark} # No ECN bit s    
1286         run_cmd "${ns_a}" socat OPEN:/dev/zer    
1287                 UDP:"${dst1}":50000,tos="${ds    
1288                                                  
1289         dsfield=$(printf "%#x" $((policy_mark    
1290         run_cmd "${ns_a}" socat OPEN:/dev/zer    
1291                 UDP:"${dst2}":50000,tos="${ds    
1292                                                  
1293         # Check that exceptions have been cre    
1294         pmtu_1="$(route_get_dst_pmtu_from_exc    
1295         check_pmtu_value "1400" "${pmtu_1}" "    
1296         pmtu_2="$(route_get_dst_pmtu_from_exc    
1297         check_pmtu_value "1500" "${pmtu_2}" "    
1298 }                                                
1299                                                  
1300 test_pmtu_ipvX_over_vxlanY_or_geneveY_excepti    
1301         type=${1}                                
1302         family=${2}                              
1303         outer_family=${3}                        
1304         ll_mtu=4000                              
1305                                                  
1306         if [ ${outer_family} -eq 4 ]; then       
1307                 setup namespaces routing ${ty    
1308                 #                      IPv4 h    
1309                 exp_mtu=$((${ll_mtu} - 20        
1310         else                                     
1311                 setup namespaces routing ${ty    
1312                 #                      IPv6 h    
1313                 exp_mtu=$((${ll_mtu} - 40        
1314         fi                                       
1315                                                  
1316         trace "${ns_a}" ${type}_a    "${ns_b}    
1317               "${ns_a}" veth_A-R1    "${ns_r1    
1318               "${ns_b}" veth_B-R1    "${ns_r1    
1319                                                  
1320         if [ ${family} -eq 4 ]; then             
1321                 ping=ping                        
1322                 dst=${tunnel4_b_addr}            
1323         else                                     
1324                 ping=${ping6}                    
1325                 dst=${tunnel6_b_addr}            
1326         fi                                       
1327                                                  
1328         # Create route exception by exceeding    
1329         mtu "${ns_a}"  veth_A-R1 $((${ll_mtu}    
1330         mtu "${ns_r1}" veth_R1-A $((${ll_mtu}    
1331         mtu "${ns_b}"  veth_B-R1 ${ll_mtu}       
1332         mtu "${ns_r1}" veth_R1-B ${ll_mtu}       
1333                                                  
1334         mtu "${ns_a}" ${type}_a $((${ll_mtu}     
1335         mtu "${ns_b}" ${type}_b $((${ll_mtu}     
1336         run_cmd ${ns_a} ${ping} -q -M want -i    
1337                                                  
1338         # Check that exception was created       
1339         pmtu="$(route_get_dst_pmtu_from_excep    
1340         check_pmtu_value ${exp_mtu} "${pmtu}"    
1341 }                                                
1342                                                  
1343 test_pmtu_ipv4_vxlan4_exception() {              
1344         test_pmtu_ipvX_over_vxlanY_or_geneveY    
1345 }                                                
1346                                                  
1347 test_pmtu_ipv6_vxlan4_exception() {              
1348         test_pmtu_ipvX_over_vxlanY_or_geneveY    
1349 }                                                
1350                                                  
1351 test_pmtu_ipv4_geneve4_exception() {             
1352         test_pmtu_ipvX_over_vxlanY_or_geneveY    
1353 }                                                
1354                                                  
1355 test_pmtu_ipv6_geneve4_exception() {             
1356         test_pmtu_ipvX_over_vxlanY_or_geneveY    
1357 }                                                
1358                                                  
1359 test_pmtu_ipv4_vxlan6_exception() {              
1360         test_pmtu_ipvX_over_vxlanY_or_geneveY    
1361 }                                                
1362                                                  
1363 test_pmtu_ipv6_vxlan6_exception() {              
1364         test_pmtu_ipvX_over_vxlanY_or_geneveY    
1365 }                                                
1366                                                  
1367 test_pmtu_ipv4_geneve6_exception() {             
1368         test_pmtu_ipvX_over_vxlanY_or_geneveY    
1369 }                                                
1370                                                  
1371 test_pmtu_ipv6_geneve6_exception() {             
1372         test_pmtu_ipvX_over_vxlanY_or_geneveY    
1373 }                                                
1374                                                  
1375 test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY    
1376         type=${1}                                
1377         family=${2}                              
1378         outer_family=${3}                        
1379         ll_mtu=4000                              
1380                                                  
1381         if [ ${outer_family} -eq 4 ]; then       
1382                 setup namespaces routing brid    
1383                 #                      IPv4 h    
1384                 exp_mtu=$((${ll_mtu} - 20        
1385         else                                     
1386                 setup namespaces routing brid    
1387                 #                      IPv6 h    
1388                 exp_mtu=$((${ll_mtu} - 40        
1389         fi                                       
1390                                                  
1391         trace "${ns_a}" ${type}_a    "${ns_b}    
1392               "${ns_a}" veth_A-R1    "${ns_r1    
1393               "${ns_b}" veth_B-R1    "${ns_r1    
1394               "${ns_a}" br0          "${ns_a}    
1395               "${ns_c}" veth_C-A                 
1396                                                  
1397         if [ ${family} -eq 4 ]; then             
1398                 ping=ping                        
1399                 dst=${tunnel4_b_addr}            
1400         else                                     
1401                 ping=${ping6}                    
1402                 dst=${tunnel6_b_addr}            
1403         fi                                       
1404                                                  
1405         # Create route exception by exceeding    
1406         mtu "${ns_a}"  veth_A-R1 $((${ll_mtu}    
1407         mtu "${ns_a}"  br0       $((${ll_mtu}    
1408         mtu "${ns_a}"  veth_A-C  $((${ll_mtu}    
1409         mtu "${ns_c}"  veth_C-A  $((${ll_mtu}    
1410         mtu "${ns_r1}" veth_R1-A $((${ll_mtu}    
1411         mtu "${ns_b}"  veth_B-R1 ${ll_mtu}       
1412         mtu "${ns_r1}" veth_R1-B ${ll_mtu}       
1413                                                  
1414         mtu "${ns_a}" ${type}_a $((${ll_mtu}     
1415         mtu "${ns_b}" ${type}_b $((${ll_mtu}     
1416                                                  
1417         run_cmd ${ns_c} ${ping} -q -M want -i    
1418         run_cmd ${ns_a} ${ping} -q -M want -i    
1419                                                  
1420         # Check that exceptions were created     
1421         pmtu="$(route_get_dst_pmtu_from_excep    
1422         check_pmtu_value ${exp_mtu} "${pmtu}"    
1423         pmtu="$(route_get_dst_pmtu_from_excep    
1424         check_pmtu_value ${exp_mtu} "${pmtu}"    
1425                                                  
1426         tmpoutfile=$(mktemp)                     
1427                                                  
1428         # Flush Exceptions, retry with TCP       
1429         run_cmd ${ns_a} ip route flush cached    
1430         run_cmd ${ns_b} ip route flush cached    
1431         run_cmd ${ns_c} ip route flush cached    
1432                                                  
1433         for target in "${ns_a}" "${ns_c}" ; d    
1434                 if [ ${family} -eq 4 ]; then     
1435                         TCPDST=TCP:${dst}:500    
1436                 else                             
1437                         TCPDST="TCP:[${dst}]:    
1438                 fi                               
1439                 ${ns_b} socat -T 3 -u -6 TCP-    
1440                 local socat_pid=$!               
1441                                                  
1442                 wait_local_port_listen ${NS_B    
1443                                                  
1444                 dd if=/dev/zero status=none b    
1445                                                  
1446                 wait ${socat_pid}                
1447                 size=$(du -sb $tmpoutfile)       
1448                 size=${size%%/tmp/*}             
1449                                                  
1450                 [ $size -ne 1048576 ] && err     
1451         done                                     
1452                                                  
1453         rm -f "$tmpoutfile"                      
1454                                                  
1455         # Check that exceptions were created     
1456         pmtu="$(route_get_dst_pmtu_from_excep    
1457         check_pmtu_value ${exp_mtu} "${pmtu}"    
1458         pmtu="$(route_get_dst_pmtu_from_excep    
1459         check_pmtu_value ${exp_mtu} "${pmtu}"    
1460 }                                                
1461                                                  
1462 test_pmtu_ipv4_br_vxlan4_exception() {           
1463         test_pmtu_ipvX_over_bridged_vxlanY_or    
1464 }                                                
1465                                                  
1466 test_pmtu_ipv6_br_vxlan4_exception() {           
1467         test_pmtu_ipvX_over_bridged_vxlanY_or    
1468 }                                                
1469                                                  
1470 test_pmtu_ipv4_br_geneve4_exception() {          
1471         test_pmtu_ipvX_over_bridged_vxlanY_or    
1472 }                                                
1473                                                  
1474 test_pmtu_ipv6_br_geneve4_exception() {          
1475         test_pmtu_ipvX_over_bridged_vxlanY_or    
1476 }                                                
1477                                                  
1478 test_pmtu_ipv4_br_vxlan6_exception() {           
1479         test_pmtu_ipvX_over_bridged_vxlanY_or    
1480 }                                                
1481                                                  
1482 test_pmtu_ipv6_br_vxlan6_exception() {           
1483         test_pmtu_ipvX_over_bridged_vxlanY_or    
1484 }                                                
1485                                                  
1486 test_pmtu_ipv4_br_geneve6_exception() {          
1487         test_pmtu_ipvX_over_bridged_vxlanY_or    
1488 }                                                
1489                                                  
1490 test_pmtu_ipv6_br_geneve6_exception() {          
1491         test_pmtu_ipvX_over_bridged_vxlanY_or    
1492 }                                                
1493                                                  
1494 test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exc    
1495         type=${1}                                
1496         family=${2}                              
1497         outer_family=${3}                        
1498         ll_mtu=4000                              
1499                                                  
1500         if [ "${type}" = "vxlan" ]; then         
1501                 tun_a="vxlan_sys_4789"           
1502         elif [ "${type}" = "geneve" ]; then      
1503                 tun_a="genev_sys_6081"           
1504         fi                                       
1505                                                  
1506         if [ ${outer_family} -eq 4 ]; then       
1507                 setup namespaces routing ovs_    
1508                 #                      IPv4 h    
1509                 exp_mtu=$((${ll_mtu} - 20        
1510         else                                     
1511                 setup namespaces routing ovs_    
1512                 #                      IPv6 h    
1513                 exp_mtu=$((${ll_mtu} - 40        
1514         fi                                       
1515                                                  
1516         trace ""        ${type}_a    "${ns_b}    
1517               ""        veth_A-R1    "${ns_r1    
1518               "${ns_b}" veth_B-R1    "${ns_r1    
1519               ""        ovs_br0      ""          
1520               "${ns_c}" veth_C-A     ""          
1521                                                  
1522         if [ ${family} -eq 4 ]; then             
1523                 ping=ping                        
1524                 dst=${tunnel4_b_addr}            
1525         else                                     
1526                 ping=${ping6}                    
1527                 dst=${tunnel6_b_addr}            
1528         fi                                       
1529                                                  
1530         # Create route exception by exceeding    
1531         mtu ""         veth_A-R1 $((${ll_mtu}    
1532         mtu ""         ovs_br0   $((${ll_mtu}    
1533         mtu ""         veth_A-C  $((${ll_mtu}    
1534         mtu "${ns_c}"  veth_C-A  $((${ll_mtu}    
1535         mtu "${ns_r1}" veth_R1-A $((${ll_mtu}    
1536         mtu "${ns_b}"  veth_B-R1 ${ll_mtu}       
1537         mtu "${ns_r1}" veth_R1-B ${ll_mtu}       
1538                                                  
1539         mtu ""        ${tun_a}  $((${ll_mtu}     
1540                 mtu ""        ${type}_a  $(($    
1541         mtu "${ns_b}" ${type}_b  $((${ll_mtu}    
1542                                                  
1543         run_cmd ${ns_c} ${ping} -q -M want -i    
1544                                                  
1545         # Check that exceptions were created     
1546         pmtu="$(route_get_dst_pmtu_from_excep    
1547         check_pmtu_value ${exp_mtu} "${pmtu}"    
1548 }                                                
1549                                                  
1550 test_pmtu_ipv4_ovs_vxlan4_exception() {          
1551         test_pmtu_ipvX_over_ovs_vxlanY_or_gen    
1552 }                                                
1553                                                  
1554 test_pmtu_ipv6_ovs_vxlan4_exception() {          
1555         test_pmtu_ipvX_over_ovs_vxlanY_or_gen    
1556 }                                                
1557                                                  
1558 test_pmtu_ipv4_ovs_geneve4_exception() {         
1559         test_pmtu_ipvX_over_ovs_vxlanY_or_gen    
1560 }                                                
1561                                                  
1562 test_pmtu_ipv6_ovs_geneve4_exception() {         
1563         test_pmtu_ipvX_over_ovs_vxlanY_or_gen    
1564 }                                                
1565                                                  
1566 test_pmtu_ipv4_ovs_vxlan6_exception() {          
1567         test_pmtu_ipvX_over_ovs_vxlanY_or_gen    
1568 }                                                
1569                                                  
1570 test_pmtu_ipv6_ovs_vxlan6_exception() {          
1571         test_pmtu_ipvX_over_ovs_vxlanY_or_gen    
1572 }                                                
1573                                                  
1574 test_pmtu_ipv4_ovs_geneve6_exception() {         
1575         test_pmtu_ipvX_over_ovs_vxlanY_or_gen    
1576 }                                                
1577                                                  
1578 test_pmtu_ipv6_ovs_geneve6_exception() {         
1579         test_pmtu_ipvX_over_ovs_vxlanY_or_gen    
1580 }                                                
1581                                                  
1582 test_pmtu_ipvX_over_fouY_or_gueY() {             
1583         inner_family=${1}                        
1584         outer_family=${2}                        
1585         encap=${3}                               
1586         ll_mtu=4000                              
1587                                                  
1588         setup namespaces routing ${encap}${ou    
1589         trace "${ns_a}" ${encap}_a   "${ns_b}    
1590               "${ns_a}" veth_A-R1    "${ns_r1    
1591               "${ns_b}" veth_B-R1    "${ns_r1    
1592                                                  
1593         if [ ${inner_family} -eq 4 ]; then       
1594                 ping=ping                        
1595                 dst=${tunnel4_b_addr}            
1596         else                                     
1597                 ping=${ping6}                    
1598                 dst=${tunnel6_b_addr}            
1599         fi                                       
1600                                                  
1601         if [ "${encap}" = "gue" ]; then          
1602                 encap_overhead=4                 
1603         else                                     
1604                 encap_overhead=0                 
1605         fi                                       
1606                                                  
1607         if [ ${outer_family} -eq 4 ]; then       
1608                 #                      IPv4 h    
1609                 exp_mtu=$((${ll_mtu} - 20        
1610         else                                     
1611                 #                      IPv6 h    
1612                 exp_mtu=$((${ll_mtu} - 40        
1613         fi                                       
1614                                                  
1615         # Create route exception by exceeding    
1616         mtu "${ns_a}"  veth_A-R1 $((${ll_mtu}    
1617         mtu "${ns_r1}" veth_R1-A $((${ll_mtu}    
1618         mtu "${ns_b}"  veth_B-R1 ${ll_mtu}       
1619         mtu "${ns_r1}" veth_R1-B ${ll_mtu}       
1620                                                  
1621         mtu "${ns_a}" ${encap}_a $((${ll_mtu}    
1622         mtu "${ns_b}" ${encap}_b $((${ll_mtu}    
1623         run_cmd ${ns_a} ${ping} -q -M want -i    
1624                                                  
1625         # Check that exception was created       
1626         pmtu="$(route_get_dst_pmtu_from_excep    
1627         check_pmtu_value ${exp_mtu} "${pmtu}"    
1628 }                                                
1629                                                  
1630 test_pmtu_ipv4_fou4_exception() {                
1631         test_pmtu_ipvX_over_fouY_or_gueY 4 4     
1632 }                                                
1633                                                  
1634 test_pmtu_ipv6_fou4_exception() {                
1635         test_pmtu_ipvX_over_fouY_or_gueY 6 4     
1636 }                                                
1637                                                  
1638 test_pmtu_ipv4_fou6_exception() {                
1639         test_pmtu_ipvX_over_fouY_or_gueY 4 6     
1640 }                                                
1641                                                  
1642 test_pmtu_ipv6_fou6_exception() {                
1643         test_pmtu_ipvX_over_fouY_or_gueY 6 6     
1644 }                                                
1645                                                  
1646 test_pmtu_ipv4_gue4_exception() {                
1647         test_pmtu_ipvX_over_fouY_or_gueY 4 4     
1648 }                                                
1649                                                  
1650 test_pmtu_ipv6_gue4_exception() {                
1651         test_pmtu_ipvX_over_fouY_or_gueY 6 4     
1652 }                                                
1653                                                  
1654 test_pmtu_ipv4_gue6_exception() {                
1655         test_pmtu_ipvX_over_fouY_or_gueY 4 6     
1656 }                                                
1657                                                  
1658 test_pmtu_ipv6_gue6_exception() {                
1659         test_pmtu_ipvX_over_fouY_or_gueY 6 6     
1660 }                                                
1661                                                  
1662 test_pmtu_ipvX_over_ipvY_exception() {           
1663         inner=${1}                               
1664         outer=${2}                               
1665         ll_mtu=4000                              
1666                                                  
1667         setup namespaces routing ip${inner}ip    
1668                                                  
1669         trace "${ns_a}" ip_a         "${ns_b}    
1670               "${ns_a}" veth_A-R1    "${ns_r1    
1671               "${ns_b}" veth_B-R1    "${ns_r1    
1672                                                  
1673         if [ ${inner} -eq 4 ]; then              
1674                 ping=ping                        
1675                 dst=${tunnel4_b_addr}            
1676         else                                     
1677                 ping=${ping6}                    
1678                 dst=${tunnel6_b_addr}            
1679         fi                                       
1680                                                  
1681         if [ ${outer} -eq 4 ]; then              
1682                 #                      IPv4 h    
1683                 exp_mtu=$((${ll_mtu} - 20))      
1684         else                                     
1685                 #                      IPv6 h    
1686                 exp_mtu=$((${ll_mtu} - 40        
1687         fi                                       
1688                                                  
1689         # Create route exception by exceeding    
1690         mtu "${ns_a}"  veth_A-R1 $((${ll_mtu}    
1691         mtu "${ns_r1}" veth_R1-A $((${ll_mtu}    
1692         mtu "${ns_b}"  veth_B-R1 ${ll_mtu}       
1693         mtu "${ns_r1}" veth_R1-B ${ll_mtu}       
1694                                                  
1695         mtu "${ns_a}" ip_a $((${ll_mtu} + 100    
1696         mtu "${ns_b}" ip_b $((${ll_mtu} + 100    
1697         run_cmd ${ns_a} ${ping} -q -M want -i    
1698                                                  
1699         # Check that exception was created       
1700         pmtu="$(route_get_dst_pmtu_from_excep    
1701         check_pmtu_value ${exp_mtu} "${pmtu}"    
1702 }                                                
1703                                                  
1704 test_pmtu_ipv4_ipv4_exception() {                
1705         test_pmtu_ipvX_over_ipvY_exception 4     
1706 }                                                
1707                                                  
1708 test_pmtu_ipv6_ipv4_exception() {                
1709         test_pmtu_ipvX_over_ipvY_exception 6     
1710 }                                                
1711                                                  
1712 test_pmtu_ipv4_ipv6_exception() {                
1713         test_pmtu_ipvX_over_ipvY_exception 4     
1714 }                                                
1715                                                  
1716 test_pmtu_ipv6_ipv6_exception() {                
1717         test_pmtu_ipvX_over_ipvY_exception 6     
1718 }                                                
1719                                                  
1720 test_pmtu_vti4_exception() {                     
1721         setup namespaces veth vti4 xfrm4 || r    
1722         trace "${ns_a}" veth_a    "${ns_b}" v    
1723               "${ns_a}" vti4_a    "${ns_b}" v    
1724                                                  
1725         veth_mtu=1500                            
1726         vti_mtu=$((veth_mtu - 20))               
1727                                                  
1728         #                                SPI     
1729         esp_payload_rfc4106=$((vti_mtu - 4       
1730         ping_payload=$((esp_payload_rfc4106 -    
1731                                                  
1732         mtu "${ns_a}" veth_a ${veth_mtu}         
1733         mtu "${ns_b}" veth_b ${veth_mtu}         
1734         mtu "${ns_a}" vti4_a ${vti_mtu}          
1735         mtu "${ns_b}" vti4_b ${vti_mtu}          
1736                                                  
1737         # Send DF packet without exceeding li    
1738         # exception is created                   
1739         run_cmd ${ns_a} ping -q -M want -i 0.    
1740         pmtu="$(route_get_dst_pmtu_from_excep    
1741         check_pmtu_value "" "${pmtu}" "sendin    
1742                                                  
1743         # Now exceed link layer MTU by one by    
1744         # with the right PMTU value              
1745         run_cmd ${ns_a} ping -q -M want -i 0.    
1746         pmtu="$(route_get_dst_pmtu_from_excep    
1747         check_pmtu_value "${esp_payload_rfc41    
1748 }                                                
1749                                                  
1750 test_pmtu_vti6_exception() {                     
1751         setup namespaces veth vti6 xfrm6 || r    
1752         trace "${ns_a}" veth_a    "${ns_b}" v    
1753               "${ns_a}" vti6_a    "${ns_b}" v    
1754         fail=0                                   
1755                                                  
1756         # Create route exception by exceeding    
1757         mtu "${ns_a}" veth_a 4000                
1758         mtu "${ns_b}" veth_b 4000                
1759         mtu "${ns_a}" vti6_a 5000                
1760         mtu "${ns_b}" vti6_b 5000                
1761         run_cmd ${ns_a} ${ping6} -q -i 0.1 -w    
1762                                                  
1763         # Check that exception was created       
1764         pmtu="$(route_get_dst_pmtu_from_excep    
1765         check_pmtu_value any "${pmtu}" "creat    
1766                                                  
1767         # Decrease tunnel MTU, check for PMTU    
1768         mtu "${ns_a}" vti6_a 3000                
1769         pmtu="$(route_get_dst_pmtu_from_excep    
1770         check_pmtu_value "3000" "${pmtu}" "de    
1771                                                  
1772         # Increase tunnel MTU, check for PMTU    
1773         mtu "${ns_a}" vti6_a 9000                
1774         pmtu="$(route_get_dst_pmtu_from_excep    
1775         check_pmtu_value "9000" "${pmtu}" "in    
1776                                                  
1777         return ${fail}                           
1778 }                                                
1779                                                  
1780 test_pmtu_vti4_udp_exception() {                 
1781         setup namespaces veth vti4 xfrm4udp |    
1782         trace "${ns_a}" veth_a    "${ns_b}" v    
1783               "${ns_a}" vti4_a    "${ns_b}" v    
1784                                                  
1785         veth_mtu=1500                            
1786         vti_mtu=$((veth_mtu - 20))               
1787                                                  
1788         #                                UDP     
1789         esp_payload_rfc4106=$((vti_mtu - 8       
1790         ping_payload=$((esp_payload_rfc4106 -    
1791                                                  
1792         mtu "${ns_a}" veth_a ${veth_mtu}         
1793         mtu "${ns_b}" veth_b ${veth_mtu}         
1794         mtu "${ns_a}" vti4_a ${vti_mtu}          
1795         mtu "${ns_b}" vti4_b ${vti_mtu}          
1796                                                  
1797         # Send DF packet without exceeding li    
1798         # exception is created                   
1799         run_cmd ${ns_a} ping -q -M want -i 0.    
1800         pmtu="$(route_get_dst_pmtu_from_excep    
1801         check_pmtu_value "" "${pmtu}" "sendin    
1802                                                  
1803         # Now exceed link layer MTU by one by    
1804         # with the right PMTU value              
1805         run_cmd ${ns_a} ping -q -M want -i 0.    
1806         pmtu="$(route_get_dst_pmtu_from_excep    
1807         check_pmtu_value "${esp_payload_rfc41    
1808 }                                                
1809                                                  
1810 test_pmtu_vti6_udp_exception() {                 
1811         setup namespaces veth vti6 xfrm6udp |    
1812         trace "${ns_a}" veth_a    "${ns_b}" v    
1813               "${ns_a}" vti6_a    "${ns_b}" v    
1814         fail=0                                   
1815                                                  
1816         # Create route exception by exceeding    
1817         mtu "${ns_a}" veth_a 4000                
1818         mtu "${ns_b}" veth_b 4000                
1819         mtu "${ns_a}" vti6_a 5000                
1820         mtu "${ns_b}" vti6_b 5000                
1821         run_cmd ${ns_a} ${ping6} -q -i 0.1 -w    
1822                                                  
1823         # Check that exception was created       
1824         pmtu="$(route_get_dst_pmtu_from_excep    
1825         check_pmtu_value any "${pmtu}" "creat    
1826                                                  
1827         # Decrease tunnel MTU, check for PMTU    
1828         mtu "${ns_a}" vti6_a 3000                
1829         pmtu="$(route_get_dst_pmtu_from_excep    
1830         check_pmtu_value "3000" "${pmtu}" "de    
1831                                                  
1832         # Increase tunnel MTU, check for PMTU    
1833         mtu "${ns_a}" vti6_a 9000                
1834         pmtu="$(route_get_dst_pmtu_from_excep    
1835         check_pmtu_value "9000" "${pmtu}" "in    
1836                                                  
1837         return ${fail}                           
1838 }                                                
1839                                                  
1840 test_pmtu_vti4_udp_routed_exception() {          
1841         setup namespaces routing vti4routed x    
1842         trace "${ns_a}" veth_A-R1    "${ns_b}    
1843               "${ns_a}" vti4_a       "${ns_b}    
1844                                                  
1845         veth_mtu=1500                            
1846         vti_mtu=$((veth_mtu - 20))               
1847                                                  
1848         #                                UDP     
1849         esp_payload_rfc4106=$((vti_mtu - 8       
1850         ping_payload=$((esp_payload_rfc4106 -    
1851                                                  
1852         mtu "${ns_a}"  veth_A-R1 ${veth_mtu}     
1853         mtu "${ns_r1}" veth_R1-A ${veth_mtu}     
1854         mtu "${ns_b}"  veth_B-R1 ${veth_mtu}     
1855         mtu "${ns_r1}" veth_R1-B ${veth_mtu}     
1856                                                  
1857         mtu "${ns_a}" vti4_a ${vti_mtu}          
1858         mtu "${ns_b}" vti4_b ${vti_mtu}          
1859                                                  
1860         # Send DF packet without exceeding li    
1861         # exception is created                   
1862         run_cmd ${ns_a} ping -q -M want -i 0.    
1863         pmtu="$(route_get_dst_pmtu_from_excep    
1864         check_pmtu_value "" "${pmtu}" "sendin    
1865                                                  
1866         # Now decrease link layer MTU by 8 by    
1867         # with the right PMTU value              
1868         mtu "${ns_r1}" veth_R1-B $((veth_mtu     
1869         run_cmd ${ns_a} ping -q -M want -i 0.    
1870         pmtu="$(route_get_dst_pmtu_from_excep    
1871         check_pmtu_value "$((esp_payload_rfc4    
1872 }                                                
1873                                                  
1874 test_pmtu_vti6_udp_routed_exception() {          
1875         setup namespaces routing vti6routed x    
1876         trace "${ns_a}" veth_A-R1    "${ns_b}    
1877               "${ns_a}" vti6_a       "${ns_b}    
1878                                                  
1879         veth_mtu=1500                            
1880         vti_mtu=$((veth_mtu - 40))               
1881                                                  
1882         #                                UDP     
1883         esp_payload_rfc4106=$((vti_mtu - 8       
1884         ping_payload=$((esp_payload_rfc4106 -    
1885                                                  
1886         mtu "${ns_a}"  veth_A-R1 ${veth_mtu}     
1887         mtu "${ns_r1}" veth_R1-A ${veth_mtu}     
1888         mtu "${ns_b}"  veth_B-R1 ${veth_mtu}     
1889         mtu "${ns_r1}" veth_R1-B ${veth_mtu}     
1890                                                  
1891         # mtu "${ns_a}" vti6_a ${vti_mtu}        
1892         # mtu "${ns_b}" vti6_b ${vti_mtu}        
1893                                                  
1894         run_cmd ${ns_a} ${ping6} -q -M want -    
1895                                                  
1896         # Check that exception was not create    
1897         pmtu="$(route_get_dst_pmtu_from_excep    
1898         check_pmtu_value "" "${pmtu}" "sendin    
1899                                                  
1900         # Now decrease link layer MTU by 8 by    
1901         # with the right PMTU value              
1902         mtu "${ns_r1}" veth_R1-B $((veth_mtu     
1903         run_cmd ${ns_a} ${ping6} -q -M want -    
1904         pmtu="$(route_get_dst_pmtu_from_excep    
1905         check_pmtu_value "$((esp_payload_rfc4    
1906                                                  
1907 }                                                
1908                                                  
1909 test_pmtu_vti4_default_mtu() {                   
1910         setup namespaces veth vti4 || return     
1911                                                  
1912         # Check that MTU of vti device is MTU    
1913         veth_mtu="$(link_get_mtu "${ns_a}" ve    
1914         vti4_mtu="$(link_get_mtu "${ns_a}" vt    
1915         if [ $((veth_mtu - vti4_mtu)) -ne 20     
1916                 err "  vti MTU ${vti4_mtu} is    
1917                 return 1                         
1918         fi                                       
1919 }                                                
1920                                                  
1921 test_pmtu_vti6_default_mtu() {                   
1922         setup namespaces veth vti6 || return     
1923                                                  
1924         # Check that MTU of vti device is MTU    
1925         veth_mtu="$(link_get_mtu "${ns_a}" ve    
1926         vti6_mtu="$(link_get_mtu "${ns_a}" vt    
1927         if [ $((veth_mtu - vti6_mtu)) -ne 40     
1928                 err "  vti MTU ${vti6_mtu} is    
1929                 return 1                         
1930         fi                                       
1931 }                                                
1932                                                  
1933 test_pmtu_vti4_link_add_mtu() {                  
1934         setup namespaces || return $ksft_skip    
1935                                                  
1936         run_cmd ${ns_a} ip link add vti4_a ty    
1937         [ $? -ne 0 ] && err "  vti not suppor    
1938         run_cmd ${ns_a} ip link del vti4_a       
1939                                                  
1940         fail=0                                   
1941                                                  
1942         min=68                                   
1943         max=$((65535 - 20))                      
1944         # Check invalid values first             
1945         for v in $((min - 1)) $((max + 1)); d    
1946                 run_cmd ${ns_a} ip link add v    
1947                 # This can fail, or MTU can b    
1948                 [ $? -ne 0 ] && continue         
1949                 mtu="$(link_get_mtu "${ns_a}"    
1950                 if [ ${mtu} -lt ${min} -o ${m    
1951                         err "  vti tunnel cre    
1952                         fail=1                   
1953                 fi                               
1954                 run_cmd ${ns_a} ip link del v    
1955         done                                     
1956                                                  
1957         # Now check valid values                 
1958         for v in ${min} 1300 ${max}; do          
1959                 run_cmd ${ns_a} ip link add v    
1960                 mtu="$(link_get_mtu "${ns_a}"    
1961                 run_cmd ${ns_a} ip link del v    
1962                 if [ "${mtu}" != "${v}" ]; th    
1963                         err "  vti MTU ${mtu}    
1964                         fail=1                   
1965                 fi                               
1966         done                                     
1967                                                  
1968         return ${fail}                           
1969 }                                                
1970                                                  
1971 test_pmtu_vti6_link_add_mtu() {                  
1972         setup namespaces || return $ksft_skip    
1973                                                  
1974         run_cmd ${ns_a} ip link add vti6_a ty    
1975         [ $? -ne 0 ] && err "  vti6 not suppo    
1976         run_cmd ${ns_a} ip link del vti6_a       
1977                                                  
1978         fail=0                                   
1979                                                  
1980         min=68                  # vti6 can ca    
1981         max=$((65535 - 40))                      
1982         # Check invalid values first             
1983         for v in $((min - 1)) $((max + 1)); d    
1984                 run_cmd ${ns_a} ip link add v    
1985                 # This can fail, or MTU can b    
1986                 [ $? -ne 0 ] && continue         
1987                 mtu="$(link_get_mtu "${ns_a}"    
1988                 if [ ${mtu} -lt ${min} -o ${m    
1989                         err "  vti6 tunnel cr    
1990                         fail=1                   
1991                 fi                               
1992                 run_cmd ${ns_a} ip link del v    
1993         done                                     
1994                                                  
1995         # Now check valid values                 
1996         for v in 68 1280 1300 $((65535 - 40))    
1997                 run_cmd ${ns_a} ip link add v    
1998                 mtu="$(link_get_mtu "${ns_a}"    
1999                 run_cmd ${ns_a} ip link del v    
2000                 if [ "${mtu}" != "${v}" ]; th    
2001                         err "  vti6 MTU ${mtu    
2002                         fail=1                   
2003                 fi                               
2004         done                                     
2005                                                  
2006         return ${fail}                           
2007 }                                                
2008                                                  
2009 test_pmtu_vti6_link_change_mtu() {               
2010         setup namespaces || return $ksft_skip    
2011                                                  
2012         run_cmd ${ns_a} ip link add dummy0 mt    
2013         [ $? -ne 0 ] && err "  dummy not supp    
2014         run_cmd ${ns_a} ip link add dummy1 mt    
2015         run_cmd ${ns_a} ip link set dummy0 up    
2016         run_cmd ${ns_a} ip link set dummy1 up    
2017                                                  
2018         run_cmd ${ns_a} ip addr add ${dummy6_    
2019         run_cmd ${ns_a} ip addr add ${dummy6_    
2020                                                  
2021         fail=0                                   
2022                                                  
2023         # Create vti6 interface bound to devi    
2024         run_cmd ${ns_a} ip link add vti6_a mt    
2025         mtu="$(link_get_mtu "${ns_a}" vti6_a)    
2026         if [ ${mtu} -ne 1300 ]; then             
2027                 err "  vti6 MTU ${mtu} doesn'    
2028                 fail=1                           
2029         fi                                       
2030                                                  
2031         # Move to another device with differe    
2032         # MTU is adjusted                        
2033         run_cmd ${ns_a} ip link set vti6_a ty    
2034         mtu="$(link_get_mtu "${ns_a}" vti6_a)    
2035         if [ ${mtu} -ne $((3000 - 40)) ]; the    
2036                 err "  vti MTU ${mtu} is not     
2037                 fail=1                           
2038         fi                                       
2039                                                  
2040         # Move it back, passing MTU, check MT    
2041         run_cmd ${ns_a} ip link set vti6_a mt    
2042         mtu="$(link_get_mtu "${ns_a}" vti6_a)    
2043         if [ ${mtu} -ne 1280 ]; then             
2044                 err "  vti6 MTU ${mtu} doesn'    
2045                 fail=1                           
2046         fi                                       
2047                                                  
2048         return ${fail}                           
2049 }                                                
2050                                                  
2051 check_command() {                                
2052         cmd=${1}                                 
2053                                                  
2054         if ! which ${cmd} > /dev/null 2>&1; t    
2055                 err "  missing required comma    
2056                 return 1                         
2057         fi                                       
2058         return 0                                 
2059 }                                                
2060                                                  
2061 check_running() {                                
2062         pid=${1}                                 
2063         cmd=${2}                                 
2064                                                  
2065         [ "$(cat /proc/${pid}/cmdline 2>/dev/    
2066 }                                                
2067                                                  
2068 test_cleanup_vxlanX_exception() {                
2069         outer="${1}"                             
2070         encap="vxlan"                            
2071         ll_mtu=4000                              
2072                                                  
2073         check_command taskset || return $ksft    
2074         cpu_list=$(grep -m 2 processor /proc/    
2075                                                  
2076         setup namespaces routing ${encap}${ou    
2077         trace "${ns_a}" ${encap}_a   "${ns_b}    
2078               "${ns_a}" veth_A-R1    "${ns_r1    
2079               "${ns_b}" veth_B-R1    "${ns_r1    
2080                                                  
2081         # Create route exception by exceeding    
2082         mtu "${ns_a}"  veth_A-R1 $((${ll_mtu}    
2083         mtu "${ns_r1}" veth_R1-A $((${ll_mtu}    
2084         mtu "${ns_b}"  veth_B-R1 ${ll_mtu}       
2085         mtu "${ns_r1}" veth_R1-B ${ll_mtu}       
2086                                                  
2087         mtu "${ns_a}" ${encap}_a $((${ll_mtu}    
2088         mtu "${ns_b}" ${encap}_b $((${ll_mtu}    
2089                                                  
2090         # Fill exception cache for multiple C    
2091         # we can always use inner IPv4 for th    
2092         for cpu in ${cpu_list}; do               
2093                 run_cmd taskset --cpu-list ${    
2094         done                                     
2095                                                  
2096         ${ns_a} ip link del dev veth_A-R1 &      
2097         iplink_pid=$!                            
2098         for i in $(seq 1 20); do                 
2099                 check_running ${iplink_pid} "    
2100                 sleep 0.1                        
2101         done                                     
2102         err "  can't delete veth device in a     
2103         return 1                                 
2104 }                                                
2105                                                  
2106 test_cleanup_ipv6_exception() {                  
2107         test_cleanup_vxlanX_exception 6          
2108 }                                                
2109                                                  
2110 test_cleanup_ipv4_exception() {                  
2111         test_cleanup_vxlanX_exception 4          
2112 }                                                
2113                                                  
2114 run_test() {                                     
2115         (                                        
2116         tname="$1"                               
2117         tdesc="$2"                               
2118                                                  
2119         unset IFS                                
2120                                                  
2121         # Since cleanup() relies on variables    
2122         # has to run in this context.            
2123         trap cleanup EXIT                        
2124                                                  
2125         if [ "$VERBOSE" = "1" ]; then            
2126                 printf "\n###################    
2127         fi                                       
2128                                                  
2129         eval test_${tname}                       
2130         ret=$?                                   
2131                                                  
2132         if [ $ret -eq 0 ]; then                  
2133                 printf "TEST: %-60s  [ OK ]\n    
2134         elif [ $ret -eq 1 ]; then                
2135                 printf "TEST: %-60s  [FAIL]\n    
2136                 if [ "${PAUSE_ON_FAIL}" = "ye    
2137                         echo                     
2138                         echo "Pausing. Hit en    
2139                         read a                   
2140                 fi                               
2141                 err_flush                        
2142                 exit 1                           
2143         elif [ $ret -eq $ksft_skip ]; then       
2144                 printf "TEST: %-60s  [SKIP]\n    
2145                 err_flush                        
2146         fi                                       
2147                                                  
2148         return $ret                              
2149         )                                        
2150         ret=$?                                   
2151         case $ret in                             
2152                 0)                               
2153                         all_skipped=false        
2154                         [ $exitcode -eq $ksft    
2155                 ;;                               
2156                 $ksft_skip)                      
2157                         [ $all_skipped = true    
2158                 ;;                               
2159                 *)                               
2160                         all_skipped=false        
2161                         exitcode=1               
2162                 ;;                               
2163         esac                                     
2164                                                  
2165         return $ret                              
2166 }                                                
2167                                                  
2168 run_test_nh() {                                  
2169         tname="$1"                               
2170         tdesc="$2"                               
2171                                                  
2172         USE_NH=yes                               
2173         run_test "${tname}" "${tdesc} - nexth    
2174         USE_NH=no                                
2175 }                                                
2176                                                  
2177 test_list_flush_ipv4_exception() {               
2178         setup namespaces routing || return $k    
2179         trace "${ns_a}"  veth_A-R1    "${ns_r    
2180               "${ns_r1}" veth_R1-B    "${ns_b    
2181               "${ns_a}"  veth_A-R2    "${ns_r    
2182               "${ns_r2}" veth_R2-B    "${ns_b    
2183                                                  
2184         dst_prefix1="${prefix4}.${b_r1}."        
2185         dst2="${prefix4}.${b_r2}.1"              
2186                                                  
2187         # Set up initial MTU values              
2188         mtu "${ns_a}"  veth_A-R1 2000            
2189         mtu "${ns_r1}" veth_R1-A 2000            
2190         mtu "${ns_r1}" veth_R1-B 1500            
2191         mtu "${ns_b}"  veth_B-R1 1500            
2192                                                  
2193         mtu "${ns_a}"  veth_A-R2 2000            
2194         mtu "${ns_r2}" veth_R2-A 2000            
2195         mtu "${ns_r2}" veth_R2-B 1500            
2196         mtu "${ns_b}"  veth_B-R2 1500            
2197                                                  
2198         fail=0                                   
2199                                                  
2200         # Add 100 addresses for veth endpoint    
2201         for i in $(seq 100 199); do              
2202                 run_cmd ${ns_b} ip addr add "    
2203         done                                     
2204                                                  
2205         # Create 100 cached route exceptions     
2206         # that with IPv4 we need to actually     
2207         # the exception caused by ICMP, in or    
2208         # route, so we need to ping each dest    
2209         for i in $(seq 100 199); do              
2210                 run_cmd ${ns_a} ping -q -M wa    
2211         done                                     
2212         run_cmd ${ns_a} ping -q -M want -i 0.    
2213                                                  
2214         if [ "$(${ns_a} ip -oneline route lis    
2215                 err "  can't list cached exce    
2216                 fail=1                           
2217         fi                                       
2218                                                  
2219         run_cmd ${ns_a} ip route flush cache     
2220         pmtu1="$(route_get_dst_pmtu_from_exce    
2221         pmtu2="$(route_get_dst_pmtu_from_exce    
2222         if [ -n "${pmtu1}" ] || [ -n "${pmtu2    
2223            [ -n "$(${ns_a} ip route list cach    
2224                 err "  can't flush cached exc    
2225                 fail=1                           
2226         fi                                       
2227                                                  
2228         return ${fail}                           
2229 }                                                
2230                                                  
2231 test_list_flush_ipv6_exception() {               
2232         setup namespaces routing || return $k    
2233         trace "${ns_a}"  veth_A-R1    "${ns_r    
2234               "${ns_r1}" veth_R1-B    "${ns_b    
2235               "${ns_a}"  veth_A-R2    "${ns_r    
2236               "${ns_r2}" veth_R2-B    "${ns_b    
2237                                                  
2238         dst_prefix1="${prefix6}:${b_r1}::"       
2239         dst2="${prefix6}:${b_r2}::1"             
2240                                                  
2241         # Set up initial MTU values              
2242         mtu "${ns_a}"  veth_A-R1 2000            
2243         mtu "${ns_r1}" veth_R1-A 2000            
2244         mtu "${ns_r1}" veth_R1-B 1500            
2245         mtu "${ns_b}"  veth_B-R1 1500            
2246                                                  
2247         mtu "${ns_a}"  veth_A-R2 2000            
2248         mtu "${ns_r2}" veth_R2-A 2000            
2249         mtu "${ns_r2}" veth_R2-B 1500            
2250         mtu "${ns_b}"  veth_B-R2 1500            
2251                                                  
2252         fail=0                                   
2253                                                  
2254         # Add 100 addresses for veth endpoint    
2255         for i in $(seq 100 199); do              
2256                 run_cmd ${ns_b} ip addr add "    
2257         done                                     
2258                                                  
2259         # Create 100 cached route exceptions     
2260         for i in $(seq 100 199); do              
2261                 run_cmd ${ns_a} ping -q -M wa    
2262         done                                     
2263         run_cmd ${ns_a} ping -q -M want -i 0.    
2264         if [ "$(${ns_a} ip -oneline -6 route     
2265                 err "  can't list cached exce    
2266                 fail=1                           
2267         fi                                       
2268                                                  
2269         run_cmd ${ns_a} ip -6 route flush cac    
2270         pmtu1="$(route_get_dst_pmtu_from_exce    
2271         pmtu2="$(route_get_dst_pmtu_from_exce    
2272         if [ -n "${pmtu1}" ] || [ -n "${pmtu2    
2273            [ -n "$(${ns_a} ip -6 route list c    
2274                 err "  can't flush cached exc    
2275                 fail=1                           
2276         fi                                       
2277                                                  
2278         return ${fail}                           
2279 }                                                
2280                                                  
2281 test_pmtu_ipvX_route_change() {                  
2282         family=${1}                              
2283                                                  
2284         setup namespaces routing || return 2     
2285         trace "${ns_a}"  veth_A-R1    "${ns_r    
2286               "${ns_r1}" veth_R1-B    "${ns_b    
2287               "${ns_a}"  veth_A-R2    "${ns_r    
2288               "${ns_r2}" veth_R2-B    "${ns_b    
2289                                                  
2290         if [ ${family} -eq 4 ]; then             
2291                 ping=ping                        
2292                 dst1="${prefix4}.${b_r1}.1"      
2293                 dst2="${prefix4}.${b_r2}.1"      
2294                 gw="${prefix4}.${a_r1}.2"        
2295         else                                     
2296                 ping=${ping6}                    
2297                 dst1="${prefix6}:${b_r1}::1"     
2298                 dst2="${prefix6}:${b_r2}::1"     
2299                 gw="${prefix6}:${a_r1}::2"       
2300         fi                                       
2301                                                  
2302         # Set up initial MTU values              
2303         mtu "${ns_a}"  veth_A-R1 2000            
2304         mtu "${ns_r1}" veth_R1-A 2000            
2305         mtu "${ns_r1}" veth_R1-B 1400            
2306         mtu "${ns_b}"  veth_B-R1 1400            
2307                                                  
2308         mtu "${ns_a}"  veth_A-R2 2000            
2309         mtu "${ns_r2}" veth_R2-A 2000            
2310         mtu "${ns_r2}" veth_R2-B 1500            
2311         mtu "${ns_b}"  veth_B-R2 1500            
2312                                                  
2313         # Create route exceptions                
2314         run_cmd ${ns_a} ${ping} -q -M want -i    
2315         run_cmd ${ns_a} ${ping} -q -M want -i    
2316                                                  
2317         # Check that exceptions have been cre    
2318         pmtu_1="$(route_get_dst_pmtu_from_exc    
2319         check_pmtu_value "1400" "${pmtu_1}" "    
2320         pmtu_2="$(route_get_dst_pmtu_from_exc    
2321         check_pmtu_value "1500" "${pmtu_2}" "    
2322                                                  
2323         # Replace the route from A to R1         
2324         run_cmd ${ns_a} ip route change defau    
2325                                                  
2326         # Delete the device in A                 
2327         run_cmd ${ns_a} ip link del "veth_A-R    
2328 }                                                
2329                                                  
2330 test_pmtu_ipv4_route_change() {                  
2331         test_pmtu_ipvX_route_change 4            
2332 }                                                
2333                                                  
2334 test_pmtu_ipv6_route_change() {                  
2335         test_pmtu_ipvX_route_change 6            
2336 }                                                
2337                                                  
2338 usage() {                                        
2339         echo                                     
2340         echo "$0 [OPTIONS] [TEST]..."            
2341         echo "If no TEST argument is given, a    
2342         echo                                     
2343         echo "Options"                           
2344         echo "  --trace: capture traffic to T    
2345         echo                                     
2346         echo "Available tests${tests}"           
2347         exit 1                                   
2348 }                                                
2349                                                  
2350 #############################################    
2351 #                                                
2352 exitcode=0                                       
2353 desc=0                                           
2354 all_skipped=true                                 
2355                                                  
2356 while getopts :ptv o                             
2357 do                                               
2358         case $o in                               
2359         p) PAUSE_ON_FAIL=yes;;                   
2360         v) VERBOSE=1;;                           
2361         t) if which tcpdump > /dev/null 2>&1;    
2362                 TRACING=1                        
2363            else                                  
2364                 echo "=== tcpdump not availab    
2365            fi                                    
2366            ;;                                    
2367         *) usage;;                               
2368         esac                                     
2369 done                                             
2370 shift $(($OPTIND-1))                             
2371                                                  
2372 IFS="                                            
2373 "                                                
2374                                                  
2375 for arg do                                       
2376         # Check first that all requested test    
2377         command -v > /dev/null "test_${arg}"     
2378 done                                             
2379                                                  
2380 trap cleanup EXIT                                
2381                                                  
2382 # start clean                                    
2383 cleanup                                          
2384                                                  
2385 HAVE_NH=no                                       
2386 ip nexthop ls >/dev/null 2>&1                    
2387 [ $? -eq 0 ] && HAVE_NH=yes                      
2388                                                  
2389 name=""                                          
2390 desc=""                                          
2391 rerun_nh=0                                       
2392 for t in ${tests}; do                            
2393         [ "${name}" = "" ]      && name="${t}    
2394         [ "${desc}" = "" ]      && desc="${t}    
2395                                                  
2396         if [ "${HAVE_NH}" = "yes" ]; then        
2397                 rerun_nh="${t}"                  
2398         fi                                       
2399                                                  
2400         run_this=1                               
2401         for arg do                               
2402                 [ "${arg}" != "${arg#--*}" ]     
2403                 [ "${arg}" = "${name}" ] && r    
2404                 run_this=0                       
2405         done                                     
2406         if [ $run_this -eq 1 ]; then             
2407                 run_test "${name}" "${desc}"     
2408                 # if test was skipped no need    
2409                 [ $? -eq $ksft_skip ] && reru    
2410                                                  
2411                 if [ "${rerun_nh}" = "1" ]; t    
2412                         run_test_nh "${name}"    
2413                 fi                               
2414         fi                                       
2415         name=""                                  
2416         desc=""                                  
2417         rerun_nh=0                               
2418 done                                             
2419                                                  
2420 exit ${exitcode}                                 
                                                      

~ [ 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