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