Renato Botelho do Couto | ead1e53 | 2019-10-31 13:31:07 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 2 | |
Paul Vinciguerra | 8feeaff | 2019-03-27 11:25:48 -0700 | [diff] [blame] | 3 | import unittest |
| 4 | |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 5 | from framework import VppTestCase |
| 6 | from asfframework import VppTestRunner |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 7 | from vpp_ip_route import VppIpTable |
| 8 | |
| 9 | from scapy.packet import Raw |
| 10 | from scapy.layers.l2 import Ether |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 11 | from scapy.layers.inet import IP, UDP |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 12 | from scapy.layers.inet6 import IPv6 |
| 13 | |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 14 | from vpp_papi import VppEnum |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 15 | from config import config |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 16 | |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 17 | NUM_PKTS = 67 |
| 18 | |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 19 | |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 20 | @unittest.skipIf("svs" in config.excluded_plugins, "Exclude SVS plugin tests") |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 21 | class TestSVS(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 22 | """SVS Test Case""" |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 23 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 24 | @classmethod |
| 25 | def setUpClass(cls): |
| 26 | super(TestSVS, cls).setUpClass() |
| 27 | |
| 28 | @classmethod |
| 29 | def tearDownClass(cls): |
| 30 | super(TestSVS, cls).tearDownClass() |
| 31 | |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 32 | def setUp(self): |
| 33 | super(TestSVS, self).setUp() |
| 34 | |
| 35 | # create 2 pg interfaces |
| 36 | self.create_pg_interfaces(range(4)) |
| 37 | |
| 38 | table_id = 0 |
| 39 | |
| 40 | for i in self.pg_interfaces: |
| 41 | i.admin_up() |
| 42 | |
| 43 | if table_id != 0: |
| 44 | tbl = VppIpTable(self, table_id) |
| 45 | tbl.add_vpp_config() |
| 46 | tbl = VppIpTable(self, table_id, is_ip6=1) |
| 47 | tbl.add_vpp_config() |
| 48 | |
| 49 | i.set_table_ip4(table_id) |
| 50 | i.set_table_ip6(table_id) |
| 51 | i.config_ip4() |
| 52 | i.resolve_arp() |
| 53 | i.config_ip6() |
| 54 | i.resolve_ndp() |
| 55 | table_id += 1 |
| 56 | |
| 57 | def tearDown(self): |
| 58 | for i in self.pg_interfaces: |
| 59 | i.unconfig_ip4() |
| 60 | i.unconfig_ip6() |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 61 | i.set_table_ip4(0) |
| 62 | i.set_table_ip6(0) |
| 63 | i.admin_down() |
| 64 | super(TestSVS, self).tearDown() |
| 65 | |
| 66 | def test_svs4(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 67 | """Source VRF Select IP4""" |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 68 | |
| 69 | # |
Paul Vinciguerra | 8feeaff | 2019-03-27 11:25:48 -0700 | [diff] [blame] | 70 | # packets destined out of the 3 non-default table interfaces |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 71 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 72 | pkts_0 = [ |
| 73 | ( |
| 74 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 75 | / IP(src="1.1.1.1", dst=self.pg1.remote_ip4) |
| 76 | / UDP(sport=1234, dport=1234) |
| 77 | / Raw(b"\xa5" * 100) |
| 78 | ), |
| 79 | ( |
| 80 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 81 | / IP(src="2.2.2.2", dst=self.pg2.remote_ip4) |
| 82 | / UDP(sport=1234, dport=1234) |
| 83 | / Raw(b"\xa5" * 100) |
| 84 | ), |
| 85 | ( |
| 86 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 87 | / IP(src="3.3.3.3", dst=self.pg3.remote_ip4) |
| 88 | / UDP(sport=1234, dport=1234) |
| 89 | / Raw(b"\xa5" * 100) |
| 90 | ), |
| 91 | ] |
| 92 | pkts_1 = [ |
| 93 | ( |
| 94 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) |
| 95 | / IP(src="1.1.1.1", dst=self.pg1.remote_ip4) |
| 96 | / UDP(sport=1234, dport=1234) |
| 97 | / Raw(b"\xa5" * 100) |
| 98 | ), |
| 99 | ( |
| 100 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) |
| 101 | / IP(src="2.2.2.2", dst=self.pg2.remote_ip4) |
| 102 | / UDP(sport=1234, dport=1234) |
| 103 | / Raw(b"\xa5" * 100) |
| 104 | ), |
| 105 | ( |
| 106 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) |
| 107 | / IP(src="3.3.3.3", dst=self.pg3.remote_ip4) |
| 108 | / UDP(sport=1234, dport=1234) |
| 109 | / Raw(b"\xa5" * 100) |
| 110 | ), |
| 111 | ] |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 112 | |
| 113 | # |
| 114 | # before adding the SVS config all these packets are dropped when |
| 115 | # ingressing on pg0 since pg0 is in the default table |
| 116 | # |
| 117 | for p in pkts_0: |
| 118 | self.send_and_assert_no_replies(self.pg0, p * 1) |
| 119 | |
| 120 | # |
| 121 | # Add table 1001 & 1002 into which we'll add the routes |
Paul Vinciguerra | 8feeaff | 2019-03-27 11:25:48 -0700 | [diff] [blame] | 122 | # determining the source VRF selection |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 123 | # |
| 124 | table_ids = [101, 102] |
| 125 | |
| 126 | for table_id in table_ids: |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 127 | self.vapi.svs_table_add_del( |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 128 | is_add=1, |
| 129 | af=VppEnum.vl_api_address_family_t.ADDRESS_IP4, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 130 | table_id=table_id, |
| 131 | ) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 132 | |
| 133 | # |
| 134 | # map X.0.0.0/8 to each SVS table for lookup in table X |
| 135 | # |
| 136 | for i in range(1, 4): |
| 137 | self.vapi.svs_route_add_del( |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 138 | is_add=1, |
| 139 | prefix="%d.0.0.0/8" % i, |
| 140 | table_id=table_id, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 141 | source_table_id=i, |
| 142 | ) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 143 | |
| 144 | # |
| 145 | # Enable SVS on pg0/pg1 using table 1001/1002 |
| 146 | # |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 147 | self.vapi.svs_enable_disable( |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 148 | is_enable=1, |
| 149 | af=VppEnum.vl_api_address_family_t.ADDRESS_IP4, |
| 150 | table_id=table_ids[0], |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 151 | sw_if_index=self.pg0.sw_if_index, |
| 152 | ) |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 153 | self.vapi.svs_enable_disable( |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 154 | is_enable=1, |
| 155 | af=VppEnum.vl_api_address_family_t.ADDRESS_IP4, |
| 156 | table_id=table_ids[1], |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 157 | sw_if_index=self.pg1.sw_if_index, |
| 158 | ) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 159 | |
| 160 | # |
| 161 | # now all the packets should be delivered out the respective interface |
| 162 | # |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 163 | self.send_and_expect(self.pg0, pkts_0[0] * NUM_PKTS, self.pg1) |
| 164 | self.send_and_expect(self.pg0, pkts_0[1] * NUM_PKTS, self.pg2) |
| 165 | self.send_and_expect(self.pg0, pkts_0[2] * NUM_PKTS, self.pg3) |
| 166 | self.send_and_expect(self.pg1, pkts_1[0] * NUM_PKTS, self.pg1) |
| 167 | self.send_and_expect(self.pg1, pkts_1[1] * NUM_PKTS, self.pg2) |
| 168 | self.send_and_expect(self.pg1, pkts_1[2] * NUM_PKTS, self.pg3) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 169 | |
| 170 | # |
| 171 | # check that if the SVS lookup does not match a route the packet |
| 172 | # is forwarded using the interface's routing table |
| 173 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 174 | p = ( |
| 175 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 176 | / IP(src=self.pg0.remote_ip4, dst=self.pg0.remote_ip4) |
| 177 | / UDP(sport=1234, dport=1234) |
| 178 | / Raw(b"\xa5" * 100) |
| 179 | ) |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 180 | self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg0) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 181 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 182 | p = ( |
| 183 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) |
| 184 | / IP(src=self.pg1.remote_ip4, dst=self.pg1.remote_ip4) |
| 185 | / UDP(sport=1234, dport=1234) |
| 186 | / Raw(b"\xa5" * 100) |
| 187 | ) |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 188 | self.send_and_expect(self.pg1, p * NUM_PKTS, self.pg1) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 189 | |
| 190 | # |
| 191 | # dump the SVS configs |
| 192 | # |
| 193 | ss = self.vapi.svs_dump() |
| 194 | |
| 195 | self.assertEqual(ss[0].table_id, table_ids[0]) |
| 196 | self.assertEqual(ss[0].sw_if_index, self.pg0.sw_if_index) |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 197 | self.assertEqual(ss[0].af, VppEnum.vl_api_address_family_t.ADDRESS_IP4) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 198 | self.assertEqual(ss[1].table_id, table_ids[1]) |
| 199 | self.assertEqual(ss[1].sw_if_index, self.pg1.sw_if_index) |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 200 | self.assertEqual(ss[1].af, VppEnum.vl_api_address_family_t.ADDRESS_IP4) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 201 | |
| 202 | # |
| 203 | # cleanup |
| 204 | # |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 205 | self.vapi.svs_enable_disable( |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 206 | is_enable=0, |
| 207 | af=VppEnum.vl_api_address_family_t.ADDRESS_IP4, |
| 208 | table_id=table_ids[0], |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 209 | sw_if_index=self.pg0.sw_if_index, |
| 210 | ) |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 211 | self.vapi.svs_enable_disable( |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 212 | is_enable=0, |
| 213 | af=VppEnum.vl_api_address_family_t.ADDRESS_IP4, |
| 214 | table_id=table_ids[1], |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 215 | sw_if_index=self.pg1.sw_if_index, |
| 216 | ) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 217 | |
| 218 | for table_id in table_ids: |
| 219 | for i in range(1, 4): |
| 220 | self.vapi.svs_route_add_del( |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 221 | is_add=0, |
| 222 | prefix="%d.0.0.0/8" % i, |
| 223 | table_id=table_id, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 224 | source_table_id=0, |
| 225 | ) |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 226 | |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 227 | self.vapi.svs_table_add_del( |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 228 | is_add=0, |
| 229 | af=VppEnum.vl_api_address_family_t.ADDRESS_IP4, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 230 | table_id=table_id, |
| 231 | ) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 232 | |
| 233 | def test_svs6(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 234 | """Source VRF Select IP6""" |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 235 | |
| 236 | # |
Paul Vinciguerra | 8feeaff | 2019-03-27 11:25:48 -0700 | [diff] [blame] | 237 | # packets destined out of the 3 non-default table interfaces |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 238 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 239 | pkts_0 = [ |
| 240 | ( |
| 241 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 242 | / IPv6(src="2001:1::1", dst=self.pg1.remote_ip6) |
| 243 | / UDP(sport=1234, dport=1234) |
| 244 | / Raw(b"\xa5" * 100) |
| 245 | ), |
| 246 | ( |
| 247 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 248 | / IPv6(src="2001:2::1", dst=self.pg2.remote_ip6) |
| 249 | / UDP(sport=1234, dport=1234) |
| 250 | / Raw(b"\xa5" * 100) |
| 251 | ), |
| 252 | ( |
| 253 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 254 | / IPv6(src="2001:3::1", dst=self.pg3.remote_ip6) |
| 255 | / UDP(sport=1234, dport=1234) |
| 256 | / Raw(b"\xa5" * 100) |
| 257 | ), |
| 258 | ] |
| 259 | pkts_1 = [ |
| 260 | ( |
| 261 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) |
| 262 | / IPv6(src="2001:1::1", dst=self.pg1.remote_ip6) |
| 263 | / UDP(sport=1234, dport=1234) |
| 264 | / Raw(b"\xa5" * 100) |
| 265 | ), |
| 266 | ( |
| 267 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) |
| 268 | / IPv6(src="2001:2::1", dst=self.pg2.remote_ip6) |
| 269 | / UDP(sport=1234, dport=1234) |
| 270 | / Raw(b"\xa5" * 100) |
| 271 | ), |
| 272 | ( |
| 273 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) |
| 274 | / IPv6(src="2001:3::1", dst=self.pg3.remote_ip6) |
| 275 | / UDP(sport=1234, dport=1234) |
| 276 | / Raw(b"\xa5" * 100) |
| 277 | ), |
| 278 | ] |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 279 | |
| 280 | # |
| 281 | # before adding the SVS config all these packets are dropped when |
| 282 | # ingressing on pg0 since pg0 is in the default table |
| 283 | # |
| 284 | for p in pkts_0: |
| 285 | self.send_and_assert_no_replies(self.pg0, p * 1) |
| 286 | |
| 287 | # |
| 288 | # Add table 1001 & 1002 into which we'll add the routes |
Paul Vinciguerra | 8feeaff | 2019-03-27 11:25:48 -0700 | [diff] [blame] | 289 | # determining the source VRF selection |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 290 | # |
| 291 | table_ids = [101, 102] |
| 292 | |
| 293 | for table_id in table_ids: |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 294 | self.vapi.svs_table_add_del( |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 295 | is_add=1, |
| 296 | af=VppEnum.vl_api_address_family_t.ADDRESS_IP6, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 297 | table_id=table_id, |
| 298 | ) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 299 | |
| 300 | # |
| 301 | # map X.0.0.0/8 to each SVS table for lookup in table X |
| 302 | # |
| 303 | for i in range(1, 4): |
| 304 | self.vapi.svs_route_add_del( |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 305 | is_add=1, |
| 306 | prefix="2001:%d::/32" % i, |
| 307 | table_id=table_id, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 308 | source_table_id=i, |
| 309 | ) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 310 | |
| 311 | # |
| 312 | # Enable SVS on pg0/pg1 using table 1001/1002 |
| 313 | # |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 314 | self.vapi.svs_enable_disable( |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 315 | is_enable=1, |
| 316 | af=VppEnum.vl_api_address_family_t.ADDRESS_IP6, |
| 317 | table_id=table_ids[0], |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 318 | sw_if_index=self.pg0.sw_if_index, |
| 319 | ) |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 320 | self.vapi.svs_enable_disable( |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 321 | is_enable=1, |
| 322 | af=VppEnum.vl_api_address_family_t.ADDRESS_IP6, |
| 323 | table_id=table_ids[1], |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 324 | sw_if_index=self.pg1.sw_if_index, |
| 325 | ) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 326 | |
| 327 | # |
| 328 | # now all the packets should be delivered out the respective interface |
| 329 | # |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 330 | self.send_and_expect(self.pg0, pkts_0[0] * NUM_PKTS, self.pg1) |
| 331 | self.send_and_expect(self.pg0, pkts_0[1] * NUM_PKTS, self.pg2) |
| 332 | self.send_and_expect(self.pg0, pkts_0[2] * NUM_PKTS, self.pg3) |
| 333 | self.send_and_expect(self.pg1, pkts_1[0] * NUM_PKTS, self.pg1) |
| 334 | self.send_and_expect(self.pg1, pkts_1[1] * NUM_PKTS, self.pg2) |
| 335 | self.send_and_expect(self.pg1, pkts_1[2] * NUM_PKTS, self.pg3) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 336 | |
| 337 | # |
| 338 | # check that if the SVS lookup does not match a route the packet |
| 339 | # is forwarded using the interface's routing table |
| 340 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 341 | p = ( |
| 342 | Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) |
| 343 | / IPv6(src=self.pg0.remote_ip6, dst=self.pg0.remote_ip6) |
| 344 | / UDP(sport=1234, dport=1234) |
| 345 | / Raw(b"\xa5" * 100) |
| 346 | ) |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 347 | self.send_and_expect(self.pg0, p * NUM_PKTS, self.pg0) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 348 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 349 | p = ( |
| 350 | Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac) |
| 351 | / IPv6(src=self.pg1.remote_ip6, dst=self.pg1.remote_ip6) |
| 352 | / UDP(sport=1234, dport=1234) |
| 353 | / Raw(b"\xa5" * 100) |
| 354 | ) |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 355 | self.send_and_expect(self.pg1, p * NUM_PKTS, self.pg1) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 356 | |
| 357 | # |
| 358 | # dump the SVS configs |
| 359 | # |
| 360 | ss = self.vapi.svs_dump() |
| 361 | |
| 362 | self.assertEqual(ss[0].table_id, table_ids[0]) |
| 363 | self.assertEqual(ss[0].sw_if_index, self.pg0.sw_if_index) |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 364 | self.assertEqual(ss[0].af, VppEnum.vl_api_address_family_t.ADDRESS_IP6) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 365 | self.assertEqual(ss[1].table_id, table_ids[1]) |
| 366 | self.assertEqual(ss[1].sw_if_index, self.pg1.sw_if_index) |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 367 | self.assertEqual(ss[1].af, VppEnum.vl_api_address_family_t.ADDRESS_IP6) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 368 | |
| 369 | # |
| 370 | # cleanup |
| 371 | # |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 372 | self.vapi.svs_enable_disable( |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 373 | is_enable=0, |
| 374 | af=VppEnum.vl_api_address_family_t.ADDRESS_IP6, |
| 375 | table_id=table_ids[0], |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 376 | sw_if_index=self.pg0.sw_if_index, |
| 377 | ) |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 378 | self.vapi.svs_enable_disable( |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 379 | is_enable=0, |
| 380 | af=VppEnum.vl_api_address_family_t.ADDRESS_IP6, |
| 381 | table_id=table_ids[1], |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 382 | sw_if_index=self.pg1.sw_if_index, |
| 383 | ) |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 384 | |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 385 | for table_id in table_ids: |
| 386 | for i in range(1, 4): |
| 387 | self.vapi.svs_route_add_del( |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 388 | is_add=0, |
| 389 | prefix="2001:%d::/32" % i, |
| 390 | table_id=table_id, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 391 | source_table_id=0, |
| 392 | ) |
Ole Troan | 0685da4 | 2018-10-16 14:42:50 +0200 | [diff] [blame] | 393 | |
Ole Troan | 5c2a237 | 2020-11-19 16:01:23 +0100 | [diff] [blame] | 394 | self.vapi.svs_table_add_del( |
| 395 | is_add=0, |
| 396 | af=VppEnum.vl_api_address_family_t.ADDRESS_IP6, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 397 | table_id=table_id, |
| 398 | ) |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 399 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 400 | |
| 401 | if __name__ == "__main__": |
Neale Ranns | ccc70f6 | 2018-10-02 07:28:16 -0700 | [diff] [blame] | 402 | unittest.main(testRunner=VppTestRunner) |