^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/bin/sh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # Check that route PMTU values match expectations, and that initial device MTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) # values are assigned correctly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) # Tests currently implemented:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) # - pmtu_ipv4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) # Set up two namespaces, A and B, with two paths between them over routers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) # R1 and R2 (also implemented with namespaces), with different MTUs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) # segment a_r1 segment b_r1 a_r1: 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) # .--------------R1--------------. b_r1: 1400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) # A B a_r2: 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) # '--------------R2--------------' b_r2: 1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) # segment a_r2 segment b_r2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) # Check that PMTU exceptions with the correct PMTU are created. Then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) # decrease and increase the MTU of the local link for one of the paths,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) # A to R1, checking that route exception PMTU changes accordingly over
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) # this path. Also check that locked exceptions are created when an ICMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) # message advertising a PMTU smaller than net.ipv4.route.min_pmtu is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) # received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) # - pmtu_ipv6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) # Same as pmtu_ipv4, except for locked PMTU tests, using IPv6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) # - pmtu_ipv4_vxlan4_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) # Set up the same network topology as pmtu_ipv4, create a VXLAN tunnel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) # over IPv4 between A and B, routed via R1. On the link between R1 and B,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) # set a MTU lower than the VXLAN MTU and the MTU on the link between A and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) # R1. Send IPv4 packets, exceeding the MTU between R1 and B, over VXLAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) # from A to B and check that the PMTU exception is created with the right
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) # value on A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) # - pmtu_ipv6_vxlan4_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) # Same as pmtu_ipv4_vxlan4_exception, but send IPv6 packets from A to B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) # - pmtu_ipv4_vxlan6_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) # Same as pmtu_ipv4_vxlan4_exception, but use IPv6 transport from A to B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) # - pmtu_ipv6_vxlan6_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) # Same as pmtu_ipv4_vxlan6_exception, but send IPv6 packets from A to B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) # - pmtu_ipv4_geneve4_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) # Same as pmtu_ipv4_vxlan4_exception, but using a GENEVE tunnel instead of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) # VXLAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) # - pmtu_ipv6_geneve4_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) # Same as pmtu_ipv6_vxlan4_exception, but using a GENEVE tunnel instead of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) # VXLAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) # - pmtu_ipv4_geneve6_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) # Same as pmtu_ipv4_vxlan6_exception, but using a GENEVE tunnel instead of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) # VXLAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) # - pmtu_ipv6_geneve6_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) # Same as pmtu_ipv6_vxlan6_exception, but using a GENEVE tunnel instead of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) # VXLAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) # - pmtu_ipv{4,6}_br_vxlan{4,6}_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) # Set up three namespaces, A, B, and C, with routing between A and B over
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) # R1. R2 is unused in these tests. A has a veth connection to C, and is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) # connected to B via a VXLAN endpoint, which is directly bridged to C.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) # MTU on the B-R1 link is lower than other MTUs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) # Check that both C and A are able to communicate with B over the VXLAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) # tunnel, and that PMTU exceptions with the correct values are created.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) # segment a_r1 segment b_r1 b_r1: 4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) # .--------------R1--------------. everything
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) # C---veth A B else: 5000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) # ' bridge |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) # '---- - - - - - VXLAN - - - - - - - '
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) # - pmtu_ipv{4,6}_br_geneve{4,6}_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) # Same as pmtu_ipv{4,6}_br_vxlan{4,6}_exception, with a GENEVE tunnel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) # instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) # - pmtu_ipv{4,6}_ovs_vxlan{4,6}_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) # Set up two namespaces, B, and C, with routing between the init namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) # and B over R1. A and R2 are unused in these tests. The init namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) # has a veth connection to C, and is connected to B via a VXLAN endpoint,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) # which is handled by Open vSwitch and bridged to C. MTU on the B-R1 link
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) # is lower than other MTUs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) # Check that C is able to communicate with B over the VXLAN tunnel, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) # that PMTU exceptions with the correct values are created.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) # segment a_r1 segment b_r1 b_r1: 4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) # .--------------R1--------------. everything
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) # C---veth init B else: 5000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) # '- ovs |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) # '---- - - - - - VXLAN - - - - - - - '
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) # - pmtu_ipv{4,6}_ovs_geneve{4,6}_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) # Same as pmtu_ipv{4,6}_ovs_vxlan{4,6}_exception, with a GENEVE tunnel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) # instead.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) # - pmtu_ipv{4,6}_fou{4,6}_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) # Same as pmtu_ipv4_vxlan4, but using a direct IPv4/IPv6 encapsulation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) # (FoU) over IPv4/IPv6, instead of VXLAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) # - pmtu_ipv{4,6}_fou{4,6}_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) # Same as pmtu_ipv4_vxlan4, but using a generic UDP IPv4/IPv6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) # encapsulation (GUE) over IPv4/IPv6, instead of VXLAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) # - pmtu_ipv{4,6}_ipv{4,6}_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) # Same as pmtu_ipv4_vxlan4, but using a IPv4/IPv6 tunnel over IPv4/IPv6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) # instead of VXLAN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) # - pmtu_vti4_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) # Set up vti tunnel on top of veth, with xfrm states and policies, in two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) # namespaces with matching endpoints. Check that route exception is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) # created if link layer MTU is not exceeded, then exceed it and check that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) # exception is created with the expected PMTU. The approach described
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) # below for IPv6 doesn't apply here, because, on IPv4, administrative MTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) # changes alone won't affect PMTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) # - pmtu_vti6_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) # Set up vti6 tunnel on top of veth, with xfrm states and policies, in two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) # namespaces with matching endpoints. Check that route exception is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) # created by exceeding link layer MTU with ping to other endpoint. Then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) # decrease and increase MTU of tunnel, checking that route exception PMTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) # changes accordingly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) # - pmtu_vti4_default_mtu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) # Set up vti4 tunnel on top of veth, in two namespaces with matching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) # endpoints. Check that MTU assigned to vti interface is the MTU of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) # lower layer (veth) minus additional lower layer headers (zero, for veth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) # minus IPv4 header length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) # - pmtu_vti6_default_mtu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) # Same as above, for IPv6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) # - pmtu_vti4_link_add_mtu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) # Set up vti4 interface passing MTU value at link creation, check MTU is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) # configured, and that link is not created with invalid MTU values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) # - pmtu_vti6_link_add_mtu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) # Same as above, for IPv6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) # - pmtu_vti6_link_change_mtu
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) # Set up two dummy interfaces with different MTUs, create a vti6 tunnel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) # and check that configured MTU is used on link creation and changes, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) # that MTU is properly calculated instead when MTU is not configured from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) # userspace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) # - cleanup_ipv4_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) # Similar to pmtu_ipv4_vxlan4_exception, but explicitly generate PMTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) # exceptions on multiple CPUs and check that the veth device tear-down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) # happens in a timely manner
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) # - cleanup_ipv6_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) # Same as above, but use IPv6 transport from A to B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) # - list_flush_ipv4_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) # Using the same topology as in pmtu_ipv4, create exceptions, and check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) # they are shown when listing exception caches, gone after flushing them
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) # - list_flush_ipv6_exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) # Using the same topology as in pmtu_ipv6, create exceptions, and check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) # they are shown when listing exception caches, gone after flushing them
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) # - pmtu_ipv4_route_change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) # Use the same topology as in pmtu_ipv4, but issue a route replacement
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) # command and delete the corresponding device afterward. This tests for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) # proper cleanup of the PMTU exceptions by the route replacement path.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) # Device unregistration should complete successfully
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) # - pmtu_ipv6_route_change
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) # Same as above but with IPv6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) # Kselftest framework requirement - SKIP code is 4.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) ksft_skip=4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) PAUSE_ON_FAIL=no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) VERBOSE=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) TRACING=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) # Some systems don't have a ping6 binary anymore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) which ping6 > /dev/null 2>&1 && ping6=$(which ping6) || ping6=$(which ping)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) # Name Description re-run with nh
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) tests="
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) pmtu_ipv4_exception ipv4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) pmtu_ipv6_exception ipv6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) pmtu_ipv4_vxlan4_exception IPv4 over vxlan4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) pmtu_ipv6_vxlan4_exception IPv6 over vxlan4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) pmtu_ipv4_vxlan6_exception IPv4 over vxlan6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) pmtu_ipv6_vxlan6_exception IPv6 over vxlan6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) pmtu_ipv4_geneve4_exception IPv4 over geneve4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) pmtu_ipv6_geneve4_exception IPv6 over geneve4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) pmtu_ipv4_geneve6_exception IPv4 over geneve6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) pmtu_ipv6_geneve6_exception IPv6 over geneve6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) pmtu_ipv4_br_vxlan4_exception IPv4, bridged vxlan4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) pmtu_ipv6_br_vxlan4_exception IPv6, bridged vxlan4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) pmtu_ipv4_br_vxlan6_exception IPv4, bridged vxlan6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) pmtu_ipv6_br_vxlan6_exception IPv6, bridged vxlan6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) pmtu_ipv4_br_geneve4_exception IPv4, bridged geneve4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) pmtu_ipv6_br_geneve4_exception IPv6, bridged geneve4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) pmtu_ipv4_br_geneve6_exception IPv4, bridged geneve6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) pmtu_ipv6_br_geneve6_exception IPv6, bridged geneve6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) pmtu_ipv4_ovs_vxlan4_exception IPv4, OVS vxlan4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) pmtu_ipv6_ovs_vxlan4_exception IPv6, OVS vxlan4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) pmtu_ipv4_ovs_vxlan6_exception IPv4, OVS vxlan6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) pmtu_ipv6_ovs_vxlan6_exception IPv6, OVS vxlan6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) pmtu_ipv4_ovs_geneve4_exception IPv4, OVS geneve4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) pmtu_ipv6_ovs_geneve4_exception IPv6, OVS geneve4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) pmtu_ipv4_ovs_geneve6_exception IPv4, OVS geneve6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) pmtu_ipv6_ovs_geneve6_exception IPv6, OVS geneve6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) pmtu_ipv4_fou4_exception IPv4 over fou4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) pmtu_ipv6_fou4_exception IPv6 over fou4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) pmtu_ipv4_fou6_exception IPv4 over fou6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) pmtu_ipv6_fou6_exception IPv6 over fou6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) pmtu_ipv4_gue4_exception IPv4 over gue4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) pmtu_ipv6_gue4_exception IPv6 over gue4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) pmtu_ipv4_gue6_exception IPv4 over gue6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) pmtu_ipv6_gue6_exception IPv6 over gue6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) pmtu_ipv4_ipv4_exception IPv4 over IPv4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) pmtu_ipv6_ipv4_exception IPv6 over IPv4: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) pmtu_ipv4_ipv6_exception IPv4 over IPv6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) pmtu_ipv6_ipv6_exception IPv6 over IPv6: PMTU exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) pmtu_vti6_exception vti6: PMTU exceptions 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) pmtu_vti4_exception vti4: PMTU exceptions 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) pmtu_vti4_default_mtu vti4: default MTU assignment 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) pmtu_vti6_default_mtu vti6: default MTU assignment 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) pmtu_vti4_link_add_mtu vti4: MTU setting on link creation 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) pmtu_vti6_link_add_mtu vti6: MTU setting on link creation 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) pmtu_vti6_link_change_mtu vti6: MTU changes on link changes 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) cleanup_ipv4_exception ipv4: cleanup of cached exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) cleanup_ipv6_exception ipv6: cleanup of cached exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) list_flush_ipv4_exception ipv4: list and flush cached exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) list_flush_ipv6_exception ipv6: list and flush cached exceptions 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) pmtu_ipv4_route_change ipv4: PMTU exception w/route replace 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) pmtu_ipv6_route_change ipv6: PMTU exception w/route replace 1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) NS_A="ns-A"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) NS_B="ns-B"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) NS_C="ns-C"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) NS_R1="ns-R1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) NS_R2="ns-R2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) ns_a="ip netns exec ${NS_A}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) ns_b="ip netns exec ${NS_B}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) ns_c="ip netns exec ${NS_C}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) ns_r1="ip netns exec ${NS_R1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) ns_r2="ip netns exec ${NS_R2}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) # Addressing and routing for tests with routers: four network segments, with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) # index SEGMENT between 1 and 4, a common prefix (PREFIX4 or PREFIX6) and an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) # identifier ID, which is 1 for hosts (A and B), 2 for routers (R1 and R2).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) # Addresses are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) # - IPv4: PREFIX4.SEGMENT.ID (/24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) # - IPv6: PREFIX6:SEGMENT::ID (/64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) prefix4="10.0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) prefix6="fc00"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) a_r1=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) a_r2=2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) b_r1=3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) b_r2=4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) # ns peer segment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) routing_addrs="
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) A R1 ${a_r1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) A R2 ${a_r2}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) B R1 ${b_r1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) B R2 ${b_r2}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) # Traffic from A to B goes through R1 by default, and through R2, if destined to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) # B's address on the b_r2 segment.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) # Traffic from B to A goes through R1.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) # ns destination gateway
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) routes="
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) A default ${prefix4}.${a_r1}.2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) A ${prefix4}.${b_r2}.1 ${prefix4}.${a_r2}.2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) B default ${prefix4}.${b_r1}.2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) A default ${prefix6}:${a_r1}::2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) A ${prefix6}:${b_r2}::1 ${prefix6}:${a_r2}::2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) B default ${prefix6}:${b_r1}::2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) USE_NH="no"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) # ns family nh id destination gateway
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) nexthops="
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) A 4 41 ${prefix4}.${a_r1}.2 veth_A-R1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) A 4 42 ${prefix4}.${a_r2}.2 veth_A-R2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) B 4 41 ${prefix4}.${b_r1}.2 veth_B-R1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) A 6 61 ${prefix6}:${a_r1}::2 veth_A-R1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) A 6 62 ${prefix6}:${a_r2}::2 veth_A-R2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) B 6 61 ${prefix6}:${b_r1}::2 veth_B-R1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) # nexthop id correlates to id in nexthops config above
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) # ns family prefix nh id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) routes_nh="
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) A 4 default 41
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) A 4 ${prefix4}.${b_r2}.1 42
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) B 4 default 41
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) A 6 default 61
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) A 6 ${prefix6}:${b_r2}::1 62
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) B 6 default 61
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) veth4_a_addr="192.168.1.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) veth4_b_addr="192.168.1.2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) veth4_c_addr="192.168.2.10"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) veth4_mask="24"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) veth6_a_addr="fd00:1::a"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) veth6_b_addr="fd00:1::b"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) veth6_c_addr="fd00:2::c"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) veth6_mask="64"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) tunnel4_a_addr="192.168.2.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) tunnel4_b_addr="192.168.2.2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) tunnel4_mask="24"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) tunnel6_a_addr="fd00:2::a"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) tunnel6_b_addr="fd00:2::b"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) tunnel6_mask="64"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) dummy6_0_prefix="fc00:1000::"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) dummy6_1_prefix="fc00:1001::"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) dummy6_mask="64"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) err_buf=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) tcpdump_pids=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) err() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) err_buf="${err_buf}${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) err_flush() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) echo -n "${err_buf}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) err_buf=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) run_cmd() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) cmd="$*"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) if [ "$VERBOSE" = "1" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) printf " COMMAND: $cmd\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) out="$($cmd 2>&1)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) rc=$?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) if [ "$VERBOSE" = "1" -a -n "$out" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) echo " $out"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) echo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) return $rc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) # Find the auto-generated name for this namespace
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) nsname() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) eval echo \$NS_$1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) setup_fou_or_gue() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) outer="${1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) inner="${2}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) encap="${3}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) if [ "${outer}" = "4" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) modprobe fou || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) a_addr="${prefix4}.${a_r1}.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) b_addr="${prefix4}.${b_r1}.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) if [ "${inner}" = "4" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) type="ipip"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) ipproto="4"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) type="sit"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) ipproto="41"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) modprobe fou6 || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) a_addr="${prefix6}:${a_r1}::1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) b_addr="${prefix6}:${b_r1}::1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) if [ "${inner}" = "4" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) type="ip6tnl"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) mode="mode ipip6"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) ipproto="4 -6"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) type="ip6tnl"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) mode="mode ip6ip6"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) ipproto="41 -6"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) run_cmd ${ns_a} ip fou add port 5555 ipproto ${ipproto} || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 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 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) run_cmd ${ns_b} ip fou add port 5556 ipproto ${ipproto}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) if [ "${inner}" = "4" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) run_cmd ${ns_a} ip addr add ${tunnel4_a_addr}/${tunnel4_mask} dev ${encap}_a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) run_cmd ${ns_b} ip addr add ${tunnel4_b_addr}/${tunnel4_mask} dev ${encap}_b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) run_cmd ${ns_a} ip addr add ${tunnel6_a_addr}/${tunnel6_mask} dev ${encap}_a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) run_cmd ${ns_b} ip addr add ${tunnel6_b_addr}/${tunnel6_mask} dev ${encap}_b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) run_cmd ${ns_a} ip link set ${encap}_a up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) run_cmd ${ns_b} ip link set ${encap}_b up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) setup_fou44() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) setup_fou_or_gue 4 4 fou
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) setup_fou46() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) setup_fou_or_gue 4 6 fou
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) setup_fou64() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) setup_fou_or_gue 6 4 fou
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) setup_fou66() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) setup_fou_or_gue 6 6 fou
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) setup_gue44() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) setup_fou_or_gue 4 4 gue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) setup_gue46() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) setup_fou_or_gue 4 6 gue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) setup_gue64() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) setup_fou_or_gue 6 4 gue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) setup_gue66() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) setup_fou_or_gue 6 6 gue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) setup_ipvX_over_ipvY() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) inner=${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) outer=${2}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) if [ "${outer}" -eq 4 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) a_addr="${prefix4}.${a_r1}.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) b_addr="${prefix4}.${b_r1}.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) if [ "${inner}" -eq 4 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) type="ipip"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) mode="ipip"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) type="sit"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) mode="ip6ip"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) a_addr="${prefix6}:${a_r1}::1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) b_addr="${prefix6}:${b_r1}::1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) type="ip6tnl"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) if [ "${inner}" -eq 4 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) mode="ipip6"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) mode="ip6ip6"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) run_cmd ${ns_a} ip link add ip_a type ${type} local ${a_addr} remote ${b_addr} mode ${mode} || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) run_cmd ${ns_b} ip link add ip_b type ${type} local ${b_addr} remote ${a_addr} mode ${mode}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) run_cmd ${ns_a} ip link set ip_a up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) run_cmd ${ns_b} ip link set ip_b up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) if [ "${inner}" = "4" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) run_cmd ${ns_a} ip addr add ${tunnel4_a_addr}/${tunnel4_mask} dev ip_a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) run_cmd ${ns_b} ip addr add ${tunnel4_b_addr}/${tunnel4_mask} dev ip_b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) run_cmd ${ns_a} ip addr add ${tunnel6_a_addr}/${tunnel6_mask} dev ip_a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) run_cmd ${ns_b} ip addr add ${tunnel6_b_addr}/${tunnel6_mask} dev ip_b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) setup_ip4ip4() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) setup_ipvX_over_ipvY 4 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) setup_ip6ip4() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) setup_ipvX_over_ipvY 6 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) setup_ip4ip6() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) setup_ipvX_over_ipvY 4 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) setup_ip6ip6() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) setup_ipvX_over_ipvY 6 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) setup_namespaces() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) for n in ${NS_A} ${NS_B} ${NS_C} ${NS_R1} ${NS_R2}; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) ip netns add ${n} || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) # Disable DAD, so that we don't have to wait to use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) # configured IPv6 addresses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) ip netns exec ${n} sysctl -q net/ipv6/conf/default/accept_dad=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) setup_veth() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) run_cmd ${ns_a} ip link add veth_a type veth peer name veth_b || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) run_cmd ${ns_a} ip link set veth_b netns ${NS_B}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) run_cmd ${ns_a} ip addr add ${veth4_a_addr}/${veth4_mask} dev veth_a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) run_cmd ${ns_b} ip addr add ${veth4_b_addr}/${veth4_mask} dev veth_b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) run_cmd ${ns_a} ip addr add ${veth6_a_addr}/${veth6_mask} dev veth_a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) run_cmd ${ns_b} ip addr add ${veth6_b_addr}/${veth6_mask} dev veth_b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) run_cmd ${ns_a} ip link set veth_a up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) run_cmd ${ns_b} ip link set veth_b up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) setup_vti() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) proto=${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) veth_a_addr="${2}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) veth_b_addr="${3}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) vti_a_addr="${4}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) vti_b_addr="${5}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) vti_mask=${6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) [ ${proto} -eq 6 ] && vti_type="vti6" || vti_type="vti"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) run_cmd ${ns_b} ip link add vti${proto}_b type ${vti_type} local ${veth_b_addr} remote ${veth_a_addr} key 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) run_cmd ${ns_a} ip addr add ${vti_a_addr}/${vti_mask} dev vti${proto}_a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) run_cmd ${ns_b} ip addr add ${vti_b_addr}/${vti_mask} dev vti${proto}_b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) run_cmd ${ns_a} ip link set vti${proto}_a up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) run_cmd ${ns_b} ip link set vti${proto}_b up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) setup_vti4() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) setup_vti 4 ${veth4_a_addr} ${veth4_b_addr} ${tunnel4_a_addr} ${tunnel4_b_addr} ${tunnel4_mask}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) setup_vti6() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) setup_vti 6 ${veth6_a_addr} ${veth6_b_addr} ${tunnel6_a_addr} ${tunnel6_b_addr} ${tunnel6_mask}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) setup_vxlan_or_geneve() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) type="${1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) a_addr="${2}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) b_addr="${3}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) opts="${4}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) br_if_a="${5}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) if [ "${type}" = "vxlan" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) opts="${opts} ttl 64 dstport 4789"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) opts_a="local ${a_addr}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) opts_b="local ${b_addr}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) opts_a=""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) opts_b=""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) run_cmd ${ns_a} ip link add ${type}_a type ${type} id 1 ${opts_a} remote ${b_addr} ${opts} || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) run_cmd ${ns_b} ip link add ${type}_b type ${type} id 1 ${opts_b} remote ${a_addr} ${opts}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) if [ -n "${br_if_a}" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) run_cmd ${ns_a} ip addr add ${tunnel4_a_addr}/${tunnel4_mask} dev ${br_if_a}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) run_cmd ${ns_a} ip addr add ${tunnel6_a_addr}/${tunnel6_mask} dev ${br_if_a}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) run_cmd ${ns_a} ip link set ${type}_a master ${br_if_a}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) run_cmd ${ns_a} ip addr add ${tunnel4_a_addr}/${tunnel4_mask} dev ${type}_a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) run_cmd ${ns_a} ip addr add ${tunnel6_a_addr}/${tunnel6_mask} dev ${type}_a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) run_cmd ${ns_b} ip addr add ${tunnel4_b_addr}/${tunnel4_mask} dev ${type}_b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) run_cmd ${ns_b} ip addr add ${tunnel6_b_addr}/${tunnel6_mask} dev ${type}_b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) run_cmd ${ns_a} ip link set ${type}_a up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) run_cmd ${ns_b} ip link set ${type}_b up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) setup_geneve4() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) setup_vxlan_or_geneve geneve ${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1 "df set"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) setup_vxlan4() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) setup_vxlan_or_geneve vxlan ${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1 "df set"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) setup_geneve6() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) setup_vxlan_or_geneve geneve ${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1 ""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) setup_vxlan6() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) setup_vxlan_or_geneve vxlan ${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1 ""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) setup_bridged_geneve4() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) setup_vxlan_or_geneve geneve ${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1 "df set" "br0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) setup_bridged_vxlan4() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) setup_vxlan_or_geneve vxlan ${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1 "df set" "br0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) setup_bridged_geneve6() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) setup_vxlan_or_geneve geneve ${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1 "" "br0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) setup_bridged_vxlan6() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) setup_vxlan_or_geneve vxlan ${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1 "" "br0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) setup_xfrm() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) proto=${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) veth_a_addr="${2}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) veth_b_addr="${3}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 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 || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) setup_xfrm4() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) setup_xfrm 4 ${veth4_a_addr} ${veth4_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) setup_xfrm6() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) setup_xfrm 6 ${veth6_a_addr} ${veth6_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) setup_routing_old() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) for i in ${routes}; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) [ "${ns}" = "" ] && ns="${i}" && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) [ "${addr}" = "" ] && addr="${i}" && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) [ "${gw}" = "" ] && gw="${i}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) ns_name="$(nsname ${ns})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) ip -n ${ns_name} route add ${addr} via ${gw}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) ns=""; addr=""; gw=""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) setup_routing_new() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) for i in ${nexthops}; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) [ "${ns}" = "" ] && ns="${i}" && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) [ "${fam}" = "" ] && fam="${i}" && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) [ "${nhid}" = "" ] && nhid="${i}" && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) [ "${gw}" = "" ] && gw="${i}" && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) [ "${dev}" = "" ] && dev="${i}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) ns_name="$(nsname ${ns})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) ip -n ${ns_name} -${fam} nexthop add id ${nhid} via ${gw} dev ${dev}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) ns=""; fam=""; nhid=""; gw=""; dev=""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) for i in ${routes_nh}; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) [ "${ns}" = "" ] && ns="${i}" && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) [ "${fam}" = "" ] && fam="${i}" && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) [ "${addr}" = "" ] && addr="${i}" && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) [ "${nhid}" = "" ] && nhid="${i}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) ns_name="$(nsname ${ns})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) ip -n ${ns_name} -${fam} route add ${addr} nhid ${nhid}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) ns=""; fam=""; addr=""; nhid=""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) setup_routing() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) for i in ${NS_R1} ${NS_R2}; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) ip netns exec ${i} sysctl -q net/ipv4/ip_forward=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) ip netns exec ${i} sysctl -q net/ipv6/conf/all/forwarding=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) for i in ${routing_addrs}; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) [ "${ns}" = "" ] && ns="${i}" && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) [ "${peer}" = "" ] && peer="${i}" && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) [ "${segment}" = "" ] && segment="${i}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) ns_name="$(nsname ${ns})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) peer_name="$(nsname ${peer})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) if="veth_${ns}-${peer}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) ifpeer="veth_${peer}-${ns}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) # Create veth links
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) ip link add ${if} up netns ${ns_name} type veth peer name ${ifpeer} netns ${peer_name} || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) ip -n ${peer_name} link set dev ${ifpeer} up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) # Add addresses
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) ip -n ${ns_name} addr add ${prefix4}.${segment}.1/24 dev ${if}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) ip -n ${ns_name} addr add ${prefix6}:${segment}::1/64 dev ${if}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) ip -n ${peer_name} addr add ${prefix4}.${segment}.2/24 dev ${ifpeer}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) ip -n ${peer_name} addr add ${prefix6}:${segment}::2/64 dev ${ifpeer}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) ns=""; peer=""; segment=""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) if [ "$USE_NH" = "yes" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) setup_routing_new
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) setup_routing_old
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) return 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) setup_bridge() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) run_cmd ${ns_a} ip link add br0 type bridge || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) run_cmd ${ns_a} ip link set br0 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) run_cmd ${ns_c} ip link add veth_C-A type veth peer name veth_A-C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) run_cmd ${ns_c} ip link set veth_A-C netns ns-A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) run_cmd ${ns_a} ip link set veth_A-C up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) run_cmd ${ns_c} ip link set veth_C-A up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) run_cmd ${ns_c} ip addr add ${veth4_c_addr}/${veth4_mask} dev veth_C-A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) run_cmd ${ns_c} ip addr add ${veth6_c_addr}/${veth6_mask} dev veth_C-A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) run_cmd ${ns_a} ip link set veth_A-C master br0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) setup_ovs_vxlan_or_geneve() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) type="${1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) a_addr="${2}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) b_addr="${3}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) if [ "${type}" = "vxlan" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) opts="${opts} ttl 64 dstport 4789"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) opts_b="local ${b_addr}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) run_cmd ovs-vsctl add-port ovs_br0 ${type}_a -- \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) set interface ${type}_a type=${type} \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) options:remote_ip=${b_addr} options:key=1 options:csum=true || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) run_cmd ${ns_b} ip link add ${type}_b type ${type} id 1 ${opts_b} remote ${a_addr} ${opts} || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) run_cmd ${ns_b} ip addr add ${tunnel4_b_addr}/${tunnel4_mask} dev ${type}_b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) run_cmd ${ns_b} ip addr add ${tunnel6_b_addr}/${tunnel6_mask} dev ${type}_b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) run_cmd ${ns_b} ip link set ${type}_b up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) setup_ovs_geneve4() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) setup_ovs_vxlan_or_geneve geneve ${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) setup_ovs_vxlan4() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) setup_ovs_vxlan_or_geneve vxlan ${prefix4}.${a_r1}.1 ${prefix4}.${b_r1}.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) setup_ovs_geneve6() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) setup_ovs_vxlan_or_geneve geneve ${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) setup_ovs_vxlan6() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) setup_ovs_vxlan_or_geneve vxlan ${prefix6}:${a_r1}::1 ${prefix6}:${b_r1}::1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) setup_ovs_bridge() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) run_cmd ovs-vsctl add-br ovs_br0 || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) run_cmd ip link set ovs_br0 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) run_cmd ${ns_c} ip link add veth_C-A type veth peer name veth_A-C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) run_cmd ${ns_c} ip link set veth_A-C netns 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) run_cmd ip link set veth_A-C up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) run_cmd ${ns_c} ip link set veth_C-A up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) run_cmd ${ns_c} ip addr add ${veth4_c_addr}/${veth4_mask} dev veth_C-A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) run_cmd ${ns_c} ip addr add ${veth6_c_addr}/${veth6_mask} dev veth_C-A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) run_cmd ovs-vsctl add-port ovs_br0 veth_A-C
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) # Move veth_A-R1 to init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) run_cmd ${ns_a} ip link set veth_A-R1 netns 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) run_cmd ip addr add ${prefix4}.${a_r1}.1/${veth4_mask} dev veth_A-R1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) run_cmd ip addr add ${prefix6}:${a_r1}::1/${veth6_mask} dev veth_A-R1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) run_cmd ip link set veth_A-R1 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) run_cmd ip route add ${prefix4}.${b_r1}.1 via ${prefix4}.${a_r1}.2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) run_cmd ip route add ${prefix6}:${b_r1}::1 via ${prefix6}:${a_r1}::2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) setup() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) [ "$(id -u)" -ne 0 ] && echo " need to run as root" && return $ksft_skip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) for arg do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) eval setup_${arg} || { echo " ${arg} not supported"; return 1; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) trace() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) [ $TRACING -eq 0 ] && return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) for arg do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) [ "${ns_cmd}" = "" ] && ns_cmd="${arg}" && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) ${ns_cmd} tcpdump --immediate-mode -s 0 -i "${arg}" -w "${name}_${arg}.pcap" 2> /dev/null &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) tcpdump_pids="${tcpdump_pids} $!"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) ns_cmd=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) sleep 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) cleanup() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) for pid in ${tcpdump_pids}; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) kill ${pid}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) tcpdump_pids=
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) for n in ${NS_A} ${NS_B} ${NS_C} ${NS_R1} ${NS_R2}; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) ip netns del ${n} 2> /dev/null
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) ip link del veth_A-C 2>/dev/null
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) ip link del veth_A-R1 2>/dev/null
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) ovs-vsctl --if-exists del-port vxlan_a 2>/dev/null
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) ovs-vsctl --if-exists del-br ovs_br0 2>/dev/null
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) mtu() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) ns_cmd="${1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) dev="${2}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) mtu="${3}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) ${ns_cmd} ip link set dev ${dev} mtu ${mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) mtu_parse() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) input="${1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) next=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) for i in ${input}; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) [ ${next} -eq 1 -a "${i}" = "lock" ] && next=2 && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) [ ${next} -eq 1 ] && echo "${i}" && return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) [ ${next} -eq 2 ] && echo "lock ${i}" && return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) [ "${i}" = "mtu" ] && next=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) link_get() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) ns_cmd="${1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) name="${2}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) ${ns_cmd} ip link show dev "${name}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) link_get_mtu() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) ns_cmd="${1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) name="${2}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) mtu_parse "$(link_get "${ns_cmd}" ${name})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) route_get_dst_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) ns_cmd="${1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) dst="${2}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) ${ns_cmd} ip route get "${dst}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) route_get_dst_pmtu_from_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) ns_cmd="${1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) dst="${2}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) mtu_parse "$(route_get_dst_exception "${ns_cmd}" ${dst})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) check_pmtu_value() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) expected="${1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) value="${2}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) event="${3}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) [ "${expected}" = "any" ] && [ -n "${value}" ] && return 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) [ "${value}" = "${expected}" ] && return 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) [ -z "${value}" ] && err " PMTU exception wasn't created after ${event}" && return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) [ -z "${expected}" ] && err " PMTU exception shouldn't exist after ${event}" && return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) err " found PMTU exception with incorrect MTU ${value}, expected ${expected}, after ${event}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) test_pmtu_ipvX() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) family=${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) setup namespaces routing || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) "${ns_r1}" veth_R1-B "${ns_b}" veth_B-R1 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) "${ns_a}" veth_A-R2 "${ns_r2}" veth_R2-A \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) "${ns_r2}" veth_R2-B "${ns_b}" veth_B-R2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) if [ ${family} -eq 4 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) ping=ping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) dst1="${prefix4}.${b_r1}.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) dst2="${prefix4}.${b_r2}.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) ping=${ping6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) dst1="${prefix6}:${b_r1}::1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) dst2="${prefix6}:${b_r2}::1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) # Set up initial MTU values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) mtu "${ns_a}" veth_A-R1 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) mtu "${ns_r1}" veth_R1-A 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) mtu "${ns_r1}" veth_R1-B 1400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) mtu "${ns_b}" veth_B-R1 1400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) mtu "${ns_a}" veth_A-R2 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) mtu "${ns_r2}" veth_R2-A 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) mtu "${ns_r2}" veth_R2-B 1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) mtu "${ns_b}" veth_B-R2 1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) # Create route exceptions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1800 ${dst1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1800 ${dst2}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) # Check that exceptions have been created with the correct PMTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) pmtu_1="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst1})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) check_pmtu_value "1400" "${pmtu_1}" "exceeding MTU" || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) check_pmtu_value "1500" "${pmtu_2}" "exceeding MTU" || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) # Decrease local MTU below PMTU, check for PMTU decrease in route exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) mtu "${ns_a}" veth_A-R1 1300
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) mtu "${ns_r1}" veth_R1-A 1300
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) pmtu_1="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst1})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) check_pmtu_value "1300" "${pmtu_1}" "decreasing local MTU" || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) # Second exception shouldn't be modified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) check_pmtu_value "1500" "${pmtu_2}" "changing local MTU on a link not on this path" || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) # Increase MTU, check for PMTU increase in route exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) mtu "${ns_a}" veth_A-R1 1700
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) mtu "${ns_r1}" veth_R1-A 1700
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) pmtu_1="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst1})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) check_pmtu_value "1700" "${pmtu_1}" "increasing local MTU" || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) # Second exception shouldn't be modified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) check_pmtu_value "1500" "${pmtu_2}" "changing local MTU on a link not on this path" || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) # Skip PMTU locking tests for IPv6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) [ $family -eq 6 ] && return 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) # Decrease remote MTU on path via R2, get new exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) mtu "${ns_r2}" veth_R2-B 400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) mtu "${ns_b}" veth_B-R2 400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1400 ${dst2}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) check_pmtu_value "lock 552" "${pmtu_2}" "exceeding MTU, with MTU < min_pmtu" || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) # Decrease local MTU below PMTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) mtu "${ns_a}" veth_A-R2 500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) mtu "${ns_r2}" veth_R2-A 500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) check_pmtu_value "500" "${pmtu_2}" "decreasing local MTU" || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) # Increase local MTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) mtu "${ns_a}" veth_A-R2 1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) mtu "${ns_r2}" veth_R2-A 1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) check_pmtu_value "1500" "${pmtu_2}" "increasing local MTU" || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) # Get new exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1400 ${dst2}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) check_pmtu_value "lock 552" "${pmtu_2}" "exceeding MTU, with MTU < min_pmtu" || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) test_pmtu_ipv4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) test_pmtu_ipvX 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) test_pmtu_ipv6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) test_pmtu_ipvX 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) test_pmtu_ipvX_over_vxlanY_or_geneveY_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) type=${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) family=${2}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) outer_family=${3}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) ll_mtu=4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) if [ ${outer_family} -eq 4 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) setup namespaces routing ${type}4 || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) # IPv4 header UDP header VXLAN/GENEVE header Ethernet header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) exp_mtu=$((${ll_mtu} - 20 - 8 - 8 - 14))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) setup namespaces routing ${type}6 || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) # IPv6 header UDP header VXLAN/GENEVE header Ethernet header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) exp_mtu=$((${ll_mtu} - 40 - 8 - 8 - 14))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) trace "${ns_a}" ${type}_a "${ns_b}" ${type}_b \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) "${ns_b}" veth_B-R1 "${ns_r1}" veth_R1-B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) if [ ${family} -eq 4 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) ping=ping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) dst=${tunnel4_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) ping=${ping6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) dst=${tunnel6_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) # Create route exception by exceeding link layer MTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) mtu "${ns_a}" veth_A-R1 $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) mtu "${ns_r1}" veth_R1-A $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) mtu "${ns_b}" veth_B-R1 ${ll_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) mtu "${ns_r1}" veth_R1-B ${ll_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) mtu "${ns_a}" ${type}_a $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) mtu "${ns_b}" ${type}_b $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${dst}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) # Check that exception was created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) check_pmtu_value ${exp_mtu} "${pmtu}" "exceeding link layer MTU on ${type} interface"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) test_pmtu_ipv4_vxlan4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) test_pmtu_ipvX_over_vxlanY_or_geneveY_exception vxlan 4 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) test_pmtu_ipv6_vxlan4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) test_pmtu_ipvX_over_vxlanY_or_geneveY_exception vxlan 6 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) test_pmtu_ipv4_geneve4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) test_pmtu_ipvX_over_vxlanY_or_geneveY_exception geneve 4 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) test_pmtu_ipv6_geneve4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) test_pmtu_ipvX_over_vxlanY_or_geneveY_exception geneve 6 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) test_pmtu_ipv4_vxlan6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) test_pmtu_ipvX_over_vxlanY_or_geneveY_exception vxlan 4 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) test_pmtu_ipv6_vxlan6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) test_pmtu_ipvX_over_vxlanY_or_geneveY_exception vxlan 6 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) test_pmtu_ipv4_geneve6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) test_pmtu_ipvX_over_vxlanY_or_geneveY_exception geneve 4 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) test_pmtu_ipv6_geneve6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) test_pmtu_ipvX_over_vxlanY_or_geneveY_exception geneve 6 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) type=${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) family=${2}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) outer_family=${3}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) ll_mtu=4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) if [ ${outer_family} -eq 4 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) setup namespaces routing bridge bridged_${type}4 || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) # IPv4 header UDP header VXLAN/GENEVE header Ethernet header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) exp_mtu=$((${ll_mtu} - 20 - 8 - 8 - 14))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) setup namespaces routing bridge bridged_${type}6 || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) # IPv6 header UDP header VXLAN/GENEVE header Ethernet header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) exp_mtu=$((${ll_mtu} - 40 - 8 - 8 - 14))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) trace "${ns_a}" ${type}_a "${ns_b}" ${type}_b \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) "${ns_b}" veth_B-R1 "${ns_r1}" veth_R1-B \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) "${ns_a}" br0 "${ns_a}" veth-A-C \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) "${ns_c}" veth_C-A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) if [ ${family} -eq 4 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) ping=ping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) dst=${tunnel4_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) ping=${ping6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) dst=${tunnel6_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) # Create route exception by exceeding link layer MTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) mtu "${ns_a}" veth_A-R1 $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) mtu "${ns_a}" br0 $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) mtu "${ns_a}" veth_A-C $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) mtu "${ns_c}" veth_C-A $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) mtu "${ns_r1}" veth_R1-A $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) mtu "${ns_b}" veth_B-R1 ${ll_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) mtu "${ns_r1}" veth_R1-B ${ll_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) mtu "${ns_a}" ${type}_a $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) mtu "${ns_b}" ${type}_b $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) run_cmd ${ns_c} ${ping} -q -M want -i 0.1 -c 10 -s $((${ll_mtu} + 500)) ${dst} || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${dst} || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) # Check that exceptions were created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) pmtu="$(route_get_dst_pmtu_from_exception "${ns_c}" ${dst})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) check_pmtu_value ${exp_mtu} "${pmtu}" "exceeding link layer MTU on bridged ${type} interface"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) check_pmtu_value ${exp_mtu} "${pmtu}" "exceeding link layer MTU on locally bridged ${type} interface"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) test_pmtu_ipv4_br_vxlan4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception vxlan 4 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) test_pmtu_ipv6_br_vxlan4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception vxlan 6 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) test_pmtu_ipv4_br_geneve4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception geneve 4 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) test_pmtu_ipv6_br_geneve4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception geneve 6 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) test_pmtu_ipv4_br_vxlan6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception vxlan 4 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) test_pmtu_ipv6_br_vxlan6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception vxlan 6 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) test_pmtu_ipv4_br_geneve6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception geneve 4 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) test_pmtu_ipv6_br_geneve6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) test_pmtu_ipvX_over_bridged_vxlanY_or_geneveY_exception geneve 6 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) type=${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) family=${2}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) outer_family=${3}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) ll_mtu=4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) if [ ${outer_family} -eq 4 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) setup namespaces routing ovs_bridge ovs_${type}4 || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) # IPv4 header UDP header VXLAN/GENEVE header Ethernet header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) exp_mtu=$((${ll_mtu} - 20 - 8 - 8 - 14))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) setup namespaces routing ovs_bridge ovs_${type}6 || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) # IPv6 header UDP header VXLAN/GENEVE header Ethernet header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) exp_mtu=$((${ll_mtu} - 40 - 8 - 8 - 14))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) if [ "${type}" = "vxlan" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) tun_a="vxlan_sys_4789"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) elif [ "${type}" = "geneve" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) tun_a="genev_sys_6081"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) trace "" "${tun_a}" "${ns_b}" ${type}_b \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) "" veth_A-R1 "${ns_r1}" veth_R1-A \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) "${ns_b}" veth_B-R1 "${ns_r1}" veth_R1-B \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) "" ovs_br0 "" veth-A-C \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) "${ns_c}" veth_C-A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) if [ ${family} -eq 4 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) ping=ping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) dst=${tunnel4_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) ping=${ping6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) dst=${tunnel6_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) # Create route exception by exceeding link layer MTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) mtu "" veth_A-R1 $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) mtu "" ovs_br0 $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) mtu "" veth_A-C $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) mtu "${ns_c}" veth_C-A $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) mtu "${ns_r1}" veth_R1-A $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) mtu "${ns_b}" veth_B-R1 ${ll_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) mtu "${ns_r1}" veth_R1-B ${ll_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) mtu "" ${tun_a} $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) mtu "${ns_b}" ${type}_b $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) run_cmd ${ns_c} ${ping} -q -M want -i 0.1 -c 20 -s $((${ll_mtu} + 500)) ${dst} || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) # Check that exceptions were created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) pmtu="$(route_get_dst_pmtu_from_exception "${ns_c}" ${dst})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) check_pmtu_value ${exp_mtu} "${pmtu}" "exceeding link layer MTU on Open vSwitch ${type} interface"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) test_pmtu_ipv4_ovs_vxlan4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception vxlan 4 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) test_pmtu_ipv6_ovs_vxlan4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception vxlan 6 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) test_pmtu_ipv4_ovs_geneve4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception geneve 4 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) test_pmtu_ipv6_ovs_geneve4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception geneve 6 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) test_pmtu_ipv4_ovs_vxlan6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception vxlan 4 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) test_pmtu_ipv6_ovs_vxlan6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception vxlan 6 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) test_pmtu_ipv4_ovs_geneve6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception geneve 4 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) test_pmtu_ipv6_ovs_geneve6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) test_pmtu_ipvX_over_ovs_vxlanY_or_geneveY_exception geneve 6 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) test_pmtu_ipvX_over_fouY_or_gueY() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) inner_family=${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) outer_family=${2}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) encap=${3}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) ll_mtu=4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) setup namespaces routing ${encap}${outer_family}${inner_family} || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) trace "${ns_a}" ${encap}_a "${ns_b}" ${encap}_b \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) "${ns_b}" veth_B-R1 "${ns_r1}" veth_R1-B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) if [ ${inner_family} -eq 4 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) ping=ping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) dst=${tunnel4_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) ping=${ping6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) dst=${tunnel6_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) if [ "${encap}" = "gue" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) encap_overhead=4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) encap_overhead=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) if [ ${outer_family} -eq 4 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) # IPv4 header UDP header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) exp_mtu=$((${ll_mtu} - 20 - 8 - ${encap_overhead}))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) # IPv6 header Option 4 UDP header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) exp_mtu=$((${ll_mtu} - 40 - 8 - 8 - ${encap_overhead}))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) # Create route exception by exceeding link layer MTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) mtu "${ns_a}" veth_A-R1 $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) mtu "${ns_r1}" veth_R1-A $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) mtu "${ns_b}" veth_B-R1 ${ll_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) mtu "${ns_r1}" veth_R1-B ${ll_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) mtu "${ns_a}" ${encap}_a $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) mtu "${ns_b}" ${encap}_b $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${dst}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) # Check that exception was created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) check_pmtu_value ${exp_mtu} "${pmtu}" "exceeding link layer MTU on ${encap} interface"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) test_pmtu_ipv4_fou4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) test_pmtu_ipvX_over_fouY_or_gueY 4 4 fou
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) test_pmtu_ipv6_fou4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) test_pmtu_ipvX_over_fouY_or_gueY 6 4 fou
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) test_pmtu_ipv4_fou6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) test_pmtu_ipvX_over_fouY_or_gueY 4 6 fou
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) test_pmtu_ipv6_fou6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) test_pmtu_ipvX_over_fouY_or_gueY 6 6 fou
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) test_pmtu_ipv4_gue4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) test_pmtu_ipvX_over_fouY_or_gueY 4 4 gue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) test_pmtu_ipv6_gue4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) test_pmtu_ipvX_over_fouY_or_gueY 6 4 gue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) test_pmtu_ipv4_gue6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) test_pmtu_ipvX_over_fouY_or_gueY 4 6 gue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) test_pmtu_ipv6_gue6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) test_pmtu_ipvX_over_fouY_or_gueY 6 6 gue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) test_pmtu_ipvX_over_ipvY_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) inner=${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) outer=${2}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) ll_mtu=4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) setup namespaces routing ip${inner}ip${outer} || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) trace "${ns_a}" ip_a "${ns_b}" ip_b \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) "${ns_b}" veth_B-R1 "${ns_r1}" veth_R1-B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) if [ ${inner} -eq 4 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) ping=ping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) dst=${tunnel4_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) ping=${ping6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) dst=${tunnel6_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) if [ ${outer} -eq 4 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) # IPv4 header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) exp_mtu=$((${ll_mtu} - 20))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) # IPv6 header Option 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) exp_mtu=$((${ll_mtu} - 40 - 8))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) # Create route exception by exceeding link layer MTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) mtu "${ns_a}" veth_A-R1 $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) mtu "${ns_r1}" veth_R1-A $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) mtu "${ns_b}" veth_B-R1 ${ll_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) mtu "${ns_r1}" veth_R1-B ${ll_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) mtu "${ns_a}" ip_a $((${ll_mtu} + 1000)) || return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) mtu "${ns_b}" ip_b $((${ll_mtu} + 1000)) || return
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${dst}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) # Check that exception was created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) check_pmtu_value ${exp_mtu} "${pmtu}" "exceeding link layer MTU on ip${inner}ip${outer} interface"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) test_pmtu_ipv4_ipv4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) test_pmtu_ipvX_over_ipvY_exception 4 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) test_pmtu_ipv6_ipv4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) test_pmtu_ipvX_over_ipvY_exception 6 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) test_pmtu_ipv4_ipv6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) test_pmtu_ipvX_over_ipvY_exception 4 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) test_pmtu_ipv6_ipv6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) test_pmtu_ipvX_over_ipvY_exception 6 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) test_pmtu_vti4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) setup namespaces veth vti4 xfrm4 || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) trace "${ns_a}" veth_a "${ns_b}" veth_b \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) "${ns_a}" vti4_a "${ns_b}" vti4_b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) veth_mtu=1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) vti_mtu=$((veth_mtu - 20))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) # SPI SN IV ICV pad length next header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) esp_payload_rfc4106=$((vti_mtu - 4 - 4 - 8 - 16 - 1 - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) ping_payload=$((esp_payload_rfc4106 - 28))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) mtu "${ns_a}" veth_a ${veth_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) mtu "${ns_b}" veth_b ${veth_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) mtu "${ns_a}" vti4_a ${vti_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) mtu "${ns_b}" vti4_b ${vti_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) # Send DF packet without exceeding link layer MTU, check that no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) # exception is created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) run_cmd ${ns_a} ping -q -M want -i 0.1 -w 1 -s ${ping_payload} ${tunnel4_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel4_b_addr})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) check_pmtu_value "" "${pmtu}" "sending packet smaller than PMTU (IP payload length ${esp_payload_rfc4106})" || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) # Now exceed link layer MTU by one byte, check that exception is created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) # with the right PMTU value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) run_cmd ${ns_a} ping -q -M want -i 0.1 -w 1 -s $((ping_payload + 1)) ${tunnel4_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel4_b_addr})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) check_pmtu_value "${esp_payload_rfc4106}" "${pmtu}" "exceeding PMTU (IP payload length $((esp_payload_rfc4106 + 1)))"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) test_pmtu_vti6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) setup namespaces veth vti6 xfrm6 || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) trace "${ns_a}" veth_a "${ns_b}" veth_b \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) "${ns_a}" vti6_a "${ns_b}" vti6_b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) fail=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) # Create route exception by exceeding link layer MTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) mtu "${ns_a}" veth_a 4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) mtu "${ns_b}" veth_b 4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) mtu "${ns_a}" vti6_a 5000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) mtu "${ns_b}" vti6_b 5000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) run_cmd ${ns_a} ${ping6} -q -i 0.1 -w 1 -s 60000 ${tunnel6_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) # Check that exception was created
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel6_b_addr})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) check_pmtu_value any "${pmtu}" "creating tunnel exceeding link layer MTU" || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) # Decrease tunnel MTU, check for PMTU decrease in route exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) mtu "${ns_a}" vti6_a 3000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel6_b_addr})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) check_pmtu_value "3000" "${pmtu}" "decreasing tunnel MTU" || fail=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) # Increase tunnel MTU, check for PMTU increase in route exception
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) mtu "${ns_a}" vti6_a 9000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) pmtu="$(route_get_dst_pmtu_from_exception "${ns_a}" ${tunnel6_b_addr})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) check_pmtu_value "9000" "${pmtu}" "increasing tunnel MTU" || fail=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) return ${fail}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) test_pmtu_vti4_default_mtu() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) setup namespaces veth vti4 || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) # Check that MTU of vti device is MTU of veth minus IPv4 header length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) veth_mtu="$(link_get_mtu "${ns_a}" veth_a)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) vti4_mtu="$(link_get_mtu "${ns_a}" vti4_a)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) if [ $((veth_mtu - vti4_mtu)) -ne 20 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) err " vti MTU ${vti4_mtu} is not veth MTU ${veth_mtu} minus IPv4 header length"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) test_pmtu_vti6_default_mtu() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) setup namespaces veth vti6 || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) # Check that MTU of vti device is MTU of veth minus IPv6 header length
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) veth_mtu="$(link_get_mtu "${ns_a}" veth_a)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) vti6_mtu="$(link_get_mtu "${ns_a}" vti6_a)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) if [ $((veth_mtu - vti6_mtu)) -ne 40 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) err " vti MTU ${vti6_mtu} is not veth MTU ${veth_mtu} minus IPv6 header length"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) test_pmtu_vti4_link_add_mtu() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) setup namespaces || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) run_cmd ${ns_a} ip link add vti4_a type vti local ${veth4_a_addr} remote ${veth4_b_addr} key 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) [ $? -ne 0 ] && err " vti not supported" && return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) run_cmd ${ns_a} ip link del vti4_a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) fail=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) min=68
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) max=$((65535 - 20))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) # Check invalid values first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) for v in $((min - 1)) $((max + 1)); do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) run_cmd ${ns_a} ip link add vti4_a mtu ${v} type vti local ${veth4_a_addr} remote ${veth4_b_addr} key 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) # This can fail, or MTU can be adjusted to a proper value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) [ $? -ne 0 ] && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) mtu="$(link_get_mtu "${ns_a}" vti4_a)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) if [ ${mtu} -lt ${min} -o ${mtu} -gt ${max} ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) err " vti tunnel created with invalid MTU ${mtu}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) fail=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) run_cmd ${ns_a} ip link del vti4_a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) # Now check valid values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) for v in ${min} 1300 ${max}; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) run_cmd ${ns_a} ip link add vti4_a mtu ${v} type vti local ${veth4_a_addr} remote ${veth4_b_addr} key 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) mtu="$(link_get_mtu "${ns_a}" vti4_a)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) run_cmd ${ns_a} ip link del vti4_a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) if [ "${mtu}" != "${v}" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) err " vti MTU ${mtu} doesn't match configured value ${v}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) fail=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) return ${fail}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) test_pmtu_vti6_link_add_mtu() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) setup namespaces || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) run_cmd ${ns_a} ip link add vti6_a type vti6 local ${veth6_a_addr} remote ${veth6_b_addr} key 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) [ $? -ne 0 ] && err " vti6 not supported" && return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) run_cmd ${ns_a} ip link del vti6_a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) fail=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) min=68 # vti6 can carry IPv4 packets too
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) max=$((65535 - 40))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) # Check invalid values first
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) for v in $((min - 1)) $((max + 1)); do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) run_cmd ${ns_a} ip link add vti6_a mtu ${v} type vti6 local ${veth6_a_addr} remote ${veth6_b_addr} key 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) # This can fail, or MTU can be adjusted to a proper value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) [ $? -ne 0 ] && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) mtu="$(link_get_mtu "${ns_a}" vti6_a)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) if [ ${mtu} -lt ${min} -o ${mtu} -gt ${max} ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) err " vti6 tunnel created with invalid MTU ${v}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) fail=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) run_cmd ${ns_a} ip link del vti6_a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) # Now check valid values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) for v in 68 1280 1300 $((65535 - 40)); do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) run_cmd ${ns_a} ip link add vti6_a mtu ${v} type vti6 local ${veth6_a_addr} remote ${veth6_b_addr} key 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523) mtu="$(link_get_mtu "${ns_a}" vti6_a)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) run_cmd ${ns_a} ip link del vti6_a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) if [ "${mtu}" != "${v}" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) err " vti6 MTU ${mtu} doesn't match configured value ${v}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) fail=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) return ${fail}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) test_pmtu_vti6_link_change_mtu() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) setup namespaces || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) run_cmd ${ns_a} ip link add dummy0 mtu 1500 type dummy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) [ $? -ne 0 ] && err " dummy not supported" && return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) run_cmd ${ns_a} ip link add dummy1 mtu 3000 type dummy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) run_cmd ${ns_a} ip link set dummy0 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) run_cmd ${ns_a} ip link set dummy1 up
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) run_cmd ${ns_a} ip addr add ${dummy6_0_prefix}1/${dummy6_mask} dev dummy0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) run_cmd ${ns_a} ip addr add ${dummy6_1_prefix}1/${dummy6_mask} dev dummy1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) fail=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) # Create vti6 interface bound to device, passing MTU, check it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) run_cmd ${ns_a} ip link add vti6_a mtu 1300 type vti6 remote ${dummy6_0_prefix}2 local ${dummy6_0_prefix}1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) mtu="$(link_get_mtu "${ns_a}" vti6_a)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) if [ ${mtu} -ne 1300 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) err " vti6 MTU ${mtu} doesn't match configured value 1300"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) fail=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) # Move to another device with different MTU, without passing MTU, check
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) # MTU is adjusted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) run_cmd ${ns_a} ip link set vti6_a type vti6 remote ${dummy6_1_prefix}2 local ${dummy6_1_prefix}1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) mtu="$(link_get_mtu "${ns_a}" vti6_a)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) if [ ${mtu} -ne $((3000 - 40)) ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) err " vti MTU ${mtu} is not dummy MTU 3000 minus IPv6 header length"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) fail=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) # Move it back, passing MTU, check MTU is not overridden
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) run_cmd ${ns_a} ip link set vti6_a mtu 1280 type vti6 remote ${dummy6_0_prefix}2 local ${dummy6_0_prefix}1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) mtu="$(link_get_mtu "${ns_a}" vti6_a)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) if [ ${mtu} -ne 1280 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) err " vti6 MTU ${mtu} doesn't match configured value 1280"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) fail=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) return ${fail}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) check_command() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) cmd=${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) if ! which ${cmd} > /dev/null 2>&1; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) err " missing required command: '${cmd}'"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) return 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) test_cleanup_vxlanX_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) outer="${1}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) encap="vxlan"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) ll_mtu=4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) check_command taskset || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) cpu_list=$(grep -m 2 processor /proc/cpuinfo | cut -d ' ' -f 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) setup namespaces routing ${encap}${outer} || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) trace "${ns_a}" ${encap}_a "${ns_b}" ${encap}_b \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) "${ns_b}" veth_B-R1 "${ns_r1}" veth_R1-B
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) # Create route exception by exceeding link layer MTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) mtu "${ns_a}" veth_A-R1 $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) mtu "${ns_r1}" veth_R1-A $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) mtu "${ns_b}" veth_B-R1 ${ll_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) mtu "${ns_r1}" veth_R1-B ${ll_mtu}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) mtu "${ns_a}" ${encap}_a $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) mtu "${ns_b}" ${encap}_b $((${ll_mtu} + 1000))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) # Fill exception cache for multiple CPUs (2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) # we can always use inner IPv4 for that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) for cpu in ${cpu_list}; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) run_cmd taskset --cpu-list ${cpu} ${ns_a} ping -q -M want -i 0.1 -w 1 -s $((${ll_mtu} + 500)) ${tunnel4_b_addr}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) ${ns_a} ip link del dev veth_A-R1 &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) iplink_pid=$!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) sleep 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) if [ "$(cat /proc/${iplink_pid}/cmdline 2>/dev/null | tr -d '\0')" = "iplinkdeldevveth_A-R1" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) err " can't delete veth device in a timely manner, PMTU dst likely leaked"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) test_cleanup_ipv6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) test_cleanup_vxlanX_exception 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) test_cleanup_ipv4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) test_cleanup_vxlanX_exception 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) run_test() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633) tname="$1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) tdesc="$2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) unset IFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) # Since cleanup() relies on variables modified by this subshell, it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) # has to run in this context.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) trap cleanup EXIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) if [ "$VERBOSE" = "1" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) printf "\n##########################################################################\n\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) eval test_${tname}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) ret=$?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) if [ $ret -eq 0 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) printf "TEST: %-60s [ OK ]\n" "${tdesc}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) elif [ $ret -eq 1 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) printf "TEST: %-60s [FAIL]\n" "${tdesc}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) if [ "${PAUSE_ON_FAIL}" = "yes" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) echo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) echo "Pausing. Hit enter to continue"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) read a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) err_flush
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659) exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) elif [ $ret -eq 2 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) printf "TEST: %-60s [SKIP]\n" "${tdesc}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) err_flush
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) return $ret
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) ret=$?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) [ $ret -ne 0 ] && exitcode=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) return $ret
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) run_test_nh() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) tname="$1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) tdesc="$2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) USE_NH=yes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) run_test "${tname}" "${tdesc} - nexthop objects"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) USE_NH=no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) test_list_flush_ipv4_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) setup namespaces routing || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) "${ns_r1}" veth_R1-B "${ns_b}" veth_B-R1 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) "${ns_a}" veth_A-R2 "${ns_r2}" veth_R2-A \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) "${ns_r2}" veth_R2-B "${ns_b}" veth_B-R2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) dst_prefix1="${prefix4}.${b_r1}."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) dst2="${prefix4}.${b_r2}.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) # Set up initial MTU values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) mtu "${ns_a}" veth_A-R1 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) mtu "${ns_r1}" veth_R1-A 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) mtu "${ns_r1}" veth_R1-B 1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) mtu "${ns_b}" veth_B-R1 1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) mtu "${ns_a}" veth_A-R2 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) mtu "${ns_r2}" veth_R2-A 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) mtu "${ns_r2}" veth_R2-B 1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) mtu "${ns_b}" veth_B-R2 1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) fail=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) # Add 100 addresses for veth endpoint on B reached by default A route
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706) for i in $(seq 100 199); do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) run_cmd ${ns_b} ip addr add "${dst_prefix1}${i}" dev veth_B-R1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) # Create 100 cached route exceptions for path via R1, one via R2. Note
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) # that with IPv4 we need to actually cause a route lookup that matches
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) # the exception caused by ICMP, in order to actually have a cached
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713) # route, so we need to ping each destination twice
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) for i in $(seq 100 199); do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) run_cmd ${ns_a} ping -q -M want -i 0.1 -c 2 -s 1800 "${dst_prefix1}${i}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) run_cmd ${ns_a} ping -q -M want -i 0.1 -c 2 -s 1800 "${dst2}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) if [ "$(${ns_a} ip -oneline route list cache | wc -l)" -ne 101 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) err " can't list cached exceptions"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) fail=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) run_cmd ${ns_a} ip route flush cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) pmtu1="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst_prefix}1)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) pmtu2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst_prefix}2)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) if [ -n "${pmtu1}" ] || [ -n "${pmtu2}" ] || \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) [ -n "$(${ns_a} ip route list cache)" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729) err " can't flush cached exceptions"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) fail=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) return ${fail}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) test_list_flush_ipv6_exception() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) setup namespaces routing || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) "${ns_r1}" veth_R1-B "${ns_b}" veth_B-R1 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) "${ns_a}" veth_A-R2 "${ns_r2}" veth_R2-A \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) "${ns_r2}" veth_R2-B "${ns_b}" veth_B-R2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) dst_prefix1="${prefix6}:${b_r1}::"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) dst2="${prefix6}:${b_r2}::1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) # Set up initial MTU values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) mtu "${ns_a}" veth_A-R1 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) mtu "${ns_r1}" veth_R1-A 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) mtu "${ns_r1}" veth_R1-B 1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) mtu "${ns_b}" veth_B-R1 1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) mtu "${ns_a}" veth_A-R2 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) mtu "${ns_r2}" veth_R2-A 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) mtu "${ns_r2}" veth_R2-B 1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755) mtu "${ns_b}" veth_B-R2 1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) fail=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) # Add 100 addresses for veth endpoint on B reached by default A route
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) for i in $(seq 100 199); do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) run_cmd ${ns_b} ip addr add "${dst_prefix1}${i}" dev veth_B-R1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) # Create 100 cached route exceptions for path via R1, one via R2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) for i in $(seq 100 199); do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) run_cmd ${ns_a} ping -q -M want -i 0.1 -w 1 -s 1800 "${dst_prefix1}${i}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) run_cmd ${ns_a} ping -q -M want -i 0.1 -w 1 -s 1800 "${dst2}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) if [ "$(${ns_a} ip -oneline -6 route list cache | wc -l)" -ne 101 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) err " can't list cached exceptions"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) fail=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) run_cmd ${ns_a} ip -6 route flush cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) pmtu1="$(route_get_dst_pmtu_from_exception "${ns_a}" "${dst_prefix1}100")"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) pmtu2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) if [ -n "${pmtu1}" ] || [ -n "${pmtu2}" ] || \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) [ -n "$(${ns_a} ip -6 route list cache)" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) err " can't flush cached exceptions"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) fail=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) return ${fail}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) test_pmtu_ipvX_route_change() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) family=${1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) setup namespaces routing || return 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) trace "${ns_a}" veth_A-R1 "${ns_r1}" veth_R1-A \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) "${ns_r1}" veth_R1-B "${ns_b}" veth_B-R1 \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) "${ns_a}" veth_A-R2 "${ns_r2}" veth_R2-A \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) "${ns_r2}" veth_R2-B "${ns_b}" veth_B-R2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) if [ ${family} -eq 4 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796) ping=ping
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) dst1="${prefix4}.${b_r1}.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) dst2="${prefix4}.${b_r2}.1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) gw="${prefix4}.${a_r1}.2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) ping=${ping6}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) dst1="${prefix6}:${b_r1}::1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) dst2="${prefix6}:${b_r2}::1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) gw="${prefix6}:${a_r1}::2"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) # Set up initial MTU values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) mtu "${ns_a}" veth_A-R1 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) mtu "${ns_r1}" veth_R1-A 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) mtu "${ns_r1}" veth_R1-B 1400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) mtu "${ns_b}" veth_B-R1 1400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) mtu "${ns_a}" veth_A-R2 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) mtu "${ns_r2}" veth_R2-A 2000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) mtu "${ns_r2}" veth_R2-B 1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) mtu "${ns_b}" veth_B-R2 1500
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) # Create route exceptions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1800 ${dst1}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) run_cmd ${ns_a} ${ping} -q -M want -i 0.1 -w 1 -s 1800 ${dst2}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822) # Check that exceptions have been created with the correct PMTU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) pmtu_1="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst1})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) check_pmtu_value "1400" "${pmtu_1}" "exceeding MTU" || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) pmtu_2="$(route_get_dst_pmtu_from_exception "${ns_a}" ${dst2})"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) check_pmtu_value "1500" "${pmtu_2}" "exceeding MTU" || return 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) # Replace the route from A to R1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) run_cmd ${ns_a} ip route change default via ${gw}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) # Delete the device in A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) run_cmd ${ns_a} ip link del "veth_A-R1"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) test_pmtu_ipv4_route_change() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836) test_pmtu_ipvX_route_change 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) test_pmtu_ipv6_route_change() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) test_pmtu_ipvX_route_change 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) usage() {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) echo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) echo "$0 [OPTIONS] [TEST]..."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) echo "If no TEST argument is given, all tests will be run."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) echo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) echo "Options"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) echo " --trace: capture traffic to TEST_INTERFACE.pcap"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) echo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) echo "Available tests${tests}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) ################################################################################
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) exitcode=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) desc=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) while getopts :ptv o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) case $o in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) p) PAUSE_ON_FAIL=yes;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) v) VERBOSE=1;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865) t) if which tcpdump > /dev/null 2>&1; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) TRACING=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) echo "=== tcpdump not available, tracing disabled"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) ;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) *) usage;;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) esac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) shift $(($OPTIND-1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) IFS="
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) for arg do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) # Check first that all requested tests are available before running any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) command -v > /dev/null "test_${arg}" || { echo "=== Test ${arg} not found"; usage; }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) trap cleanup EXIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) # start clean
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) cleanup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) HAVE_NH=no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) ip nexthop ls >/dev/null 2>&1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) [ $? -eq 0 ] && HAVE_NH=yes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) name=""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) desc=""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) rerun_nh=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) for t in ${tests}; do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) [ "${name}" = "" ] && name="${t}" && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) [ "${desc}" = "" ] && desc="${t}" && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) if [ "${HAVE_NH}" = "yes" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) rerun_nh="${t}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) run_this=1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) for arg do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) [ "${arg}" != "${arg#--*}" ] && continue
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) [ "${arg}" = "${name}" ] && run_this=1 && break
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) run_this=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910) if [ $run_this -eq 1 ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) run_test "${name}" "${desc}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) # if test was skipped no need to retry with nexthop objects
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) [ $? -eq 2 ] && rerun_nh=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) if [ "${rerun_nh}" = "1" ]; then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) run_test_nh "${name}" "${desc}"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) fi
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) name=""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) desc=""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) rerun_nh=0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) done
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) exit ${exitcode}