blob: 13fa02ecc2c12bb9bb6ab300dfc29e32420f012f [file] [log] [blame]
Renato Botelho do Coutoead1e532019-10-31 13:31:07 -05001#!/usr/bin/env python3
Jakub Grajciarf34f1a42019-05-27 12:23:57 +02002
3import unittest
4
5from scapy.layers.l2 import Ether
6from scapy.layers.inet6 import IPv6
7
Andrew Yourtchenko8dc0d482021-01-29 13:17:19 +00008from framework import tag_fixme_vpp_workers
Jakub Grajciarf34f1a42019-05-27 12:23:57 +02009from framework import VppTestCase
10
11
Andrew Yourtchenko8dc0d482021-01-29 13:17:19 +000012@tag_fixme_vpp_workers
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020013class TestL2tp(VppTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020014 """L2TP Test Case"""
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020015
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 Sekerad9b0c6f2022-04-26 19:02:15 +020025 """L2TP don't accept packets unless configured"""
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020026
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020027 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 Grajciarf34f1a42019-05-27 12:23:57 +020030
31 self.pg0.add_stream(pkt)
32 self.pg_start()
33
34 # l2tp should not accept packets
35 err = self.statistics.get_counter(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020036 "/err/l2tp-decap-local/l2tpv3 session not found"
37 )[0]
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020038 self.assertEqual(err, 0)
39 err_count = err
40
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020041 self.vapi.l2tpv3_create_tunnel(
42 client_address=self.pg0.local_ip6, our_address=self.pg0.remote_ip6
43 )
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020044
45 self.pg0.add_stream(pkt)
46 self.pg_start()
47
48 # l2tp accepts packets
49 err = self.statistics.get_counter(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020050 "/err/l2tp-decap-local/l2tpv3 session not found"
51 )[0]
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020052 self.assertEqual(err, 1)
53 err_count = err