blob: 5a665238260ead2943cac2bb58bac00308ac0d28 [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):
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 Grajciar3ae52622019-10-28 10:22:01 +010039 self.vapi.l2tpv3_create_tunnel(client_address=self.pg0.local_ip6,
40 our_address=self.pg0.remote_ip6)
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020041
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