aboutsummaryrefslogtreecommitdiffstats
path: root/test/vpp_pppoe_interface.py
blob: 505ac4c6425cf89655f355356f34d93a1b951609 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from vpp_interface import VppInterface
import socket
from vpp_papi import mac_pton


class VppPppoeInterface(VppInterface):
    """
    VPP Pppoe interface
    """

    def __init__(self, test, client_ip, client_mac,
                 session_id, decap_vrf_id=0):
        """ Create VPP PPPoE4 interface """
        super(VppPppoeInterface, self).__init__(test)
        self.client_ip = client_ip
        self.client_mac = client_mac
        self.session_id = session_id
        self.decap_vrf_id = decap_vrf_id
        self.vpp_sw_if_index = -1

    def add_vpp_config(self):
        r = self.test.vapi.pppoe_add_del_session(
                self.client_ip, self.client_mac,
                session_id=self.session_id,
                decap_vrf_id=self.decap_vrf_id)
        self.set_sw_if_index(r.sw_if_index)
        self.vpp_sw_if_index = r.sw_if_index
        self.generate_remote_hosts()

    def remove_vpp_config(self):
        self.unconfig()
        self.test.vapi.pppoe_add_del_session(
                self.client_ip, self.client_mac,
                session_id=self.session_id,
                decap_vrf_id=self.decap_vrf_id,
                is_add=0)

    def set_unnumbered(self, swif_iface):
        self.test.vapi.sw_interface_set_unnumbered(
            swif_iface,
            self.vpp_sw_if_index)
tionTestCase, self).tearDown() def show_commands_at_teardown(self): self.logger.info(self.vapi.cli("show ip neighbors")) def run_basic_conn_test(self, af, acl_side): """Basic connectivity test""" conn1 = Conn(self, self.pg0, self.pg1, af, UDP, 42001, 4242) conn1.send_through(0) # the return packets should pass conn1.send_through(1) def run_negative_conn_test(self, af, acl_side): """Packets with local spoofed address""" conn1 = Conn(self, self.pg0, self.pg1, af, UDP, 42001, 4242) try: p2 = conn1.send_through(0).command() except: # If we asserted while waiting, it's good. # the conn should have timed out. p2 = None self.assert_equal(p2, None, ": packet should have been dropped") def test_0010_basic_conn_test(self): """IPv4 basic connectivity test""" self.run_basic_conn_test(AF_INET, 0) def test_0011_basic_conn_test(self): """IPv6 basic connectivity test""" self.run_basic_conn_test(AF_INET6, 0) def test_0050_loopback_prepare_test(self): """Create loopbacks overlapping with remote addresses""" self.create_loopback_interfaces(2) for i in range(2): intf = self.lo_interfaces[i] intf.admin_up() intf.local_ip4 = self.pg_interfaces[i].remote_ip4 intf.local_ip4_prefix_len = 32 intf.config_ip4() intf.local_ip6 = self.pg_interfaces[i].remote_ip6 intf.local_ip6_prefix_len = 128 intf.config_ip6() def test_0110_basic_conn_test(self): """IPv4 local-spoof connectivity test""" self.run_negative_conn_test(AF_INET, 0) def test_0111_basic_conn_test(self): """IPv6 local-spoof connectivity test""" self.run_negative_conn_test(AF_INET, 1) def test_0200_basic_conn_test(self): """Configure container commands""" for i in range(2): for addr in [ self.pg_interfaces[i].remote_ip4, self.pg_interfaces[i].remote_ip6, ]: self.vapi.ppcli( "ip container " + addr + " " + self.pg_interfaces[i].name ) self.vapi.ppcli( "stn rule address " + addr + " interface " + self.pg_interfaces[i].name ) def test_0210_basic_conn_test(self): """IPv4 test after configuring container""" self.run_basic_conn_test(AF_INET, 0) def test_0211_basic_conn_test(self): """IPv6 test after configuring container""" self.run_basic_conn_test(AF_INET, 1) def test_0300_unconfigure_commands(self): """Unconfigure container commands""" for i in range(2): for addr in [ self.pg_interfaces[i].remote_ip4, self.pg_interfaces[i].remote_ip6, ]: self.vapi.ppcli( "ip container " + addr + " " + self.pg_interfaces[i].name + " del" ) self.vapi.ppcli( "stn rule address " + addr + " interface " + self.pg_interfaces[i].name + " del" ) def test_0410_spoof_test(self): """IPv4 local-spoof after unconfig test""" self.run_negative_conn_test(AF_INET, 0) def test_0411_spoof_test(self): """IPv6 local-spoof after unconfig test""" self.run_negative_conn_test(AF_INET, 1)