aboutsummaryrefslogtreecommitdiffstats
path: root/test/vpp_pppoe_interface.py
blob: 9a8b8699328ef92a7dd17d55b114aecb1cb32d31 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from vpp_interface import VppInterface
import socket
from util import ppp, ppc, mactobinary


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

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

    def add_vpp_config(self):
        cip = socket.inet_pton(socket.AF_INET, self.client_ip)
        cmac = mactobinary(self.client_mac)
        r = self.test.vapi.pppoe_add_del_session(
                cip, cmac,
                session_id=self.session_id,
                decap_vrf_id=self.decap_vrf_id)
        self._sw_if_index = r.sw_if_index
        self.generate_remote_hosts()

    def remove_vpp_config(self):
        cip = socket.inet_pton(socket.AF_INET, self.client_ip)
        cmac = mactobinary(self.client_mac)
        self.unconfig()
        r = self.test.vapi.pppoe_add_del_session(
                cip, cmac,
                session_id=self.session_id,
                decap_vrf_id=self.decap_vrf_id,
                is_add=0)


class VppPppoe6Interface(VppInterface):
    """
    VPP Pppoe IPv6 interface
    """

    def __init__(self, test, src_ip, dst_ip, outer_fib_id=0, is_teb=0):
        """ Create VPP PPPoE6 interface """
        self._sw_if_index = 0
        super(VppPppoe6Interface, self).__init__(test)
        self._test = test
        self.client_ip = client_ip
        self.client_mac = client_mac
        self.session_id = session_id
        self.decap_vrf_id = decap_vrf_id

    def add_vpp_config(self):
        cip = socket.inet_pton(socket.AF_INET6, self.client_ip)
        cmac = mactobinary(self.client_mac)
        r = self.test.vapi.pppoe_add_del_session(
                cip, cmac,
                session_id=self.session_id,
                decap_vrf_id=self.decap_vrf_id,
                is_ip6=1)
        self._sw_if_index = r.sw_if_index
        self.generate_remote_hosts()

    def remove_vpp_config(self):
        cip = socket.inet_pton(socket.AF_INET6, self.client_ip)
        cmac = mactobinary(self.client_mac)
        self.unconfig()
        r = self.test.vapi.pppoe_add_del_session(
                cip, cmac,
                session_id=self.session_id,
                decap_vrf_id=self.decap_vrf_id,
                is_add=0,
                is_ip6=1)
pan class="n">node->next_nodes, nnexts - 1); for (k = 0; k < nnexts; k++) node->next_nodes[k] = unserialize_likely_small_unsigned_integer (sm); stats_present = unserialize_likely_small_unsigned_integer (sm); if (stats_present) { /* total clocks */ unserialize_integer (sm, &l, 8); node->stats_total.clocks = l; node->stats_last_clear.clocks = 0; /* Total calls */ unserialize_integer (sm, &c, 8); node->stats_total.calls = c; /* Total vectors */ unserialize_integer (sm, &v, 8); node->stats_total.vectors = v; /* Total suspends */ unserialize_integer (sm, &d, 8); node->stats_total.suspends = d; } } } return nodes_by_thread; } #if TEST_CODE static clib_error_t * test_node_serialize_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { vlib_node_main_t *nm = &vm->node_main; u8 *vector = 0; vlib_node_t ***nodes_by_thread; vlib_node_t **nodes; vlib_node_t *node; vlib_node_t *next_node; int i, j, k; u32 max_threads = (u32) ~ 0; int include_nexts = 0; int include_stats = 0; while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) { if (unformat (input, "max-threads %d", &max_threads)) ; else if (unformat (input, "stats")) include_stats = 1; else if (unformat (input, "nexts")) include_nexts = 1; else break; } /* * Keep the number of memcpy ops to a minimum (e.g. 1). * The current size of the serialized vector is * slightly under 4K. */ vec_validate (vector, 16383); vec_reset_length (vector); vector = vlib_node_serialize (nm, vector, max_threads, include_nexts, include_stats); vlib_cli_output (vm, "result vector %d bytes", vec_len (vector)); nodes_by_thread = vlib_node_unserialize (vector); vec_free (vector); for (i = 0; i < vec_len (nodes_by_thread); i++) { nodes = nodes_by_thread[i]; vlib_cli_output (vm, "thread %d", i); for (j = 0; j < vec_len (nodes); j++) { node = nodes[j]; vlib_cli_output (vm, "[%d] %s state %s", j, node->name, node->state_string); vlib_cli_output (vm, " clocks %lld calls %lld suspends" " %lld vectors %lld", node->stats_total.clocks, node->stats_total.calls, node->stats_total.suspends, node->stats_total.vectors); for (k = 0; k < vec_len (node->next_nodes); k++) { if (node->next_nodes[k] != ~0) { next_node = nodes[node->next_nodes[k]]; vlib_cli_output (vm, " [%d] %s", k, next_node->name); } } } } for (j = 0; j < vec_len (nodes_by_thread); j++) { nodes = nodes_by_thread[j]; for (i = 0; i < vec_len (nodes); i++) { vec_free (nodes[i]->name); vec_free (nodes[i]->next_nodes); vec_free (nodes[i]); } vec_free (nodes); } vec_free (nodes_by_thread); return 0; } /* *INDENT-OFF* */ VLIB_CLI_COMMAND (test_node_serialize_node, static) = { .path = "test node serialize", .short_help = "test node serialize [max-threads NN] nexts stats", .function = test_node_serialize_command_fn, }; /* *INDENT-ON* */ #endif /* * fd.io coding-style-patch-verification: ON * * Local Variables: * eval: (c-set-style "gnu") * End: */