Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | import unittest |
| 3 | from random import shuffle |
| 4 | |
| 5 | from framework import VppTestCase, VppTestRunner |
| 6 | |
| 7 | from scapy.packet import Raw |
| 8 | from scapy.layers.l2 import Ether, GRE |
| 9 | from scapy.layers.inet import IP, UDP |
| 10 | from util import ppp, fragment_rfc791, fragment_rfc8200 |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 11 | from scapy.layers.inet6 import IPv6, IPv6ExtHdrFragment, ICMPv6ParamProblem,\ |
| 12 | ICMPv6TimeExceeded |
| 13 | from vpp_gre_interface import VppGreInterface, VppGre6Interface |
| 14 | from vpp_ip_route import VppIpRoute, VppRoutePath, DpoProto |
| 15 | |
| 16 | test_packet_count = 257 |
| 17 | |
| 18 | |
| 19 | class TestIPv4Reassembly(VppTestCase): |
| 20 | """ IPv4 Reassembly """ |
| 21 | |
| 22 | @classmethod |
| 23 | def setUpClass(cls): |
| 24 | super(TestIPv4Reassembly, cls).setUpClass() |
| 25 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 26 | cls.create_pg_interfaces([0, 1]) |
| 27 | cls.src_if = cls.pg0 |
| 28 | cls.dst_if = cls.pg1 |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 29 | |
| 30 | # setup all interfaces |
| 31 | for i in cls.pg_interfaces: |
| 32 | i.admin_up() |
| 33 | i.config_ip4() |
| 34 | i.resolve_arp() |
| 35 | |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 36 | # packet sizes |
| 37 | cls.packet_sizes = [64, 512, 1518, 9018] |
| 38 | cls.padding = " abcdefghijklmn" |
| 39 | cls.create_stream(cls.packet_sizes) |
| 40 | cls.create_fragments() |
| 41 | |
| 42 | def setUp(self): |
| 43 | """ Test setup - force timeout on existing reassemblies """ |
| 44 | super(TestIPv4Reassembly, self).setUp() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 45 | self.vapi.ip_reassembly_enable_disable( |
| 46 | sw_if_index=self.src_if.sw_if_index, enable_ip4=True) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 47 | self.vapi.ip_reassembly_set(timeout_ms=0, max_reassemblies=1000, |
| 48 | expire_walk_interval_ms=10) |
| 49 | self.sleep(.25) |
| 50 | self.vapi.ip_reassembly_set(timeout_ms=1000000, max_reassemblies=1000, |
| 51 | expire_walk_interval_ms=10000) |
| 52 | |
| 53 | def tearDown(self): |
| 54 | super(TestIPv4Reassembly, self).tearDown() |
| 55 | self.logger.debug(self.vapi.ppcli("show ip4-reassembly details")) |
| 56 | |
| 57 | @classmethod |
| 58 | def create_stream(cls, packet_sizes, packet_count=test_packet_count): |
| 59 | """Create input packet stream for defined interface. |
| 60 | |
| 61 | :param list packet_sizes: Required packet sizes. |
| 62 | """ |
| 63 | for i in range(0, packet_count): |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 64 | info = cls.create_packet_info(cls.src_if, cls.src_if) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 65 | payload = cls.info_to_payload(info) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 66 | p = (Ether(dst=cls.src_if.local_mac, src=cls.src_if.remote_mac) / |
| 67 | IP(id=info.index, src=cls.src_if.remote_ip4, |
| 68 | dst=cls.dst_if.remote_ip4) / |
| 69 | UDP(sport=1234, dport=5678) / |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 70 | Raw(payload)) |
| 71 | size = packet_sizes[(i // 2) % len(packet_sizes)] |
| 72 | cls.extend_packet(p, size, cls.padding) |
| 73 | info.data = p |
| 74 | |
| 75 | @classmethod |
| 76 | def create_fragments(cls): |
| 77 | infos = cls._packet_infos |
| 78 | cls.pkt_infos = [] |
| 79 | for index, info in infos.iteritems(): |
| 80 | p = info.data |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 81 | # cls.logger.debug(ppp("Packet:", p.__class__(str(p)))) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 82 | fragments_400 = fragment_rfc791(p, 400) |
| 83 | fragments_300 = fragment_rfc791(p, 300) |
| 84 | fragments_200 = [ |
| 85 | x for f in fragments_400 for x in fragment_rfc791(f, 200)] |
| 86 | cls.pkt_infos.append( |
| 87 | (index, fragments_400, fragments_300, fragments_200)) |
| 88 | cls.fragments_400 = [ |
| 89 | x for (_, frags, _, _) in cls.pkt_infos for x in frags] |
| 90 | cls.fragments_300 = [ |
| 91 | x for (_, _, frags, _) in cls.pkt_infos for x in frags] |
| 92 | cls.fragments_200 = [ |
| 93 | x for (_, _, _, frags) in cls.pkt_infos for x in frags] |
| 94 | cls.logger.debug("Fragmented %s packets into %s 400-byte fragments, " |
| 95 | "%s 300-byte fragments and %s 200-byte fragments" % |
| 96 | (len(infos), len(cls.fragments_400), |
| 97 | len(cls.fragments_300), len(cls.fragments_200))) |
| 98 | |
| 99 | def verify_capture(self, capture, dropped_packet_indexes=[]): |
| 100 | """Verify captured packet stream. |
| 101 | |
| 102 | :param list capture: Captured packet stream. |
| 103 | """ |
| 104 | info = None |
| 105 | seen = set() |
| 106 | for packet in capture: |
| 107 | try: |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 108 | self.logger.debug(ppp("Got packet:", packet)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 109 | ip = packet[IP] |
| 110 | udp = packet[UDP] |
| 111 | payload_info = self.payload_to_info(str(packet[Raw])) |
| 112 | packet_index = payload_info.index |
| 113 | self.assertTrue( |
| 114 | packet_index not in dropped_packet_indexes, |
| 115 | ppp("Packet received, but should be dropped:", packet)) |
| 116 | if packet_index in seen: |
| 117 | raise Exception(ppp("Duplicate packet received", packet)) |
| 118 | seen.add(packet_index) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 119 | self.assertEqual(payload_info.dst, self.src_if.sw_if_index) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 120 | info = self._packet_infos[packet_index] |
| 121 | self.assertTrue(info is not None) |
| 122 | self.assertEqual(packet_index, info.index) |
| 123 | saved_packet = info.data |
| 124 | self.assertEqual(ip.src, saved_packet[IP].src) |
| 125 | self.assertEqual(ip.dst, saved_packet[IP].dst) |
| 126 | self.assertEqual(udp.payload, saved_packet[UDP].payload) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 127 | except Exception: |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 128 | self.logger.error(ppp("Unexpected or invalid packet:", packet)) |
| 129 | raise |
| 130 | for index in self._packet_infos: |
| 131 | self.assertTrue(index in seen or index in dropped_packet_indexes, |
| 132 | "Packet with packet_index %d not received" % index) |
| 133 | |
| 134 | def test_reassembly(self): |
| 135 | """ basic reassembly """ |
| 136 | |
| 137 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 138 | self.src_if.add_stream(self.fragments_200) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 139 | self.pg_start() |
| 140 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 141 | packets = self.dst_if.get_capture(len(self.pkt_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 142 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 143 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 144 | |
| 145 | # run it all again to verify correctness |
| 146 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 147 | self.src_if.add_stream(self.fragments_200) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 148 | self.pg_start() |
| 149 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 150 | packets = self.dst_if.get_capture(len(self.pkt_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 151 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 152 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 153 | |
| 154 | def test_reversed(self): |
| 155 | """ reverse order reassembly """ |
| 156 | |
| 157 | fragments = list(self.fragments_200) |
| 158 | fragments.reverse() |
| 159 | |
| 160 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 161 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 162 | self.pg_start() |
| 163 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 164 | packets = self.dst_if.get_capture(len(self.packet_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 165 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 166 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 167 | |
| 168 | # run it all again to verify correctness |
| 169 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 170 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 171 | self.pg_start() |
| 172 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 173 | packets = self.dst_if.get_capture(len(self.packet_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 174 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 175 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 176 | |
| 177 | def test_random(self): |
| 178 | """ random order reassembly """ |
| 179 | |
| 180 | fragments = list(self.fragments_200) |
| 181 | shuffle(fragments) |
| 182 | |
| 183 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 184 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 185 | self.pg_start() |
| 186 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 187 | packets = self.dst_if.get_capture(len(self.packet_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 188 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 189 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 190 | |
| 191 | # run it all again to verify correctness |
| 192 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 193 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 194 | self.pg_start() |
| 195 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 196 | packets = self.dst_if.get_capture(len(self.packet_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 197 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 198 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 199 | |
| 200 | def test_duplicates(self): |
| 201 | """ duplicate fragments """ |
| 202 | |
| 203 | fragments = [ |
| 204 | x for (_, frags, _, _) in self.pkt_infos |
| 205 | for x in frags |
| 206 | for _ in range(0, min(2, len(frags))) |
| 207 | ] |
| 208 | |
| 209 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 210 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 211 | self.pg_start() |
| 212 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 213 | packets = self.dst_if.get_capture(len(self.pkt_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 214 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 215 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 216 | |
| 217 | def test_overlap1(self): |
| 218 | """ overlapping fragments case #1 """ |
| 219 | |
| 220 | fragments = [] |
| 221 | for _, _, frags_300, frags_200 in self.pkt_infos: |
| 222 | if len(frags_300) == 1: |
| 223 | fragments.extend(frags_300) |
| 224 | else: |
| 225 | for i, j in zip(frags_200, frags_300): |
| 226 | fragments.extend(i) |
| 227 | fragments.extend(j) |
| 228 | |
| 229 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 230 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 231 | self.pg_start() |
| 232 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 233 | packets = self.dst_if.get_capture(len(self.pkt_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 234 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 235 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 236 | |
| 237 | # run it all to verify correctness |
| 238 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 239 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 240 | self.pg_start() |
| 241 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 242 | packets = self.dst_if.get_capture(len(self.pkt_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 243 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 244 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 245 | |
| 246 | def test_overlap2(self): |
| 247 | """ overlapping fragments case #2 """ |
| 248 | |
| 249 | fragments = [] |
| 250 | for _, _, frags_300, frags_200 in self.pkt_infos: |
| 251 | if len(frags_300) == 1: |
| 252 | fragments.extend(frags_300) |
| 253 | else: |
| 254 | # care must be taken here so that there are no fragments |
| 255 | # received by vpp after reassembly is finished, otherwise |
| 256 | # new reassemblies will be started and packet generator will |
| 257 | # freak out when it detects unfreed buffers |
| 258 | zipped = zip(frags_300, frags_200) |
| 259 | for i, j in zipped[:-1]: |
| 260 | fragments.extend(i) |
| 261 | fragments.extend(j) |
| 262 | fragments.append(zipped[-1][0]) |
| 263 | |
| 264 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 265 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 266 | self.pg_start() |
| 267 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 268 | packets = self.dst_if.get_capture(len(self.pkt_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 269 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 270 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 271 | |
| 272 | # run it all to verify correctness |
| 273 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 274 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 275 | self.pg_start() |
| 276 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 277 | packets = self.dst_if.get_capture(len(self.pkt_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 278 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 279 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 280 | |
| 281 | def test_timeout_inline(self): |
| 282 | """ timeout (inline) """ |
| 283 | |
| 284 | dropped_packet_indexes = set( |
| 285 | index for (index, frags, _, _) in self.pkt_infos if len(frags) > 1 |
| 286 | ) |
| 287 | |
| 288 | self.vapi.ip_reassembly_set(timeout_ms=0, max_reassemblies=1000, |
| 289 | expire_walk_interval_ms=10000) |
| 290 | |
| 291 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 292 | self.src_if.add_stream(self.fragments_400) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 293 | self.pg_start() |
| 294 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 295 | packets = self.dst_if.get_capture( |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 296 | len(self.pkt_infos) - len(dropped_packet_indexes)) |
| 297 | self.verify_capture(packets, dropped_packet_indexes) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 298 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 299 | |
| 300 | def test_timeout_cleanup(self): |
| 301 | """ timeout (cleanup) """ |
| 302 | |
| 303 | # whole packets + fragmented packets sans last fragment |
| 304 | fragments = [ |
| 305 | x for (_, frags_400, _, _) in self.pkt_infos |
| 306 | for x in frags_400[:-1 if len(frags_400) > 1 else None] |
| 307 | ] |
| 308 | |
| 309 | # last fragments for fragmented packets |
| 310 | fragments2 = [frags_400[-1] |
| 311 | for (_, frags_400, _, _) in self.pkt_infos |
| 312 | if len(frags_400) > 1] |
| 313 | |
| 314 | dropped_packet_indexes = set( |
| 315 | index for (index, frags_400, _, _) in self.pkt_infos |
| 316 | if len(frags_400) > 1) |
| 317 | |
| 318 | self.vapi.ip_reassembly_set(timeout_ms=100, max_reassemblies=1000, |
| 319 | expire_walk_interval_ms=50) |
| 320 | |
| 321 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 322 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 323 | self.pg_start() |
| 324 | |
| 325 | self.sleep(.25, "wait before sending rest of fragments") |
| 326 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 327 | self.src_if.add_stream(fragments2) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 328 | self.pg_start() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 329 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 330 | packets = self.dst_if.get_capture( |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 331 | len(self.pkt_infos) - len(dropped_packet_indexes)) |
| 332 | self.verify_capture(packets, dropped_packet_indexes) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 333 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 334 | |
| 335 | def test_disabled(self): |
| 336 | """ reassembly disabled """ |
| 337 | |
| 338 | dropped_packet_indexes = set( |
| 339 | index for (index, frags_400, _, _) in self.pkt_infos |
| 340 | if len(frags_400) > 1) |
| 341 | |
| 342 | self.vapi.ip_reassembly_set(timeout_ms=1000, max_reassemblies=0, |
| 343 | expire_walk_interval_ms=10000) |
| 344 | |
| 345 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 346 | self.src_if.add_stream(self.fragments_400) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 347 | self.pg_start() |
| 348 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 349 | packets = self.dst_if.get_capture( |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 350 | len(self.pkt_infos) - len(dropped_packet_indexes)) |
| 351 | self.verify_capture(packets, dropped_packet_indexes) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 352 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 353 | |
| 354 | |
| 355 | class TestIPv6Reassembly(VppTestCase): |
| 356 | """ IPv6 Reassembly """ |
| 357 | |
| 358 | @classmethod |
| 359 | def setUpClass(cls): |
| 360 | super(TestIPv6Reassembly, cls).setUpClass() |
| 361 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 362 | cls.create_pg_interfaces([0, 1]) |
| 363 | cls.src_if = cls.pg0 |
| 364 | cls.dst_if = cls.pg1 |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 365 | |
| 366 | # setup all interfaces |
| 367 | for i in cls.pg_interfaces: |
| 368 | i.admin_up() |
| 369 | i.config_ip6() |
| 370 | i.resolve_ndp() |
| 371 | |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 372 | # packet sizes |
| 373 | cls.packet_sizes = [64, 512, 1518, 9018] |
| 374 | cls.padding = " abcdefghijklmn" |
| 375 | cls.create_stream(cls.packet_sizes) |
| 376 | cls.create_fragments() |
| 377 | |
| 378 | def setUp(self): |
| 379 | """ Test setup - force timeout on existing reassemblies """ |
| 380 | super(TestIPv6Reassembly, self).setUp() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 381 | self.vapi.ip_reassembly_enable_disable( |
| 382 | sw_if_index=self.src_if.sw_if_index, enable_ip6=True) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 383 | self.vapi.ip_reassembly_set(timeout_ms=0, max_reassemblies=1000, |
| 384 | expire_walk_interval_ms=10, is_ip6=1) |
| 385 | self.sleep(.25) |
| 386 | self.vapi.ip_reassembly_set(timeout_ms=1000000, max_reassemblies=1000, |
| 387 | expire_walk_interval_ms=10000, is_ip6=1) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 388 | self.logger.debug(self.vapi.ppcli("show ip6-reassembly details")) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 389 | |
| 390 | def tearDown(self): |
| 391 | super(TestIPv6Reassembly, self).tearDown() |
| 392 | self.logger.debug(self.vapi.ppcli("show ip6-reassembly details")) |
| 393 | |
| 394 | @classmethod |
| 395 | def create_stream(cls, packet_sizes, packet_count=test_packet_count): |
| 396 | """Create input packet stream for defined interface. |
| 397 | |
| 398 | :param list packet_sizes: Required packet sizes. |
| 399 | """ |
| 400 | for i in range(0, packet_count): |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 401 | info = cls.create_packet_info(cls.src_if, cls.src_if) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 402 | payload = cls.info_to_payload(info) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 403 | p = (Ether(dst=cls.src_if.local_mac, src=cls.src_if.remote_mac) / |
| 404 | IPv6(src=cls.src_if.remote_ip6, |
| 405 | dst=cls.dst_if.remote_ip6) / |
| 406 | UDP(sport=1234, dport=5678) / |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 407 | Raw(payload)) |
| 408 | size = packet_sizes[(i // 2) % len(packet_sizes)] |
| 409 | cls.extend_packet(p, size, cls.padding) |
| 410 | info.data = p |
| 411 | |
| 412 | @classmethod |
| 413 | def create_fragments(cls): |
| 414 | infos = cls._packet_infos |
| 415 | cls.pkt_infos = [] |
| 416 | for index, info in infos.iteritems(): |
| 417 | p = info.data |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 418 | # cls.logger.debug(ppp("Packet:", p.__class__(str(p)))) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 419 | fragments_400 = fragment_rfc8200(p, info.index, 400) |
| 420 | fragments_300 = fragment_rfc8200(p, info.index, 300) |
| 421 | cls.pkt_infos.append((index, fragments_400, fragments_300)) |
| 422 | cls.fragments_400 = [ |
| 423 | x for _, frags, _ in cls.pkt_infos for x in frags] |
| 424 | cls.fragments_300 = [ |
| 425 | x for _, _, frags in cls.pkt_infos for x in frags] |
| 426 | cls.logger.debug("Fragmented %s packets into %s 400-byte fragments, " |
| 427 | "and %s 300-byte fragments" % |
| 428 | (len(infos), len(cls.fragments_400), |
| 429 | len(cls.fragments_300))) |
| 430 | |
| 431 | def verify_capture(self, capture, dropped_packet_indexes=[]): |
| 432 | """Verify captured packet strea . |
| 433 | |
| 434 | :param list capture: Captured packet stream. |
| 435 | """ |
| 436 | info = None |
| 437 | seen = set() |
| 438 | for packet in capture: |
| 439 | try: |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 440 | self.logger.debug(ppp("Got packet:", packet)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 441 | ip = packet[IPv6] |
| 442 | udp = packet[UDP] |
| 443 | payload_info = self.payload_to_info(str(packet[Raw])) |
| 444 | packet_index = payload_info.index |
| 445 | self.assertTrue( |
| 446 | packet_index not in dropped_packet_indexes, |
| 447 | ppp("Packet received, but should be dropped:", packet)) |
| 448 | if packet_index in seen: |
| 449 | raise Exception(ppp("Duplicate packet received", packet)) |
| 450 | seen.add(packet_index) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 451 | self.assertEqual(payload_info.dst, self.src_if.sw_if_index) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 452 | info = self._packet_infos[packet_index] |
| 453 | self.assertTrue(info is not None) |
| 454 | self.assertEqual(packet_index, info.index) |
| 455 | saved_packet = info.data |
| 456 | self.assertEqual(ip.src, saved_packet[IPv6].src) |
| 457 | self.assertEqual(ip.dst, saved_packet[IPv6].dst) |
| 458 | self.assertEqual(udp.payload, saved_packet[UDP].payload) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 459 | except Exception: |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 460 | self.logger.error(ppp("Unexpected or invalid packet:", packet)) |
| 461 | raise |
| 462 | for index in self._packet_infos: |
| 463 | self.assertTrue(index in seen or index in dropped_packet_indexes, |
| 464 | "Packet with packet_index %d not received" % index) |
| 465 | |
| 466 | def test_reassembly(self): |
| 467 | """ basic reassembly """ |
| 468 | |
| 469 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 470 | self.src_if.add_stream(self.fragments_400) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 471 | self.pg_start() |
| 472 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 473 | packets = self.dst_if.get_capture(len(self.pkt_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 474 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 475 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 476 | |
| 477 | # run it all again to verify correctness |
| 478 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 479 | self.src_if.add_stream(self.fragments_400) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 480 | self.pg_start() |
| 481 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 482 | packets = self.dst_if.get_capture(len(self.pkt_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 483 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 484 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 485 | |
| 486 | def test_reversed(self): |
| 487 | """ reverse order reassembly """ |
| 488 | |
| 489 | fragments = list(self.fragments_400) |
| 490 | fragments.reverse() |
| 491 | |
| 492 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 493 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 494 | self.pg_start() |
| 495 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 496 | packets = self.dst_if.get_capture(len(self.pkt_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 497 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 498 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 499 | |
| 500 | # run it all again to verify correctness |
| 501 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 502 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 503 | self.pg_start() |
| 504 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 505 | packets = self.dst_if.get_capture(len(self.pkt_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 506 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 507 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 508 | |
| 509 | def test_random(self): |
| 510 | """ random order reassembly """ |
| 511 | |
| 512 | fragments = list(self.fragments_400) |
| 513 | shuffle(fragments) |
| 514 | |
| 515 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 516 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 517 | self.pg_start() |
| 518 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 519 | packets = self.dst_if.get_capture(len(self.pkt_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 520 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 521 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 522 | |
| 523 | # run it all again to verify correctness |
| 524 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 525 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 526 | self.pg_start() |
| 527 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 528 | packets = self.dst_if.get_capture(len(self.pkt_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 529 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 530 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 531 | |
| 532 | def test_duplicates(self): |
| 533 | """ duplicate fragments """ |
| 534 | |
| 535 | fragments = [ |
| 536 | x for (_, frags, _) in self.pkt_infos |
| 537 | for x in frags |
| 538 | for _ in range(0, min(2, len(frags))) |
| 539 | ] |
| 540 | |
| 541 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 542 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 543 | self.pg_start() |
| 544 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 545 | packets = self.dst_if.get_capture(len(self.pkt_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 546 | self.verify_capture(packets) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 547 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 548 | |
| 549 | def test_overlap1(self): |
| 550 | """ overlapping fragments case #1 """ |
| 551 | |
| 552 | fragments = [] |
| 553 | for _, frags_400, frags_300 in self.pkt_infos: |
| 554 | if len(frags_300) == 1: |
| 555 | fragments.extend(frags_400) |
| 556 | else: |
| 557 | for i, j in zip(frags_300, frags_400): |
| 558 | fragments.extend(i) |
| 559 | fragments.extend(j) |
| 560 | |
| 561 | dropped_packet_indexes = set( |
| 562 | index for (index, _, frags) in self.pkt_infos if len(frags) > 1 |
| 563 | ) |
| 564 | |
| 565 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 566 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 567 | self.pg_start() |
| 568 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 569 | packets = self.dst_if.get_capture( |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 570 | len(self.pkt_infos) - len(dropped_packet_indexes)) |
| 571 | self.verify_capture(packets, dropped_packet_indexes) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 572 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 573 | |
| 574 | def test_overlap2(self): |
| 575 | """ overlapping fragments case #2 """ |
| 576 | |
| 577 | fragments = [] |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 578 | for _, frags_400, frags_300 in self.pkt_infos: |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 579 | if len(frags_400) == 1: |
| 580 | fragments.extend(frags_400) |
| 581 | else: |
| 582 | # care must be taken here so that there are no fragments |
| 583 | # received by vpp after reassembly is finished, otherwise |
| 584 | # new reassemblies will be started and packet generator will |
| 585 | # freak out when it detects unfreed buffers |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 586 | zipped = zip(frags_400, frags_300) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 587 | for i, j in zipped[:-1]: |
| 588 | fragments.extend(i) |
| 589 | fragments.extend(j) |
| 590 | fragments.append(zipped[-1][0]) |
| 591 | |
| 592 | dropped_packet_indexes = set( |
| 593 | index for (index, _, frags) in self.pkt_infos if len(frags) > 1 |
| 594 | ) |
| 595 | |
| 596 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 597 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 598 | self.pg_start() |
| 599 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 600 | packets = self.dst_if.get_capture( |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 601 | len(self.pkt_infos) - len(dropped_packet_indexes)) |
| 602 | self.verify_capture(packets, dropped_packet_indexes) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 603 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 604 | |
| 605 | def test_timeout_inline(self): |
| 606 | """ timeout (inline) """ |
| 607 | |
| 608 | dropped_packet_indexes = set( |
| 609 | index for (index, frags, _) in self.pkt_infos if len(frags) > 1 |
| 610 | ) |
| 611 | |
| 612 | self.vapi.ip_reassembly_set(timeout_ms=0, max_reassemblies=1000, |
| 613 | expire_walk_interval_ms=10000, is_ip6=1) |
| 614 | |
| 615 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 616 | self.src_if.add_stream(self.fragments_400) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 617 | self.pg_start() |
| 618 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 619 | packets = self.dst_if.get_capture( |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 620 | len(self.pkt_infos) - len(dropped_packet_indexes)) |
| 621 | self.verify_capture(packets, dropped_packet_indexes) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 622 | pkts = self.src_if.get_capture( |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 623 | expected_count=len(dropped_packet_indexes)) |
| 624 | for icmp in pkts: |
| 625 | self.assertIn(ICMPv6TimeExceeded, icmp) |
| 626 | self.assertIn(IPv6ExtHdrFragment, icmp) |
| 627 | self.assertIn(icmp[IPv6ExtHdrFragment].id, dropped_packet_indexes) |
| 628 | dropped_packet_indexes.remove(icmp[IPv6ExtHdrFragment].id) |
| 629 | |
| 630 | def test_timeout_cleanup(self): |
| 631 | """ timeout (cleanup) """ |
| 632 | |
| 633 | # whole packets + fragmented packets sans last fragment |
| 634 | fragments = [ |
| 635 | x for (_, frags_400, _) in self.pkt_infos |
| 636 | for x in frags_400[:-1 if len(frags_400) > 1 else None] |
| 637 | ] |
| 638 | |
| 639 | # last fragments for fragmented packets |
| 640 | fragments2 = [frags_400[-1] |
| 641 | for (_, frags_400, _) in self.pkt_infos |
| 642 | if len(frags_400) > 1] |
| 643 | |
| 644 | dropped_packet_indexes = set( |
| 645 | index for (index, frags_400, _) in self.pkt_infos |
| 646 | if len(frags_400) > 1) |
| 647 | |
| 648 | self.vapi.ip_reassembly_set(timeout_ms=100, max_reassemblies=1000, |
| 649 | expire_walk_interval_ms=50) |
| 650 | |
| 651 | self.vapi.ip_reassembly_set(timeout_ms=100, max_reassemblies=1000, |
| 652 | expire_walk_interval_ms=50, is_ip6=1) |
| 653 | |
| 654 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 655 | self.src_if.add_stream(fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 656 | self.pg_start() |
| 657 | |
| 658 | self.sleep(.25, "wait before sending rest of fragments") |
| 659 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 660 | self.src_if.add_stream(fragments2) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 661 | self.pg_start() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 662 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 663 | packets = self.dst_if.get_capture( |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 664 | len(self.pkt_infos) - len(dropped_packet_indexes)) |
| 665 | self.verify_capture(packets, dropped_packet_indexes) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 666 | pkts = self.src_if.get_capture( |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 667 | expected_count=len(dropped_packet_indexes)) |
| 668 | for icmp in pkts: |
| 669 | self.assertIn(ICMPv6TimeExceeded, icmp) |
| 670 | self.assertIn(IPv6ExtHdrFragment, icmp) |
| 671 | self.assertIn(icmp[IPv6ExtHdrFragment].id, dropped_packet_indexes) |
| 672 | dropped_packet_indexes.remove(icmp[IPv6ExtHdrFragment].id) |
| 673 | |
| 674 | def test_disabled(self): |
| 675 | """ reassembly disabled """ |
| 676 | |
| 677 | dropped_packet_indexes = set( |
| 678 | index for (index, frags_400, _) in self.pkt_infos |
| 679 | if len(frags_400) > 1) |
| 680 | |
| 681 | self.vapi.ip_reassembly_set(timeout_ms=1000, max_reassemblies=0, |
| 682 | expire_walk_interval_ms=10000, is_ip6=1) |
| 683 | |
| 684 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 685 | self.src_if.add_stream(self.fragments_400) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 686 | self.pg_start() |
| 687 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 688 | packets = self.dst_if.get_capture( |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 689 | len(self.pkt_infos) - len(dropped_packet_indexes)) |
| 690 | self.verify_capture(packets, dropped_packet_indexes) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 691 | self.src_if.assert_nothing_captured() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 692 | |
| 693 | def test_missing_upper(self): |
| 694 | """ missing upper layer """ |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 695 | p = (Ether(dst=self.src_if.local_mac, src=self.src_if.remote_mac) / |
| 696 | IPv6(src=self.src_if.remote_ip6, |
| 697 | dst=self.src_if.local_ip6) / |
| 698 | UDP(sport=1234, dport=5678) / |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 699 | Raw()) |
| 700 | self.extend_packet(p, 1000, self.padding) |
| 701 | fragments = fragment_rfc8200(p, 1, 500) |
| 702 | bad_fragment = p.__class__(str(fragments[1])) |
| 703 | bad_fragment[IPv6ExtHdrFragment].nh = 59 |
| 704 | bad_fragment[IPv6ExtHdrFragment].offset = 0 |
| 705 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 706 | self.src_if.add_stream([bad_fragment]) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 707 | self.pg_start() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 708 | pkts = self.src_if.get_capture(expected_count=1) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 709 | icmp = pkts[0] |
| 710 | self.assertIn(ICMPv6ParamProblem, icmp) |
| 711 | self.assert_equal(icmp[ICMPv6ParamProblem].code, 3, "ICMP code") |
| 712 | |
| 713 | def test_invalid_frag_size(self): |
| 714 | """ fragment size not a multiple of 8 """ |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 715 | p = (Ether(dst=self.src_if.local_mac, src=self.src_if.remote_mac) / |
| 716 | IPv6(src=self.src_if.remote_ip6, |
| 717 | dst=self.src_if.local_ip6) / |
| 718 | UDP(sport=1234, dport=5678) / |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 719 | Raw()) |
| 720 | self.extend_packet(p, 1000, self.padding) |
| 721 | fragments = fragment_rfc8200(p, 1, 500) |
| 722 | bad_fragment = fragments[0] |
| 723 | self.extend_packet(bad_fragment, len(bad_fragment) + 5) |
| 724 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 725 | self.src_if.add_stream([bad_fragment]) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 726 | self.pg_start() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 727 | pkts = self.src_if.get_capture(expected_count=1) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 728 | icmp = pkts[0] |
| 729 | self.assertIn(ICMPv6ParamProblem, icmp) |
| 730 | self.assert_equal(icmp[ICMPv6ParamProblem].code, 0, "ICMP code") |
| 731 | |
| 732 | def test_invalid_packet_size(self): |
| 733 | """ total packet size > 65535 """ |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 734 | p = (Ether(dst=self.src_if.local_mac, src=self.src_if.remote_mac) / |
| 735 | IPv6(src=self.src_if.remote_ip6, |
| 736 | dst=self.src_if.local_ip6) / |
| 737 | UDP(sport=1234, dport=5678) / |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 738 | Raw()) |
| 739 | self.extend_packet(p, 1000, self.padding) |
| 740 | fragments = fragment_rfc8200(p, 1, 500) |
| 741 | bad_fragment = fragments[1] |
| 742 | bad_fragment[IPv6ExtHdrFragment].offset = 65500 |
| 743 | self.pg_enable_capture() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 744 | self.src_if.add_stream([bad_fragment]) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 745 | self.pg_start() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 746 | pkts = self.src_if.get_capture(expected_count=1) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 747 | icmp = pkts[0] |
| 748 | self.assertIn(ICMPv6ParamProblem, icmp) |
| 749 | self.assert_equal(icmp[ICMPv6ParamProblem].code, 0, "ICMP code") |
| 750 | |
| 751 | |
| 752 | class TestFIFReassembly(VppTestCase): |
| 753 | """ Fragments in fragments reassembly """ |
| 754 | |
| 755 | @classmethod |
| 756 | def setUpClass(cls): |
| 757 | super(TestFIFReassembly, cls).setUpClass() |
| 758 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 759 | cls.create_pg_interfaces([0, 1]) |
| 760 | cls.src_if = cls.pg0 |
| 761 | cls.dst_if = cls.pg1 |
| 762 | for i in cls.pg_interfaces: |
| 763 | i.admin_up() |
| 764 | i.config_ip4() |
| 765 | i.resolve_arp() |
| 766 | i.config_ip6() |
| 767 | i.resolve_ndp() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 768 | |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 769 | cls.packet_sizes = [64, 512, 1518, 9018] |
| 770 | cls.padding = " abcdefghijklmn" |
| 771 | |
| 772 | def setUp(self): |
| 773 | """ Test setup - force timeout on existing reassemblies """ |
| 774 | super(TestFIFReassembly, self).setUp() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 775 | self.vapi.ip_reassembly_enable_disable( |
| 776 | sw_if_index=self.src_if.sw_if_index, enable_ip4=True, |
| 777 | enable_ip6=True) |
| 778 | self.vapi.ip_reassembly_enable_disable( |
| 779 | sw_if_index=self.dst_if.sw_if_index, enable_ip4=True, |
| 780 | enable_ip6=True) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 781 | self.vapi.ip_reassembly_set(timeout_ms=0, max_reassemblies=1000, |
| 782 | expire_walk_interval_ms=10) |
| 783 | self.vapi.ip_reassembly_set(timeout_ms=0, max_reassemblies=1000, |
| 784 | expire_walk_interval_ms=10, is_ip6=1) |
| 785 | self.sleep(.25) |
| 786 | self.vapi.ip_reassembly_set(timeout_ms=1000000, max_reassemblies=1000, |
| 787 | expire_walk_interval_ms=10000) |
| 788 | self.vapi.ip_reassembly_set(timeout_ms=1000000, max_reassemblies=1000, |
| 789 | expire_walk_interval_ms=10000, is_ip6=1) |
| 790 | |
| 791 | def tearDown(self): |
| 792 | self.logger.debug(self.vapi.ppcli("show ip4-reassembly details")) |
| 793 | self.logger.debug(self.vapi.ppcli("show ip6-reassembly details")) |
| 794 | super(TestFIFReassembly, self).tearDown() |
| 795 | |
| 796 | def verify_capture(self, capture, ip_class, dropped_packet_indexes=[]): |
| 797 | """Verify captured packet stream. |
| 798 | |
| 799 | :param list capture: Captured packet stream. |
| 800 | """ |
| 801 | info = None |
| 802 | seen = set() |
| 803 | for packet in capture: |
| 804 | try: |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 805 | self.logger.debug(ppp("Got packet:", packet)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 806 | ip = packet[ip_class] |
| 807 | udp = packet[UDP] |
| 808 | payload_info = self.payload_to_info(str(packet[Raw])) |
| 809 | packet_index = payload_info.index |
| 810 | self.assertTrue( |
| 811 | packet_index not in dropped_packet_indexes, |
| 812 | ppp("Packet received, but should be dropped:", packet)) |
| 813 | if packet_index in seen: |
| 814 | raise Exception(ppp("Duplicate packet received", packet)) |
| 815 | seen.add(packet_index) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 816 | self.assertEqual(payload_info.dst, self.dst_if.sw_if_index) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 817 | info = self._packet_infos[packet_index] |
| 818 | self.assertTrue(info is not None) |
| 819 | self.assertEqual(packet_index, info.index) |
| 820 | saved_packet = info.data |
| 821 | self.assertEqual(ip.src, saved_packet[ip_class].src) |
| 822 | self.assertEqual(ip.dst, saved_packet[ip_class].dst) |
| 823 | self.assertEqual(udp.payload, saved_packet[UDP].payload) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 824 | except Exception: |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 825 | self.logger.error(ppp("Unexpected or invalid packet:", packet)) |
| 826 | raise |
| 827 | for index in self._packet_infos: |
| 828 | self.assertTrue(index in seen or index in dropped_packet_indexes, |
| 829 | "Packet with packet_index %d not received" % index) |
| 830 | |
| 831 | def test_fif4(self): |
| 832 | """ Fragments in fragments (4o4) """ |
| 833 | |
| 834 | # TODO this should be ideally in setUpClass, but then we hit a bug |
| 835 | # with VppIpRoute incorrectly reporting it's present when it's not |
| 836 | # so we need to manually remove the vpp config, thus we cannot have |
| 837 | # it shared for multiple test cases |
| 838 | self.tun_ip4 = "1.1.1.2" |
| 839 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 840 | self.gre4 = VppGreInterface(self, self.src_if.local_ip4, self.tun_ip4) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 841 | self.gre4.add_vpp_config() |
| 842 | self.gre4.admin_up() |
| 843 | self.gre4.config_ip4() |
| 844 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 845 | self.vapi.ip_reassembly_enable_disable( |
| 846 | sw_if_index=self.gre4.sw_if_index, enable_ip4=True) |
| 847 | |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 848 | self.route4 = VppIpRoute(self, self.tun_ip4, 32, |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 849 | [VppRoutePath(self.src_if.remote_ip4, |
| 850 | self.src_if.sw_if_index)]) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 851 | self.route4.add_vpp_config() |
| 852 | |
| 853 | self.reset_packet_infos() |
| 854 | for i in range(test_packet_count): |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 855 | info = self.create_packet_info(self.src_if, self.dst_if) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 856 | payload = self.info_to_payload(info) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 857 | # Ethernet header here is only for size calculation, thus it |
| 858 | # doesn't matter how it's initialized. This is to ensure that |
| 859 | # reassembled packet is not > 9000 bytes, so that it's not dropped |
| 860 | p = (Ether() / |
| 861 | IP(id=i, src=self.src_if.remote_ip4, |
| 862 | dst=self.dst_if.remote_ip4) / |
| 863 | UDP(sport=1234, dport=5678) / |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 864 | Raw(payload)) |
| 865 | size = self.packet_sizes[(i // 2) % len(self.packet_sizes)] |
| 866 | self.extend_packet(p, size, self.padding) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 867 | info.data = p[IP] # use only IP part, without ethernet header |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 868 | |
| 869 | fragments = [x for _, p in self._packet_infos.iteritems() |
| 870 | for x in fragment_rfc791(p.data, 400)] |
| 871 | |
| 872 | encapped_fragments = \ |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 873 | [Ether(dst=self.src_if.local_mac, src=self.src_if.remote_mac) / |
| 874 | IP(src=self.tun_ip4, dst=self.src_if.local_ip4) / |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 875 | GRE() / |
| 876 | p |
| 877 | for p in fragments] |
| 878 | |
| 879 | fragmented_encapped_fragments = \ |
| 880 | [x for p in encapped_fragments |
| 881 | for x in fragment_rfc791(p, 200)] |
| 882 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 883 | self.src_if.add_stream(fragmented_encapped_fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 884 | |
| 885 | self.pg_enable_capture(self.pg_interfaces) |
| 886 | self.pg_start() |
| 887 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 888 | self.src_if.assert_nothing_captured() |
| 889 | packets = self.dst_if.get_capture(len(self._packet_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 890 | self.verify_capture(packets, IP) |
| 891 | |
| 892 | # TODO remove gre vpp config by hand until VppIpRoute gets fixed |
| 893 | # so that it's query_vpp_config() works as it should |
| 894 | self.gre4.remove_vpp_config() |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 895 | self.logger.debug(self.vapi.ppcli("show interface")) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 896 | |
| 897 | def test_fif6(self): |
| 898 | """ Fragments in fragments (6o6) """ |
| 899 | # TODO this should be ideally in setUpClass, but then we hit a bug |
| 900 | # with VppIpRoute incorrectly reporting it's present when it's not |
| 901 | # so we need to manually remove the vpp config, thus we cannot have |
| 902 | # it shared for multiple test cases |
| 903 | self.tun_ip6 = "1002::1" |
| 904 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 905 | self.gre6 = VppGre6Interface(self, self.src_if.local_ip6, self.tun_ip6) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 906 | self.gre6.add_vpp_config() |
| 907 | self.gre6.admin_up() |
| 908 | self.gre6.config_ip6() |
| 909 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 910 | self.vapi.ip_reassembly_enable_disable( |
| 911 | sw_if_index=self.gre6.sw_if_index, enable_ip6=True) |
| 912 | |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 913 | self.route6 = VppIpRoute(self, self.tun_ip6, 128, |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 914 | [VppRoutePath(self.src_if.remote_ip6, |
| 915 | self.src_if.sw_if_index, |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 916 | proto=DpoProto.DPO_PROTO_IP6)], |
| 917 | is_ip6=1) |
| 918 | self.route6.add_vpp_config() |
| 919 | |
| 920 | self.reset_packet_infos() |
| 921 | for i in range(test_packet_count): |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 922 | info = self.create_packet_info(self.src_if, self.dst_if) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 923 | payload = self.info_to_payload(info) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 924 | # Ethernet header here is only for size calculation, thus it |
| 925 | # doesn't matter how it's initialized. This is to ensure that |
| 926 | # reassembled packet is not > 9000 bytes, so that it's not dropped |
| 927 | p = (Ether() / |
| 928 | IPv6(src=self.src_if.remote_ip6, dst=self.dst_if.remote_ip6) / |
| 929 | UDP(sport=1234, dport=5678) / |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 930 | Raw(payload)) |
| 931 | size = self.packet_sizes[(i // 2) % len(self.packet_sizes)] |
| 932 | self.extend_packet(p, size, self.padding) |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 933 | info.data = p[IPv6] # use only IPv6 part, without ethernet header |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 934 | |
| 935 | fragments = [x for _, i in self._packet_infos.iteritems() |
| 936 | for x in fragment_rfc8200( |
| 937 | i.data, i.index, 400)] |
| 938 | |
| 939 | encapped_fragments = \ |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 940 | [Ether(dst=self.src_if.local_mac, src=self.src_if.remote_mac) / |
| 941 | IPv6(src=self.tun_ip6, dst=self.src_if.local_ip6) / |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 942 | GRE() / |
| 943 | p |
| 944 | for p in fragments] |
| 945 | |
| 946 | fragmented_encapped_fragments = \ |
| 947 | [x for p in encapped_fragments for x in ( |
| 948 | fragment_rfc8200( |
| 949 | p, |
| 950 | 2 * len(self._packet_infos) + p[IPv6ExtHdrFragment].id, |
| 951 | 200) |
| 952 | if IPv6ExtHdrFragment in p else [p] |
| 953 | ) |
| 954 | ] |
| 955 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 956 | self.src_if.add_stream(fragmented_encapped_fragments) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 957 | |
| 958 | self.pg_enable_capture(self.pg_interfaces) |
| 959 | self.pg_start() |
| 960 | |
Klement Sekera | 4c53313 | 2018-02-22 11:41:12 +0100 | [diff] [blame] | 961 | self.src_if.assert_nothing_captured() |
| 962 | packets = self.dst_if.get_capture(len(self._packet_infos)) |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 963 | self.verify_capture(packets, IPv6) |
| 964 | |
| 965 | # TODO remove gre vpp config by hand until VppIpRoute gets fixed |
| 966 | # so that it's query_vpp_config() works as it should |
Klement Sekera | 3ecc221 | 2018-03-27 10:34:43 +0200 | [diff] [blame] | 967 | self.gre6.remove_vpp_config() |
Klement Sekera | 75e7d13 | 2017-09-20 08:26:30 +0200 | [diff] [blame] | 968 | |
| 969 | |
| 970 | if __name__ == '__main__': |
| 971 | unittest.main(testRunner=VppTestRunner) |