Renato Botelho do Couto | ead1e53 | 2019-10-31 13:31:07 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 2 | |
| 3 | import unittest |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 4 | |
| 5 | from framework import VppTestCase, VppTestRunner |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 6 | from vpp_sub_interface import VppDot1QSubint |
Neale Ranns | c0a9314 | 2018-09-05 15:42:26 -0700 | [diff] [blame] | 7 | from vpp_ip import DpoProto |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 8 | from vpp_ip_route import ( |
| 9 | VppIpRoute, |
| 10 | VppRoutePath, |
| 11 | VppMplsRoute, |
| 12 | VppMplsLabel, |
| 13 | VppMplsTable, |
| 14 | FibPathProto, |
| 15 | ) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 16 | |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 17 | import scapy.compat |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 18 | from scapy.packet import Raw |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 19 | from scapy.layers.l2 import Ether, Dot1Q |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 20 | from scapy.layers.inet import IP, UDP |
| 21 | from scapy.layers.inet6 import IPv6 |
| 22 | from scapy.contrib.mpls import MPLS |
Paul Vinciguerra | b765820 | 2019-05-17 09:48:15 -0400 | [diff] [blame] | 23 | from vpp_papi import VppEnum |
Neale Ranns | 83832e7 | 2019-07-31 02:48:02 -0700 | [diff] [blame] | 24 | from vpp_qos import VppQosRecord, VppQosEgressMap, VppQosMark, VppQosStore |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 25 | |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 26 | NUM_PKTS = 67 |
| 27 | |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 28 | |
| 29 | class TestQOS(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 30 | """QOS Test Case""" |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 31 | |
Paul Vinciguerra | b765820 | 2019-05-17 09:48:15 -0400 | [diff] [blame] | 32 | # Note: Since the enums aren't created dynamically until after |
| 33 | # the papi client attaches to VPP, we put it in a property to |
| 34 | # ensure it is the value at runtime, not at module load time. |
| 35 | @property |
| 36 | def QOS_SOURCE(self): |
| 37 | return VppEnum.vl_api_qos_source_t |
| 38 | |
Paul Vinciguerra | 7f9b7f9 | 2019-03-12 19:23:27 -0700 | [diff] [blame] | 39 | @classmethod |
| 40 | def setUpClass(cls): |
| 41 | super(TestQOS, cls).setUpClass() |
| 42 | |
| 43 | @classmethod |
| 44 | def tearDownClass(cls): |
| 45 | super(TestQOS, cls).tearDownClass() |
| 46 | |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 47 | def setUp(self): |
| 48 | super(TestQOS, self).setUp() |
| 49 | |
| 50 | self.create_pg_interfaces(range(5)) |
| 51 | |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 52 | tbl = VppMplsTable(self, 0) |
| 53 | tbl.add_vpp_config() |
| 54 | |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 55 | for i in self.pg_interfaces: |
| 56 | i.admin_up() |
| 57 | i.config_ip4() |
| 58 | i.resolve_arp() |
| 59 | i.config_ip6() |
| 60 | i.resolve_ndp() |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 61 | i.enable_mpls() |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 62 | |
| 63 | def tearDown(self): |
| 64 | for i in self.pg_interfaces: |
| 65 | i.unconfig_ip4() |
| 66 | i.unconfig_ip6() |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 67 | i.disable_mpls() |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 68 | |
| 69 | super(TestQOS, self).tearDown() |
| 70 | |
| 71 | def test_qos_ip(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 72 | """QoS Mark/Record/Store IP""" |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 73 | |
| 74 | # |
| 75 | # for table 1 map the n=0xff possible values of input QoS mark, |
| 76 | # n to 1-n |
| 77 | # |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 78 | output = [scapy.compat.chb(0)] * 256 |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 79 | for i in range(0, 255): |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 80 | output[i] = scapy.compat.chb(255 - i) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 81 | os = b"".join(output) |
| 82 | rows = [{"outputs": os}, {"outputs": os}, {"outputs": os}, {"outputs": os}] |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 83 | |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 84 | qem1 = VppQosEgressMap(self, 1, rows).add_vpp_config() |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 85 | |
| 86 | # |
| 87 | # For table 2 (and up) use the value n for everything |
| 88 | # |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 89 | output = [scapy.compat.chb(2)] * 256 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 90 | os = b"".join(output) |
| 91 | rows = [{"outputs": os}, {"outputs": os}, {"outputs": os}, {"outputs": os}] |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 92 | |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 93 | qem2 = VppQosEgressMap(self, 2, rows).add_vpp_config() |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 94 | |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 95 | output = [scapy.compat.chb(3)] * 256 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 96 | os = b"".join(output) |
| 97 | rows = [{"outputs": os}, {"outputs": os}, {"outputs": os}, {"outputs": os}] |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 98 | |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 99 | qem3 = VppQosEgressMap(self, 3, rows).add_vpp_config() |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 100 | |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 101 | output = [scapy.compat.chb(4)] * 256 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 102 | os = b"".join(output) |
| 103 | rows = [{"outputs": os}, {"outputs": os}, {"outputs": os}, {"outputs": os}] |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 104 | |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 105 | qem4 = VppQosEgressMap(self, 4, rows).add_vpp_config() |
| 106 | qem5 = VppQosEgressMap(self, 5, rows).add_vpp_config() |
| 107 | qem6 = VppQosEgressMap(self, 6, rows).add_vpp_config() |
| 108 | qem7 = VppQosEgressMap(self, 7, rows).add_vpp_config() |
| 109 | |
| 110 | self.assertTrue(qem7.query_vpp_config()) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 111 | self.logger.info(self.vapi.cli("sh qos eg map")) |
| 112 | |
| 113 | # |
| 114 | # Bind interface pgN to table n |
| 115 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 116 | qm1 = VppQosMark( |
| 117 | self, self.pg1, qem1, self.QOS_SOURCE.QOS_API_SOURCE_IP |
| 118 | ).add_vpp_config() |
| 119 | qm2 = VppQosMark( |
| 120 | self, self.pg2, qem2, self.QOS_SOURCE.QOS_API_SOURCE_IP |
| 121 | ).add_vpp_config() |
| 122 | qm3 = VppQosMark( |
| 123 | self, self.pg3, qem3, self.QOS_SOURCE.QOS_API_SOURCE_IP |
| 124 | ).add_vpp_config() |
| 125 | qm4 = VppQosMark( |
| 126 | self, self.pg4, qem4, self.QOS_SOURCE.QOS_API_SOURCE_IP |
| 127 | ).add_vpp_config() |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 128 | self.assertTrue(qm3.query_vpp_config()) |
| 129 | |
| 130 | self.logger.info(self.vapi.cli("sh qos mark")) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 131 | |
| 132 | # |
| 133 | # packets ingress on Pg0 |
| 134 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 135 | p_v4 = ( |
| 136 | Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) |
| 137 | / IP(src=self.pg0.remote_ip4, dst=self.pg1.remote_ip4, tos=1) |
| 138 | / UDP(sport=1234, dport=1234) |
| 139 | / Raw(scapy.compat.chb(100) * NUM_PKTS) |
| 140 | ) |
| 141 | p_v6 = ( |
| 142 | Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) |
| 143 | / IPv6(src=self.pg0.remote_ip6, dst=self.pg1.remote_ip6, tc=1) |
| 144 | / UDP(sport=1234, dport=1234) |
| 145 | / Raw(scapy.compat.chb(100) * NUM_PKTS) |
| 146 | ) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 147 | |
| 148 | # |
| 149 | # Since we have not yet enabled the recording of the input QoS |
| 150 | # from the input iP header, the egress packet's ToS will be unchanged |
| 151 | # |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 152 | rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 153 | for p in rx: |
| 154 | self.assertEqual(p[IP].tos, 1) |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 155 | rx = self.send_and_expect(self.pg0, p_v6 * NUM_PKTS, self.pg1) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 156 | for p in rx: |
| 157 | self.assertEqual(p[IPv6].tc, 1) |
| 158 | |
| 159 | # |
Paul Vinciguerra | 8feeaff | 2019-03-27 11:25:48 -0700 | [diff] [blame] | 160 | # Enable QoS recording on IP input for pg0 |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 161 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 162 | qr1 = VppQosRecord(self, self.pg0, self.QOS_SOURCE.QOS_API_SOURCE_IP) |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 163 | qr1.add_vpp_config() |
| 164 | self.logger.info(self.vapi.cli("sh qos record")) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 165 | |
| 166 | # |
| 167 | # send the same packets, this time expect the input TOS of 1 |
| 168 | # to be mapped to pg1's egress value of 254 |
| 169 | # |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 170 | rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 171 | for p in rx: |
| 172 | self.assertEqual(p[IP].tos, 254) |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 173 | rx = self.send_and_expect(self.pg0, p_v6 * NUM_PKTS, self.pg1) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 174 | for p in rx: |
| 175 | self.assertEqual(p[IPv6].tc, 254) |
| 176 | |
| 177 | # |
| 178 | # different input ToS to test the mapping |
| 179 | # |
| 180 | p_v4[IP].tos = 127 |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 181 | rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 182 | for p in rx: |
| 183 | self.assertEqual(p[IP].tos, 128) |
| 184 | p_v6[IPv6].tc = 127 |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 185 | rx = self.send_and_expect(self.pg0, p_v6 * NUM_PKTS, self.pg1) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 186 | for p in rx: |
| 187 | self.assertEqual(p[IPv6].tc, 128) |
| 188 | |
| 189 | p_v4[IP].tos = 254 |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 190 | rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 191 | for p in rx: |
| 192 | self.assertEqual(p[IP].tos, 1) |
| 193 | p_v6[IPv6].tc = 254 |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 194 | rx = self.send_and_expect(self.pg0, p_v6 * NUM_PKTS, self.pg1) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 195 | for p in rx: |
| 196 | self.assertEqual(p[IPv6].tc, 1) |
| 197 | |
| 198 | # |
| 199 | # send packets out the other interfaces to test the maps are |
| 200 | # correctly applied |
| 201 | # |
| 202 | p_v4[IP].dst = self.pg2.remote_ip4 |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 203 | rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg2) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 204 | for p in rx: |
| 205 | self.assertEqual(p[IP].tos, 2) |
| 206 | |
| 207 | p_v4[IP].dst = self.pg3.remote_ip4 |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 208 | rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg3) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 209 | for p in rx: |
| 210 | self.assertEqual(p[IP].tos, 3) |
| 211 | |
| 212 | p_v6[IPv6].dst = self.pg3.remote_ip6 |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 213 | rx = self.send_and_expect(self.pg0, p_v6 * NUM_PKTS, self.pg3) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 214 | for p in rx: |
| 215 | self.assertEqual(p[IPv6].tc, 3) |
| 216 | |
| 217 | # |
| 218 | # remove the map on pg2 and pg3, now expect an unchanged IP tos |
| 219 | # |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 220 | qm2.remove_vpp_config() |
| 221 | qm3.remove_vpp_config() |
| 222 | self.logger.info(self.vapi.cli("sh qos mark")) |
| 223 | |
| 224 | self.assertFalse(qm3.query_vpp_config()) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 225 | self.logger.info(self.vapi.cli("sh int feat pg2")) |
| 226 | |
| 227 | p_v4[IP].dst = self.pg2.remote_ip4 |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 228 | rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg2) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 229 | for p in rx: |
| 230 | self.assertEqual(p[IP].tos, 254) |
| 231 | |
| 232 | p_v4[IP].dst = self.pg3.remote_ip4 |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 233 | rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg3) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 234 | for p in rx: |
| 235 | self.assertEqual(p[IP].tos, 254) |
| 236 | |
| 237 | # |
| 238 | # still mapping out of pg1 |
| 239 | # |
| 240 | p_v4[IP].dst = self.pg1.remote_ip4 |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 241 | rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 242 | for p in rx: |
| 243 | self.assertEqual(p[IP].tos, 1) |
| 244 | |
| 245 | # |
| 246 | # disable the input recording on pg0 |
| 247 | # |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 248 | self.assertTrue(qr1.query_vpp_config()) |
| 249 | qr1.remove_vpp_config() |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 250 | |
| 251 | # |
| 252 | # back to an unchanged TOS value |
| 253 | # |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 254 | rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 255 | for p in rx: |
| 256 | self.assertEqual(p[IP].tos, 254) |
| 257 | |
| 258 | # |
Neale Ranns | 83832e7 | 2019-07-31 02:48:02 -0700 | [diff] [blame] | 259 | # enable QoS stroe instead of record |
| 260 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 261 | qst1 = VppQosStore( |
| 262 | self, self.pg0, self.QOS_SOURCE.QOS_API_SOURCE_IP, 5 |
| 263 | ).add_vpp_config() |
Neale Ranns | 83832e7 | 2019-07-31 02:48:02 -0700 | [diff] [blame] | 264 | self.logger.info(self.vapi.cli("sh qos store")) |
| 265 | |
| 266 | p_v4[IP].dst = self.pg1.remote_ip4 |
| 267 | rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1) |
| 268 | for p in rx: |
| 269 | self.assertEqual(p[IP].tos, 250) |
| 270 | |
| 271 | # |
| 272 | # disable the input storing on pg0 |
| 273 | # |
| 274 | self.assertTrue(qst1.query_vpp_config()) |
| 275 | qst1.remove_vpp_config() |
| 276 | |
| 277 | # |
| 278 | # back to an unchanged TOS value |
| 279 | # |
| 280 | rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1) |
| 281 | for p in rx: |
| 282 | self.assertEqual(p[IP].tos, 254) |
| 283 | |
| 284 | # |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 285 | # disable the egress map on pg1 and pg4 |
| 286 | # |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 287 | qm1.remove_vpp_config() |
| 288 | qm4.remove_vpp_config() |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 289 | |
| 290 | # |
| 291 | # unchanged Tos on pg1 |
| 292 | # |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 293 | rx = self.send_and_expect(self.pg0, p_v4 * NUM_PKTS, self.pg1) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 294 | for p in rx: |
| 295 | self.assertEqual(p[IP].tos, 254) |
| 296 | |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 297 | def test_qos_mpls(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 298 | """QoS Mark/Record MPLS""" |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 299 | |
| 300 | # |
| 301 | # 255 QoS for all input values |
| 302 | # |
Neale Ranns | 1866884 | 2018-11-15 07:46:12 +0000 | [diff] [blame] | 303 | from_ext = 7 |
| 304 | from_ip = 6 |
| 305 | from_mpls = 5 |
| 306 | from_vlan = 4 |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 307 | output = [scapy.compat.chb(from_ext)] * 256 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 308 | os1 = b"".join(output) |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 309 | output = [scapy.compat.chb(from_vlan)] * 256 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 310 | os2 = b"".join(output) |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 311 | output = [scapy.compat.chb(from_mpls)] * 256 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 312 | os3 = b"".join(output) |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 313 | output = [scapy.compat.chb(from_ip)] * 256 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 314 | os4 = b"".join(output) |
| 315 | rows = [{"outputs": os1}, {"outputs": os2}, {"outputs": os3}, {"outputs": os4}] |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 316 | |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 317 | qem1 = VppQosEgressMap(self, 1, rows).add_vpp_config() |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 318 | |
| 319 | # |
| 320 | # a route with 1 MPLS label |
| 321 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 322 | route_10_0_0_1 = VppIpRoute( |
| 323 | self, |
| 324 | "10.0.0.1", |
| 325 | 32, |
| 326 | [VppRoutePath(self.pg1.remote_ip4, self.pg1.sw_if_index, labels=[32])], |
| 327 | ) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 328 | route_10_0_0_1.add_vpp_config() |
| 329 | |
| 330 | # |
| 331 | # a route with 3 MPLS labels |
| 332 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 333 | route_10_0_0_3 = VppIpRoute( |
| 334 | self, |
| 335 | "10.0.0.3", |
| 336 | 32, |
| 337 | [ |
| 338 | VppRoutePath( |
| 339 | self.pg1.remote_ip4, self.pg1.sw_if_index, labels=[63, 33, 34] |
| 340 | ) |
| 341 | ], |
| 342 | ) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 343 | route_10_0_0_3.add_vpp_config() |
| 344 | |
| 345 | # |
| 346 | # enable IP QoS recording on the input Pg0 and MPLS egress marking |
| 347 | # on Pg1 |
| 348 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 349 | qr1 = VppQosRecord( |
| 350 | self, self.pg0, self.QOS_SOURCE.QOS_API_SOURCE_IP |
| 351 | ).add_vpp_config() |
| 352 | qm1 = VppQosMark( |
| 353 | self, self.pg1, qem1, self.QOS_SOURCE.QOS_API_SOURCE_MPLS |
| 354 | ).add_vpp_config() |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 355 | |
| 356 | # |
| 357 | # packet that will get one label added and 3 labels added resp. |
| 358 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 359 | p_1 = ( |
| 360 | Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) |
| 361 | / IP(src=self.pg0.remote_ip4, dst="10.0.0.1", tos=1) |
| 362 | / UDP(sport=1234, dport=1234) |
| 363 | / Raw(scapy.compat.chb(100) * NUM_PKTS) |
| 364 | ) |
| 365 | p_3 = ( |
| 366 | Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) |
| 367 | / IP(src=self.pg0.remote_ip4, dst="10.0.0.3", tos=1) |
| 368 | / UDP(sport=1234, dport=1234) |
| 369 | / Raw(scapy.compat.chb(100) * NUM_PKTS) |
| 370 | ) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 371 | |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 372 | rx = self.send_and_expect(self.pg0, p_1 * NUM_PKTS, self.pg1) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 373 | |
| 374 | # |
| 375 | # only 3 bits of ToS value in MPLS make sure tos is correct |
| 376 | # and the label and EOS bit have not been corrupted |
| 377 | # |
| 378 | for p in rx: |
Neale Ranns | 1866884 | 2018-11-15 07:46:12 +0000 | [diff] [blame] | 379 | self.assertEqual(p[MPLS].cos, from_ip) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 380 | self.assertEqual(p[MPLS].label, 32) |
| 381 | self.assertEqual(p[MPLS].s, 1) |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 382 | rx = self.send_and_expect(self.pg0, p_3 * NUM_PKTS, self.pg1) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 383 | for p in rx: |
Neale Ranns | 1866884 | 2018-11-15 07:46:12 +0000 | [diff] [blame] | 384 | self.assertEqual(p[MPLS].cos, from_ip) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 385 | self.assertEqual(p[MPLS].label, 63) |
| 386 | self.assertEqual(p[MPLS].s, 0) |
| 387 | h = p[MPLS].payload |
Neale Ranns | 1866884 | 2018-11-15 07:46:12 +0000 | [diff] [blame] | 388 | self.assertEqual(h[MPLS].cos, from_ip) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 389 | self.assertEqual(h[MPLS].label, 33) |
| 390 | self.assertEqual(h[MPLS].s, 0) |
| 391 | h = h[MPLS].payload |
Neale Ranns | 1866884 | 2018-11-15 07:46:12 +0000 | [diff] [blame] | 392 | self.assertEqual(h[MPLS].cos, from_ip) |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 393 | self.assertEqual(h[MPLS].label, 34) |
| 394 | self.assertEqual(h[MPLS].s, 1) |
| 395 | |
| 396 | # |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 397 | # enable MPLS QoS recording on the input Pg0 and IP egress marking |
| 398 | # on Pg1 |
| 399 | # |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 400 | qr2 = VppQosRecord( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 401 | self, self.pg0, self.QOS_SOURCE.QOS_API_SOURCE_MPLS |
| 402 | ).add_vpp_config() |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 403 | qm2 = VppQosMark( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 404 | self, self.pg1, qem1, self.QOS_SOURCE.QOS_API_SOURCE_IP |
| 405 | ).add_vpp_config() |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 406 | |
| 407 | # |
Neale Ranns | 1866884 | 2018-11-15 07:46:12 +0000 | [diff] [blame] | 408 | # MPLS x-connect - COS according to pg1 map |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 409 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 410 | route_32_eos = VppMplsRoute( |
| 411 | self, |
| 412 | 32, |
| 413 | 1, |
| 414 | [ |
| 415 | VppRoutePath( |
| 416 | self.pg1.remote_ip4, self.pg1.sw_if_index, labels=[VppMplsLabel(33)] |
| 417 | ) |
| 418 | ], |
| 419 | ) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 420 | route_32_eos.add_vpp_config() |
| 421 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 422 | p_m1 = ( |
| 423 | Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) |
| 424 | / MPLS(label=32, cos=3, ttl=2) |
| 425 | / IP(src=self.pg0.remote_ip4, dst="10.0.0.1", tos=1) |
| 426 | / UDP(sport=1234, dport=1234) |
| 427 | / Raw(scapy.compat.chb(100) * NUM_PKTS) |
| 428 | ) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 429 | |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 430 | rx = self.send_and_expect(self.pg0, p_m1 * NUM_PKTS, self.pg1) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 431 | for p in rx: |
Neale Ranns | 1866884 | 2018-11-15 07:46:12 +0000 | [diff] [blame] | 432 | self.assertEqual(p[MPLS].cos, from_mpls) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 433 | self.assertEqual(p[MPLS].label, 33) |
| 434 | self.assertEqual(p[MPLS].s, 1) |
| 435 | |
| 436 | # |
| 437 | # MPLS deag - COS is copied from MPLS to IP |
| 438 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 439 | route_33_eos = VppMplsRoute( |
| 440 | self, 33, 1, [VppRoutePath("0.0.0.0", 0xFFFFFFFF, nh_table_id=0)] |
| 441 | ) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 442 | route_33_eos.add_vpp_config() |
| 443 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 444 | route_10_0_0_4 = VppIpRoute( |
| 445 | self, |
| 446 | "10.0.0.4", |
| 447 | 32, |
| 448 | [VppRoutePath(self.pg1.remote_ip4, self.pg1.sw_if_index)], |
| 449 | ) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 450 | route_10_0_0_4.add_vpp_config() |
| 451 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 452 | p_m2 = ( |
| 453 | Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) |
| 454 | / MPLS(label=33, ttl=2, cos=3) |
| 455 | / IP(src=self.pg0.remote_ip4, dst="10.0.0.4", tos=1) |
| 456 | / UDP(sport=1234, dport=1234) |
| 457 | / Raw(scapy.compat.chb(100) * NUM_PKTS) |
| 458 | ) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 459 | |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 460 | rx = self.send_and_expect(self.pg0, p_m2 * NUM_PKTS, self.pg1) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 461 | |
| 462 | for p in rx: |
Neale Ranns | 1866884 | 2018-11-15 07:46:12 +0000 | [diff] [blame] | 463 | self.assertEqual(p[IP].tos, from_mpls) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 464 | |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 465 | def test_qos_vlan(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 466 | """QoS mark/record VLAN""" |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 467 | |
| 468 | # |
| 469 | # QoS for all input values |
| 470 | # |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 471 | output = [scapy.compat.chb(0)] * 256 |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 472 | for i in range(0, 255): |
Paul Vinciguerra | a7427ec | 2019-03-10 10:04:23 -0700 | [diff] [blame] | 473 | output[i] = scapy.compat.chb(255 - i) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 474 | os = b"".join(output) |
| 475 | rows = [{"outputs": os}, {"outputs": os}, {"outputs": os}, {"outputs": os}] |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 476 | |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 477 | qem1 = VppQosEgressMap(self, 1, rows).add_vpp_config() |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 478 | |
| 479 | sub_if = VppDot1QSubint(self, self.pg0, 11) |
| 480 | |
| 481 | sub_if.admin_up() |
| 482 | sub_if.config_ip4() |
| 483 | sub_if.resolve_arp() |
| 484 | sub_if.config_ip6() |
| 485 | sub_if.resolve_ndp() |
| 486 | |
| 487 | # |
| 488 | # enable VLAN QoS recording/marking on the input Pg0 subinterface and |
| 489 | # |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 490 | qr_v = VppQosRecord( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 491 | self, sub_if, self.QOS_SOURCE.QOS_API_SOURCE_VLAN |
| 492 | ).add_vpp_config() |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 493 | qm_v = VppQosMark( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 494 | self, sub_if, qem1, self.QOS_SOURCE.QOS_API_SOURCE_VLAN |
| 495 | ).add_vpp_config() |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 496 | |
| 497 | # |
| 498 | # IP marking/recording on pg1 |
| 499 | # |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 500 | qr_ip = VppQosRecord( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 501 | self, self.pg1, self.QOS_SOURCE.QOS_API_SOURCE_IP |
| 502 | ).add_vpp_config() |
Neale Ranns | 5281a90 | 2019-07-23 08:16:19 -0700 | [diff] [blame] | 503 | qm_ip = VppQosMark( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 504 | self, self.pg1, qem1, self.QOS_SOURCE.QOS_API_SOURCE_IP |
| 505 | ).add_vpp_config() |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 506 | |
| 507 | # |
| 508 | # a routes to/from sub-interface |
| 509 | # |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 510 | route_10_0_0_1 = VppIpRoute( |
| 511 | self, "10.0.0.1", 32, [VppRoutePath(sub_if.remote_ip4, sub_if.sw_if_index)] |
| 512 | ) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 513 | route_10_0_0_1.add_vpp_config() |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 514 | route_10_0_0_2 = VppIpRoute( |
| 515 | self, |
| 516 | "10.0.0.2", |
| 517 | 32, |
| 518 | [VppRoutePath(self.pg1.remote_ip4, self.pg1.sw_if_index)], |
| 519 | ) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 520 | route_10_0_0_2.add_vpp_config() |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 521 | route_2001_1 = VppIpRoute( |
| 522 | self, "2001::1", 128, [VppRoutePath(sub_if.remote_ip6, sub_if.sw_if_index)] |
| 523 | ) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 524 | route_2001_1.add_vpp_config() |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 525 | route_2001_2 = VppIpRoute( |
| 526 | self, |
| 527 | "2001::2", |
| 528 | 128, |
| 529 | [VppRoutePath(self.pg1.remote_ip6, self.pg1.sw_if_index)], |
| 530 | ) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 531 | route_2001_2.add_vpp_config() |
| 532 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 533 | p_v1 = ( |
| 534 | Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) |
| 535 | / Dot1Q(vlan=11, prio=1) |
| 536 | / IP(src="1.1.1.1", dst="10.0.0.2", tos=1) |
| 537 | / UDP(sport=1234, dport=1234) |
| 538 | / Raw(scapy.compat.chb(100) * NUM_PKTS) |
| 539 | ) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 540 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 541 | p_v2 = ( |
| 542 | Ether(src=self.pg1.remote_mac, dst=self.pg1.local_mac) |
| 543 | / IP(src="1.1.1.1", dst="10.0.0.1", tos=1) |
| 544 | / UDP(sport=1234, dport=1234) |
| 545 | / Raw(scapy.compat.chb(100) * NUM_PKTS) |
| 546 | ) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 547 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 548 | p_v3 = ( |
| 549 | Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) |
| 550 | / Dot1Q(vlan=11, prio=1, id=1) |
| 551 | / IP(src="1.1.1.1", dst="10.0.0.2", tos=2) |
| 552 | / UDP(sport=1234, dport=1234) |
| 553 | / Raw(scapy.compat.chb(100) * NUM_PKTS) |
| 554 | ) |
Prashant Maheshwari | 3bcf1a9 | 2019-07-31 21:37:33 +0530 | [diff] [blame] | 555 | |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 556 | rx = self.send_and_expect(self.pg1, p_v2 * NUM_PKTS, self.pg0) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 557 | |
| 558 | for p in rx: |
Prashant Maheshwari | 3bcf1a9 | 2019-07-31 21:37:33 +0530 | [diff] [blame] | 559 | self.assertEqual(p[Dot1Q].prio, 7) |
| 560 | self.assertEqual(p[Dot1Q].id, 0) |
| 561 | |
| 562 | rx = self.send_and_expect(self.pg0, p_v3 * NUM_PKTS, self.pg1) |
| 563 | |
| 564 | for p in rx: |
| 565 | self.assertEqual(p[IP].tos, 252) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 566 | |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 567 | rx = self.send_and_expect(self.pg0, p_v1 * NUM_PKTS, self.pg1) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 568 | |
| 569 | for p in rx: |
Prashant Maheshwari | 3bcf1a9 | 2019-07-31 21:37:33 +0530 | [diff] [blame] | 570 | self.assertEqual(p[IP].tos, 253) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 571 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 572 | p_v1 = ( |
| 573 | Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) |
| 574 | / Dot1Q(vlan=11, prio=2) |
| 575 | / IPv6(src="2001::1", dst="2001::2", tc=1) |
| 576 | / UDP(sport=1234, dport=1234) |
| 577 | / Raw(scapy.compat.chb(100) * NUM_PKTS) |
| 578 | ) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 579 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 580 | p_v2 = ( |
| 581 | Ether(src=self.pg1.remote_mac, dst=self.pg1.local_mac) |
| 582 | / IPv6(src="3001::1", dst="2001::1", tc=1) |
| 583 | / UDP(sport=1234, dport=1234) |
| 584 | / Raw(scapy.compat.chb(100) * NUM_PKTS) |
| 585 | ) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 586 | |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 587 | rx = self.send_and_expect(self.pg1, p_v2 * NUM_PKTS, self.pg0) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 588 | |
| 589 | for p in rx: |
Prashant Maheshwari | 3bcf1a9 | 2019-07-31 21:37:33 +0530 | [diff] [blame] | 590 | self.assertEqual(p[Dot1Q].prio, 7) |
| 591 | self.assertEqual(p[Dot1Q].id, 0) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 592 | |
Paul Vinciguerra | 4271c97 | 2019-05-14 13:25:49 -0400 | [diff] [blame] | 593 | rx = self.send_and_expect(self.pg0, p_v1 * NUM_PKTS, self.pg1) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 594 | |
| 595 | for p in rx: |
Prashant Maheshwari | 3bcf1a9 | 2019-07-31 21:37:33 +0530 | [diff] [blame] | 596 | self.assertEqual(p[IPv6].tc, 251) |
Neale Ranns | 0809f6c | 2018-07-16 04:14:21 -0700 | [diff] [blame] | 597 | |
| 598 | # |
| 599 | # cleanup |
| 600 | # |
| 601 | sub_if.unconfig_ip4() |
| 602 | sub_if.unconfig_ip6() |
| 603 | |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 604 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 605 | if __name__ == "__main__": |
Neale Ranns | 039cbfe | 2018-02-27 03:45:38 -0800 | [diff] [blame] | 606 | unittest.main(testRunner=VppTestRunner) |