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