blob: 172b0b8e0b8c1c8037b359b75b8c537a87180283 [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
8
9
Andrew Yourtchenko8dc0d482021-01-29 13:17:19 +000010@tag_fixme_vpp_workers
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020011class TestL2tp(VppTestCase):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020012 """L2TP Test Case"""
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020013
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):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020023 """L2TP don't accept packets unless configured"""
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020024
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020025 pkt = Ether(dst=self.pg0.local_mac, src=self.pg0.remote_mac) / IPv6(
26 src=self.pg0.remote_ip6, dst=self.pg0.local_ip6, nh=115
27 )
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020028
29 self.pg0.add_stream(pkt)
30 self.pg_start()
31
32 # l2tp should not accept packets
33 err = self.statistics.get_counter(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020034 "/err/l2tp-decap-local/l2tpv3 session not found"
35 )[0]
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020036 self.assertEqual(err, 0)
37 err_count = err
38
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020039 self.vapi.l2tpv3_create_tunnel(
40 client_address=self.pg0.local_ip6, our_address=self.pg0.remote_ip6
41 )
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020042
43 self.pg0.add_stream(pkt)
44 self.pg_start()
45
46 # l2tp accepts packets
47 err = self.statistics.get_counter(
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020048 "/err/l2tp-decap-local/l2tpv3 session not found"
49 )[0]
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020050 self.assertEqual(err, 1)
51 err_count = err