blob: d5aebb0add44b71779add5f520d3014a56aefa44 [file] [log] [blame]
Renato Botelho do Coutoead1e532019-10-31 13:31:07 -05001#!/usr/bin/env python3
Pavel Kotucek15ac81c2017-06-20 14:00:26 +02002import random
3import unittest
Pavel Kotucek15ac81c2017-06-20 14:00:26 +02004import re
5
6from scapy.packet import Raw
7from scapy.layers.l2 import Ether
8from scapy.layers.inet import IP, UDP
9from scapy.layers.inet6 import IPv6
10
Dave Wallace8800f732023-08-31 00:47:44 -040011from framework import VppTestCase
12from asfframework import VppTestRunner
Pavel Kotucek15ac81c2017-06-20 14:00:26 +020013from vpp_sub_interface import VppP2PSubint
Neale Rannsc0a93142018-09-05 15:42:26 -070014from vpp_ip_route import VppIpRoute, VppRoutePath
Ole Troan8006c6a2018-12-17 12:02:26 +010015from vpp_papi import mac_pton
Pavel Kotucek15ac81c2017-06-20 14:00:26 +020016
17
18class P2PEthernetAPI(VppTestCase):
19 """P2P Ethernet tests"""
20
21 p2p_sub_ifs = []
22
23 @classmethod
24 def setUpClass(cls):
25 super(P2PEthernetAPI, cls).setUpClass()
26
27 # Create pg interfaces
28 cls.create_pg_interfaces(range(4))
29
30 # Set up all interfaces
31 for i in cls.pg_interfaces:
32 i.admin_up()
33
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -070034 @classmethod
35 def tearDownClass(cls):
36 super(P2PEthernetAPI, cls).tearDownClass()
37
Pavel Kotucek15ac81c2017-06-20 14:00:26 +020038 def create_p2p_ethernet(self, parent_if, sub_id, remote_mac):
Ole Troan8006c6a2018-12-17 12:02:26 +010039 p2p = VppP2PSubint(self, parent_if, sub_id, mac_pton(remote_mac))
Pavel Kotucek15ac81c2017-06-20 14:00:26 +020040 self.p2p_sub_ifs.append(p2p)
41
42 def delete_p2p_ethernet(self, parent_if, remote_mac):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020043 self.vapi.p2p_ethernet_del(parent_if.sw_if_index, mac_pton(remote_mac))
Pavel Kotucek15ac81c2017-06-20 14:00:26 +020044
45 def test_api(self):
46 """delete/create p2p subif"""
47 self.logger.info("FFP_TEST_START_0000")
48
49 self.create_p2p_ethernet(self.pg0, 1, "de:ad:00:00:00:01")
50 self.create_p2p_ethernet(self.pg0, 2, "de:ad:00:00:00:02")
51 intfs = self.vapi.cli("show interface")
52
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020053 self.assertIn("pg0.1", intfs)
54 self.assertIn("pg0.2", intfs)
55 self.assertNotIn("pg0.5", intfs)
Pavel Kotucek15ac81c2017-06-20 14:00:26 +020056
57 # create pg2.5 subif
58 self.create_p2p_ethernet(self.pg0, 5, "de:ad:00:00:00:ff")
59 intfs = self.vapi.cli("show interface")
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020060 self.assertIn("pg0.5", intfs)
Pavel Kotucek15ac81c2017-06-20 14:00:26 +020061 # delete pg2.5 subif
62 self.delete_p2p_ethernet(self.pg0, "de:ad:00:00:00:ff")
63
64 intfs = self.vapi.cli("show interface")
65
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020066 self.assertIn("pg0.1", intfs)
67 self.assertIn("pg0.2", intfs)
68 self.assertNotIn("pg0.5", intfs)
Pavel Kotucek15ac81c2017-06-20 14:00:26 +020069
70 self.logger.info("FFP_TEST_FINISH_0000")
71
72 def test_p2p_subif_creation_1k(self):
73 """create 1k of p2p subifs"""
74 self.logger.info("FFP_TEST_START_0001")
75
76 macs = []
77 clients = 1000
78 mac = int("dead00000000", 16)
79
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020080 for i in range(1, clients + 1):
Pavel Kotucek15ac81c2017-06-20 14:00:26 +020081 try:
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020082 macs.append(":".join(re.findall("..", "{:02x}".format(mac + i))))
83 self.vapi.p2p_ethernet_add(
84 self.pg2.sw_if_index, mac_pton(macs[i - 1]), i
85 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +020086 except Exception:
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020087 self.logger.info("Failed to create subif %d %s" % (i, macs[i - 1]))
Pavel Kotucek15ac81c2017-06-20 14:00:26 +020088 raise
89
90 intfs = self.vapi.cli("show interface").split("\n")
91 count = 0
92 for intf in intfs:
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020093 if intf.startswith("pg2."):
Pavel Kotucek15ac81c2017-06-20 14:00:26 +020094 count += 1
95 self.assertEqual(count, clients)
96
97 self.logger.info("FFP_TEST_FINISH_0001")
98
Pavel Kotucek15ac81c2017-06-20 14:00:26 +020099
100class P2PEthernetIPV6(VppTestCase):
101 """P2P Ethernet IPv6 tests"""
102
103 p2p_sub_ifs = []
104 packets = []
105
106 @classmethod
107 def setUpClass(cls):
108 super(P2PEthernetIPV6, cls).setUpClass()
109
110 # Create pg interfaces
111 cls.create_pg_interfaces(range(3))
112
113 # Packet sizes
114 cls.pg_if_packet_sizes = [64, 512, 1518, 9018]
115
116 # Set up all interfaces
117 for i in cls.pg_interfaces:
118 i.admin_up()
119
120 cls.pg0.generate_remote_hosts(3)
121 cls.pg0.configure_ipv6_neighbors()
122
123 cls.pg1.config_ip6()
124 cls.pg1.generate_remote_hosts(3)
125 cls.pg1.configure_ipv6_neighbors()
126 cls.pg1.disable_ipv6_ra()
127
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -0700128 @classmethod
129 def tearDownClass(cls):
130 super(P2PEthernetIPV6, cls).tearDownClass()
131
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200132 def setUp(self):
133 super(P2PEthernetIPV6, self).setUp()
134 for p in self.packets:
135 self.packets.remove(p)
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700136 self.p2p_sub_ifs.append(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200137 self.create_p2p_ethernet(self.pg0, 1, self.pg0._remote_hosts[0].mac)
138 )
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700139 self.p2p_sub_ifs.append(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200140 self.create_p2p_ethernet(self.pg0, 2, self.pg0._remote_hosts[1].mac)
141 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200142 self.vapi.cli("trace add p2p-ethernet-input 50")
143
144 def tearDown(self):
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700145 while len(self.p2p_sub_ifs):
146 p2p = self.p2p_sub_ifs.pop()
147 self.delete_p2p_ethernet(p2p)
148
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200149 super(P2PEthernetIPV6, self).tearDown()
150
151 def create_p2p_ethernet(self, parent_if, sub_id, remote_mac):
Ole Troan8006c6a2018-12-17 12:02:26 +0100152 p2p = VppP2PSubint(self, parent_if, sub_id, mac_pton(remote_mac))
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200153 p2p.admin_up()
154 p2p.config_ip6()
155 p2p.disable_ipv6_ra()
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700156 return p2p
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200157
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700158 def delete_p2p_ethernet(self, p2p):
159 p2p.unconfig_ip6()
160 p2p.admin_down()
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200161 self.vapi.p2p_ethernet_del(p2p.parent.sw_if_index, p2p.p2p_remote_mac)
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200162
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200163 def create_stream(
164 self, src_mac=None, dst_mac=None, src_ip=None, dst_ip=None, size=None
165 ):
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200166 pkt_size = size
167 if size is None:
168 pkt_size = random.choice(self.pg_if_packet_sizes)
169 p = Ether(src=src_mac, dst=dst_mac)
170 p /= IPv6(src=src_ip, dst=dst_ip)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200171 p /= UDP(sport=1234, dport=4321) / Raw(b"\xa5" * 20)
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200172 self.extend_packet(p, pkt_size)
173 return p
174
175 def send_packets(self, src_if=None, dst_if=None, packets=None, count=None):
176 self.pg_enable_capture([dst_if])
177 if packets is None:
178 packets = self.packets
179 src_if.add_stream(packets)
180 self.pg_start()
181 if count is None:
182 count = len(packets)
183 return dst_if.get_capture(count)
184
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200185 def test_no_p2p_subif(self):
186 """standard routing without p2p subinterfaces"""
187 self.logger.info("FFP_TEST_START_0001")
188
Neale Rannsdc617b82020-08-20 08:22:56 +0000189 self.pg0.config_ip6()
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200190 route_8000 = VppIpRoute(
191 self,
192 "8000::",
193 64,
194 [VppRoutePath(self.pg0.remote_ip6, self.pg0.sw_if_index)],
195 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200196 route_8000.add_vpp_config()
197
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200198 self.packets = [
199 (
200 Ether(dst=self.pg1.local_mac, src=self.pg1.remote_mac)
201 / IPv6(src="3001::1", dst="8000::100")
202 / UDP(sport=1234, dport=1234)
203 / Raw(b"\xa5" * 100)
204 )
205 ]
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200206 self.send_packets(self.pg1, self.pg0)
207
Neale Rannsdc617b82020-08-20 08:22:56 +0000208 self.pg0.unconfig_ip6()
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200209 self.logger.info("FFP_TEST_FINISH_0001")
210
211 def test_ip6_rx_p2p_subif(self):
212 """receive ipv6 packet via p2p subinterface"""
213 self.logger.info("FFP_TEST_START_0002")
214
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200215 route_9001 = VppIpRoute(
216 self,
217 "9001::",
218 64,
219 [VppRoutePath(self.pg1.remote_ip6, self.pg1.sw_if_index)],
220 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200221 route_9001.add_vpp_config()
222
223 self.packets.append(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200224 self.create_stream(
225 src_mac=self.pg0._remote_hosts[0].mac,
226 dst_mac=self.pg0.local_mac,
227 src_ip=self.p2p_sub_ifs[0].remote_ip6,
228 dst_ip="9001::100",
229 )
230 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200231
232 self.send_packets(self.pg0, self.pg1, self.packets)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200233 self.assert_packet_counter_equal("p2p-ethernet-input", 1)
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200234
235 route_9001.remove_vpp_config()
236 self.logger.info("FFP_TEST_FINISH_0002")
237
238 def test_ip6_rx_p2p_subif_route(self):
239 """route rx ip6 packet not matching p2p subinterface"""
240 self.logger.info("FFP_TEST_START_0003")
241
242 self.pg0.config_ip6()
243
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200244 route_3 = VppIpRoute(
245 self,
246 "9000::",
247 64,
248 [VppRoutePath(self.pg1._remote_hosts[0].ip6, self.pg1.sw_if_index)],
249 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200250 route_3.add_vpp_config()
251
252 self.packets.append(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200253 self.create_stream(
254 src_mac="02:03:00:00:ff:ff",
255 dst_mac=self.pg0.local_mac,
256 src_ip="a000::100",
257 dst_ip="9000::100",
258 )
259 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200260
261 self.send_packets(self.pg0, self.pg1)
262
263 self.pg0.unconfig_ip6()
264
265 route_3.remove_vpp_config()
266
267 self.logger.info("FFP_TEST_FINISH_0003")
268
269 def test_ip6_rx_p2p_subif_drop(self):
270 """drop rx packet not matching p2p subinterface"""
271 self.logger.info("FFP_TEST_START_0004")
272
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200273 route_9001 = VppIpRoute(
274 self,
275 "9000::",
276 64,
277 [VppRoutePath(self.pg1._remote_hosts[0].ip6, self.pg1.sw_if_index)],
278 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200279 route_9001.add_vpp_config()
280
281 self.packets.append(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200282 self.create_stream(
283 src_mac="02:03:00:00:ff:ff",
284 dst_mac=self.pg0.local_mac,
285 src_ip="a000::100",
286 dst_ip="9000::100",
287 )
288 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200289
290 # no packet received
291 self.send_packets(self.pg0, self.pg1, count=0)
292 self.logger.info("FFP_TEST_FINISH_0004")
293
294 def test_ip6_tx_p2p_subif(self):
295 """send packet via p2p subinterface"""
296 self.logger.info("FFP_TEST_START_0005")
297
Neale Rannsdc617b82020-08-20 08:22:56 +0000298 self.pg0.config_ip6()
299
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200300 route_8000 = VppIpRoute(
301 self,
302 "8000::",
303 64,
304 [VppRoutePath(self.pg0.remote_hosts[0].ip6, self.pg0.sw_if_index)],
305 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200306 route_8000.add_vpp_config()
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200307 route_8001 = VppIpRoute(
308 self,
309 "8001::",
310 64,
311 [
312 VppRoutePath(
313 self.p2p_sub_ifs[0].remote_ip6, self.p2p_sub_ifs[0].sw_if_index
314 )
315 ],
316 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200317 route_8001.add_vpp_config()
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200318 route_8002 = VppIpRoute(
319 self,
320 "8002::",
321 64,
322 [
323 VppRoutePath(
324 self.p2p_sub_ifs[1].remote_ip6, self.p2p_sub_ifs[1].sw_if_index
325 )
326 ],
327 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200328 route_8002.add_vpp_config()
329
330 for i in range(0, 3):
331 self.packets.append(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200332 self.create_stream(
333 src_mac=self.pg1.remote_mac,
334 dst_mac=self.pg1.local_mac,
335 src_ip=self.pg1.remote_ip6,
336 dst_ip="800%d::100" % i,
337 )
338 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200339
340 self.send_packets(self.pg1, self.pg0, count=3)
341
342 route_8000.remove_vpp_config()
343 route_8001.remove_vpp_config()
344 route_8002.remove_vpp_config()
345
Neale Rannsdc617b82020-08-20 08:22:56 +0000346 self.pg0.unconfig_ip6()
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200347 self.logger.info("FFP_TEST_FINISH_0005")
348
349 def test_ip6_tx_p2p_subif_drop(self):
350 """drop tx ip6 packet not matching p2p subinterface"""
351 self.logger.info("FFP_TEST_START_0006")
352
353 self.packets.append(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200354 self.create_stream(
355 src_mac="02:03:00:00:ff:ff",
356 dst_mac=self.pg0.local_mac,
357 src_ip="a000::100",
358 dst_ip="9000::100",
359 )
360 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200361
362 # no packet received
363 self.send_packets(self.pg0, self.pg1, count=0)
364 self.logger.info("FFP_TEST_FINISH_0006")
365
366
367class P2PEthernetIPV4(VppTestCase):
368 """P2P Ethernet IPv4 tests"""
369
370 p2p_sub_ifs = []
371 packets = []
372
373 @classmethod
374 def setUpClass(cls):
375 super(P2PEthernetIPV4, cls).setUpClass()
376
377 # Create pg interfaces
378 cls.create_pg_interfaces(range(3))
379
380 # Packet sizes
381 cls.pg_if_packet_sizes = [64, 512, 1518, 9018]
382
383 # Set up all interfaces
384 for i in cls.pg_interfaces:
385 i.admin_up()
386
387 cls.pg0.config_ip4()
388 cls.pg0.generate_remote_hosts(5)
389 cls.pg0.configure_ipv4_neighbors()
390
391 cls.pg1.config_ip4()
392 cls.pg1.generate_remote_hosts(5)
393 cls.pg1.configure_ipv4_neighbors()
394
Paul Vinciguerra7f9b7f92019-03-12 19:23:27 -0700395 @classmethod
396 def tearDownClass(cls):
397 super(P2PEthernetIPV4, cls).tearDownClass()
398
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200399 def setUp(self):
400 super(P2PEthernetIPV4, self).setUp()
401 for p in self.packets:
402 self.packets.remove(p)
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700403 self.p2p_sub_ifs.append(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200404 self.create_p2p_ethernet(self.pg0, 1, self.pg0._remote_hosts[0].mac)
405 )
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700406 self.p2p_sub_ifs.append(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200407 self.create_p2p_ethernet(self.pg0, 2, self.pg0._remote_hosts[1].mac)
408 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200409 self.vapi.cli("trace add p2p-ethernet-input 50")
410
411 def tearDown(self):
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700412 while len(self.p2p_sub_ifs):
413 p2p = self.p2p_sub_ifs.pop()
414 self.delete_p2p_ethernet(p2p)
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200415 super(P2PEthernetIPV4, self).tearDown()
416
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200417 def create_stream(
418 self, src_mac=None, dst_mac=None, src_ip=None, dst_ip=None, size=None
419 ):
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200420 pkt_size = size
421 if size is None:
422 pkt_size = random.choice(self.pg_if_packet_sizes)
423 p = Ether(src=src_mac, dst=dst_mac)
424 p /= IP(src=src_ip, dst=dst_ip)
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200425 p /= UDP(sport=1234, dport=4321) / Raw(b"\xa5" * 20)
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200426 self.extend_packet(p, pkt_size)
427 return p
428
429 def send_packets(self, src_if=None, dst_if=None, packets=None, count=None):
430 self.pg_enable_capture([dst_if])
431 if packets is None:
432 packets = self.packets
433 src_if.add_stream(packets)
434 self.pg_start()
435 if count is None:
436 count = len(packets)
437 return dst_if.get_capture(count)
438
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200439 def create_p2p_ethernet(self, parent_if, sub_id, remote_mac):
Ole Troan8006c6a2018-12-17 12:02:26 +0100440 p2p = VppP2PSubint(self, parent_if, sub_id, mac_pton(remote_mac))
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200441 p2p.admin_up()
442 p2p.config_ip4()
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700443 return p2p
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200444
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700445 def delete_p2p_ethernet(self, p2p):
446 p2p.unconfig_ip4()
447 p2p.admin_down()
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200448 self.vapi.p2p_ethernet_del(p2p.parent.sw_if_index, p2p.p2p_remote_mac)
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200449
450 def test_ip4_rx_p2p_subif(self):
451 """receive ipv4 packet via p2p subinterface"""
452 self.logger.info("FFP_TEST_START_0002")
453
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200454 route_9000 = VppIpRoute(
455 self,
456 "9.0.0.0",
457 16,
458 [VppRoutePath(self.pg1.remote_ip4, self.pg1.sw_if_index)],
459 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200460 route_9000.add_vpp_config()
461
462 self.packets.append(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200463 self.create_stream(
464 src_mac=self.pg0._remote_hosts[0].mac,
465 dst_mac=self.pg0.local_mac,
466 src_ip=self.p2p_sub_ifs[0].remote_ip4,
467 dst_ip="9.0.0.100",
468 )
469 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200470
471 self.send_packets(self.pg0, self.pg1, self.packets)
472
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200473 self.assert_packet_counter_equal("p2p-ethernet-input", 1)
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200474
475 route_9000.remove_vpp_config()
476 self.logger.info("FFP_TEST_FINISH_0002")
477
478 def test_ip4_rx_p2p_subif_route(self):
479 """route rx packet not matching p2p subinterface"""
480 self.logger.info("FFP_TEST_START_0003")
481
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200482 route_9001 = VppIpRoute(
483 self,
484 "9.0.0.0",
485 24,
486 [VppRoutePath(self.pg1.remote_ip4, self.pg1.sw_if_index)],
487 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200488 route_9001.add_vpp_config()
489
490 self.packets.append(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200491 self.create_stream(
492 src_mac="02:01:00:00:ff:ff",
493 dst_mac=self.pg0.local_mac,
494 src_ip="8.0.0.100",
495 dst_ip="9.0.0.100",
496 )
497 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200498
499 self.send_packets(self.pg0, self.pg1)
500
501 route_9001.remove_vpp_config()
502
503 self.logger.info("FFP_TEST_FINISH_0003")
504
505 def test_ip4_tx_p2p_subif(self):
506 """send ip4 packet via p2p subinterface"""
507 self.logger.info("FFP_TEST_START_0005")
508
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200509 route_9100 = VppIpRoute(
510 self,
511 "9.1.0.100",
512 24,
513 [
514 VppRoutePath(
515 self.pg0.remote_ip4,
516 self.pg0.sw_if_index,
517 )
518 ],
519 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200520 route_9100.add_vpp_config()
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200521 route_9200 = VppIpRoute(
522 self,
523 "9.2.0.100",
524 24,
525 [
526 VppRoutePath(
527 self.p2p_sub_ifs[0].remote_ip4,
528 self.p2p_sub_ifs[0].sw_if_index,
529 )
530 ],
531 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200532 route_9200.add_vpp_config()
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200533 route_9300 = VppIpRoute(
534 self,
535 "9.3.0.100",
536 24,
537 [
538 VppRoutePath(
539 self.p2p_sub_ifs[1].remote_ip4, self.p2p_sub_ifs[1].sw_if_index
540 )
541 ],
542 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200543 route_9300.add_vpp_config()
544
545 for i in range(0, 3):
546 self.packets.append(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200547 self.create_stream(
548 src_mac=self.pg1.remote_mac,
549 dst_mac=self.pg1.local_mac,
550 src_ip=self.pg1.remote_ip4,
551 dst_ip="9.%d.0.100" % (i + 1),
552 )
553 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200554
555 self.send_packets(self.pg1, self.pg0)
556
557 # route_7000.remove_vpp_config()
558 route_9100.remove_vpp_config()
559 route_9200.remove_vpp_config()
560 route_9300.remove_vpp_config()
561
562 self.logger.info("FFP_TEST_FINISH_0005")
563
564 def test_ip4_tx_p2p_subif_drop(self):
565 """drop tx ip4 packet not matching p2p subinterface"""
566 self.logger.info("FFP_TEST_START_0006")
567
568 self.packets.append(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200569 self.create_stream(
570 src_mac="02:01:00:00:ff:ff",
571 dst_mac=self.pg0.local_mac,
572 src_ip="8.0.0.100",
573 dst_ip="9.0.0.100",
574 )
575 )
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200576
577 # no packet received
578 self.send_packets(self.pg0, self.pg1, count=0)
579 self.logger.info("FFP_TEST_FINISH_0006")
580
581
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200582if __name__ == "__main__":
Pavel Kotucek15ac81c2017-06-20 14:00:26 +0200583 unittest.main(testRunner=VppTestRunner)