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