Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 1 | import socket |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 2 | |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 3 | import scapy.compat |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 4 | from scapy.layers.inet import IP, UDP |
Klement Sekera | 65cc8c0 | 2016-12-18 15:49:54 +0100 | [diff] [blame] | 5 | from scapy.layers.inet6 import IPv6 |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 6 | from scapy.layers.l2 import Ether, GRE |
| 7 | from scapy.packet import Raw |
Hongjun Ni | 6fb0d9b | 2018-06-08 07:12:05 +0800 | [diff] [blame] | 8 | from scapy.data import IP_PROTOS |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 9 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 10 | from framework import VppTestCase |
Klement Sekera | 7bb873a | 2016-11-18 07:38:42 +0100 | [diff] [blame] | 11 | from util import ppp |
Neale Ranns | 097fa66 | 2018-05-01 05:17:55 -0700 | [diff] [blame] | 12 | from vpp_ip_route import VppIpRoute, VppRoutePath |
| 13 | from vpp_ip import INVALID_INDEX |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 14 | |
| 15 | """ TestLB is a subclass of VPPTestCase classes. |
| 16 | |
| 17 | TestLB class defines Load Balancer test cases for: |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 18 | - IP4 to GRE4 encap on per-port vip case |
| 19 | - IP4 to GRE6 encap on per-port vip case |
| 20 | - IP6 to GRE4 encap on per-port vip case |
| 21 | - IP6 to GRE6 encap on per-port vip case |
| 22 | - IP4 to L3DSR encap on vip case |
| 23 | - IP4 to L3DSR encap on per-port vip case |
Nobuhiro MIKI | 613e6dc | 2022-09-28 15:53:17 +0900 | [diff] [blame] | 24 | - IP4 to L3DSR encap on per-port vip with src_ip_sticky case |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 25 | - IP4 to NAT4 encap on per-port vip case |
| 26 | - IP6 to NAT6 encap on per-port vip case |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 27 | |
| 28 | As stated in comments below, GRE has issues with IPv6. |
| 29 | All test cases involving IPv6 are executed, but |
| 30 | received packets are not parsed and checked. |
| 31 | |
| 32 | """ |
| 33 | |
| 34 | |
| 35 | class TestLB(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 36 | """Load Balancer Test Case""" |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 37 | |
| 38 | @classmethod |
| 39 | def setUpClass(cls): |
| 40 | super(TestLB, cls).setUpClass() |
| 41 | |
| 42 | cls.ass = range(5) |
Nobuhiro MIKI | 613e6dc | 2022-09-28 15:53:17 +0900 | [diff] [blame] | 43 | cls.packets = range(100) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 44 | |
| 45 | try: |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 46 | cls.create_pg_interfaces(range(2)) |
| 47 | cls.interfaces = list(cls.pg_interfaces) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 48 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 49 | for i in cls.interfaces: |
| 50 | i.admin_up() |
| 51 | i.config_ip4() |
| 52 | i.config_ip6() |
| 53 | i.disable_ipv6_ra() |
| 54 | i.resolve_arp() |
| 55 | i.resolve_ndp() |
Neale Ranns | 097fa66 | 2018-05-01 05:17:55 -0700 | [diff] [blame] | 56 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 57 | dst4 = VppIpRoute( |
| 58 | cls, |
| 59 | "10.0.0.0", |
| 60 | 24, |
| 61 | [VppRoutePath(cls.pg1.remote_ip4, INVALID_INDEX)], |
| 62 | register=False, |
| 63 | ) |
Neale Ranns | 097fa66 | 2018-05-01 05:17:55 -0700 | [diff] [blame] | 64 | dst4.add_vpp_config() |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 65 | dst6 = VppIpRoute( |
| 66 | cls, |
| 67 | "2002::", |
| 68 | 16, |
| 69 | [VppRoutePath(cls.pg1.remote_ip6, INVALID_INDEX)], |
| 70 | register=False, |
| 71 | ) |
Neale Ranns | 097fa66 | 2018-05-01 05:17:55 -0700 | [diff] [blame] | 72 | dst6.add_vpp_config() |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 73 | cls.vapi.lb_conf(ip4_src_address="39.40.41.42", ip6_src_address="2004::1") |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 74 | except Exception: |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 75 | super(TestLB, cls).tearDownClass() |
| 76 | raise |
| 77 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 78 | @classmethod |
| 79 | def tearDownClass(cls): |
| 80 | super(TestLB, cls).tearDownClass() |
| 81 | |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 82 | def tearDown(self): |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 83 | super(TestLB, self).tearDown() |
Paul Vinciguerra | 90cf21b | 2019-03-13 09:23:05 -0700 | [diff] [blame] | 84 | |
| 85 | def show_commands_at_teardown(self): |
| 86 | self.logger.info(self.vapi.cli("show lb vip verbose")) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 87 | |
| 88 | def getIPv4Flow(self, id): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 89 | return IP( |
| 90 | dst="90.0.%u.%u" % (id / 255, id % 255), |
| 91 | src="40.0.%u.%u" % (id / 255, id % 255), |
| 92 | ) / UDP(sport=10000 + id, dport=20000) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 93 | |
| 94 | def getIPv6Flow(self, id): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 95 | return IPv6(dst="2001::%u" % (id), src="fd00:f00d:ffff::%u" % (id)) / UDP( |
| 96 | sport=10000 + id, dport=20000 |
| 97 | ) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 98 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 99 | def generatePackets(self, src_if, isv4): |
Klement Sekera | dab231a | 2016-12-21 08:50:14 +0100 | [diff] [blame] | 100 | self.reset_packet_infos() |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 101 | pkts = [] |
| 102 | for pktid in self.packets: |
Klement Sekera | dab231a | 2016-12-21 08:50:14 +0100 | [diff] [blame] | 103 | info = self.create_packet_info(src_if, self.pg1) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 104 | payload = self.info_to_payload(info) |
| 105 | ip = self.getIPv4Flow(pktid) if isv4 else self.getIPv6Flow(pktid) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 106 | packet = ( |
| 107 | Ether(dst=src_if.local_mac, src=src_if.remote_mac) / ip / Raw(payload) |
| 108 | ) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 109 | self.extend_packet(packet, 128) |
| 110 | info.data = packet.copy() |
| 111 | pkts.append(packet) |
| 112 | return pkts |
| 113 | |
| 114 | def checkInner(self, gre, isv4): |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 115 | IPver = IP if isv4 else IPv6 |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 116 | self.assertEqual(gre.proto, 0x0800 if isv4 else 0x86DD) |
| 117 | self.assertEqual(gre.flags, 0) |
| 118 | self.assertEqual(gre.version, 0) |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 119 | inner = IPver(scapy.compat.raw(gre.payload)) |
Paul Vinciguerra | eaea421 | 2019-03-06 11:58:06 -0800 | [diff] [blame] | 120 | payload_info = self.payload_to_info(inner[Raw]) |
Klement Sekera | dab231a | 2016-12-21 08:50:14 +0100 | [diff] [blame] | 121 | self.info = self.packet_infos[payload_info.index] |
| 122 | self.assertEqual(payload_info.src, self.pg0.sw_if_index) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 123 | self.assertEqual( |
| 124 | scapy.compat.raw(inner), scapy.compat.raw(self.info.data[IPver]) |
| 125 | ) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 126 | |
Nobuhiro MIKI | 613e6dc | 2022-09-28 15:53:17 +0900 | [diff] [blame] | 127 | def checkCapture(self, encap, isv4, src_ip_sticky=False): |
Klement Sekera | 65cc8c0 | 2016-12-18 15:49:54 +0100 | [diff] [blame] | 128 | self.pg0.assert_nothing_captured() |
Klement Sekera | dab231a | 2016-12-21 08:50:14 +0100 | [diff] [blame] | 129 | out = self.pg1.get_capture(len(self.packets)) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 130 | |
| 131 | load = [0] * len(self.ass) |
Nobuhiro MIKI | 613e6dc | 2022-09-28 15:53:17 +0900 | [diff] [blame] | 132 | sticky_as = {} |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 133 | self.info = None |
| 134 | for p in out: |
| 135 | try: |
| 136 | asid = 0 |
| 137 | gre = None |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 138 | if encap == "gre4": |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 139 | ip = p[IP] |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 140 | asid = int(ip.dst.split(".")[3]) |
| 141 | self.assertEqual(ip.version, 4) |
| 142 | self.assertEqual(ip.flags, 0) |
| 143 | self.assertEqual(ip.src, "39.40.41.42") |
| 144 | self.assertEqual(ip.dst, "10.0.0.%u" % asid) |
| 145 | self.assertEqual(ip.proto, 47) |
| 146 | self.assertEqual(len(ip.options), 0) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 147 | gre = p[GRE] |
Hongjun Ni | 647f609 | 2018-01-23 19:17:23 +0800 | [diff] [blame] | 148 | self.checkInner(gre, isv4) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 149 | elif encap == "gre6": |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 150 | ip = p[IPv6] |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 151 | asid = ip.dst.split(":") |
| 152 | asid = asid[len(asid) - 1] |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 153 | asid = 0 if asid == "" else int(asid) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 154 | self.assertEqual(ip.version, 6) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 155 | self.assertEqual(ip.tc, 0) |
| 156 | self.assertEqual(ip.fl, 0) |
| 157 | self.assertEqual(ip.src, "2004::1") |
| 158 | self.assertEqual( |
| 159 | socket.inet_pton(socket.AF_INET6, ip.dst), |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 160 | socket.inet_pton(socket.AF_INET6, "2002::%u" % asid), |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 161 | ) |
| 162 | self.assertEqual(ip.nh, 47) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 163 | # self.assertEqual(len(ip.options), 0) |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 164 | gre = GRE(scapy.compat.raw(p[IPv6].payload)) |
Hongjun Ni | 647f609 | 2018-01-23 19:17:23 +0800 | [diff] [blame] | 165 | self.checkInner(gre, isv4) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 166 | elif encap == "l3dsr": |
Hongjun Ni | 647f609 | 2018-01-23 19:17:23 +0800 | [diff] [blame] | 167 | ip = p[IP] |
| 168 | asid = int(ip.dst.split(".")[3]) |
| 169 | self.assertEqual(ip.version, 4) |
| 170 | self.assertEqual(ip.flags, 0) |
| 171 | self.assertEqual(ip.dst, "10.0.0.%u" % asid) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 172 | self.assertEqual(ip.tos, 0x1C) |
Hongjun Ni | 647f609 | 2018-01-23 19:17:23 +0800 | [diff] [blame] | 173 | self.assertEqual(len(ip.options), 0) |
Hongjun Ni | 6fb0d9b | 2018-06-08 07:12:05 +0800 | [diff] [blame] | 174 | self.assert_ip_checksum_valid(p) |
| 175 | if ip.proto == IP_PROTOS.tcp: |
| 176 | self.assert_tcp_checksum_valid(p) |
| 177 | elif ip.proto == IP_PROTOS.udp: |
| 178 | self.assert_udp_checksum_valid(p) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 179 | elif encap == "nat4": |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 180 | ip = p[IP] |
| 181 | asid = int(ip.dst.split(".")[3]) |
| 182 | self.assertEqual(ip.version, 4) |
| 183 | self.assertEqual(ip.flags, 0) |
| 184 | self.assertEqual(ip.dst, "10.0.0.%u" % asid) |
| 185 | self.assertEqual(ip.proto, 17) |
| 186 | self.assertEqual(len(ip.options), 0) |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 187 | udp = p[UDP] |
| 188 | self.assertEqual(udp.dport, 3307) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 189 | elif encap == "nat6": |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 190 | ip = p[IPv6] |
| 191 | asid = ip.dst.split(":") |
| 192 | asid = asid[len(asid) - 1] |
| 193 | asid = 0 if asid == "" else int(asid) |
| 194 | self.assertEqual(ip.version, 6) |
| 195 | self.assertEqual(ip.tc, 0) |
| 196 | self.assertEqual(ip.fl, 0) |
| 197 | self.assertEqual( |
| 198 | socket.inet_pton(socket.AF_INET6, ip.dst), |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 199 | socket.inet_pton(socket.AF_INET6, "2002::%u" % asid), |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 200 | ) |
| 201 | self.assertEqual(ip.nh, 17) |
| 202 | self.assertGreaterEqual(ip.hlim, 63) |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 203 | udp = UDP(scapy.compat.raw(p[IPv6].payload)) |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 204 | self.assertEqual(udp.dport, 3307) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 205 | load[asid] += 1 |
Nobuhiro MIKI | 613e6dc | 2022-09-28 15:53:17 +0900 | [diff] [blame] | 206 | |
| 207 | # In case of source ip sticky, check that packets with same |
| 208 | # src_ip are routed to same as. |
| 209 | if src_ip_sticky and sticky_as.get(ip.src, asid) != asid: |
| 210 | raise Exception("Packets with same src_ip are routed to another as") |
| 211 | sticky_as[ip.src] = asid |
| 212 | |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 213 | except: |
Klement Sekera | 7bb873a | 2016-11-18 07:38:42 +0100 | [diff] [blame] | 214 | self.logger.error(ppp("Unexpected or invalid packet:", p)) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 215 | raise |
| 216 | |
Paul Vinciguerra | f7f1334 | 2019-03-19 11:54:39 -0700 | [diff] [blame] | 217 | # This is just to roughly check that the balancing algorithm |
| 218 | # is not completely biased. |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 219 | for asid in self.ass: |
snaramre | ec44e26 | 2019-10-16 22:36:47 +0000 | [diff] [blame] | 220 | if load[asid] < int(len(self.packets) / (len(self.ass) * 2)): |
Gabriel Ganne | 8e66b9b | 2017-12-14 16:20:37 +0100 | [diff] [blame] | 221 | self.logger.error( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 222 | "ASS is not balanced: load[%d] = %d" % (asid, load[asid]) |
| 223 | ) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 224 | raise Exception("Load Balancer algorithm is biased") |
| 225 | |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 226 | def test_lb_ip4_gre4(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 227 | """Load Balancer IP4 GRE4 on vip case""" |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 228 | try: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 229 | self.vapi.cli("lb vip 90.0.0.0/8 encap gre4") |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 230 | for asid in self.ass: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 231 | self.vapi.cli("lb as 90.0.0.0/8 10.0.0.%u" % (asid)) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 232 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 233 | self.pg0.add_stream(self.generatePackets(self.pg0, isv4=True)) |
| 234 | self.pg_enable_capture(self.pg_interfaces) |
| 235 | self.pg_start() |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 236 | self.checkCapture(encap="gre4", isv4=True) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 237 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 238 | finally: |
| 239 | for asid in self.ass: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 240 | self.vapi.cli("lb as 90.0.0.0/8 10.0.0.%u del" % (asid)) |
| 241 | self.vapi.cli("lb vip 90.0.0.0/8 encap gre4 del") |
Gabriel Ganne | b3d1b20 | 2017-10-30 15:44:31 +0100 | [diff] [blame] | 242 | self.vapi.cli("test lb flowtable flush") |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 243 | |
| 244 | def test_lb_ip6_gre4(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 245 | """Load Balancer IP6 GRE4 on vip case""" |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 246 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 247 | try: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 248 | self.vapi.cli("lb vip 2001::/16 encap gre4") |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 249 | for asid in self.ass: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 250 | self.vapi.cli("lb as 2001::/16 10.0.0.%u" % (asid)) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 251 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 252 | self.pg0.add_stream(self.generatePackets(self.pg0, isv4=False)) |
| 253 | self.pg_enable_capture(self.pg_interfaces) |
| 254 | self.pg_start() |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 255 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 256 | self.checkCapture(encap="gre4", isv4=False) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 257 | finally: |
| 258 | for asid in self.ass: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 259 | self.vapi.cli("lb as 2001::/16 10.0.0.%u del" % (asid)) |
| 260 | self.vapi.cli("lb vip 2001::/16 encap gre4 del") |
Gabriel Ganne | b3d1b20 | 2017-10-30 15:44:31 +0100 | [diff] [blame] | 261 | self.vapi.cli("test lb flowtable flush") |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 262 | |
| 263 | def test_lb_ip4_gre6(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 264 | """Load Balancer IP4 GRE6 on vip case""" |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 265 | try: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 266 | self.vapi.cli("lb vip 90.0.0.0/8 encap gre6") |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 267 | for asid in self.ass: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 268 | self.vapi.cli("lb as 90.0.0.0/8 2002::%u" % (asid)) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 269 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 270 | self.pg0.add_stream(self.generatePackets(self.pg0, isv4=True)) |
| 271 | self.pg_enable_capture(self.pg_interfaces) |
| 272 | self.pg_start() |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 273 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 274 | self.checkCapture(encap="gre6", isv4=True) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 275 | finally: |
| 276 | for asid in self.ass: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 277 | self.vapi.cli("lb as 90.0.0.0/8 2002::%u del" % (asid)) |
| 278 | self.vapi.cli("lb vip 90.0.0.0/8 encap gre6 del") |
Gabriel Ganne | b3d1b20 | 2017-10-30 15:44:31 +0100 | [diff] [blame] | 279 | self.vapi.cli("test lb flowtable flush") |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 280 | |
| 281 | def test_lb_ip6_gre6(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 282 | """Load Balancer IP6 GRE6 on vip case""" |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 283 | try: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 284 | self.vapi.cli("lb vip 2001::/16 encap gre6") |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 285 | for asid in self.ass: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 286 | self.vapi.cli("lb as 2001::/16 2002::%u" % (asid)) |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 287 | |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 288 | self.pg0.add_stream(self.generatePackets(self.pg0, isv4=False)) |
| 289 | self.pg_enable_capture(self.pg_interfaces) |
| 290 | self.pg_start() |
Pierre Pfister | f588f35 | 2016-10-07 16:31:57 +0100 | [diff] [blame] | 291 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 292 | self.checkCapture(encap="gre6", isv4=False) |
Klement Sekera | f62ae12 | 2016-10-11 11:47:09 +0200 | [diff] [blame] | 293 | finally: |
| 294 | for asid in self.ass: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 295 | self.vapi.cli("lb as 2001::/16 2002::%u del" % (asid)) |
| 296 | self.vapi.cli("lb vip 2001::/16 encap gre6 del") |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 297 | self.vapi.cli("test lb flowtable flush") |
| 298 | |
| 299 | def test_lb_ip4_gre4_port(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 300 | """Load Balancer IP4 GRE4 on per-port-vip case""" |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 301 | try: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 302 | self.vapi.cli("lb vip 90.0.0.0/8 protocol udp port 20000 encap gre4") |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 303 | for asid in self.ass: |
| 304 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 305 | "lb as 90.0.0.0/8 protocol udp port 20000 10.0.0.%u" % (asid) |
| 306 | ) |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 307 | |
| 308 | self.pg0.add_stream(self.generatePackets(self.pg0, isv4=True)) |
| 309 | self.pg_enable_capture(self.pg_interfaces) |
| 310 | self.pg_start() |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 311 | self.checkCapture(encap="gre4", isv4=True) |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 312 | |
| 313 | finally: |
| 314 | for asid in self.ass: |
| 315 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 316 | "lb as 90.0.0.0/8 protocol udp port 20000 10.0.0.%u del" % (asid) |
| 317 | ) |
| 318 | self.vapi.cli("lb vip 90.0.0.0/8 protocol udp port 20000 encap gre4 del") |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 319 | self.vapi.cli("test lb flowtable flush") |
| 320 | |
| 321 | def test_lb_ip6_gre4_port(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 322 | """Load Balancer IP6 GRE4 on per-port-vip case""" |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 323 | |
| 324 | try: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 325 | self.vapi.cli("lb vip 2001::/16 protocol udp port 20000 encap gre4") |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 326 | for asid in self.ass: |
| 327 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 328 | "lb as 2001::/16 protocol udp port 20000 10.0.0.%u" % (asid) |
| 329 | ) |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 330 | |
| 331 | self.pg0.add_stream(self.generatePackets(self.pg0, isv4=False)) |
| 332 | self.pg_enable_capture(self.pg_interfaces) |
| 333 | self.pg_start() |
| 334 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 335 | self.checkCapture(encap="gre4", isv4=False) |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 336 | finally: |
| 337 | for asid in self.ass: |
| 338 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 339 | "lb as 2001::/16 protocol udp port 20000 10.0.0.%u del" % (asid) |
| 340 | ) |
| 341 | self.vapi.cli("lb vip 2001::/16 protocol udp port 20000 encap gre4 del") |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 342 | self.vapi.cli("test lb flowtable flush") |
| 343 | |
| 344 | def test_lb_ip4_gre6_port(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 345 | """Load Balancer IP4 GRE6 on per-port-vip case""" |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 346 | try: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 347 | self.vapi.cli("lb vip 90.0.0.0/8 protocol udp port 20000 encap gre6") |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 348 | for asid in self.ass: |
| 349 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 350 | "lb as 90.0.0.0/8 protocol udp port 20000 2002::%u" % (asid) |
| 351 | ) |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 352 | |
| 353 | self.pg0.add_stream(self.generatePackets(self.pg0, isv4=True)) |
| 354 | self.pg_enable_capture(self.pg_interfaces) |
| 355 | self.pg_start() |
| 356 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 357 | self.checkCapture(encap="gre6", isv4=True) |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 358 | finally: |
| 359 | for asid in self.ass: |
| 360 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 361 | "lb as 90.0.0.0/8 protocol udp port 20000 2002::%u del" % (asid) |
| 362 | ) |
| 363 | self.vapi.cli("lb vip 90.0.0.0/8 protocol udp port 20000 encap gre6 del") |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 364 | self.vapi.cli("test lb flowtable flush") |
| 365 | |
| 366 | def test_lb_ip6_gre6_port(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 367 | """Load Balancer IP6 GRE6 on per-port-vip case""" |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 368 | try: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 369 | self.vapi.cli("lb vip 2001::/16 protocol udp port 20000 encap gre6") |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 370 | for asid in self.ass: |
| 371 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 372 | "lb as 2001::/16 protocol udp port 20000 2002::%u" % (asid) |
| 373 | ) |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 374 | |
| 375 | self.pg0.add_stream(self.generatePackets(self.pg0, isv4=False)) |
| 376 | self.pg_enable_capture(self.pg_interfaces) |
| 377 | self.pg_start() |
| 378 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 379 | self.checkCapture(encap="gre6", isv4=False) |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 380 | finally: |
| 381 | for asid in self.ass: |
| 382 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 383 | "lb as 2001::/16 protocol udp port 20000 2002::%u del" % (asid) |
| 384 | ) |
| 385 | self.vapi.cli("lb vip 2001::/16 protocol udp port 20000 encap gre6 del") |
Gabriel Ganne | b3d1b20 | 2017-10-30 15:44:31 +0100 | [diff] [blame] | 386 | self.vapi.cli("test lb flowtable flush") |
Hongjun Ni | 647f609 | 2018-01-23 19:17:23 +0800 | [diff] [blame] | 387 | |
| 388 | def test_lb_ip4_l3dsr(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 389 | """Load Balancer IP4 L3DSR on vip case""" |
Hongjun Ni | 647f609 | 2018-01-23 19:17:23 +0800 | [diff] [blame] | 390 | try: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 391 | self.vapi.cli("lb vip 90.0.0.0/8 encap l3dsr dscp 7") |
Hongjun Ni | 647f609 | 2018-01-23 19:17:23 +0800 | [diff] [blame] | 392 | for asid in self.ass: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 393 | self.vapi.cli("lb as 90.0.0.0/8 10.0.0.%u" % (asid)) |
Hongjun Ni | 647f609 | 2018-01-23 19:17:23 +0800 | [diff] [blame] | 394 | |
| 395 | self.pg0.add_stream(self.generatePackets(self.pg0, isv4=True)) |
| 396 | self.pg_enable_capture(self.pg_interfaces) |
| 397 | self.pg_start() |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 398 | self.checkCapture(encap="l3dsr", isv4=True) |
Hongjun Ni | 647f609 | 2018-01-23 19:17:23 +0800 | [diff] [blame] | 399 | |
| 400 | finally: |
| 401 | for asid in self.ass: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 402 | self.vapi.cli("lb as 90.0.0.0/8 10.0.0.%u del" % (asid)) |
| 403 | self.vapi.cli("lb vip 90.0.0.0/8 encap l3dsr dscp 7 del") |
Hongjun Ni | 647f609 | 2018-01-23 19:17:23 +0800 | [diff] [blame] | 404 | self.vapi.cli("test lb flowtable flush") |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 405 | |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 406 | def test_lb_ip4_l3dsr_port(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 407 | """Load Balancer IP4 L3DSR on per-port-vip case""" |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 408 | try: |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 409 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 410 | "lb vip 90.0.0.0/8 protocol udp port 20000 encap l3dsr dscp 7" |
| 411 | ) |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 412 | for asid in self.ass: |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 413 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 414 | "lb as 90.0.0.0/8 protocol udp port 20000 10.0.0.%u" % (asid) |
| 415 | ) |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 416 | |
| 417 | self.pg0.add_stream(self.generatePackets(self.pg0, isv4=True)) |
| 418 | self.pg_enable_capture(self.pg_interfaces) |
| 419 | self.pg_start() |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 420 | self.checkCapture(encap="l3dsr", isv4=True) |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 421 | |
| 422 | finally: |
| 423 | for asid in self.ass: |
| 424 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 425 | "lb as 90.0.0.0/8 protocol udp port 20000 10.0.0.%u del" % (asid) |
| 426 | ) |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 427 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 428 | "lb vip 90.0.0.0/8 protocol udp port 20000 encap l3dsr dscp 7 del" |
| 429 | ) |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 430 | self.vapi.cli("test lb flowtable flush") |
| 431 | |
Nobuhiro MIKI | 613e6dc | 2022-09-28 15:53:17 +0900 | [diff] [blame] | 432 | def test_lb_ip4_l3dsr_port_src_ip_sticky(self): |
| 433 | """Load Balancer IP4 L3DSR on per-port-vip with src_ip_sticky case""" |
| 434 | try: |
| 435 | self.vapi.cli( |
| 436 | "lb vip 90.0.0.0/8 protocol udp port 20000 encap l3dsr dscp 7 src_ip_sticky" |
| 437 | ) |
| 438 | for asid in self.ass: |
| 439 | self.vapi.cli( |
| 440 | "lb as 90.0.0.0/8 protocol udp port 20000 10.0.0.%u" % (asid) |
| 441 | ) |
| 442 | |
| 443 | # Generate duplicated packets |
| 444 | pkts = self.generatePackets(self.pg0, isv4=True) |
| 445 | pkts = pkts[: len(pkts) // 2] |
| 446 | pkts = pkts + pkts |
| 447 | |
| 448 | self.pg0.add_stream(pkts) |
| 449 | self.pg_enable_capture(self.pg_interfaces) |
| 450 | self.pg_start() |
| 451 | self.checkCapture(encap="l3dsr", isv4=True, src_ip_sticky=True) |
| 452 | |
| 453 | finally: |
| 454 | for asid in self.ass: |
| 455 | self.vapi.cli( |
| 456 | "lb as 90.0.0.0/8 protocol udp port 20000 10.0.0.%u del" % (asid) |
| 457 | ) |
| 458 | self.vapi.cli( |
| 459 | "lb vip 90.0.0.0/8 protocol udp port 20000 encap l3dsr dscp 7 src_ip_sticky del" |
| 460 | ) |
| 461 | self.vapi.cli("test lb flowtable flush") |
| 462 | |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 463 | def test_lb_ip4_nat4_port(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 464 | """Load Balancer IP4 NAT4 on per-port-vip case""" |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 465 | try: |
| 466 | self.vapi.cli( |
| 467 | "lb vip 90.0.0.0/8 protocol udp port 20000 encap nat4" |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 468 | " type clusterip target_port 3307" |
| 469 | ) |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 470 | for asid in self.ass: |
| 471 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 472 | "lb as 90.0.0.0/8 protocol udp port 20000 10.0.0.%u" % (asid) |
| 473 | ) |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 474 | |
| 475 | self.pg0.add_stream(self.generatePackets(self.pg0, isv4=True)) |
| 476 | self.pg_enable_capture(self.pg_interfaces) |
| 477 | self.pg_start() |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 478 | self.checkCapture(encap="nat4", isv4=True) |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 479 | |
| 480 | finally: |
| 481 | for asid in self.ass: |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 482 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 483 | "lb as 90.0.0.0/8 protocol udp port 20000 10.0.0.%u del" % (asid) |
| 484 | ) |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 485 | self.vapi.cli( |
| 486 | "lb vip 90.0.0.0/8 protocol udp port 20000 encap nat4" |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 487 | " type clusterip target_port 3307 del" |
| 488 | ) |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 489 | self.vapi.cli("test lb flowtable flush") |
| 490 | |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 491 | def test_lb_ip6_nat6_port(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 492 | """Load Balancer IP6 NAT6 on per-port-vip case""" |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 493 | try: |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 494 | self.vapi.cli( |
| 495 | "lb vip 2001::/16 protocol udp port 20000 encap nat6" |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 496 | " type clusterip target_port 3307" |
| 497 | ) |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 498 | for asid in self.ass: |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 499 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 500 | "lb as 2001::/16 protocol udp port 20000 2002::%u" % (asid) |
| 501 | ) |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 502 | |
| 503 | self.pg0.add_stream(self.generatePackets(self.pg0, isv4=False)) |
| 504 | self.pg_enable_capture(self.pg_interfaces) |
| 505 | self.pg_start() |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 506 | self.checkCapture(encap="nat6", isv4=False) |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 507 | |
| 508 | finally: |
| 509 | for asid in self.ass: |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 510 | self.vapi.cli( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 511 | "lb as 2001::/16 protocol udp port 20000 2002::%u del" % (asid) |
| 512 | ) |
Hongjun Ni | 219cc90 | 2018-06-28 20:14:19 +0800 | [diff] [blame] | 513 | self.vapi.cli( |
| 514 | "lb vip 2001::/16 protocol udp port 20000 encap nat6" |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 515 | " type clusterip target_port 3307 del" |
| 516 | ) |
Hongjun Ni | d92a0b5 | 2018-02-06 23:00:22 +0800 | [diff] [blame] | 517 | self.vapi.cli("test lb flowtable flush") |