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): |
| 14 | """ L2TP Test Case """ |
| 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): |
| 25 | """ L2TP don't accept packets unless configured """ |
| 26 | |
| 27 | pkt = (Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) / |
| 28 | IPv6(src=self.pg0.remote_ip6, dst=self.pg0.local_ip6, nh=115)) |
| 29 | |
| 30 | self.pg0.add_stream(pkt) |
| 31 | self.pg_start() |
| 32 | |
| 33 | # l2tp should not accept packets |
| 34 | err = self.statistics.get_counter( |
| 35 | '/err/l2tp-decap-local/l2tpv3 session not found')[0] |
| 36 | self.assertEqual(err, 0) |
| 37 | err_count = err |
| 38 | |
Jakub Grajciar | 3ae5262 | 2019-10-28 10:22:01 +0100 | [diff] [blame] | 39 | self.vapi.l2tpv3_create_tunnel(client_address=self.pg0.local_ip6, |
| 40 | our_address=self.pg0.remote_ip6) |
Jakub Grajciar | f34f1a4 | 2019-05-27 12:23:57 +0200 | [diff] [blame] | 41 | |
| 42 | self.pg0.add_stream(pkt) |
| 43 | self.pg_start() |
| 44 | |
| 45 | # l2tp accepts packets |
| 46 | err = self.statistics.get_counter( |
| 47 | '/err/l2tp-decap-local/l2tpv3 session not found')[0] |
| 48 | self.assertEqual(err, 1) |
| 49 | err_count = err |