blob: c57b5912de1851a0273c900d067e895ed4c98fe1 [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
8from framework import VppTestCase
9
10
11class 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 Grajciar3ae52622019-10-28 10:22:01 +010037 self.vapi.l2tpv3_create_tunnel(client_address=self.pg0.local_ip6,
38 our_address=self.pg0.remote_ip6)
Jakub Grajciarf34f1a42019-05-27 12:23:57 +020039
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