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 | |
| 3 | import unittest |
| 4 | |
| 5 | from scapy.layers.l2 import Ether |
| 6 | from scapy.layers.inet6 import IPv6 |
| 7 | |
Andrew Yourtchenko | 8dc0d48 | 2021-01-29 13:17:19 +0000 | [diff] [blame] | 8 | from framework import tag_fixme_vpp_workers |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 9 | from framework import VppTestCase |
| 10 | |
| 11 | |
Andrew Yourtchenko | 8dc0d48 | 2021-01-29 13:17:19 +0000 | [diff] [blame] | 12 | @tag_fixme_vpp_workers |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 13 | class TestL2tp(VppTestCase): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 14 | """L2TP Test Case""" |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 15 | |
| 16 | @classmethod |
| 17 | def setUpClass(cls): |
| 18 | super(TestL2tp, cls).setUpClass() |
| 19 | |
| 20 | cls.create_pg_interfaces(range(1)) |
| 21 | cls.pg0.admin_up() |
| 22 | cls.pg0.config_ip6() |
| 23 | |
| 24 | def test_l2tp_decap_local(self): |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 25 | """L2TP don't accept packets unless configured""" |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 26 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 27 | pkt = Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) / IPv6( |
| 28 | src=self.pg0.remote_ip6, dst=self.pg0.local_ip6, nh=115 |
| 29 | ) |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 30 | |
| 31 | self.pg0.add_stream(pkt) |
| 32 | self.pg_start() |
| 33 | |
| 34 | # l2tp should not accept packets |
| 35 | err = self.statistics.get_counter( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 36 | "/err/l2tp-decap-local/l2tpv3 session not found" |
| 37 | )[0] |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 38 | self.assertEqual(err, 0) |
| 39 | err_count = err |
| 40 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 41 | self.vapi.l2tpv3_create_tunnel( |
| 42 | client_address=self.pg0.local_ip6, our_address=self.pg0.remote_ip6 |
| 43 | ) |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 44 | |
| 45 | self.pg0.add_stream(pkt) |
| 46 | self.pg_start() |
| 47 | |
| 48 | # l2tp accepts packets |
| 49 | err = self.statistics.get_counter( |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 50 | "/err/l2tp-decap-local/l2tpv3 session not found" |
| 51 | )[0] |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 52 | self.assertEqual(err, 1) |
| 53 | err_count = err |