aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/robot/honeycomb/tap.robot
blob: 8a80c4d555e74f9d52b4dbad814210374c01c944 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Copyright (c) 2016 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

*** Settings ***
| Library | resources.libraries.python.InterfaceUtil
| Library | resources.libraries.python.honeycomb.HcAPIKwInterfaces.InterfaceKeywords
| Documentation | Keywords used to manipulate TAP interfaces.

*** Keywords ***
| Honeycomb creates TAP interface
| | [Documentation] | Uses Honeycomb API to configure a new TAP interface.
| | ...
| | ... | *Arguments:*
| | ... | - node - information about a DUT node. Type: dictionary
| | ... | - interface - name of an interface on the specified node. Type: string
| | ... | - settings - Configuration data for TAP. Type: dictionary
| | ...
| | ... | *Example:*
| | ... | \| Honeycomb creates TAP interface \
| | ... | \| ${nodes['DUT1']} \| tap_int1 \| ${{'host-interface-name':'tap1',\
| | ... | 'mac':'08:00:27:60:26:ab', 'id':3}} \|
| | ...
| | [Arguments] | ${node} | ${interface} | ${settings}
| | Create TAP interface | ${node} | ${interface}
| | ... | &{settings}

| Honeycomb configures TAP interface
| | [Documentation] | Uses Honeycomb API to configure an existing TAP interface.
| | ...
| | ... | *Arguments:*
| | ... | - node - information about a DUT node. Type: dictionary
| | ... | - interface - name of an interface on the specified node. Type: string
| | ... | - settings - Configuration data for TAP. Type: dictionary
| | ...
| | ... | *Example:*
| | ... | \| Honeycomb configures TAP interface \
| | ... | \| ${nodes['DUT1']} \| tap_int1 \| ${{'host-interface-name':'tap1',\
| | ... | 'mac':'08:00:27:60:26:ab', 'id':3}} \|
| | ...
| | [Arguments] | ${node} | ${interface} | ${settings}
| | Configure interface TAP | ${node} | ${interface}
| | ... | &{settings}

| Honeycomb removes TAP interface
| | [Documentation] | Uses Honeycomb API to remove a TAP interface.
| | ...
| | ... | *Arguments:*
| | ... | - node - information about a DUT node. Type: dictionary
| | ... | - interface - name of an interface on the specified node. Type: string
| | ...
| | ... | *Example:*
| | ...
| | ... | \| Honeycomb removes TAP interface \
| | ... | \| ${nodes['DUT1']} \| tap_int1 \|
| | [Arguments] | ${node} | ${interface}
| | Delete interface | ${node} | ${interface}

| TAP Operational Data From Honeycomb Should Be
| | [Documentation] | Retrieves interface TAP configuration through Honeycomb\
| | ... | and compares with settings supplied in argument.
| | ...
| | ... | *Arguments:*
| | ... | - node - information about a DUT node. Type: dictionary
| | ... | - interface - name of an interface on the specified node. Type: string
| | ... | - settings - Configuration data for TAP. Type: dictionary
| | ...
| | ... | *Example:*
| | ...
| | ... | \| TAP Operational Data From Honeycomb Should Be \
| | ... | \| ${nodes['DUT1']} \| tap_int1 \| ${{'host-interface-name':'tap1',\
| | ... | 'mac':'08:00:27:60:26:ab', 'id':3}} \|
| | ...
| | [Arguments] | ${node} | ${interface} | ${settings}
| | ${api_data}= | Get interface oper data | ${node} | ${interface}
| | ${api_tap}= | Set Variable | ${api_data['v3po:tap-v2']}
| | Should be equal | ${api_tap['device-name']} | ${settings['device-name']}
| | ${api_mac}= | Set Variable | ${api_data['phys-address']}
| | Should be equal | ${api_mac} | ${settings['mac']}

| TAP Operational Data From VAT Should Be
| | [Documentation] | Retrieves interface TAP configuration through VAT and\
| | ... | compares with settings supplied in argument.
| | ...
| | ... | *Arguments:*
| | ... | - node - information about a DUT node. Type: dictionary
| | ... | - settings - Configuration data for TAP. Type: dictionary
| | ...
| | ... | *Example:*
| | ...
| | ... | \| TAP Operational Data From Honeycomb Should Be \
| | ... | \| ${nodes['DUT1']} \| ${{'host-interface-name':'tap1',\
| | ... | 'mac':'08:00:27:60:26:ab', 'id':3}} \|
| | ...
| | [Arguments] | ${node} | ${interface} | ${settings}
| | ${vat_data}= | TAP Dump | ${node} | ${interface}
| | Should be equal | ${vat_data['dev_name']} | ${settings['dev_name']}
| | Should be equal | ${vat_data['rx_ring_sz']} | ${settings['rx_ring_sz']}
| | Should be equal | ${vat_data['tx_ring_sz']} | ${settings['tx_ring_sz']}
# other settings not accessible through VAT commands

| TAP Operational Data From Honeycomb Should Be empty
| | [Documentation] | Attempts to retrieve interface TAP configuration\
| | ... | through Honeycomb and expects to recieve an empty dictionary.
| | ...
| | ... | *Arguments:*
| | ... | - node - information about a DUT node. Type: dictionary
| | ... | - interface - name of an interface on the specified node. Type: string
| | ...
| | ... | *Example:*
| | ...
| | ... | \| TAP Operational Data From Honeycomb Should Be empty\
| | ... | \| ${nodes['DUT1']} \| tap_int1 \|
| | ...
| | [Arguments] | ${node} | ${interface}
| | ${api_data}= | Get interface oper data | ${node} | ${interface}
| | Run keyword and expect error | *KeyError: 'v3po:tap-v2' | Set Variable
| | ... | ${api_data['v3po:tap-v2']}

| TAP Operational Data From VAT Should Be empty
| | [Documentation] | Attempts to retrieve interface TAP configuration\
| | ... | through VAT and expects a "no data" error.
| | ...
| | ... | *Arguments:*
| | ... | - node - information about a DUT node. Type: dictionary
| | ... | - interface - name of an interface on the specified node. Type: string
| | ...
| | ... | *Example:*
| | ...
| | ... | \| TAP Operational Data From VAT Should Be empty\
| | ... | \| ${nodes['DUT1']} \| tap_int1 \|
| | ...
| | [Arguments] | ${node} | ${interface}
| | Run Keyword And Expect Error | ValueError: No JSON object could be decoded
| | ... | TAP Dump | ${node} | ${interface}
pan class="n">mdd_locks) { dpo_reset(&mdd->mdd_dpo); pool_put(mpls_disp_dpo_pool, mdd); } } #endif /* CLIB_MARCH_VARIANT */ /** * @brief A struct to hold tracing information for the MPLS label disposition * node. */ typedef struct mpls_label_disposition_trace_t_ { dpo_proto_t mddt_payload_proto; fib_rpf_id_t mddt_rpf_id; fib_mpls_lsp_mode_t mddt_mode; } mpls_label_disposition_trace_t; extern vlib_node_registration_t ip4_mpls_label_disposition_pipe_node; extern vlib_node_registration_t ip6_mpls_label_disposition_pipe_node; extern vlib_node_registration_t ip4_mpls_label_disposition_uniform_node; extern vlib_node_registration_t ip6_mpls_label_disposition_uniform_node; always_inline uword mpls_label_disposition_inline (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * from_frame, u8 payload_is_ip4, u8 payload_is_ip6, fib_mpls_lsp_mode_t mode) { u32 n_left_from, next_index, * from, * to_next; vlib_node_runtime_t *error_node; if (payload_is_ip4) { if (FIB_MPLS_LSP_MODE_PIPE == mode) error_node = vlib_node_get_runtime(vm, ip4_mpls_label_disposition_pipe_node.index); else error_node = vlib_node_get_runtime(vm, ip4_mpls_label_disposition_uniform_node.index); } else { if (FIB_MPLS_LSP_MODE_PIPE == mode) error_node = vlib_node_get_runtime(vm, ip6_mpls_label_disposition_pipe_node.index); else error_node = vlib_node_get_runtime(vm, ip6_mpls_label_disposition_uniform_node.index); } from = vlib_frame_vector_args(from_frame); n_left_from = from_frame->n_vectors; next_index = node->cached_next_index; while (n_left_from > 0) { u32 n_left_to_next; vlib_get_next_frame(vm, node, next_index, to_next, n_left_to_next); while (n_left_from >= 4 && n_left_to_next >= 2) { mpls_disp_dpo_t *mdd0, *mdd1; u32 bi0, mddi0, bi1, mddi1; vlib_buffer_t * b0, *b1; u32 next0, next1; bi0 = to_next[0] = from[0]; bi1 = to_next[1] = from[1]; /* Prefetch next iteration. */ { vlib_buffer_t * p2, * p3; p2 = vlib_get_buffer(vm, from[2]); p3 = vlib_get_buffer(vm, from[3]); vlib_prefetch_buffer_header(p2, STORE); vlib_prefetch_buffer_header(p3, STORE); CLIB_PREFETCH(p2->data, sizeof(ip6_header_t), STORE); CLIB_PREFETCH(p3->data, sizeof(ip6_header_t), STORE); } from += 2; to_next += 2; n_left_from -= 2; n_left_to_next -= 2; b0 = vlib_get_buffer(vm, bi0); b1 = vlib_get_buffer(vm, bi1); /* dst lookup was done by ip4 lookup */ mddi0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX]; mddi1 = vnet_buffer(b1)->ip.adj_index[VLIB_TX]; mdd0 = mpls_disp_dpo_get(mddi0); mdd1 = mpls_disp_dpo_get(mddi1); next0 = mdd0->mdd_dpo.dpoi_next_node; next1 = mdd1->mdd_dpo.dpoi_next_node; if (payload_is_ip4) { ip4_header_t *ip0, *ip1; ip0 = vlib_buffer_get_current(b0); ip1 = vlib_buffer_get_current(b1); /* * IPv4 input checks on the exposed IP header * including checksum */ ip4_input_check_x2(vm, error_node, b0, b1, ip0, ip1, &next0, &next1, 1); if (FIB_MPLS_LSP_MODE_UNIFORM == mode) { /* * Copy the TTL from the MPLS packet into the * exposed IP. recalc the chksum */ ip0->ttl = vnet_buffer(b0)->mpls.ttl; ip1->ttl = vnet_buffer(b1)->mpls.ttl; ip0->tos = mpls_exp_to_ip_dscp(vnet_buffer(b0)->mpls.exp); ip1->tos = mpls_exp_to_ip_dscp(vnet_buffer(b1)->mpls.exp); ip0->checksum = ip4_header_checksum(ip0); ip1->checksum = ip4_header_checksum(ip1); } } else if (payload_is_ip6) { ip6_header_t *ip0, *ip1; ip0 = vlib_buffer_get_current(b0); ip1 = vlib_buffer_get_current(b1); /* * IPv6 input checks on the exposed IP header */ ip6_input_check_x2(vm, error_node, b0, b1, ip0, ip1, &next0, &next1); if (FIB_MPLS_LSP_MODE_UNIFORM == mode) { /* * Copy the TTL from the MPLS packet into the * exposed IP */ ip0->hop_limit = vnet_buffer(b0)->mpls.ttl; ip1->hop_limit = vnet_buffer(b1)->mpls.ttl; ip6_set_traffic_class_network_order( ip0, mpls_exp_to_ip_dscp(vnet_buffer(b0)->mpls.exp)); ip6_set_traffic_class_network_order( ip1, mpls_exp_to_ip_dscp(vnet_buffer(b1)->mpls.exp)); } } vnet_buffer(b0)->ip.adj_index[VLIB_TX] = mdd0->mdd_dpo.dpoi_index; vnet_buffer(b1)->ip.adj_index[VLIB_TX] = mdd1->mdd_dpo.dpoi_index; vnet_buffer(b0)->ip.rpf_id = mdd0->mdd_rpf_id; vnet_buffer(b1)->ip.rpf_id = mdd1->mdd_rpf_id; if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) { mpls_label_disposition_trace_t *tr = vlib_add_trace(vm, node, b0, sizeof(*tr)); tr->mddt_payload_proto = mdd0->mdd_payload_proto; tr->mddt_rpf_id = mdd0->mdd_rpf_id; tr->mddt_mode = mdd0->mdd_mode; } if (PREDICT_FALSE(b1->flags & VLIB_BUFFER_IS_TRACED)) { mpls_label_disposition_trace_t *tr = vlib_add_trace(vm, node, b1, sizeof(*tr)); tr->mddt_payload_proto = mdd1->mdd_payload_proto; tr->mddt_rpf_id = mdd1->mdd_rpf_id; tr->mddt_mode = mdd1->mdd_mode; } vlib_validate_buffer_enqueue_x2(vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1); } while (n_left_from > 0 && n_left_to_next > 0) { mpls_disp_dpo_t *mdd0; vlib_buffer_t * b0; u32 bi0, mddi0; u32 next0; bi0 = from[0]; to_next[0] = bi0; from += 1; to_next += 1; n_left_from -= 1; n_left_to_next -= 1; b0 = vlib_get_buffer(vm, bi0); /* dst lookup was done by ip4 lookup */ mddi0 = vnet_buffer(b0)->ip.adj_index[VLIB_TX]; mdd0 = mpls_disp_dpo_get(mddi0); next0 = mdd0->mdd_dpo.dpoi_next_node; if (payload_is_ip4) { ip4_header_t *ip0; ip0 = vlib_buffer_get_current(b0); /* * IPv4 input checks on the exposed IP header * including checksum */ ip4_input_check_x1(vm, error_node, b0, ip0, &next0, 1); if (FIB_MPLS_LSP_MODE_UNIFORM == mode) { /* * Copy the TTL from the MPLS packet into the * exposed IP. recalc the chksum */ ip0->ttl = vnet_buffer(b0)->mpls.ttl; ip0->tos = mpls_exp_to_ip_dscp(vnet_buffer(b0)->mpls.exp); ip0->checksum = ip4_header_checksum(ip0); } } else if (payload_is_ip6) { ip6_header_t *ip0; ip0 = vlib_buffer_get_current(b0); /* * IPv6 input checks on the exposed IP header */ ip6_input_check_x1(vm, error_node, b0, ip0, &next0); if (FIB_MPLS_LSP_MODE_UNIFORM == mode) { /* * Copy the TTL from the MPLS packet into the * exposed IP */ ip0->hop_limit = vnet_buffer(b0)->mpls.ttl; ip6_set_traffic_class_network_order( ip0, mpls_exp_to_ip_dscp(vnet_buffer(b0)->mpls.exp)); } } vnet_buffer(b0)->ip.adj_index[VLIB_TX] = mdd0->mdd_dpo.dpoi_index; vnet_buffer(b0)->ip.rpf_id = mdd0->mdd_rpf_id; if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED)) { mpls_label_disposition_trace_t *tr = vlib_add_trace(vm, node, b0, sizeof(*tr)); tr->mddt_payload_proto = mdd0->mdd_payload_proto; tr->mddt_rpf_id = mdd0->mdd_rpf_id; tr->mddt_mode = mdd0->mdd_mode; } vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0); } vlib_put_next_frame(vm, node, next_index, n_left_to_next); } return from_frame->n_vectors; } static u8 * format_mpls_label_disposition_trace (u8 * s, va_list * args) { CLIB_UNUSED(vlib_main_t * vm) = va_arg(*args, vlib_main_t *); CLIB_UNUSED(vlib_node_t * node) = va_arg(*args, vlib_node_t *); CLIB_UNUSED(mpls_label_disposition_trace_t * t); t = va_arg(*args, mpls_label_disposition_trace_t *); s = format(s, "rpf-id:%d %U, %U", t->mddt_rpf_id, format_dpo_proto, t->mddt_payload_proto, format_fib_mpls_lsp_mode, t->mddt_mode); return (s); } VLIB_NODE_FN (ip4_mpls_label_disposition_pipe_node) (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { return (mpls_label_disposition_inline(vm, node, frame, 1, 0, FIB_MPLS_LSP_MODE_PIPE)); } VLIB_REGISTER_NODE(ip4_mpls_label_disposition_pipe_node) = { .name = "ip4-mpls-label-disposition-pipe", .vector_size = sizeof(u32), .format_trace = format_mpls_label_disposition_trace, .sibling_of = "ip4-input", .n_errors = IP4_N_ERROR, .error_strings = ip4_error_strings, }; VLIB_NODE_FN (ip6_mpls_label_disposition_pipe_node) (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { return (mpls_label_disposition_inline(vm, node, frame, 0, 1, FIB_MPLS_LSP_MODE_PIPE)); } VLIB_REGISTER_NODE(ip6_mpls_label_disposition_pipe_node) = { .name = "ip6-mpls-label-disposition-pipe", .vector_size = sizeof(u32), .format_trace = format_mpls_label_disposition_trace, .sibling_of = "ip6-input", .n_errors = IP6_N_ERROR, .error_strings = ip6_error_strings, }; VLIB_NODE_FN (ip4_mpls_label_disposition_uniform_node) (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { return (mpls_label_disposition_inline(vm, node, frame, 1, 0, FIB_MPLS_LSP_MODE_UNIFORM)); } VLIB_REGISTER_NODE(ip4_mpls_label_disposition_uniform_node) = { .name = "ip4-mpls-label-disposition-uniform", .vector_size = sizeof(u32), .format_trace = format_mpls_label_disposition_trace, .sibling_of = "ip4-input", .n_errors = IP4_N_ERROR, .error_strings = ip4_error_strings, }; VLIB_NODE_FN (ip6_mpls_label_disposition_uniform_node) (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { return (mpls_label_disposition_inline(vm, node, frame, 0, 1, FIB_MPLS_LSP_MODE_UNIFORM)); } VLIB_REGISTER_NODE(ip6_mpls_label_disposition_uniform_node) = { .name = "ip6-mpls-label-disposition-uniform", .vector_size = sizeof(u32), .format_trace = format_mpls_label_disposition_trace, .sibling_of = "ip6-input", .n_errors = IP6_N_ERROR, .error_strings = ip6_error_strings, }; #ifndef CLIB_MARCH_VARIANT static void mpls_disp_dpo_mem_show (void) { fib_show_memory_usage("MPLS label", pool_elts(mpls_disp_dpo_pool), pool_len(mpls_disp_dpo_pool), sizeof(mpls_disp_dpo_t)); } const static dpo_vft_t mdd_vft = { .dv_lock = mpls_disp_dpo_lock, .dv_unlock = mpls_disp_dpo_unlock, .dv_format = format_mpls_disp_dpo, .dv_mem_show = mpls_disp_dpo_mem_show, }; const static char* const mpls_label_disp_pipe_ip4_nodes[] = { "ip4-mpls-label-disposition-pipe", NULL, }; const static char* const mpls_label_disp_pipe_ip6_nodes[] = { "ip6-mpls-label-disposition-pipe", NULL, }; const static char* const * const mpls_label_disp_pipe_nodes[DPO_PROTO_NUM] = { [DPO_PROTO_IP4] = mpls_label_disp_pipe_ip4_nodes, [DPO_PROTO_IP6] = mpls_label_disp_pipe_ip6_nodes, }; const static char* const mpls_label_disp_uniform_ip4_nodes[] = { "ip4-mpls-label-disposition-uniform", NULL, }; const static char* const mpls_label_disp_uniform_ip6_nodes[] = { "ip6-mpls-label-disposition-uniform", NULL, }; const static char* const * const mpls_label_disp_uniform_nodes[DPO_PROTO_NUM] = { [DPO_PROTO_IP4] = mpls_label_disp_uniform_ip4_nodes, [DPO_PROTO_IP6] = mpls_label_disp_uniform_ip6_nodes, }; void mpls_disp_dpo_module_init(void) { dpo_register(DPO_MPLS_DISPOSITION_PIPE, &mdd_vft, mpls_label_disp_pipe_nodes); dpo_register(DPO_MPLS_DISPOSITION_UNIFORM, &mdd_vft, mpls_label_disp_uniform_nodes); } #endif /* CLIB_MARCH_VARIANT */