Renato Botelho do Couto | ead1e53 | 2019-10-31 13:31:07 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Paul Vinciguerra | 661f91f | 2018-11-28 19:06:41 -0800 | [diff] [blame] | 2 | from __future__ import print_function |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 3 | import binascii |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 4 | import random |
| 5 | import socket |
| 6 | import unittest |
| 7 | import time |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 8 | import re |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 9 | |
| 10 | from scapy.packet import Raw |
| 11 | from scapy.layers.l2 import Ether |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 12 | from scapy.layers.inet import IP, TCP, UDP |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 13 | from scapy.layers.inet6 import IPv6 |
| 14 | |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 15 | from config import config |
Dave Wallace | 670724c | 2022-09-20 21:52:18 -0400 | [diff] [blame] | 16 | from framework import tag_fixme_vpp_workers, tag_fixme_ubuntu2204, tag_fixme_debian11 |
| 17 | from framework import is_distro_ubuntu2204, is_distro_debian11 |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 18 | from framework import VppTestCase, VppTestRunner |
Andrew Yourtchenko | 06f3281 | 2021-01-14 10:19:08 +0000 | [diff] [blame] | 19 | from framework import tag_run_solo |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 20 | from vpp_object import VppObject |
| 21 | from vpp_pg_interface import CaptureTimeoutError |
| 22 | from util import ppp |
| 23 | from ipfix import IPFIX, Set, Template, Data, IPFIXDecoder |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 24 | from vpp_ip_route import VppIpRoute, VppRoutePath |
Ole Troan | b0d83f1 | 2019-10-21 23:13:46 +0200 | [diff] [blame] | 25 | from vpp_papi.macaddress import mac_ntop |
| 26 | from socket import inet_ntop |
Ole Troan | 3013e69 | 2019-12-09 15:51:44 +0100 | [diff] [blame] | 27 | from vpp_papi import VppEnum |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 28 | |
| 29 | |
| 30 | class VppCFLOW(VppObject): |
| 31 | """CFLOW object for IPFIX exporter and Flowprobe feature""" |
| 32 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 33 | def __init__( |
| 34 | self, |
| 35 | test, |
| 36 | intf="pg2", |
| 37 | active=0, |
| 38 | passive=0, |
| 39 | timeout=100, |
| 40 | mtu=1024, |
| 41 | datapath="l2", |
| 42 | layer="l2 l3 l4", |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 43 | direction="tx", |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 44 | ): |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 45 | self._test = test |
| 46 | self._intf = intf |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 47 | self._intf_obj = getattr(self._test, intf) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 48 | self._active = active |
| 49 | if passive == 0 or passive < active: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 50 | self._passive = active + 1 |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 51 | else: |
| 52 | self._passive = passive |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 53 | self._datapath = datapath # l2 ip4 ip6 |
| 54 | self._collect = layer # l2 l3 l4 |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 55 | self._direction = direction # rx tx both |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 56 | self._timeout = timeout |
| 57 | self._mtu = mtu |
| 58 | self._configured = False |
| 59 | |
| 60 | def add_vpp_config(self): |
| 61 | self.enable_exporter() |
Ole Troan | 3013e69 | 2019-12-09 15:51:44 +0100 | [diff] [blame] | 62 | l2_flag = 0 |
| 63 | l3_flag = 0 |
| 64 | l4_flag = 0 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 65 | if "l2" in self._collect.lower(): |
| 66 | l2_flag = VppEnum.vl_api_flowprobe_record_flags_t.FLOWPROBE_RECORD_FLAG_L2 |
| 67 | if "l3" in self._collect.lower(): |
| 68 | l3_flag = VppEnum.vl_api_flowprobe_record_flags_t.FLOWPROBE_RECORD_FLAG_L3 |
| 69 | if "l4" in self._collect.lower(): |
| 70 | l4_flag = VppEnum.vl_api_flowprobe_record_flags_t.FLOWPROBE_RECORD_FLAG_L4 |
Alexander Chernavin | 86c7856 | 2022-05-12 14:56:24 +0000 | [diff] [blame] | 71 | self._test.vapi.flowprobe_set_params( |
Ole Troan | 3013e69 | 2019-12-09 15:51:44 +0100 | [diff] [blame] | 72 | record_flags=(l2_flag | l3_flag | l4_flag), |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 73 | active_timer=self._active, |
| 74 | passive_timer=self._passive, |
| 75 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 76 | self.enable_flowprobe_feature() |
| 77 | self._test.vapi.cli("ipfix flush") |
| 78 | self._configured = True |
| 79 | |
| 80 | def remove_vpp_config(self): |
| 81 | self.disable_exporter() |
| 82 | self.disable_flowprobe_feature() |
| 83 | self._test.vapi.cli("ipfix flush") |
| 84 | self._configured = False |
| 85 | |
| 86 | def enable_exporter(self): |
| 87 | self._test.vapi.set_ipfix_exporter( |
Jakub Grajciar | 2f71a88 | 2019-10-10 14:21:22 +0200 | [diff] [blame] | 88 | collector_address=self._test.pg0.remote_ip4, |
| 89 | src_address=self._test.pg0.local_ip4, |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 90 | path_mtu=self._mtu, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 91 | template_interval=self._timeout, |
| 92 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 93 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 94 | def _enable_disable_flowprobe_feature(self, is_add): |
| 95 | which_map = { |
| 96 | "l2": VppEnum.vl_api_flowprobe_which_t.FLOWPROBE_WHICH_L2, |
| 97 | "ip4": VppEnum.vl_api_flowprobe_which_t.FLOWPROBE_WHICH_IP4, |
| 98 | "ip6": VppEnum.vl_api_flowprobe_which_t.FLOWPROBE_WHICH_IP6, |
| 99 | } |
| 100 | direction_map = { |
| 101 | "rx": VppEnum.vl_api_flowprobe_direction_t.FLOWPROBE_DIRECTION_RX, |
| 102 | "tx": VppEnum.vl_api_flowprobe_direction_t.FLOWPROBE_DIRECTION_TX, |
| 103 | "both": VppEnum.vl_api_flowprobe_direction_t.FLOWPROBE_DIRECTION_BOTH, |
| 104 | } |
| 105 | self._test.vapi.flowprobe_interface_add_del( |
| 106 | is_add=is_add, |
| 107 | which=which_map[self._datapath], |
| 108 | direction=direction_map[self._direction], |
| 109 | sw_if_index=self._intf_obj.sw_if_index, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 110 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 111 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 112 | def enable_flowprobe_feature(self): |
| 113 | self._enable_disable_flowprobe_feature(is_add=True) |
| 114 | |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 115 | def disable_exporter(self): |
| 116 | self._test.vapi.cli("set ipfix exporter collector 0.0.0.0") |
| 117 | |
| 118 | def disable_flowprobe_feature(self): |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 119 | self._enable_disable_flowprobe_feature(is_add=False) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 120 | |
| 121 | def object_id(self): |
Paul Vinciguerra | e3a0e6e | 2019-03-14 08:46:52 -0700 | [diff] [blame] | 122 | return "ipfix-collector-%s-%s" % (self._src, self.dst) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 123 | |
| 124 | def query_vpp_config(self): |
| 125 | return self._configured |
| 126 | |
| 127 | def verify_templates(self, decoder=None, timeout=1, count=3): |
| 128 | templates = [] |
Klement Sekera | c479457 | 2021-09-08 15:15:59 +0200 | [diff] [blame] | 129 | self._test.assertIn(count, (1, 2, 3)) |
| 130 | for _ in range(count): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 131 | p = self._test.wait_for_cflow_packet(self._test.collector, 2, timeout) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 132 | self._test.assertTrue(p.haslayer(IPFIX)) |
| 133 | if decoder is not None and p.haslayer(Template): |
| 134 | templates.append(p[Template].templateID) |
| 135 | decoder.add_template(p.getlayer(Template)) |
| 136 | return templates |
| 137 | |
| 138 | |
| 139 | class MethodHolder(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 140 | """Flow-per-packet plugin: test L2, IP4, IP6 reporting""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 141 | |
| 142 | # Test variables |
| 143 | debug_print = False |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 144 | max_number_of_packets = 10 |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 145 | pkts = [] |
| 146 | |
| 147 | @classmethod |
| 148 | def setUpClass(cls): |
| 149 | """ |
| 150 | Perform standard class setup (defined by class method setUpClass in |
| 151 | class VppTestCase) before running the test case, set test case related |
| 152 | variables and configure VPP. |
| 153 | """ |
| 154 | super(MethodHolder, cls).setUpClass() |
Dave Wallace | 670724c | 2022-09-20 21:52:18 -0400 | [diff] [blame] | 155 | if (is_distro_ubuntu2204 == True or is_distro_debian11 == True) and not hasattr( |
| 156 | cls, "vpp" |
| 157 | ): |
| 158 | return |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 159 | try: |
| 160 | # Create pg interfaces |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 161 | cls.create_pg_interfaces(range(9)) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 162 | |
| 163 | # Packet sizes |
| 164 | cls.pg_if_packet_sizes = [64, 512, 1518, 9018] |
| 165 | |
| 166 | # Create BD with MAC learning and unknown unicast flooding disabled |
| 167 | # and put interfaces to this BD |
Laszlo Kiraly | 0f8f435 | 2022-09-16 13:20:07 +0200 | [diff] [blame] | 168 | cls.vapi.bridge_domain_add_del_v2( |
| 169 | bd_id=1, uu_flood=1, learn=1, flood=1, forward=1, is_add=1 |
| 170 | ) |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 171 | cls.vapi.sw_interface_set_l2_bridge( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 172 | rx_sw_if_index=cls.pg1._sw_if_index, bd_id=1 |
| 173 | ) |
Ole Troan | a5b2eec | 2019-03-11 19:23:25 +0100 | [diff] [blame] | 174 | cls.vapi.sw_interface_set_l2_bridge( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 175 | rx_sw_if_index=cls.pg2._sw_if_index, bd_id=1 |
| 176 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 177 | |
| 178 | # Set up all interfaces |
| 179 | for i in cls.pg_interfaces: |
| 180 | i.admin_up() |
| 181 | |
| 182 | cls.pg0.config_ip4() |
| 183 | cls.pg0.configure_ipv4_neighbors() |
| 184 | cls.collector = cls.pg0 |
| 185 | |
| 186 | cls.pg1.config_ip4() |
| 187 | cls.pg1.resolve_arp() |
| 188 | cls.pg2.config_ip4() |
| 189 | cls.pg2.resolve_arp() |
| 190 | cls.pg3.config_ip4() |
| 191 | cls.pg3.resolve_arp() |
| 192 | cls.pg4.config_ip4() |
| 193 | cls.pg4.resolve_arp() |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 194 | cls.pg7.config_ip4() |
| 195 | cls.pg8.config_ip4() |
| 196 | cls.pg8.configure_ipv4_neighbors() |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 197 | |
| 198 | cls.pg5.config_ip6() |
| 199 | cls.pg5.resolve_ndp() |
| 200 | cls.pg5.disable_ipv6_ra() |
| 201 | cls.pg6.config_ip6() |
| 202 | cls.pg6.resolve_ndp() |
| 203 | cls.pg6.disable_ipv6_ra() |
| 204 | except Exception: |
| 205 | super(MethodHolder, cls).tearDownClass() |
| 206 | raise |
| 207 | |
Paul Vinciguerra | 8d991d9 | 2019-01-25 14:05:48 -0800 | [diff] [blame] | 208 | @classmethod |
| 209 | def tearDownClass(cls): |
| 210 | super(MethodHolder, cls).tearDownClass() |
| 211 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 212 | def create_stream( |
| 213 | self, src_if=None, dst_if=None, packets=None, size=None, ip_ver="v4" |
| 214 | ): |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 215 | """Create a packet stream to tickle the plugin |
| 216 | |
| 217 | :param VppInterface src_if: Source interface for packet stream |
| 218 | :param VppInterface src_if: Dst interface for packet stream |
| 219 | """ |
| 220 | if src_if is None: |
| 221 | src_if = self.pg1 |
| 222 | if dst_if is None: |
| 223 | dst_if = self.pg2 |
| 224 | self.pkts = [] |
| 225 | if packets is None: |
| 226 | packets = random.randint(1, self.max_number_of_packets) |
| 227 | pkt_size = size |
| 228 | for p in range(0, packets): |
| 229 | if size is None: |
| 230 | pkt_size = random.choice(self.pg_if_packet_sizes) |
| 231 | info = self.create_packet_info(src_if, dst_if) |
| 232 | payload = self.info_to_payload(info) |
| 233 | p = Ether(src=src_if.remote_mac, dst=src_if.local_mac) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 234 | if ip_ver == "v4": |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 235 | p /= IP(src=src_if.remote_ip4, dst=dst_if.remote_ip4) |
| 236 | else: |
| 237 | p /= IPv6(src=src_if.remote_ip6, dst=dst_if.remote_ip6) |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 238 | p /= UDP(sport=1234, dport=4321) |
| 239 | p /= Raw(payload) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 240 | info.data = p.copy() |
| 241 | self.extend_packet(p, pkt_size) |
| 242 | self.pkts.append(p) |
| 243 | |
| 244 | def verify_cflow_data(self, decoder, capture, cflow): |
| 245 | octets = 0 |
| 246 | packets = 0 |
| 247 | for p in capture: |
| 248 | octets += p[IP].len |
| 249 | packets += 1 |
| 250 | if cflow.haslayer(Data): |
| 251 | data = decoder.decode_data_set(cflow.getlayer(Set)) |
| 252 | for record in data: |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 253 | self.assertEqual(int(binascii.hexlify(record[1]), 16), octets) |
| 254 | self.assertEqual(int(binascii.hexlify(record[2]), 16), packets) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 255 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 256 | def send_packets(self, src_if=None, dst_if=None): |
| 257 | if src_if is None: |
| 258 | src_if = self.pg1 |
| 259 | if dst_if is None: |
| 260 | dst_if = self.pg2 |
| 261 | self.pg_enable_capture([dst_if]) |
| 262 | src_if.add_stream(self.pkts) |
| 263 | self.pg_start() |
| 264 | return dst_if.get_capture(len(self.pkts)) |
| 265 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 266 | def verify_cflow_data_detail( |
| 267 | self, decoder, capture, cflow, data_set={1: "octets", 2: "packets"}, ip_ver="v4" |
| 268 | ): |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 269 | if self.debug_print: |
Paul Vinciguerra | 661f91f | 2018-11-28 19:06:41 -0800 | [diff] [blame] | 270 | print(capture[0].show()) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 271 | if cflow.haslayer(Data): |
| 272 | data = decoder.decode_data_set(cflow.getlayer(Set)) |
| 273 | if self.debug_print: |
Paul Vinciguerra | 661f91f | 2018-11-28 19:06:41 -0800 | [diff] [blame] | 274 | print(data) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 275 | if ip_ver == "v4": |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 276 | ip_layer = capture[0][IP] |
| 277 | else: |
| 278 | ip_layer = capture[0][IPv6] |
| 279 | if data_set is not None: |
| 280 | for record in data: |
Paul Vinciguerra | 8feeaff | 2019-03-27 11:25:48 -0700 | [diff] [blame] | 281 | # skip flow if ingress/egress interface is 0 |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 282 | if int(binascii.hexlify(record[10]), 16) == 0: |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 283 | continue |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 284 | if int(binascii.hexlify(record[14]), 16) == 0: |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 285 | continue |
| 286 | |
| 287 | for field in data_set: |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 288 | value = data_set[field] |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 289 | if value == "octets": |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 290 | value = ip_layer.len |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 291 | if ip_ver == "v6": |
| 292 | value += 40 # ??? is this correct |
| 293 | elif value == "packets": |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 294 | value = 1 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 295 | elif value == "src_ip": |
| 296 | if ip_ver == "v4": |
| 297 | ip = socket.inet_pton(socket.AF_INET, ip_layer.src) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 298 | else: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 299 | ip = socket.inet_pton(socket.AF_INET6, ip_layer.src) |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 300 | value = int(binascii.hexlify(ip), 16) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 301 | elif value == "dst_ip": |
| 302 | if ip_ver == "v4": |
| 303 | ip = socket.inet_pton(socket.AF_INET, ip_layer.dst) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 304 | else: |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 305 | ip = socket.inet_pton(socket.AF_INET6, ip_layer.dst) |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 306 | value = int(binascii.hexlify(ip), 16) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 307 | elif value == "sport": |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 308 | value = int(capture[0][UDP].sport) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 309 | elif value == "dport": |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 310 | value = int(capture[0][UDP].dport) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 311 | self.assertEqual( |
| 312 | int(binascii.hexlify(record[field]), 16), value |
| 313 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 314 | |
| 315 | def verify_cflow_data_notimer(self, decoder, capture, cflows): |
| 316 | idx = 0 |
| 317 | for cflow in cflows: |
| 318 | if cflow.haslayer(Data): |
| 319 | data = decoder.decode_data_set(cflow.getlayer(Set)) |
| 320 | else: |
| 321 | raise Exception("No CFLOW data") |
| 322 | |
| 323 | for rec in data: |
| 324 | p = capture[idx] |
| 325 | idx += 1 |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 326 | self.assertEqual(p[IP].len, int(binascii.hexlify(rec[1]), 16)) |
| 327 | self.assertEqual(1, int(binascii.hexlify(rec[2]), 16)) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 328 | self.assertEqual(len(capture), idx) |
| 329 | |
Klement Sekera | c479457 | 2021-09-08 15:15:59 +0200 | [diff] [blame] | 330 | def wait_for_cflow_packet(self, collector_intf, set_id=2, timeout=1): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 331 | """wait for CFLOW packet and verify its correctness |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 332 | |
| 333 | :param timeout: how long to wait |
| 334 | |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 335 | """ |
| 336 | self.logger.info("IPFIX: Waiting for CFLOW packet") |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 337 | # self.logger.debug(self.vapi.ppcli("show flow table")) |
Klement Sekera | c479457 | 2021-09-08 15:15:59 +0200 | [diff] [blame] | 338 | p = collector_intf.wait_for_packet(timeout=timeout) |
| 339 | self.assertEqual(p[Set].setID, set_id) |
| 340 | # self.logger.debug(self.vapi.ppcli("show flow table")) |
| 341 | self.logger.debug(ppp("IPFIX: Got packet:", p)) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 342 | return p |
| 343 | |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 344 | |
Andrew Yourtchenko | 06f3281 | 2021-01-14 10:19:08 +0000 | [diff] [blame] | 345 | @tag_run_solo |
Andrew Yourtchenko | 8dc0d48 | 2021-01-29 13:17:19 +0000 | [diff] [blame] | 346 | @tag_fixme_vpp_workers |
Dave Wallace | 670724c | 2022-09-20 21:52:18 -0400 | [diff] [blame] | 347 | @tag_fixme_ubuntu2204 |
| 348 | @tag_fixme_debian11 |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 349 | class Flowprobe(MethodHolder): |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 350 | """Template verification, timer tests""" |
| 351 | |
Paul Vinciguerra | 8d991d9 | 2019-01-25 14:05:48 -0800 | [diff] [blame] | 352 | @classmethod |
| 353 | def setUpClass(cls): |
| 354 | super(Flowprobe, cls).setUpClass() |
| 355 | |
| 356 | @classmethod |
| 357 | def tearDownClass(cls): |
| 358 | super(Flowprobe, cls).tearDownClass() |
| 359 | |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 360 | def test_0001(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 361 | """timer less than template timeout""" |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 362 | self.logger.info("FFP_TEST_START_0001") |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 363 | self.pg_enable_capture(self.pg_interfaces) |
| 364 | self.pkts = [] |
| 365 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 366 | ipfix = VppCFLOW(test=self, active=2) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 367 | ipfix.add_vpp_config() |
| 368 | |
| 369 | ipfix_decoder = IPFIXDecoder() |
| 370 | # template packet should arrive immediately |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 371 | templates = ipfix.verify_templates(ipfix_decoder) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 372 | |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 373 | self.create_stream(packets=1) |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 374 | self.send_packets() |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 375 | capture = self.pg2.get_capture(1) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 376 | |
| 377 | # make sure the one packet we expect actually showed up |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 378 | cflow = self.wait_for_cflow_packet(self.collector, templates[1], 15) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 379 | self.verify_cflow_data(ipfix_decoder, capture, cflow) |
| 380 | |
| 381 | ipfix.remove_vpp_config() |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 382 | self.logger.info("FFP_TEST_FINISH_0001") |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 383 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 384 | def test_0002(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 385 | """timer greater than template timeout""" |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 386 | self.logger.info("FFP_TEST_START_0002") |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 387 | self.pg_enable_capture(self.pg_interfaces) |
| 388 | self.pkts = [] |
| 389 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 390 | ipfix = VppCFLOW(test=self, timeout=3, active=4) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 391 | ipfix.add_vpp_config() |
| 392 | |
| 393 | ipfix_decoder = IPFIXDecoder() |
| 394 | # template packet should arrive immediately |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 395 | ipfix.verify_templates() |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 396 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 397 | self.create_stream(packets=2) |
| 398 | self.send_packets() |
| 399 | capture = self.pg2.get_capture(2) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 400 | |
| 401 | # next set of template packet should arrive after 20 seconds |
| 402 | # template packet should arrive within 20 s |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 403 | templates = ipfix.verify_templates(ipfix_decoder, timeout=5) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 404 | |
| 405 | # make sure the one packet we expect actually showed up |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 406 | cflow = self.wait_for_cflow_packet(self.collector, templates[1], 15) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 407 | self.verify_cflow_data(ipfix_decoder, capture, cflow) |
| 408 | |
| 409 | ipfix.remove_vpp_config() |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 410 | self.logger.info("FFP_TEST_FINISH_0002") |
| 411 | |
| 412 | def test_cflow_packet(self): |
| 413 | """verify cflow packet fields""" |
| 414 | self.logger.info("FFP_TEST_START_0000") |
| 415 | self.pg_enable_capture(self.pg_interfaces) |
| 416 | self.pkts = [] |
| 417 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 418 | ipfix = VppCFLOW( |
| 419 | test=self, intf="pg8", datapath="ip4", layer="l2 l3 l4", active=2 |
| 420 | ) |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 421 | ipfix.add_vpp_config() |
| 422 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 423 | route_9001 = VppIpRoute( |
| 424 | self, |
| 425 | "9.0.0.0", |
| 426 | 24, |
| 427 | [VppRoutePath(self.pg8._remote_hosts[0].ip4, self.pg8.sw_if_index)], |
| 428 | ) |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 429 | route_9001.add_vpp_config() |
| 430 | |
| 431 | ipfix_decoder = IPFIXDecoder() |
| 432 | templates = ipfix.verify_templates(ipfix_decoder, count=1) |
| 433 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 434 | self.pkts = [ |
| 435 | ( |
| 436 | Ether(dst=self.pg7.local_mac, src=self.pg7.remote_mac) |
| 437 | / IP(src=self.pg7.remote_ip4, dst="9.0.0.100") |
| 438 | / TCP(sport=1234, dport=4321, flags=80) |
| 439 | / Raw(b"\xa5" * 100) |
| 440 | ) |
| 441 | ] |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 442 | |
| 443 | nowUTC = int(time.time()) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 444 | nowUNIX = nowUTC + 2208988800 |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 445 | self.send_packets(src_if=self.pg7, dst_if=self.pg8) |
| 446 | |
| 447 | cflow = self.wait_for_cflow_packet(self.collector, templates[0], 10) |
| 448 | self.collector.get_capture(2) |
| 449 | |
| 450 | if cflow[0].haslayer(IPFIX): |
| 451 | self.assertEqual(cflow[IPFIX].version, 10) |
| 452 | self.assertEqual(cflow[IPFIX].observationDomainID, 1) |
| 453 | self.assertEqual(cflow[IPFIX].sequenceNumber, 0) |
| 454 | self.assertAlmostEqual(cflow[IPFIX].exportTime, nowUTC, delta=5) |
| 455 | if cflow.haslayer(Data): |
| 456 | record = ipfix_decoder.decode_data_set(cflow[0].getlayer(Set))[0] |
| 457 | # ingress interface |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 458 | self.assertEqual(int(binascii.hexlify(record[10]), 16), 8) |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 459 | # egress interface |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 460 | self.assertEqual(int(binascii.hexlify(record[14]), 16), 9) |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 461 | # direction |
| 462 | self.assertEqual(int(binascii.hexlify(record[61]), 16), 1) |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 463 | # packets |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 464 | self.assertEqual(int(binascii.hexlify(record[2]), 16), 1) |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 465 | # src mac |
Ole Troan | b0d83f1 | 2019-10-21 23:13:46 +0200 | [diff] [blame] | 466 | self.assertEqual(mac_ntop(record[56]), self.pg8.local_mac) |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 467 | # dst mac |
Ole Troan | b0d83f1 | 2019-10-21 23:13:46 +0200 | [diff] [blame] | 468 | self.assertEqual(mac_ntop(record[80]), self.pg8.remote_mac) |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 469 | flowTimestamp = int(binascii.hexlify(record[156]), 16) >> 32 |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 470 | # flow start timestamp |
| 471 | self.assertAlmostEqual(flowTimestamp, nowUNIX, delta=1) |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 472 | flowTimestamp = int(binascii.hexlify(record[157]), 16) >> 32 |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 473 | # flow end timestamp |
| 474 | self.assertAlmostEqual(flowTimestamp, nowUNIX, delta=1) |
| 475 | # ethernet type |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 476 | self.assertEqual(int(binascii.hexlify(record[256]), 16), 8) |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 477 | # src ip |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 478 | self.assertEqual(inet_ntop(socket.AF_INET, record[8]), self.pg7.remote_ip4) |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 479 | # dst ip |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 480 | self.assertEqual(inet_ntop(socket.AF_INET, record[12]), "9.0.0.100") |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 481 | # protocol (TCP) |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 482 | self.assertEqual(int(binascii.hexlify(record[4]), 16), 6) |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 483 | # src port |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 484 | self.assertEqual(int(binascii.hexlify(record[7]), 16), 1234) |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 485 | # dst port |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 486 | self.assertEqual(int(binascii.hexlify(record[11]), 16), 4321) |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 487 | # tcp flags |
Paul Vinciguerra | 6e4c6ad | 2018-11-25 10:35:29 -0800 | [diff] [blame] | 488 | self.assertEqual(int(binascii.hexlify(record[6]), 16), 80) |
Ole Troan | ed92925 | 2017-06-13 21:15:40 +0200 | [diff] [blame] | 489 | |
| 490 | ipfix.remove_vpp_config() |
| 491 | self.logger.info("FFP_TEST_FINISH_0000") |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 492 | |
Alexander Chernavin | 86c7856 | 2022-05-12 14:56:24 +0000 | [diff] [blame] | 493 | def test_interface_dump(self): |
| 494 | """Dump interfaces with IPFIX flow record generation enabled""" |
| 495 | self.logger.info("FFP_TEST_START_0003") |
| 496 | |
| 497 | # Enable feature for 3 interfaces |
| 498 | ipfix1 = VppCFLOW(test=self, intf="pg1", datapath="l2", direction="rx") |
| 499 | ipfix1.add_vpp_config() |
| 500 | |
| 501 | ipfix2 = VppCFLOW(test=self, intf="pg2", datapath="ip4", direction="tx") |
| 502 | ipfix2.enable_flowprobe_feature() |
| 503 | |
| 504 | ipfix3 = VppCFLOW(test=self, intf="pg3", datapath="ip6", direction="both") |
| 505 | ipfix3.enable_flowprobe_feature() |
| 506 | |
| 507 | # When request "all", dump should contain all enabled interfaces |
| 508 | dump = self.vapi.flowprobe_interface_dump() |
| 509 | self.assertEqual(len(dump), 3) |
| 510 | |
| 511 | # Verify 1st interface |
| 512 | self.assertEqual(dump[0].sw_if_index, self.pg1.sw_if_index) |
| 513 | self.assertEqual( |
| 514 | dump[0].which, VppEnum.vl_api_flowprobe_which_t.FLOWPROBE_WHICH_L2 |
| 515 | ) |
| 516 | self.assertEqual( |
| 517 | dump[0].direction, |
| 518 | VppEnum.vl_api_flowprobe_direction_t.FLOWPROBE_DIRECTION_RX, |
| 519 | ) |
| 520 | |
| 521 | # Verify 2nd interface |
| 522 | self.assertEqual(dump[1].sw_if_index, self.pg2.sw_if_index) |
| 523 | self.assertEqual( |
| 524 | dump[1].which, VppEnum.vl_api_flowprobe_which_t.FLOWPROBE_WHICH_IP4 |
| 525 | ) |
| 526 | self.assertEqual( |
| 527 | dump[1].direction, |
| 528 | VppEnum.vl_api_flowprobe_direction_t.FLOWPROBE_DIRECTION_TX, |
| 529 | ) |
| 530 | |
| 531 | # Verify 3rd interface |
| 532 | self.assertEqual(dump[2].sw_if_index, self.pg3.sw_if_index) |
| 533 | self.assertEqual( |
| 534 | dump[2].which, VppEnum.vl_api_flowprobe_which_t.FLOWPROBE_WHICH_IP6 |
| 535 | ) |
| 536 | self.assertEqual( |
| 537 | dump[2].direction, |
| 538 | VppEnum.vl_api_flowprobe_direction_t.FLOWPROBE_DIRECTION_BOTH, |
| 539 | ) |
| 540 | |
| 541 | # When request 2nd interface, dump should contain only the specified interface |
| 542 | dump = self.vapi.flowprobe_interface_dump(sw_if_index=self.pg2.sw_if_index) |
| 543 | self.assertEqual(len(dump), 1) |
| 544 | |
| 545 | # Verify 2nd interface |
| 546 | self.assertEqual(dump[0].sw_if_index, self.pg2.sw_if_index) |
| 547 | self.assertEqual( |
| 548 | dump[0].which, VppEnum.vl_api_flowprobe_which_t.FLOWPROBE_WHICH_IP4 |
| 549 | ) |
| 550 | self.assertEqual( |
| 551 | dump[0].direction, |
| 552 | VppEnum.vl_api_flowprobe_direction_t.FLOWPROBE_DIRECTION_TX, |
| 553 | ) |
| 554 | |
| 555 | # When request 99th interface, dump should be empty |
| 556 | dump = self.vapi.flowprobe_interface_dump(sw_if_index=99) |
| 557 | self.assertEqual(len(dump), 0) |
| 558 | |
| 559 | ipfix1.remove_vpp_config() |
| 560 | ipfix2.remove_vpp_config() |
| 561 | ipfix3.remove_vpp_config() |
| 562 | self.logger.info("FFP_TEST_FINISH_0003") |
| 563 | |
| 564 | def test_get_params(self): |
| 565 | """Get IPFIX flow record generation parameters""" |
| 566 | self.logger.info("FFP_TEST_START_0004") |
| 567 | |
| 568 | # Enable feature for an interface with custom parameters |
| 569 | ipfix = VppCFLOW(test=self, active=20, passive=40, layer="l2 l3 l4") |
| 570 | ipfix.add_vpp_config() |
| 571 | |
| 572 | # Get and verify parameters |
| 573 | params = self.vapi.flowprobe_get_params() |
| 574 | self.assertEqual(params.active_timer, 20) |
| 575 | self.assertEqual(params.passive_timer, 40) |
| 576 | record_flags = VppEnum.vl_api_flowprobe_record_flags_t.FLOWPROBE_RECORD_FLAG_L2 |
| 577 | record_flags |= VppEnum.vl_api_flowprobe_record_flags_t.FLOWPROBE_RECORD_FLAG_L3 |
| 578 | record_flags |= VppEnum.vl_api_flowprobe_record_flags_t.FLOWPROBE_RECORD_FLAG_L4 |
| 579 | self.assertEqual(params.record_flags, record_flags) |
| 580 | |
| 581 | ipfix.remove_vpp_config() |
| 582 | self.logger.info("FFP_TEST_FINISH_0004") |
| 583 | |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 584 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 585 | class DatapathTestsHolder(object): |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 586 | """collect information on Ethernet, IP4 and IP6 datapath (no timers)""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 587 | |
Paul Vinciguerra | 8d991d9 | 2019-01-25 14:05:48 -0800 | [diff] [blame] | 588 | @classmethod |
| 589 | def setUpClass(cls): |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 590 | super(DatapathTestsHolder, cls).setUpClass() |
Paul Vinciguerra | 8d991d9 | 2019-01-25 14:05:48 -0800 | [diff] [blame] | 591 | |
| 592 | @classmethod |
| 593 | def tearDownClass(cls): |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 594 | super(DatapathTestsHolder, cls).tearDownClass() |
Paul Vinciguerra | 8d991d9 | 2019-01-25 14:05:48 -0800 | [diff] [blame] | 595 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 596 | def test_templatesL2(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 597 | """verify template on L2 datapath""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 598 | self.logger.info("FFP_TEST_START_0000") |
| 599 | self.pg_enable_capture(self.pg_interfaces) |
| 600 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 601 | ipfix = VppCFLOW( |
| 602 | test=self, intf=self.intf1, layer="l2", direction=self.direction |
| 603 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 604 | ipfix.add_vpp_config() |
| 605 | |
| 606 | # template packet should arrive immediately |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 607 | self.vapi.ipfix_flush() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 608 | ipfix.verify_templates(timeout=3, count=1) |
| 609 | self.collector.get_capture(1) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 610 | |
| 611 | ipfix.remove_vpp_config() |
| 612 | self.logger.info("FFP_TEST_FINISH_0000") |
| 613 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 614 | def test_L2onL2(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 615 | """L2 data on L2 datapath""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 616 | self.logger.info("FFP_TEST_START_0001") |
| 617 | self.pg_enable_capture(self.pg_interfaces) |
| 618 | self.pkts = [] |
| 619 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 620 | ipfix = VppCFLOW( |
| 621 | test=self, intf=self.intf1, layer="l2", direction=self.direction |
| 622 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 623 | ipfix.add_vpp_config() |
| 624 | |
| 625 | ipfix_decoder = IPFIXDecoder() |
| 626 | # template packet should arrive immediately |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 627 | templates = ipfix.verify_templates(ipfix_decoder, count=1) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 628 | |
| 629 | self.create_stream(packets=1) |
| 630 | capture = self.send_packets() |
| 631 | |
| 632 | # make sure the one packet we expect actually showed up |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 633 | self.vapi.ipfix_flush() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 634 | cflow = self.wait_for_cflow_packet(self.collector, templates[0]) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 635 | self.verify_cflow_data_detail( |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 636 | ipfix_decoder, |
| 637 | capture, |
| 638 | cflow, |
| 639 | {2: "packets", 256: 8, 61: (self.direction == "tx")}, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 640 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 641 | self.collector.get_capture(2) |
| 642 | |
| 643 | ipfix.remove_vpp_config() |
| 644 | self.logger.info("FFP_TEST_FINISH_0001") |
| 645 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 646 | def test_L3onL2(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 647 | """L3 data on L2 datapath""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 648 | self.logger.info("FFP_TEST_START_0002") |
| 649 | self.pg_enable_capture(self.pg_interfaces) |
| 650 | self.pkts = [] |
| 651 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 652 | ipfix = VppCFLOW( |
| 653 | test=self, intf=self.intf1, layer="l3", direction=self.direction |
| 654 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 655 | ipfix.add_vpp_config() |
| 656 | |
| 657 | ipfix_decoder = IPFIXDecoder() |
| 658 | # template packet should arrive immediately |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 659 | templates = ipfix.verify_templates(ipfix_decoder, count=2) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 660 | |
| 661 | self.create_stream(packets=1) |
| 662 | capture = self.send_packets() |
| 663 | |
| 664 | # make sure the one packet we expect actually showed up |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 665 | self.vapi.ipfix_flush() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 666 | cflow = self.wait_for_cflow_packet(self.collector, templates[0]) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 667 | self.verify_cflow_data_detail( |
| 668 | ipfix_decoder, |
| 669 | capture, |
| 670 | cflow, |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 671 | { |
| 672 | 2: "packets", |
| 673 | 4: 17, |
| 674 | 8: "src_ip", |
| 675 | 12: "dst_ip", |
| 676 | 61: (self.direction == "tx"), |
| 677 | }, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 678 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 679 | |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 680 | self.collector.get_capture(3) |
| 681 | |
| 682 | ipfix.remove_vpp_config() |
| 683 | self.logger.info("FFP_TEST_FINISH_0002") |
| 684 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 685 | def test_L4onL2(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 686 | """L4 data on L2 datapath""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 687 | self.logger.info("FFP_TEST_START_0003") |
| 688 | self.pg_enable_capture(self.pg_interfaces) |
| 689 | self.pkts = [] |
| 690 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 691 | ipfix = VppCFLOW( |
| 692 | test=self, intf=self.intf1, layer="l4", direction=self.direction |
| 693 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 694 | ipfix.add_vpp_config() |
| 695 | |
| 696 | ipfix_decoder = IPFIXDecoder() |
| 697 | # template packet should arrive immediately |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 698 | templates = ipfix.verify_templates(ipfix_decoder, count=2) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 699 | |
| 700 | self.create_stream(packets=1) |
| 701 | capture = self.send_packets() |
| 702 | |
| 703 | # make sure the one packet we expect actually showed up |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 704 | self.vapi.ipfix_flush() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 705 | cflow = self.wait_for_cflow_packet(self.collector, templates[0]) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 706 | self.verify_cflow_data_detail( |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 707 | ipfix_decoder, |
| 708 | capture, |
| 709 | cflow, |
| 710 | {2: "packets", 7: "sport", 11: "dport", 61: (self.direction == "tx")}, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 711 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 712 | |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 713 | self.collector.get_capture(3) |
| 714 | |
| 715 | ipfix.remove_vpp_config() |
| 716 | self.logger.info("FFP_TEST_FINISH_0003") |
| 717 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 718 | def test_templatesIp4(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 719 | """verify templates on IP4 datapath""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 720 | self.logger.info("FFP_TEST_START_0000") |
| 721 | |
| 722 | self.pg_enable_capture(self.pg_interfaces) |
| 723 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 724 | ipfix = VppCFLOW( |
| 725 | test=self, intf=self.intf1, datapath="ip4", direction=self.direction |
| 726 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 727 | ipfix.add_vpp_config() |
| 728 | |
| 729 | # template packet should arrive immediately |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 730 | self.vapi.ipfix_flush() |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 731 | ipfix.verify_templates(timeout=3, count=1) |
| 732 | self.collector.get_capture(1) |
| 733 | |
| 734 | ipfix.remove_vpp_config() |
| 735 | |
| 736 | self.logger.info("FFP_TEST_FINISH_0000") |
| 737 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 738 | def test_L2onIP4(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 739 | """L2 data on IP4 datapath""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 740 | self.logger.info("FFP_TEST_START_0001") |
| 741 | self.pg_enable_capture(self.pg_interfaces) |
| 742 | self.pkts = [] |
| 743 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 744 | ipfix = VppCFLOW( |
| 745 | test=self, |
| 746 | intf=self.intf2, |
| 747 | layer="l2", |
| 748 | datapath="ip4", |
| 749 | direction=self.direction, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 750 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 751 | ipfix.add_vpp_config() |
| 752 | |
| 753 | ipfix_decoder = IPFIXDecoder() |
| 754 | # template packet should arrive immediately |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 755 | templates = ipfix.verify_templates(ipfix_decoder, count=1) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 756 | |
| 757 | self.create_stream(src_if=self.pg3, dst_if=self.pg4, packets=1) |
| 758 | capture = self.send_packets(src_if=self.pg3, dst_if=self.pg4) |
| 759 | |
| 760 | # make sure the one packet we expect actually showed up |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 761 | self.vapi.ipfix_flush() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 762 | cflow = self.wait_for_cflow_packet(self.collector, templates[0]) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 763 | self.verify_cflow_data_detail( |
| 764 | ipfix_decoder, |
| 765 | capture, |
| 766 | cflow, |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 767 | {2: "packets", 256: 8, 61: (self.direction == "tx")}, |
| 768 | ) |
| 769 | |
| 770 | # expected two templates and one cflow packet |
| 771 | self.collector.get_capture(2) |
| 772 | |
| 773 | ipfix.remove_vpp_config() |
| 774 | self.logger.info("FFP_TEST_FINISH_0001") |
| 775 | |
| 776 | def test_L3onIP4(self): |
| 777 | """L3 data on IP4 datapath""" |
| 778 | self.logger.info("FFP_TEST_START_0002") |
| 779 | self.pg_enable_capture(self.pg_interfaces) |
| 780 | self.pkts = [] |
| 781 | |
| 782 | ipfix = VppCFLOW( |
| 783 | test=self, |
| 784 | intf=self.intf2, |
| 785 | layer="l3", |
| 786 | datapath="ip4", |
| 787 | direction=self.direction, |
| 788 | ) |
| 789 | ipfix.add_vpp_config() |
| 790 | |
| 791 | ipfix_decoder = IPFIXDecoder() |
| 792 | # template packet should arrive immediately |
| 793 | templates = ipfix.verify_templates(ipfix_decoder, count=1) |
| 794 | |
| 795 | self.create_stream(src_if=self.pg3, dst_if=self.pg4, packets=1) |
| 796 | capture = self.send_packets(src_if=self.pg3, dst_if=self.pg4) |
| 797 | |
| 798 | # make sure the one packet we expect actually showed up |
| 799 | self.vapi.ipfix_flush() |
| 800 | cflow = self.wait_for_cflow_packet(self.collector, templates[0]) |
| 801 | self.verify_cflow_data_detail( |
| 802 | ipfix_decoder, |
| 803 | capture, |
| 804 | cflow, |
| 805 | { |
| 806 | 1: "octets", |
| 807 | 2: "packets", |
| 808 | 8: "src_ip", |
| 809 | 12: "dst_ip", |
| 810 | 61: (self.direction == "tx"), |
| 811 | }, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 812 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 813 | |
| 814 | # expected two templates and one cflow packet |
| 815 | self.collector.get_capture(2) |
| 816 | |
| 817 | ipfix.remove_vpp_config() |
| 818 | self.logger.info("FFP_TEST_FINISH_0002") |
| 819 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 820 | def test_L4onIP4(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 821 | """L4 data on IP4 datapath""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 822 | self.logger.info("FFP_TEST_START_0003") |
| 823 | self.pg_enable_capture(self.pg_interfaces) |
| 824 | self.pkts = [] |
| 825 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 826 | ipfix = VppCFLOW( |
| 827 | test=self, |
| 828 | intf=self.intf2, |
| 829 | layer="l4", |
| 830 | datapath="ip4", |
| 831 | direction=self.direction, |
| 832 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 833 | ipfix.add_vpp_config() |
| 834 | |
| 835 | ipfix_decoder = IPFIXDecoder() |
| 836 | # template packet should arrive immediately |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 837 | templates = ipfix.verify_templates(ipfix_decoder, count=1) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 838 | |
| 839 | self.create_stream(src_if=self.pg3, dst_if=self.pg4, packets=1) |
| 840 | capture = self.send_packets(src_if=self.pg3, dst_if=self.pg4) |
| 841 | |
| 842 | # make sure the one packet we expect actually showed up |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 843 | self.vapi.ipfix_flush() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 844 | cflow = self.wait_for_cflow_packet(self.collector, templates[0]) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 845 | self.verify_cflow_data_detail( |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 846 | ipfix_decoder, |
| 847 | capture, |
| 848 | cflow, |
| 849 | {2: "packets", 7: "sport", 11: "dport", 61: (self.direction == "tx")}, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 850 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 851 | |
| 852 | # expected two templates and one cflow packet |
| 853 | self.collector.get_capture(2) |
| 854 | |
| 855 | ipfix.remove_vpp_config() |
| 856 | self.logger.info("FFP_TEST_FINISH_0003") |
| 857 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 858 | def test_templatesIP6(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 859 | """verify templates on IP6 datapath""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 860 | self.logger.info("FFP_TEST_START_0000") |
| 861 | self.pg_enable_capture(self.pg_interfaces) |
| 862 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 863 | ipfix = VppCFLOW( |
| 864 | test=self, intf=self.intf1, datapath="ip6", direction=self.direction |
| 865 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 866 | ipfix.add_vpp_config() |
| 867 | |
| 868 | # template packet should arrive immediately |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 869 | ipfix.verify_templates(count=1) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 870 | self.collector.get_capture(1) |
| 871 | |
| 872 | ipfix.remove_vpp_config() |
| 873 | |
| 874 | self.logger.info("FFP_TEST_FINISH_0000") |
| 875 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 876 | def test_L2onIP6(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 877 | """L2 data on IP6 datapath""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 878 | self.logger.info("FFP_TEST_START_0001") |
| 879 | self.pg_enable_capture(self.pg_interfaces) |
| 880 | self.pkts = [] |
| 881 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 882 | ipfix = VppCFLOW( |
| 883 | test=self, |
| 884 | intf=self.intf3, |
| 885 | layer="l2", |
| 886 | datapath="ip6", |
| 887 | direction=self.direction, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 888 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 889 | ipfix.add_vpp_config() |
| 890 | |
| 891 | ipfix_decoder = IPFIXDecoder() |
| 892 | # template packet should arrive immediately |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 893 | templates = ipfix.verify_templates(ipfix_decoder, count=1) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 894 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 895 | self.create_stream(src_if=self.pg5, dst_if=self.pg6, packets=1, ip_ver="IPv6") |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 896 | capture = self.send_packets(src_if=self.pg5, dst_if=self.pg6) |
| 897 | |
| 898 | # make sure the one packet we expect actually showed up |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 899 | self.vapi.ipfix_flush() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 900 | cflow = self.wait_for_cflow_packet(self.collector, templates[0]) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 901 | self.verify_cflow_data_detail( |
| 902 | ipfix_decoder, |
| 903 | capture, |
| 904 | cflow, |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 905 | {2: "packets", 256: 56710, 61: (self.direction == "tx")}, |
| 906 | ip_ver="v6", |
| 907 | ) |
| 908 | |
| 909 | # expected two templates and one cflow packet |
| 910 | self.collector.get_capture(2) |
| 911 | |
| 912 | ipfix.remove_vpp_config() |
| 913 | self.logger.info("FFP_TEST_FINISH_0001") |
| 914 | |
| 915 | def test_L3onIP6(self): |
| 916 | """L3 data on IP6 datapath""" |
| 917 | self.logger.info("FFP_TEST_START_0002") |
| 918 | self.pg_enable_capture(self.pg_interfaces) |
| 919 | self.pkts = [] |
| 920 | |
| 921 | ipfix = VppCFLOW( |
| 922 | test=self, |
| 923 | intf=self.intf3, |
| 924 | layer="l3", |
| 925 | datapath="ip6", |
| 926 | direction=self.direction, |
| 927 | ) |
| 928 | ipfix.add_vpp_config() |
| 929 | |
| 930 | ipfix_decoder = IPFIXDecoder() |
| 931 | # template packet should arrive immediately |
| 932 | templates = ipfix.verify_templates(ipfix_decoder, count=1) |
| 933 | |
| 934 | self.create_stream(src_if=self.pg5, dst_if=self.pg6, packets=1, ip_ver="IPv6") |
| 935 | capture = self.send_packets(src_if=self.pg5, dst_if=self.pg6) |
| 936 | |
| 937 | # make sure the one packet we expect actually showed up |
| 938 | self.vapi.ipfix_flush() |
| 939 | cflow = self.wait_for_cflow_packet(self.collector, templates[0]) |
| 940 | self.verify_cflow_data_detail( |
| 941 | ipfix_decoder, |
| 942 | capture, |
| 943 | cflow, |
| 944 | {2: "packets", 27: "src_ip", 28: "dst_ip", 61: (self.direction == "tx")}, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 945 | ip_ver="v6", |
| 946 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 947 | |
| 948 | # expected two templates and one cflow packet |
| 949 | self.collector.get_capture(2) |
| 950 | |
| 951 | ipfix.remove_vpp_config() |
| 952 | self.logger.info("FFP_TEST_FINISH_0002") |
| 953 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 954 | def test_L4onIP6(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 955 | """L4 data on IP6 datapath""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 956 | self.logger.info("FFP_TEST_START_0003") |
| 957 | self.pg_enable_capture(self.pg_interfaces) |
| 958 | self.pkts = [] |
| 959 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 960 | ipfix = VppCFLOW( |
| 961 | test=self, |
| 962 | intf=self.intf3, |
| 963 | layer="l4", |
| 964 | datapath="ip6", |
| 965 | direction=self.direction, |
| 966 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 967 | ipfix.add_vpp_config() |
| 968 | |
| 969 | ipfix_decoder = IPFIXDecoder() |
| 970 | # template packet should arrive immediately |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 971 | templates = ipfix.verify_templates(ipfix_decoder, count=1) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 972 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 973 | self.create_stream(src_if=self.pg5, dst_if=self.pg6, packets=1, ip_ver="IPv6") |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 974 | capture = self.send_packets(src_if=self.pg5, dst_if=self.pg6) |
| 975 | |
| 976 | # make sure the one packet we expect actually showed up |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 977 | self.vapi.ipfix_flush() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 978 | cflow = self.wait_for_cflow_packet(self.collector, templates[0]) |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 979 | self.verify_cflow_data_detail( |
| 980 | ipfix_decoder, |
| 981 | capture, |
| 982 | cflow, |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 983 | {2: "packets", 7: "sport", 11: "dport", 61: (self.direction == "tx")}, |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 984 | ip_ver="v6", |
| 985 | ) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 986 | |
| 987 | # expected two templates and one cflow packet |
| 988 | self.collector.get_capture(2) |
| 989 | |
| 990 | ipfix.remove_vpp_config() |
| 991 | self.logger.info("FFP_TEST_FINISH_0003") |
| 992 | |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 993 | def test_0001(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 994 | """no timers, one CFLOW packet, 9 Flows inside""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 995 | self.logger.info("FFP_TEST_START_0001") |
| 996 | self.pg_enable_capture(self.pg_interfaces) |
| 997 | self.pkts = [] |
| 998 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 999 | ipfix = VppCFLOW(test=self, intf=self.intf1, direction=self.direction) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1000 | ipfix.add_vpp_config() |
| 1001 | |
| 1002 | ipfix_decoder = IPFIXDecoder() |
| 1003 | # template packet should arrive immediately |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1004 | templates = ipfix.verify_templates(ipfix_decoder) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1005 | |
| 1006 | self.create_stream(packets=9) |
| 1007 | capture = self.send_packets() |
| 1008 | |
| 1009 | # make sure the one packet we expect actually showed up |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 1010 | self.vapi.ipfix_flush() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1011 | cflow = self.wait_for_cflow_packet(self.collector, templates[1]) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1012 | self.verify_cflow_data_notimer(ipfix_decoder, capture, [cflow]) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1013 | self.collector.get_capture(4) |
| 1014 | |
| 1015 | ipfix.remove_vpp_config() |
| 1016 | self.logger.info("FFP_TEST_FINISH_0001") |
| 1017 | |
| 1018 | def test_0002(self): |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 1019 | """no timers, two CFLOW packets (mtu=260), 3 Flows in each""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1020 | self.logger.info("FFP_TEST_START_0002") |
| 1021 | self.pg_enable_capture(self.pg_interfaces) |
| 1022 | self.pkts = [] |
| 1023 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 1024 | ipfix = VppCFLOW(test=self, intf=self.intf1, direction=self.direction, mtu=260) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1025 | ipfix.add_vpp_config() |
| 1026 | |
| 1027 | ipfix_decoder = IPFIXDecoder() |
| 1028 | # template packet should arrive immediately |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 1029 | self.vapi.ipfix_flush() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1030 | templates = ipfix.verify_templates(ipfix_decoder) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1031 | |
| 1032 | self.create_stream(packets=6) |
| 1033 | capture = self.send_packets() |
| 1034 | |
| 1035 | # make sure the one packet we expect actually showed up |
| 1036 | cflows = [] |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 1037 | self.vapi.ipfix_flush() |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1038 | cflows.append(self.wait_for_cflow_packet(self.collector, templates[1])) |
| 1039 | cflows.append(self.wait_for_cflow_packet(self.collector, templates[1])) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1040 | self.verify_cflow_data_notimer(ipfix_decoder, capture, cflows) |
| 1041 | self.collector.get_capture(5) |
| 1042 | |
| 1043 | ipfix.remove_vpp_config() |
| 1044 | self.logger.info("FFP_TEST_FINISH_0002") |
| 1045 | |
| 1046 | |
Alexander Chernavin | 6f5ddf3 | 2022-05-06 11:35:59 +0000 | [diff] [blame] | 1047 | @tag_fixme_vpp_workers |
| 1048 | class DatapathTx(MethodHolder, DatapathTestsHolder): |
| 1049 | """Collect info on Ethernet, IP4 and IP6 datapath (TX) (no timers)""" |
| 1050 | |
| 1051 | intf1 = "pg2" |
| 1052 | intf2 = "pg4" |
| 1053 | intf3 = "pg6" |
| 1054 | direction = "tx" |
| 1055 | |
| 1056 | |
| 1057 | @tag_fixme_vpp_workers |
| 1058 | class DatapathRx(MethodHolder, DatapathTestsHolder): |
| 1059 | """Collect info on Ethernet, IP4 and IP6 datapath (RX) (no timers)""" |
| 1060 | |
| 1061 | intf1 = "pg1" |
| 1062 | intf2 = "pg3" |
| 1063 | intf3 = "pg5" |
| 1064 | direction = "rx" |
| 1065 | |
| 1066 | |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 1067 | @unittest.skipUnless(config.extended, "part of extended tests") |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1068 | class DisableIPFIX(MethodHolder): |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1069 | """Disable IPFIX""" |
| 1070 | |
Paul Vinciguerra | 8d991d9 | 2019-01-25 14:05:48 -0800 | [diff] [blame] | 1071 | @classmethod |
| 1072 | def setUpClass(cls): |
| 1073 | super(DisableIPFIX, cls).setUpClass() |
| 1074 | |
| 1075 | @classmethod |
| 1076 | def tearDownClass(cls): |
| 1077 | super(DisableIPFIX, cls).tearDownClass() |
| 1078 | |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1079 | def test_0001(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1080 | """disable IPFIX after first packets""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1081 | self.logger.info("FFP_TEST_START_0001") |
| 1082 | self.pg_enable_capture(self.pg_interfaces) |
| 1083 | self.pkts = [] |
| 1084 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1085 | ipfix = VppCFLOW(test=self) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1086 | ipfix.add_vpp_config() |
| 1087 | |
| 1088 | ipfix_decoder = IPFIXDecoder() |
| 1089 | # template packet should arrive immediately |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1090 | templates = ipfix.verify_templates(ipfix_decoder) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1091 | |
| 1092 | self.create_stream() |
| 1093 | self.send_packets() |
| 1094 | |
| 1095 | # make sure the one packet we expect actually showed up |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 1096 | self.vapi.ipfix_flush() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1097 | self.wait_for_cflow_packet(self.collector, templates[1]) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1098 | self.collector.get_capture(4) |
| 1099 | |
Paul Vinciguerra | 8feeaff | 2019-03-27 11:25:48 -0700 | [diff] [blame] | 1100 | # disable IPFIX |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1101 | ipfix.disable_exporter() |
| 1102 | self.pg_enable_capture([self.collector]) |
| 1103 | |
| 1104 | self.send_packets() |
| 1105 | |
| 1106 | # make sure no one packet arrived in 1 minute |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 1107 | self.vapi.ipfix_flush() |
Klement Sekera | c479457 | 2021-09-08 15:15:59 +0200 | [diff] [blame] | 1108 | self.sleep(1, "wait before verifying no packets sent") |
| 1109 | self.collector.assert_nothing_captured() |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1110 | |
| 1111 | ipfix.remove_vpp_config() |
| 1112 | self.logger.info("FFP_TEST_FINISH_0001") |
| 1113 | |
| 1114 | |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 1115 | @unittest.skipUnless(config.extended, "part of extended tests") |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1116 | class ReenableIPFIX(MethodHolder): |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1117 | """Re-enable IPFIX""" |
| 1118 | |
Paul Vinciguerra | 8d991d9 | 2019-01-25 14:05:48 -0800 | [diff] [blame] | 1119 | @classmethod |
| 1120 | def setUpClass(cls): |
| 1121 | super(ReenableIPFIX, cls).setUpClass() |
| 1122 | |
| 1123 | @classmethod |
| 1124 | def tearDownClass(cls): |
| 1125 | super(ReenableIPFIX, cls).tearDownClass() |
| 1126 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1127 | def test_0011(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1128 | """disable IPFIX after first packets and re-enable after few packets""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1129 | self.logger.info("FFP_TEST_START_0001") |
| 1130 | self.pg_enable_capture(self.pg_interfaces) |
| 1131 | self.pkts = [] |
| 1132 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1133 | ipfix = VppCFLOW(test=self) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1134 | ipfix.add_vpp_config() |
| 1135 | |
| 1136 | ipfix_decoder = IPFIXDecoder() |
| 1137 | # template packet should arrive immediately |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1138 | templates = ipfix.verify_templates(ipfix_decoder) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1139 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1140 | self.create_stream(packets=5) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1141 | self.send_packets() |
| 1142 | |
| 1143 | # make sure the one packet we expect actually showed up |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 1144 | self.vapi.ipfix_flush() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1145 | self.wait_for_cflow_packet(self.collector, templates[1]) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1146 | self.collector.get_capture(4) |
| 1147 | |
Paul Vinciguerra | 8d991d9 | 2019-01-25 14:05:48 -0800 | [diff] [blame] | 1148 | # disable IPFIX |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1149 | ipfix.disable_exporter() |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 1150 | self.vapi.ipfix_flush() |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1151 | self.pg_enable_capture([self.collector]) |
| 1152 | |
| 1153 | self.send_packets() |
| 1154 | |
| 1155 | # make sure no one packet arrived in active timer span |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 1156 | self.vapi.ipfix_flush() |
Klement Sekera | c479457 | 2021-09-08 15:15:59 +0200 | [diff] [blame] | 1157 | self.sleep(1, "wait before verifying no packets sent") |
| 1158 | self.collector.assert_nothing_captured() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1159 | self.pg2.get_capture(5) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1160 | |
| 1161 | # enable IPFIX |
| 1162 | ipfix.enable_exporter() |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1163 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1164 | capture = self.collector.get_capture(4) |
| 1165 | nr_templates = 0 |
| 1166 | nr_data = 0 |
| 1167 | for p in capture: |
| 1168 | self.assertTrue(p.haslayer(IPFIX)) |
| 1169 | if p.haslayer(Template): |
| 1170 | nr_templates += 1 |
| 1171 | self.assertTrue(nr_templates, 3) |
| 1172 | for p in capture: |
| 1173 | self.assertTrue(p.haslayer(IPFIX)) |
| 1174 | if p.haslayer(Data): |
| 1175 | nr_data += 1 |
| 1176 | self.assertTrue(nr_templates, 1) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1177 | |
| 1178 | ipfix.remove_vpp_config() |
| 1179 | self.logger.info("FFP_TEST_FINISH_0001") |
| 1180 | |
| 1181 | |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 1182 | @unittest.skipUnless(config.extended, "part of extended tests") |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1183 | class DisableFP(MethodHolder): |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1184 | """Disable Flowprobe feature""" |
| 1185 | |
Paul Vinciguerra | 8d991d9 | 2019-01-25 14:05:48 -0800 | [diff] [blame] | 1186 | @classmethod |
| 1187 | def setUpClass(cls): |
| 1188 | super(DisableFP, cls).setUpClass() |
| 1189 | |
| 1190 | @classmethod |
| 1191 | def tearDownClass(cls): |
| 1192 | super(DisableFP, cls).tearDownClass() |
| 1193 | |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1194 | def test_0001(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1195 | """disable flowprobe feature after first packets""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1196 | self.logger.info("FFP_TEST_START_0001") |
| 1197 | self.pg_enable_capture(self.pg_interfaces) |
| 1198 | self.pkts = [] |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1199 | ipfix = VppCFLOW(test=self) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1200 | ipfix.add_vpp_config() |
| 1201 | |
| 1202 | ipfix_decoder = IPFIXDecoder() |
| 1203 | # template packet should arrive immediately |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1204 | templates = ipfix.verify_templates(ipfix_decoder) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1205 | |
| 1206 | self.create_stream() |
| 1207 | self.send_packets() |
| 1208 | |
| 1209 | # make sure the one packet we expect actually showed up |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 1210 | self.vapi.ipfix_flush() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1211 | self.wait_for_cflow_packet(self.collector, templates[1]) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1212 | self.collector.get_capture(4) |
| 1213 | |
Paul Vinciguerra | 8feeaff | 2019-03-27 11:25:48 -0700 | [diff] [blame] | 1214 | # disable IPFIX |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1215 | ipfix.disable_flowprobe_feature() |
| 1216 | self.pg_enable_capture([self.collector]) |
| 1217 | |
| 1218 | self.send_packets() |
| 1219 | |
| 1220 | # make sure no one packet arrived in active timer span |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 1221 | self.vapi.ipfix_flush() |
Klement Sekera | c479457 | 2021-09-08 15:15:59 +0200 | [diff] [blame] | 1222 | self.sleep(1, "wait before verifying no packets sent") |
| 1223 | self.collector.assert_nothing_captured() |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1224 | |
| 1225 | ipfix.remove_vpp_config() |
| 1226 | self.logger.info("FFP_TEST_FINISH_0001") |
| 1227 | |
| 1228 | |
Klement Sekera | b23ffd7 | 2021-05-31 16:08:53 +0200 | [diff] [blame] | 1229 | @unittest.skipUnless(config.extended, "part of extended tests") |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1230 | class ReenableFP(MethodHolder): |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1231 | """Re-enable Flowprobe feature""" |
| 1232 | |
Paul Vinciguerra | 8d991d9 | 2019-01-25 14:05:48 -0800 | [diff] [blame] | 1233 | @classmethod |
| 1234 | def setUpClass(cls): |
| 1235 | super(ReenableFP, cls).setUpClass() |
| 1236 | |
| 1237 | @classmethod |
| 1238 | def tearDownClass(cls): |
| 1239 | super(ReenableFP, cls).tearDownClass() |
| 1240 | |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1241 | def test_0001(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1242 | """disable flowprobe feature after first packets and re-enable |
| 1243 | after few packets""" |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1244 | self.logger.info("FFP_TEST_START_0001") |
| 1245 | self.pg_enable_capture(self.pg_interfaces) |
| 1246 | self.pkts = [] |
| 1247 | |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1248 | ipfix = VppCFLOW(test=self) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1249 | ipfix.add_vpp_config() |
| 1250 | |
| 1251 | ipfix_decoder = IPFIXDecoder() |
| 1252 | # template packet should arrive immediately |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 1253 | self.vapi.ipfix_flush() |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1254 | templates = ipfix.verify_templates(ipfix_decoder, timeout=3) |
| 1255 | |
| 1256 | self.create_stream() |
| 1257 | self.send_packets() |
| 1258 | |
| 1259 | # make sure the one packet we expect actually showed up |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 1260 | self.vapi.ipfix_flush() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1261 | self.wait_for_cflow_packet(self.collector, templates[1], 5) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1262 | self.collector.get_capture(4) |
| 1263 | |
Paul Vinciguerra | 8feeaff | 2019-03-27 11:25:48 -0700 | [diff] [blame] | 1264 | # disable FPP feature |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1265 | ipfix.disable_flowprobe_feature() |
| 1266 | self.pg_enable_capture([self.collector]) |
| 1267 | |
| 1268 | self.send_packets() |
| 1269 | |
| 1270 | # make sure no one packet arrived in active timer span |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 1271 | self.vapi.ipfix_flush() |
Klement Sekera | c479457 | 2021-09-08 15:15:59 +0200 | [diff] [blame] | 1272 | self.sleep(5, "wait before verifying no packets sent") |
| 1273 | self.collector.assert_nothing_captured() |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1274 | |
| 1275 | # enable FPP feature |
| 1276 | ipfix.enable_flowprobe_feature() |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 1277 | self.vapi.ipfix_flush() |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1278 | templates = ipfix.verify_templates(ipfix_decoder, timeout=3) |
| 1279 | |
| 1280 | self.send_packets() |
| 1281 | |
| 1282 | # make sure the next packets (templates and data) we expect actually |
| 1283 | # showed up |
Paul Vinciguerra | 21b83e9 | 2019-06-24 09:55:46 -0400 | [diff] [blame] | 1284 | self.vapi.ipfix_flush() |
Pavel Kotucek | 89111d0 | 2017-06-12 08:26:13 +0200 | [diff] [blame] | 1285 | self.wait_for_cflow_packet(self.collector, templates[1], 5) |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1286 | self.collector.get_capture(4) |
| 1287 | |
| 1288 | ipfix.remove_vpp_config() |
| 1289 | self.logger.info("FFP_TEST_FINISH_0001") |
| 1290 | |
| 1291 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 1292 | if __name__ == "__main__": |
Ole Troan | 5c74973 | 2017-03-13 13:39:52 +0100 | [diff] [blame] | 1293 | unittest.main(testRunner=VppTestRunner) |