blob: 34022629cc672845295a3a94f82a342a55fbec71 [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
Jakub Grajciarf34f1a42019-05-27 12:23:57 +02003from scapy.layers.l2 import Ether
4from scapy.layers.inet6 import IPv6
5
Dave Wallace8800f732023-08-31 00:47:44 -04006from asfframework import tag_fixme_vpp_workers
Jakub Grajciarf34f1a42019-05-27 12:23:57 +02007from framework import VppTestCase
Dmitry Valter34fa0ce2024-03-11 10:38:46 +00008from config import config
9
10import unittest
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020011
12
Andrew Yourtchenko8dc0d482021-01-29 13:17:19 +000013@tag_fixme_vpp_workers
Dmitry Valter34fa0ce2024-03-11 10:38:46 +000014@unittest.skipIf("l2tp" in config.excluded_plugins, "Exclude L2TP plugin tests")
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020015class TestL2tp(VppTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020016 """L2TP Test Case"""
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020017
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 Sekerad9b0c6f2022-04-26 19:02:15 +020027 """L2TP don't accept packets unless configured"""
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020028
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020029 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 Grajciarf34f1a42019-05-27 12:23:57 +020032
33 self.pg0.add_stream(pkt)
34 self.pg_start()
35
36 # l2tp should not accept packets
37 err = self.statistics.get_counter(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020038 "/err/l2tp-decap-local/l2tpv3 session not found"
39 )[0]
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020040 self.assertEqual(err, 0)
41 err_count = err
42
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020043 self.vapi.l2tpv3_create_tunnel(
44 client_address=self.pg0.local_ip6, our_address=self.pg0.remote_ip6
45 )
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020046
47 self.pg0.add_stream(pkt)
48 self.pg_start()
49
50 # l2tp accepts packets
51 err = self.statistics.get_counter(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020052 "/err/l2tp-decap-local/l2tpv3 session not found"
53 )[0]
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020054 self.assertEqual(err, 1)
55 err_count = err