Renato Botelho do Couto | ead1e53 | 2019-10-31 13:31:07 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 2 | |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 3 | from scapy.layers.l2 import Ether |
| 4 | from scapy.layers.inet6 import IPv6 |
| 5 | |
Dave Wallace | 8800f73 | 2023-08-31 00:47:44 -0400 | [diff] [blame] | 6 | from asfframework import tag_fixme_vpp_workers |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 7 | from framework import VppTestCase |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 8 | from config import config |
| 9 | |
| 10 | import unittest |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 11 | |
| 12 | |
Andrew Yourtchenko | 8dc0d48 | 2021-01-29 13:17:19 +0000 | [diff] [blame] | 13 | @tag_fixme_vpp_workers |
Dmitry Valter | 34fa0ce | 2024-03-11 10:38:46 +0000 | [diff] [blame] | 14 | @unittest.skipIf("l2tp" in config.excluded_plugins, "Exclude L2TP plugin tests") |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 15 | class TestL2tp(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 16 | """L2TP Test Case""" |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 17 | |
| 18 | @classmethod |
| 19 | def setUpClass(cls): |
| 20 | super(TestL2tp, cls).setUpClass() |
| 21 | |
| 22 | cls.create_pg_interfaces(range(1)) |
| 23 | cls.pg0.admin_up() |
| 24 | cls.pg0.config_ip6() |
| 25 | |
| 26 | def test_l2tp_decap_local(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 27 | """L2TP don't accept packets unless configured""" |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 28 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 29 | pkt = Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) / IPv6( |
| 30 | src=self.pg0.remote_ip6, dst=self.pg0.local_ip6, nh=115 |
| 31 | ) |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 32 | |
| 33 | self.pg0.add_stream(pkt) |
| 34 | self.pg_start() |
| 35 | |
| 36 | # l2tp should not accept packets |
| 37 | err = self.statistics.get_counter( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 38 | "/err/l2tp-decap-local/l2tpv3 session not found" |
| 39 | )[0] |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 40 | self.assertEqual(err, 0) |
| 41 | err_count = err |
| 42 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 43 | self.vapi.l2tpv3_create_tunnel( |
| 44 | client_address=self.pg0.local_ip6, our_address=self.pg0.remote_ip6 |
| 45 | ) |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 46 | |
| 47 | self.pg0.add_stream(pkt) |
| 48 | self.pg_start() |
| 49 | |
| 50 | # l2tp accepts packets |
| 51 | err = self.statistics.get_counter( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 52 | "/err/l2tp-decap-local/l2tpv3 session not found" |
| 53 | )[0] |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 54 | self.assertEqual(err, 1) |
| 55 | err_count = err |