blob: 1d229e6e3566c6d21dc5c4281b2ec7e16c655a19 [file] [log] [blame]
Jakub Grajciarf34f1a42019-05-27 12:23:57 +02001#!/usr/bin/env python
2
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
37 self.vapi.l2tpv3_create_tunnel(client_address=self.pg0.local_ip6n,
38 our_address=self.pg0.remote_ip6n,
39 is_ipv6=1)
40
41 self.pg0.add_stream(pkt)
42 self.pg_start()
43
44 # l2tp accepts packets
45 err = self.statistics.get_counter(
46 '/err/l2tp-decap-local/l2tpv3 session not found')[0]
47 self.assertEqual(err, 1)
48 err_count = err