}
static void
-vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
+vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
+ mp)
{
vat_main_t *vam = &vat_main;
i32 retval = ntohl (mp->retval);
vam->sw_if_index = ntohl (mp->sw_if_index);
vam->result_ready = 1;
}
-
}
-static void vl_api_tap_create_v2_reply_t_handler_json
- (vl_api_tap_create_v2_reply_t * mp)
+static void vl_api_virtio_pci_create_reply_t_handler_json
+ (vl_api_virtio_pci_create_reply_t * mp)
{
vat_main_t *vam = &vat_main;
vat_json_node_t node;
}
static void
-vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
+ vl_api_virtio_pci_create_v2_reply_t_handler
+ (vl_api_virtio_pci_create_v2_reply_t * mp)
{
vat_main_t *vam = &vat_main;
i32 retval = ntohl (mp->retval);
else
{
vam->retval = retval;
+ vam->sw_if_index = ntohl (mp->sw_if_index);
vam->result_ready = 1;
}
}
-static void vl_api_tap_delete_v2_reply_t_handler_json
- (vl_api_tap_delete_v2_reply_t * mp)
+static void vl_api_virtio_pci_create_v2_reply_t_handler_json
+ (vl_api_virtio_pci_create_v2_reply_t * mp)
{
vat_main_t *vam = &vat_main;
vat_json_node_t node;
vat_json_init_object (&node);
vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
+ vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
vat_json_print (vam->ofp, &node);
vat_json_free (&node);
}
static void
-vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
+vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
mp)
{
vat_main_t *vam = &vat_main;
else
{
vam->retval = retval;
- vam->sw_if_index = ntohl (mp->sw_if_index);
vam->result_ready = 1;
}
}
-static void vl_api_virtio_pci_create_reply_t_handler_json
- (vl_api_virtio_pci_create_reply_t * mp)
+static void vl_api_virtio_pci_delete_reply_t_handler_json
+ (vl_api_virtio_pci_delete_reply_t * mp)
{
vat_main_t *vam = &vat_main;
vat_json_node_t node;
vat_json_init_object (&node);
vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
vat_json_print (vam->ofp, &node);
vat_json_free (&node);
vam->retval = ntohl (mp->retval);
vam->result_ready = 1;
-
}
-static void
- vl_api_virtio_pci_create_v2_reply_t_handler
- (vl_api_virtio_pci_create_v2_reply_t * mp)
+static void vl_api_mpls_tunnel_add_del_reply_t_handler
+ (vl_api_mpls_tunnel_add_del_reply_t * mp)
{
vat_main_t *vam = &vat_main;
i32 retval = ntohl (mp->retval);
vam->sw_if_index = ntohl (mp->sw_if_index);
vam->result_ready = 1;
}
+ vam->regenerate_interface_table = 1;
}
-static void vl_api_virtio_pci_create_v2_reply_t_handler_json
- (vl_api_virtio_pci_create_v2_reply_t * mp)
+static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
+ (vl_api_mpls_tunnel_add_del_reply_t * mp)
{
vat_main_t *vam = &vat_main;
vat_json_node_t node;
vat_json_init_object (&node);
vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
+ vat_json_object_add_uint (&node, "tunnel_sw_if_index",
+ ntohl (mp->sw_if_index));
vat_json_print (vam->ofp, &node);
vat_json_free (&node);
vam->result_ready = 1;
}
-static void
-vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
- mp)
+static void vl_api_create_vhost_user_if_reply_t_handler
+ (vl_api_create_vhost_user_if_reply_t * mp)
{
vat_main_t *vam = &vat_main;
i32 retval = ntohl (mp->retval);
else
{
vam->retval = retval;
+ vam->sw_if_index = ntohl (mp->sw_if_index);
vam->result_ready = 1;
}
+ vam->regenerate_interface_table = 1;
}
-static void vl_api_virtio_pci_delete_reply_t_handler_json
- (vl_api_virtio_pci_delete_reply_t * mp)
+static void vl_api_create_vhost_user_if_reply_t_handler_json
+ (vl_api_create_vhost_user_if_reply_t * mp)
{
vat_main_t *vam = &vat_main;
vat_json_node_t node;
vat_json_init_object (&node);
vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
+ vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
vat_json_print (vam->ofp, &node);
vat_json_free (&node);
vam->result_ready = 1;
}
-static void
-vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
+static void vl_api_create_vhost_user_if_v2_reply_t_handler
+ (vl_api_create_vhost_user_if_v2_reply_t * mp)
{
vat_main_t *vam = &vat_main;
i32 retval = ntohl (mp->retval);
-
if (vam->async_mode)
{
vam->async_errors += (retval < 0);
vam->sw_if_index = ntohl (mp->sw_if_index);
vam->result_ready = 1;
}
+ vam->regenerate_interface_table = 1;
}
-static void vl_api_bond_create_reply_t_handler_json
- (vl_api_bond_create_reply_t * mp)
+static void vl_api_create_vhost_user_if_v2_reply_t_handler_json
+ (vl_api_create_vhost_user_if_v2_reply_t * mp)
{
vat_main_t *vam = &vat_main;
vat_json_node_t node;
vam->result_ready = 1;
}
-static void
-vl_api_bond_create2_reply_t_handler (vl_api_bond_create2_reply_t * mp)
+static void vl_api_ip_address_details_t_handler
+ (vl_api_ip_address_details_t * mp)
{
vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
+ static ip_address_details_t empty_ip_address_details = { {0} };
+ ip_address_details_t *address = NULL;
+ ip_details_t *current_ip_details = NULL;
+ ip_details_t *details = NULL;
- if (vam->async_mode)
+ details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
+
+ if (!details || vam->current_sw_if_index >= vec_len (details)
+ || !details[vam->current_sw_if_index].present)
{
- vam->async_errors += (retval < 0);
+ errmsg ("ip address details arrived but not stored");
+ errmsg ("ip_dump should be called first");
+ return;
}
- else
+
+ current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
+
+#define addresses (current_ip_details->addr)
+
+ vec_validate_init_empty (addresses, vec_len (addresses),
+ empty_ip_address_details);
+
+ address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
+
+ clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
+ address->prefix_length = mp->prefix.len;
+#undef addresses
+}
+
+static void vl_api_ip_address_details_t_handler_json
+ (vl_api_ip_address_details_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ vat_json_node_t *node = NULL;
+
+ if (VAT_JSON_ARRAY != vam->json_tree.type)
{
- vam->retval = retval;
- vam->sw_if_index = ntohl (mp->sw_if_index);
- vam->result_ready = 1;
+ ASSERT (VAT_JSON_NONE == vam->json_tree.type);
+ vat_json_init_array (&vam->json_tree);
}
+ node = vat_json_array_add (&vam->json_tree);
+
+ vat_json_init_object (node);
+ vat_json_object_add_prefix (node, &mp->prefix);
}
-static void vl_api_bond_create2_reply_t_handler_json
- (vl_api_bond_create2_reply_t * mp)
+static void
+vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
{
vat_main_t *vam = &vat_main;
- vat_json_node_t node;
+ static ip_details_t empty_ip_details = { 0 };
+ ip_details_t *ip = NULL;
+ u32 sw_if_index = ~0;
- vat_json_init_object (&node);
- vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
+ sw_if_index = ntohl (mp->sw_if_index);
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
+ vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
+ sw_if_index, empty_ip_details);
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
+ ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
+ sw_if_index);
+
+ ip->present = 1;
}
static void
-vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
+vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+
+ if (VAT_JSON_ARRAY != vam->json_tree.type)
+ {
+ ASSERT (VAT_JSON_NONE == vam->json_tree.type);
+ vat_json_init_array (&vam->json_tree);
+ }
+ vat_json_array_add_uint (&vam->json_tree,
+ clib_net_to_host_u32 (mp->sw_if_index));
+}
+
+static void vl_api_get_first_msg_id_reply_t_handler
+ (vl_api_get_first_msg_id_reply_t * mp)
{
vat_main_t *vam = &vat_main;
i32 retval = ntohl (mp->retval);
vam->retval = retval;
vam->result_ready = 1;
}
+ if (retval >= 0)
+ {
+ errmsg ("first message id %d", ntohs (mp->first_msg_id));
+ }
}
-static void vl_api_bond_delete_reply_t_handler_json
- (vl_api_bond_delete_reply_t * mp)
+static void vl_api_get_first_msg_id_reply_t_handler_json
+ (vl_api_get_first_msg_id_reply_t * mp)
{
vat_main_t *vam = &vat_main;
vat_json_node_t node;
vat_json_init_object (&node);
vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
+ vat_json_object_add_uint (&node, "first_msg_id",
+ (uint) ntohs (mp->first_msg_id));
vat_json_print (vam->ofp, &node);
vat_json_free (&node);
vam->result_ready = 1;
}
-static void
-vl_api_bond_add_member_reply_t_handler (vl_api_bond_add_member_reply_t * mp)
+static void vl_api_get_node_graph_reply_t_handler
+ (vl_api_get_node_graph_reply_t * mp)
{
vat_main_t *vam = &vat_main;
i32 retval = ntohl (mp->retval);
+ u8 *pvt_copy, *reply;
+ void *oldheap;
+ vlib_node_t *node;
+ int i;
if (vam->async_mode)
{
vam->retval = retval;
vam->result_ready = 1;
}
-}
-static void vl_api_bond_add_member_reply_t_handler_json
- (vl_api_bond_add_member_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
+ /* "Should never happen..." */
+ if (retval != 0)
+ return;
- vat_json_init_object (&node);
- vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
+ reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
+ pvt_copy = vec_dup (reply);
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
+ /* Toss the shared-memory original... */
+ oldheap = vl_msg_push_heap ();
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
+ vec_free (reply);
-static void
-vl_api_bond_detach_member_reply_t_handler (vl_api_bond_detach_member_reply_t *
- mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
+ vl_msg_pop_heap (oldheap);
- if (vam->async_mode)
+ if (vam->graph_nodes)
{
- vam->async_errors += (retval < 0);
+ hash_free (vam->graph_node_index_by_name);
+
+ for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
+ {
+ node = vam->graph_nodes[0][i];
+ vec_free (node->name);
+ vec_free (node->next_nodes);
+ vec_free (node);
+ }
+ vec_free (vam->graph_nodes[0]);
+ vec_free (vam->graph_nodes);
}
- else
+
+ vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
+ vam->graph_nodes = vlib_node_unserialize (pvt_copy);
+ vec_free (pvt_copy);
+
+ for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
{
- vam->retval = retval;
- vam->result_ready = 1;
+ node = vam->graph_nodes[0][i];
+ hash_set_mem (vam->graph_node_index_by_name, node->name, i);
}
}
-static void vl_api_bond_detach_member_reply_t_handler_json
- (vl_api_bond_detach_member_reply_t * mp)
+static void vl_api_get_node_graph_reply_t_handler_json
+ (vl_api_get_node_graph_reply_t * mp)
{
vat_main_t *vam = &vat_main;
+ void *oldheap;
vat_json_node_t node;
+ u8 *reply;
+ /* $$$$ make this real? */
vat_json_init_object (&node);
vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
+ vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
+
+ reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
+
+ /* Toss the shared-memory original... */
+ oldheap = vl_msg_push_heap ();
+
+ vec_free (reply);
+
+ vl_msg_pop_heap (oldheap);
vat_json_print (vam->ofp, &node);
vat_json_free (&node);
vam->result_ready = 1;
}
-static int
-api_sw_interface_set_bond_weight (vat_main_t * vam)
+/* Format hex dump. */
+u8 *
+format_hex_bytes (u8 * s, va_list * va)
{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_bond_weight_t *mp;
- u32 sw_if_index = ~0;
- u32 weight = 0;
- u8 weight_enter = 0;
- int ret;
+ u8 *bytes = va_arg (*va, u8 *);
+ int n_bytes = va_arg (*va, int);
+ uword i;
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- ;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- ;
- else if (unformat (i, "weight %u", &weight))
- weight_enter = 1;
- else
- break;
- }
+ /* Print short or long form depending on byte count. */
+ uword short_form = n_bytes <= 32;
+ u32 indent = format_get_indent (s);
- if (sw_if_index == ~0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
- if (weight_enter == 0)
+ if (n_bytes == 0)
+ return s;
+
+ for (i = 0; i < n_bytes; i++)
{
- errmsg ("missing valid weight");
- return -99;
+ if (!short_form && (i % 32) == 0)
+ s = format (s, "%08x: ", i);
+ s = format (s, "%02x", bytes[i]);
+ if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
+ s = format (s, "\n%U", format_white_space, indent);
}
- /* Construct the API message */
- M (SW_INTERFACE_SET_BOND_WEIGHT, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->weight = ntohl (weight);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static void vl_api_sw_bond_interface_details_t_handler
- (vl_api_sw_bond_interface_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- print (vam->ofp,
- "%-16s %-12d %-12U %-13U %-14u %-14u",
- mp->interface_name, ntohl (mp->sw_if_index),
- format_bond_mode, ntohl (mp->mode), format_bond_load_balance,
- ntohl (mp->lb), ntohl (mp->active_members), ntohl (mp->members));
-}
-
-static void vl_api_sw_bond_interface_details_t_handler_json
- (vl_api_sw_bond_interface_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
- vat_json_object_add_string_copy (node, "interface_name",
- mp->interface_name);
- vat_json_object_add_uint (node, "mode", ntohl (mp->mode));
- vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb));
- vat_json_object_add_uint (node, "active_members",
- ntohl (mp->active_members));
- vat_json_object_add_uint (node, "members", ntohl (mp->members));
-}
-
-static int
-api_sw_bond_interface_dump (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_bond_interface_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- int ret;
- u32 sw_if_index = ~0;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- ;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- ;
- else
- break;
- }
-
- print (vam->ofp,
- "\n%-16s %-12s %-12s %-13s %-14s %-14s",
- "interface name", "sw_if_index", "mode", "load balance",
- "active members", "members");
-
- /* Get list of bond interfaces */
- M (SW_BOND_INTERFACE_DUMP, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-static void vl_api_sw_member_interface_details_t_handler
- (vl_api_sw_member_interface_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- print (vam->ofp,
- "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name,
- ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout,
- ntohl (mp->weight), mp->is_local_numa);
-}
-
-static void vl_api_sw_member_interface_details_t_handler_json
- (vl_api_sw_member_interface_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
- vat_json_object_add_string_copy (node, "interface_name",
- mp->interface_name);
- vat_json_object_add_uint (node, "passive", mp->is_passive);
- vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
- vat_json_object_add_uint (node, "weight", ntohl (mp->weight));
- vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa);
-}
-
-static int
-api_sw_member_interface_dump (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sw_member_interface_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- u32 sw_if_index = ~0;
- u8 sw_if_index_set = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing vpp interface name. ");
- return -99;
- }
-
- print (vam->ofp,
- "\n%-25s %-12s %-7s %-12s %-10s %-10s",
- "member interface name", "sw_if_index", "passive", "long_timeout",
- "weight", "local numa");
-
- /* Get list of bond interfaces */
- M (SW_MEMBER_INTERFACE_DUMP, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
-static void vl_api_mpls_tunnel_add_del_reply_t_handler
- (vl_api_mpls_tunnel_add_del_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
- if (vam->async_mode)
- {
- vam->async_errors += (retval < 0);
- }
- else
- {
- vam->retval = retval;
- vam->sw_if_index = ntohl (mp->sw_if_index);
- vam->result_ready = 1;
- }
- vam->regenerate_interface_table = 1;
-}
-
-static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
- (vl_api_mpls_tunnel_add_del_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
-
- vat_json_init_object (&node);
- vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_uint (&node, "tunnel_sw_if_index",
- ntohl (mp->sw_if_index));
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void vl_api_create_vhost_user_if_reply_t_handler
- (vl_api_create_vhost_user_if_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
- if (vam->async_mode)
- {
- vam->async_errors += (retval < 0);
- }
- else
- {
- vam->retval = retval;
- vam->sw_if_index = ntohl (mp->sw_if_index);
- vam->result_ready = 1;
- }
- vam->regenerate_interface_table = 1;
-}
-
-static void vl_api_create_vhost_user_if_reply_t_handler_json
- (vl_api_create_vhost_user_if_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
-
- vat_json_init_object (&node);
- vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void vl_api_create_vhost_user_if_v2_reply_t_handler
- (vl_api_create_vhost_user_if_v2_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
- if (vam->async_mode)
- {
- vam->async_errors += (retval < 0);
- }
- else
- {
- vam->retval = retval;
- vam->sw_if_index = ntohl (mp->sw_if_index);
- vam->result_ready = 1;
- }
- vam->regenerate_interface_table = 1;
-}
-
-static void vl_api_create_vhost_user_if_v2_reply_t_handler_json
- (vl_api_create_vhost_user_if_v2_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
-
- vat_json_init_object (&node);
- vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void vl_api_ip_address_details_t_handler
- (vl_api_ip_address_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- static ip_address_details_t empty_ip_address_details = { {0} };
- ip_address_details_t *address = NULL;
- ip_details_t *current_ip_details = NULL;
- ip_details_t *details = NULL;
-
- details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
-
- if (!details || vam->current_sw_if_index >= vec_len (details)
- || !details[vam->current_sw_if_index].present)
- {
- errmsg ("ip address details arrived but not stored");
- errmsg ("ip_dump should be called first");
- return;
- }
-
- current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
-
-#define addresses (current_ip_details->addr)
-
- vec_validate_init_empty (addresses, vec_len (addresses),
- empty_ip_address_details);
-
- address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
-
- clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
- address->prefix_length = mp->prefix.len;
-#undef addresses
-}
-
-static void vl_api_ip_address_details_t_handler_json
- (vl_api_ip_address_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_prefix (node, &mp->prefix);
-}
-
-static void
-vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- static ip_details_t empty_ip_details = { 0 };
- ip_details_t *ip = NULL;
- u32 sw_if_index = ~0;
-
- sw_if_index = ntohl (mp->sw_if_index);
-
- vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
- sw_if_index, empty_ip_details);
-
- ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
- sw_if_index);
-
- ip->present = 1;
-}
-
-static void
-vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- vat_json_array_add_uint (&vam->json_tree,
- clib_net_to_host_u32 (mp->sw_if_index));
-}
-
-static void vl_api_get_first_msg_id_reply_t_handler
- (vl_api_get_first_msg_id_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
-
- if (vam->async_mode)
- {
- vam->async_errors += (retval < 0);
- }
- else
- {
- vam->retval = retval;
- vam->result_ready = 1;
- }
- if (retval >= 0)
- {
- errmsg ("first message id %d", ntohs (mp->first_msg_id));
- }
-}
-
-static void vl_api_get_first_msg_id_reply_t_handler_json
- (vl_api_get_first_msg_id_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
-
- vat_json_init_object (&node);
- vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_uint (&node, "first_msg_id",
- (uint) ntohs (mp->first_msg_id));
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-static void vl_api_get_node_graph_reply_t_handler
- (vl_api_get_node_graph_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- i32 retval = ntohl (mp->retval);
- u8 *pvt_copy, *reply;
- void *oldheap;
- vlib_node_t *node;
- int i;
-
- if (vam->async_mode)
- {
- vam->async_errors += (retval < 0);
- }
- else
- {
- vam->retval = retval;
- vam->result_ready = 1;
- }
-
- /* "Should never happen..." */
- if (retval != 0)
- return;
-
- reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
- pvt_copy = vec_dup (reply);
-
- /* Toss the shared-memory original... */
- oldheap = vl_msg_push_heap ();
-
- vec_free (reply);
-
- vl_msg_pop_heap (oldheap);
-
- if (vam->graph_nodes)
- {
- hash_free (vam->graph_node_index_by_name);
-
- for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
- {
- node = vam->graph_nodes[0][i];
- vec_free (node->name);
- vec_free (node->next_nodes);
- vec_free (node);
- }
- vec_free (vam->graph_nodes[0]);
- vec_free (vam->graph_nodes);
- }
-
- vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
- vam->graph_nodes = vlib_node_unserialize (pvt_copy);
- vec_free (pvt_copy);
-
- for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
- {
- node = vam->graph_nodes[0][i];
- hash_set_mem (vam->graph_node_index_by_name, node->name, i);
- }
-}
-
-static void vl_api_get_node_graph_reply_t_handler_json
- (vl_api_get_node_graph_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- void *oldheap;
- vat_json_node_t node;
- u8 *reply;
-
- /* $$$$ make this real? */
- vat_json_init_object (&node);
- vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
-
- reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
-
- /* Toss the shared-memory original... */
- oldheap = vl_msg_push_heap ();
-
- vec_free (reply);
-
- vl_msg_pop_heap (oldheap);
-
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
-
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
-}
-
-/* Format hex dump. */
-u8 *
-format_hex_bytes (u8 * s, va_list * va)
-{
- u8 *bytes = va_arg (*va, u8 *);
- int n_bytes = va_arg (*va, int);
- uword i;
-
- /* Print short or long form depending on byte count. */
- uword short_form = n_bytes <= 32;
- u32 indent = format_get_indent (s);
-
- if (n_bytes == 0)
- return s;
-
- for (i = 0; i < n_bytes; i++)
- {
- if (!short_form && (i % 32) == 0)
- s = format (s, "%08x: ", i);
- s = format (s, "%02x", bytes[i]);
- if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
- s = format (s, "\n%U", format_white_space, indent);
- }
-
- return s;
-}
-
-/*
- * Generate boilerplate reply handlers, which
- * dig the return value out of the xxx_reply_t API message,
- * stick it into vam->retval, and set vam->result_ready
- *
- * Could also do this by pointing N message decode slots at
- * a single function, but that could break in subtle ways.
- */
-
-#define foreach_standard_reply_retval_handler \
-_(sw_interface_set_flags_reply) \
-_(sw_interface_add_del_address_reply) \
-_(sw_interface_set_rx_mode_reply) \
-_(sw_interface_set_rx_placement_reply) \
-_(sw_interface_set_table_reply) \
-_(sw_interface_set_mpls_enable_reply) \
-_(sw_interface_set_vpath_reply) \
-_(sw_interface_set_l2_bridge_reply) \
-_(sw_interface_set_bond_weight_reply) \
-_(bridge_domain_add_del_reply) \
-_(sw_interface_set_l2_xconnect_reply) \
-_(l2fib_add_del_reply) \
-_(l2fib_flush_int_reply) \
-_(l2fib_flush_bd_reply) \
-_(ip_route_add_del_reply) \
-_(ip_table_add_del_reply) \
-_(ip_table_replace_begin_reply) \
-_(ip_table_flush_reply) \
-_(ip_table_replace_end_reply) \
-_(ip_mroute_add_del_reply) \
-_(mpls_route_add_del_reply) \
-_(mpls_table_add_del_reply) \
-_(mpls_ip_bind_unbind_reply) \
-_(sw_interface_set_unnumbered_reply) \
-_(set_ip_flow_hash_reply) \
-_(sw_interface_ip6_enable_disable_reply) \
-_(l2_patch_add_del_reply) \
-_(sr_mpls_policy_add_reply) \
-_(sr_mpls_policy_mod_reply) \
-_(sr_mpls_policy_del_reply) \
-_(sr_policy_add_reply) \
-_(sr_policy_mod_reply) \
-_(sr_policy_del_reply) \
-_(sr_localsid_add_del_reply) \
-_(sr_steering_add_del_reply) \
-_(l2_fib_clear_table_reply) \
-_(l2_interface_efp_filter_reply) \
-_(l2_interface_vlan_tag_rewrite_reply) \
-_(modify_vhost_user_if_reply) \
-_(modify_vhost_user_if_v2_reply) \
-_(delete_vhost_user_if_reply) \
-_(want_l2_macs_events_reply) \
-_(delete_loopback_reply) \
-_(bd_ip_mac_add_del_reply) \
-_(bd_ip_mac_flush_reply) \
-_(want_interface_events_reply) \
-_(sw_interface_clear_stats_reply) \
-_(ioam_enable_reply) \
-_(ioam_disable_reply) \
-_(af_packet_delete_reply) \
-_(sw_interface_span_enable_disable_reply) \
-_(ip_source_and_port_range_check_add_del_reply) \
-_(ip_source_and_port_range_check_interface_add_del_reply)\
-_(delete_subif_reply) \
-_(l2_interface_pbb_tag_rewrite_reply) \
-_(set_punt_reply) \
-_(sw_interface_tag_add_del_reply) \
-_(sw_interface_add_del_mac_address_reply) \
-_(hw_interface_set_mtu_reply) \
-_(tcp_configure_src_addresses_reply) \
-_(session_rule_add_del_reply) \
-_(ip_container_proxy_add_del_reply) \
-_(qos_record_enable_disable_reply) \
-
-#define _(n) \
- static void vl_api_##n##_t_handler \
- (vl_api_##n##_t * mp) \
- { \
- vat_main_t * vam = &vat_main; \
- i32 retval = ntohl(mp->retval); \
- if (vam->async_mode) { \
- vam->async_errors += (retval < 0); \
- } else { \
- vam->retval = retval; \
- vam->result_ready = 1; \
- } \
- }
-foreach_standard_reply_retval_handler;
-#undef _
-
-#define _(n) \
- static void vl_api_##n##_t_handler_json \
- (vl_api_##n##_t * mp) \
- { \
- vat_main_t * vam = &vat_main; \
- vat_json_node_t node; \
- vat_json_init_object(&node); \
- vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
- vat_json_print(vam->ofp, &node); \
- vam->retval = ntohl(mp->retval); \
- vam->result_ready = 1; \
- }
-foreach_standard_reply_retval_handler;
-#undef _
-
-/*
- * Table of message reply handlers, must include boilerplate handlers
- * we just generated
- */
-
-#define foreach_vpe_api_reply_msg \
-_(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
-_(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
-_(SW_INTERFACE_DETAILS, sw_interface_details) \
-_(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
-_(CONTROL_PING_REPLY, control_ping_reply) \
-_(CLI_REPLY, cli_reply) \
-_(CLI_INBAND_REPLY, cli_inband_reply) \
-_(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
- sw_interface_add_del_address_reply) \
-_(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
-_(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
-_(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
-_(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
-_(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
-_(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
-_(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
- sw_interface_set_l2_xconnect_reply) \
-_(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
- sw_interface_set_l2_bridge_reply) \
-_(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
-_(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
-_(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
-_(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
-_(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
-_(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
-_(L2_FLAGS_REPLY, l2_flags_reply) \
-_(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
-_(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
-_(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
-_(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
-_(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
-_(VIRTIO_PCI_CREATE_V2_REPLY, virtio_pci_create_v2_reply) \
-_(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
-_(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
-_(BOND_CREATE_REPLY, bond_create_reply) \
-_(BOND_CREATE2_REPLY, bond_create2_reply) \
-_(BOND_DELETE_REPLY, bond_delete_reply) \
-_(BOND_ADD_MEMBER_REPLY, bond_add_member_reply) \
-_(BOND_DETACH_MEMBER_REPLY, bond_detach_member_reply) \
-_(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
-_(SW_BOND_INTERFACE_DETAILS, sw_bond_interface_details) \
-_(SW_MEMBER_INTERFACE_DETAILS, sw_member_interface_details) \
-_(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
-_(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
-_(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
-_(IP_TABLE_FLUSH_REPLY, ip_table_flush_reply) \
-_(IP_TABLE_REPLACE_END_REPLY, ip_table_replace_end_reply) \
-_(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
-_(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
-_(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
-_(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
-_(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
-_(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
- sw_interface_set_unnumbered_reply) \
-_(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
-_(CREATE_SUBIF_REPLY, create_subif_reply) \
-_(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
-_(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
- sw_interface_ip6_enable_disable_reply) \
-_(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
-_(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
-_(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
-_(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
-_(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
-_(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
-_(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
-_(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
-_(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
-_(GET_NODE_INDEX_REPLY, get_node_index_reply) \
-_(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
-_(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
-_(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
-_(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
-_(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
-_(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
-_(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
-_(CREATE_VHOST_USER_IF_V2_REPLY, create_vhost_user_if_v2_reply) \
-_(MODIFY_VHOST_USER_IF_V2_REPLY, modify_vhost_user_if_v2_reply) \
-_(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
-_(SHOW_VERSION_REPLY, show_version_reply) \
-_(SHOW_THREADS_REPLY, show_threads_reply) \
-_(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
-_(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
-_(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
-_(L2_MACS_EVENT, l2_macs_event) \
-_(IP_ADDRESS_DETAILS, ip_address_details) \
-_(IP_DETAILS, ip_details) \
-_(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
-_(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
-_(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
-_(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
-_(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
-_(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
-_(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
-_(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
-_(IOAM_ENABLE_REPLY, ioam_enable_reply) \
-_(IOAM_DISABLE_REPLY, ioam_disable_reply) \
-_(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
-_(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
-_(AF_PACKET_DETAILS, af_packet_details) \
-_(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
-_(MPLS_TABLE_DETAILS, mpls_table_details) \
-_(MPLS_ROUTE_DETAILS, mpls_route_details) \
-_(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
-_(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
-_(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
-_(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
- ip_source_and_port_range_check_add_del_reply) \
-_(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
- ip_source_and_port_range_check_interface_add_del_reply) \
-_(DELETE_SUBIF_REPLY, delete_subif_reply) \
-_(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
-_(SET_PUNT_REPLY, set_punt_reply) \
-_(IP_TABLE_DETAILS, ip_table_details) \
-_(IP_ROUTE_DETAILS, ip_route_details) \
-_(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
-_(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
-_(L2_XCONNECT_DETAILS, l2_xconnect_details) \
-_(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
-_(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
-_(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
-_(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
-_(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
-_(SESSION_RULES_DETAILS, session_rules_details) \
-_(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
-_(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply) \
-
-#define foreach_standalone_reply_msg \
-_(SW_INTERFACE_EVENT, sw_interface_event)
-
-typedef struct
-{
- u8 *name;
- u32 value;
-} name_sort_t;
-
-#define STR_VTR_OP_CASE(op) \
- case L2_VTR_ ## op: \
- return "" # op;
-
-static const char *
-str_vtr_op (u32 vtr_op)
-{
- switch (vtr_op)
- {
- STR_VTR_OP_CASE (DISABLED);
- STR_VTR_OP_CASE (PUSH_1);
- STR_VTR_OP_CASE (PUSH_2);
- STR_VTR_OP_CASE (POP_1);
- STR_VTR_OP_CASE (POP_2);
- STR_VTR_OP_CASE (TRANSLATE_1_1);
- STR_VTR_OP_CASE (TRANSLATE_1_2);
- STR_VTR_OP_CASE (TRANSLATE_2_1);
- STR_VTR_OP_CASE (TRANSLATE_2_2);
- }
-
- return "UNKNOWN";
-}
-
-static int
-dump_sub_interface_table (vat_main_t * vam)
-{
- const sw_interface_subif_t *sub = NULL;
-
- if (vam->json_output)
- {
- clib_warning
- ("JSON output supported only for VPE API calls and dump_stats_table");
- return -99;
- }
-
- print (vam->ofp,
- "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
- "Interface", "sw_if_index",
- "sub id", "dot1ad", "tags", "outer id",
- "inner id", "exact", "default", "outer any", "inner any");
-
- vec_foreach (sub, vam->sw_if_subif_table)
- {
- print (vam->ofp,
- "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
- sub->interface_name,
- sub->sw_if_index,
- sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
- sub->sub_number_of_tags, sub->sub_outer_vlan_id,
- sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
- sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
- if (sub->vtr_op != L2_VTR_DISABLED)
- {
- print (vam->ofp,
- " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
- "tag1: %d tag2: %d ]",
- str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
- sub->vtr_tag1, sub->vtr_tag2);
- }
- }
-
- return 0;
-}
-
-static int
-name_sort_cmp (void *a1, void *a2)
-{
- name_sort_t *n1 = a1;
- name_sort_t *n2 = a2;
-
- return strcmp ((char *) n1->name, (char *) n2->name);
-}
-
-static int
-dump_interface_table (vat_main_t * vam)
-{
- hash_pair_t *p;
- name_sort_t *nses = 0, *ns;
-
- if (vam->json_output)
- {
- clib_warning
- ("JSON output supported only for VPE API calls and dump_stats_table");
- return -99;
- }
-
- /* *INDENT-OFF* */
- hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
- ({
- vec_add2 (nses, ns, 1);
- ns->name = (u8 *)(p->key);
- ns->value = (u32) p->value[0];
- }));
- /* *INDENT-ON* */
-
- vec_sort_with_function (nses, name_sort_cmp);
-
- print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
- vec_foreach (ns, nses)
- {
- print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
- }
- vec_free (nses);
- return 0;
-}
-
-static int
-dump_ip_table (vat_main_t * vam, int is_ipv6)
-{
- const ip_details_t *det = NULL;
- const ip_address_details_t *address = NULL;
- u32 i = ~0;
-
- print (vam->ofp, "%-12s", "sw_if_index");
-
- vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
- {
- i++;
- if (!det->present)
- {
- continue;
- }
- print (vam->ofp, "%-12d", i);
- print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
- if (!det->addr)
- {
- continue;
- }
- vec_foreach (address, det->addr)
- {
- print (vam->ofp,
- " %-30U%-13d",
- is_ipv6 ? format_ip6_address : format_ip4_address,
- address->ip, address->prefix_length);
- }
- }
-
- return 0;
-}
-
-static int
-dump_ipv4_table (vat_main_t * vam)
-{
- if (vam->json_output)
- {
- clib_warning
- ("JSON output supported only for VPE API calls and dump_stats_table");
- return -99;
- }
-
- return dump_ip_table (vam, 0);
-}
-
-static int
-dump_ipv6_table (vat_main_t * vam)
-{
- if (vam->json_output)
- {
- clib_warning
- ("JSON output supported only for VPE API calls and dump_stats_table");
- return -99;
- }
-
- return dump_ip_table (vam, 1);
-}
+ return s;
+}
/*
- * Pass CLI buffers directly in the CLI_INBAND API message,
- * instead of an additional shared memory area.
+ * Generate boilerplate reply handlers, which
+ * dig the return value out of the xxx_reply_t API message,
+ * stick it into vam->retval, and set vam->result_ready
+ *
+ * Could also do this by pointing N message decode slots at
+ * a single function, but that could break in subtle ways.
*/
-static int
-exec_inband (vat_main_t * vam)
-{
- vl_api_cli_inband_t *mp;
- unformat_input_t *i = vam->input;
- int ret;
-
- if (vec_len (i->buffer) == 0)
- return -1;
-
- if (vam->exec_mode == 0 && unformat (i, "mode"))
- {
- vam->exec_mode = 1;
- return 0;
- }
- if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
- {
- vam->exec_mode = 0;
- return 0;
- }
-
- /*
- * In order for the CLI command to work, it
- * must be a vector ending in \n, not a C-string ending
- * in \n\0.
- */
- M2 (CLI_INBAND, mp, vec_len (vam->input->buffer));
- vl_api_vec_to_api_string (vam->input->buffer, &mp->cmd);
-
- S (mp);
- W (ret);
- /* json responses may or may not include a useful reply... */
- if (vec_len (vam->cmd_reply))
- print (vam->ofp, "%v", (char *) (vam->cmd_reply));
- return ret;
-}
-
-int
-exec (vat_main_t * vam)
-{
- return exec_inband (vam);
-}
-
-static int
-api_create_loopback (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_create_loopback_t *mp;
- vl_api_create_loopback_instance_t *mp_lbi;
- u8 mac_address[6];
- u8 mac_set = 0;
- u8 is_specified = 0;
- u32 user_instance = 0;
- int ret;
-
- clib_memset (mac_address, 0, sizeof (mac_address));
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
- mac_set = 1;
- if (unformat (i, "instance %d", &user_instance))
- is_specified = 1;
- else
- break;
- }
-
- if (is_specified)
- {
- M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
- mp_lbi->is_specified = is_specified;
- if (is_specified)
- mp_lbi->user_instance = htonl (user_instance);
- if (mac_set)
- clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
- S (mp_lbi);
- }
- else
- {
- /* Construct the API message */
- M (CREATE_LOOPBACK, mp);
- if (mac_set)
- clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
- S (mp);
- }
-
- W (ret);
- return ret;
-}
-
-static int
-api_delete_loopback (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_delete_loopback_t *mp;
- u32 sw_if_index = ~0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sw_if_index %d", &sw_if_index))
- ;
- else
- break;
- }
-
- if (sw_if_index == ~0)
- {
- errmsg ("missing sw_if_index");
- return -99;
- }
- /* Construct the API message */
- M (DELETE_LOOPBACK, mp);
- mp->sw_if_index = ntohl (sw_if_index);
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_want_interface_events (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_want_interface_events_t *mp;
- int enable = -1;
- int ret;
+#define foreach_standard_reply_retval_handler \
+_(sw_interface_set_flags_reply) \
+_(sw_interface_add_del_address_reply) \
+_(sw_interface_set_rx_mode_reply) \
+_(sw_interface_set_rx_placement_reply) \
+_(sw_interface_set_table_reply) \
+_(sw_interface_set_mpls_enable_reply) \
+_(sw_interface_set_vpath_reply) \
+_(sw_interface_set_l2_bridge_reply) \
+_(bridge_domain_add_del_reply) \
+_(sw_interface_set_l2_xconnect_reply) \
+_(l2fib_add_del_reply) \
+_(l2fib_flush_int_reply) \
+_(l2fib_flush_bd_reply) \
+_(ip_route_add_del_reply) \
+_(ip_table_add_del_reply) \
+_(ip_table_replace_begin_reply) \
+_(ip_table_flush_reply) \
+_(ip_table_replace_end_reply) \
+_(ip_mroute_add_del_reply) \
+_(mpls_route_add_del_reply) \
+_(mpls_table_add_del_reply) \
+_(mpls_ip_bind_unbind_reply) \
+_(sw_interface_set_unnumbered_reply) \
+_(set_ip_flow_hash_reply) \
+_(sw_interface_ip6_enable_disable_reply) \
+_(l2_patch_add_del_reply) \
+_(l2_fib_clear_table_reply) \
+_(l2_interface_efp_filter_reply) \
+_(l2_interface_vlan_tag_rewrite_reply) \
+_(modify_vhost_user_if_reply) \
+_(modify_vhost_user_if_v2_reply) \
+_(delete_vhost_user_if_reply) \
+_(want_l2_macs_events_reply) \
+_(delete_loopback_reply) \
+_(bd_ip_mac_add_del_reply) \
+_(bd_ip_mac_flush_reply) \
+_(want_interface_events_reply) \
+_(sw_interface_clear_stats_reply) \
+_(ioam_enable_reply) \
+_(ioam_disable_reply) \
+_(af_packet_delete_reply) \
+_(sw_interface_span_enable_disable_reply) \
+_(ip_source_and_port_range_check_add_del_reply) \
+_(ip_source_and_port_range_check_interface_add_del_reply)\
+_(delete_subif_reply) \
+_(l2_interface_pbb_tag_rewrite_reply) \
+_(set_punt_reply) \
+_(sw_interface_tag_add_del_reply) \
+_(sw_interface_add_del_mac_address_reply) \
+_(hw_interface_set_mtu_reply) \
+_(tcp_configure_src_addresses_reply) \
+_(session_rule_add_del_reply) \
+_(ip_container_proxy_add_del_reply) \
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "enable"))
- enable = 1;
- else if (unformat (i, "disable"))
- enable = 0;
- else
- break;
+#define _(n) \
+ static void vl_api_##n##_t_handler \
+ (vl_api_##n##_t * mp) \
+ { \
+ vat_main_t * vam = &vat_main; \
+ i32 retval = ntohl(mp->retval); \
+ if (vam->async_mode) { \
+ vam->async_errors += (retval < 0); \
+ } else { \
+ vam->retval = retval; \
+ vam->result_ready = 1; \
+ } \
}
+foreach_standard_reply_retval_handler;
+#undef _
- if (enable == -1)
- {
- errmsg ("missing enable|disable");
- return -99;
+#define _(n) \
+ static void vl_api_##n##_t_handler_json \
+ (vl_api_##n##_t * mp) \
+ { \
+ vat_main_t * vam = &vat_main; \
+ vat_json_node_t node; \
+ vat_json_init_object(&node); \
+ vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
+ vat_json_print(vam->ofp, &node); \
+ vam->retval = ntohl(mp->retval); \
+ vam->result_ready = 1; \
}
+foreach_standard_reply_retval_handler;
+#undef _
- M (WANT_INTERFACE_EVENTS, mp);
- mp->enable_disable = enable;
-
- vam->interface_event_display = enable;
+/*
+ * Table of message reply handlers, must include boilerplate handlers
+ * we just generated
+ */
- S (mp);
- W (ret);
- return ret;
-}
+#define foreach_vpe_api_reply_msg \
+_(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
+_(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
+_(SW_INTERFACE_DETAILS, sw_interface_details) \
+_(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
+_(CONTROL_PING_REPLY, control_ping_reply) \
+_(CLI_REPLY, cli_reply) \
+_(CLI_INBAND_REPLY, cli_inband_reply) \
+_(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
+ sw_interface_add_del_address_reply) \
+_(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
+_(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
+_(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
+_(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
+_(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
+_(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
+_(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
+ sw_interface_set_l2_xconnect_reply) \
+_(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
+ sw_interface_set_l2_bridge_reply) \
+_(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
+_(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
+_(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
+_(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
+_(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
+_(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
+_(L2_FLAGS_REPLY, l2_flags_reply) \
+_(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
+_(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
+_(VIRTIO_PCI_CREATE_V2_REPLY, virtio_pci_create_v2_reply) \
+_(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
+_(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
+_(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
+_(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
+_(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
+_(IP_TABLE_FLUSH_REPLY, ip_table_flush_reply) \
+_(IP_TABLE_REPLACE_END_REPLY, ip_table_replace_end_reply) \
+_(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
+_(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
+_(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
+_(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
+_(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
+_(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
+ sw_interface_set_unnumbered_reply) \
+_(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
+_(CREATE_SUBIF_REPLY, create_subif_reply) \
+_(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
+_(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
+ sw_interface_ip6_enable_disable_reply) \
+_(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
+_(GET_NODE_INDEX_REPLY, get_node_index_reply) \
+_(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
+_(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
+_(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
+_(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
+_(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
+_(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
+_(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
+_(CREATE_VHOST_USER_IF_V2_REPLY, create_vhost_user_if_v2_reply) \
+_(MODIFY_VHOST_USER_IF_V2_REPLY, modify_vhost_user_if_v2_reply) \
+_(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
+_(SHOW_VERSION_REPLY, show_version_reply) \
+_(SHOW_THREADS_REPLY, show_threads_reply) \
+_(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
+_(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
+_(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
+_(L2_MACS_EVENT, l2_macs_event) \
+_(IP_ADDRESS_DETAILS, ip_address_details) \
+_(IP_DETAILS, ip_details) \
+_(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
+_(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
+_(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
+_(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
+_(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
+_(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
+_(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
+_(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
+_(IOAM_ENABLE_REPLY, ioam_enable_reply) \
+_(IOAM_DISABLE_REPLY, ioam_disable_reply) \
+_(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
+_(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
+_(AF_PACKET_DETAILS, af_packet_details) \
+_(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
+_(MPLS_TABLE_DETAILS, mpls_table_details) \
+_(MPLS_ROUTE_DETAILS, mpls_route_details) \
+_(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
+_(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
+_(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
+_(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
+ ip_source_and_port_range_check_add_del_reply) \
+_(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
+ ip_source_and_port_range_check_interface_add_del_reply) \
+_(DELETE_SUBIF_REPLY, delete_subif_reply) \
+_(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
+_(SET_PUNT_REPLY, set_punt_reply) \
+_(IP_TABLE_DETAILS, ip_table_details) \
+_(IP_ROUTE_DETAILS, ip_route_details) \
+_(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
+_(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
+_(L2_XCONNECT_DETAILS, l2_xconnect_details) \
+_(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
+_(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
+_(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
+_(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
+_(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
+_(SESSION_RULES_DETAILS, session_rules_details) \
+_(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
+#define foreach_standalone_reply_msg \
+_(SW_INTERFACE_EVENT, sw_interface_event)
-/* Note: non-static, called once to set up the initial intfc table */
-int
-api_sw_interface_dump (vat_main_t * vam)
+typedef struct
{
- vl_api_sw_interface_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- hash_pair_t *p;
- name_sort_t *nses = 0, *ns;
- sw_interface_subif_t *sub = NULL;
- int ret;
-
- /* Toss the old name table */
- /* *INDENT-OFF* */
- hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
- ({
- vec_add2 (nses, ns, 1);
- ns->name = (u8 *)(p->key);
- ns->value = (u32) p->value[0];
- }));
- /* *INDENT-ON* */
-
- hash_free (vam->sw_if_index_by_interface_name);
-
- vec_foreach (ns, nses) vec_free (ns->name);
-
- vec_free (nses);
-
- vec_foreach (sub, vam->sw_if_subif_table)
- {
- vec_free (sub->interface_name);
- }
- vec_free (vam->sw_if_subif_table);
-
- /* recreate the interface name hash table */
- vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
-
- /*
- * Ask for all interface names. Otherwise, the epic catalog of
- * name filters becomes ridiculously long, and vat ends up needing
- * to be taught about new interface types.
- */
- M (SW_INTERFACE_DUMP, mp);
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
+ u8 *name;
+ u32 value;
+} name_sort_t;
- W (ret);
- return ret;
-}
+#define STR_VTR_OP_CASE(op) \
+ case L2_VTR_ ## op: \
+ return "" # op;
-static int
-api_sw_interface_set_flags (vat_main_t * vam)
+static const char *
+str_vtr_op (u32 vtr_op)
{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_flags_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u8 admin_up = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "admin-up"))
- admin_up = 1;
- else if (unformat (i, "admin-down"))
- admin_up = 0;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
- }
-
- if (sw_if_index_set == 0)
+ switch (vtr_op)
{
- errmsg ("missing interface name or sw_if_index");
- return -99;
+ STR_VTR_OP_CASE (DISABLED);
+ STR_VTR_OP_CASE (PUSH_1);
+ STR_VTR_OP_CASE (PUSH_2);
+ STR_VTR_OP_CASE (POP_1);
+ STR_VTR_OP_CASE (POP_2);
+ STR_VTR_OP_CASE (TRANSLATE_1_1);
+ STR_VTR_OP_CASE (TRANSLATE_1_2);
+ STR_VTR_OP_CASE (TRANSLATE_2_1);
+ STR_VTR_OP_CASE (TRANSLATE_2_2);
}
- /* Construct the API message */
- M (SW_INTERFACE_SET_FLAGS, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply, return the good/bad news... */
- W (ret);
- return ret;
+ return "UNKNOWN";
}
static int
-api_sw_interface_set_rx_mode (vat_main_t * vam)
+dump_sub_interface_table (vat_main_t * vam)
{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_rx_mode_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- int ret;
- u8 queue_id_valid = 0;
- u32 queue_id;
- vnet_hw_if_rx_mode mode = VNET_HW_IF_RX_MODE_UNKNOWN;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "queue %d", &queue_id))
- queue_id_valid = 1;
- else if (unformat (i, "polling"))
- mode = VNET_HW_IF_RX_MODE_POLLING;
- else if (unformat (i, "interrupt"))
- mode = VNET_HW_IF_RX_MODE_INTERRUPT;
- else if (unformat (i, "adaptive"))
- mode = VNET_HW_IF_RX_MODE_ADAPTIVE;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
- }
+ const sw_interface_subif_t *sub = NULL;
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
- if (mode == VNET_HW_IF_RX_MODE_UNKNOWN)
+ if (vam->json_output)
{
- errmsg ("missing rx-mode");
+ clib_warning
+ ("JSON output supported only for VPE API calls and dump_stats_table");
return -99;
}
- /* Construct the API message */
- M (SW_INTERFACE_SET_RX_MODE, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->mode = (vl_api_rx_mode_t) mode;
- mp->queue_id_valid = queue_id_valid;
- mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
+ print (vam->ofp,
+ "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
+ "Interface", "sw_if_index",
+ "sub id", "dot1ad", "tags", "outer id",
+ "inner id", "exact", "default", "outer any", "inner any");
- /* send it... */
- S (mp);
+ vec_foreach (sub, vam->sw_if_subif_table)
+ {
+ print (vam->ofp,
+ "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
+ sub->interface_name,
+ sub->sw_if_index,
+ sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
+ sub->sub_number_of_tags, sub->sub_outer_vlan_id,
+ sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
+ sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
+ if (sub->vtr_op != L2_VTR_DISABLED)
+ {
+ print (vam->ofp,
+ " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
+ "tag1: %d tag2: %d ]",
+ str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
+ sub->vtr_tag1, sub->vtr_tag2);
+ }
+ }
- /* Wait for a reply, return the good/bad news... */
- W (ret);
- return ret;
+ return 0;
}
static int
-api_sw_interface_set_rx_placement (vat_main_t * vam)
+name_sort_cmp (void *a1, void *a2)
{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_rx_placement_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- int ret;
- u8 is_main = 0;
- u32 queue_id, thread_index;
+ name_sort_t *n1 = a1;
+ name_sort_t *n2 = a2;
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "queue %d", &queue_id))
- ;
- else if (unformat (i, "main"))
- is_main = 1;
- else if (unformat (i, "worker %d", &thread_index))
- ;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
- }
+ return strcmp ((char *) n1->name, (char *) n2->name);
+}
- if (sw_if_index_set == 0)
+static int
+dump_interface_table (vat_main_t * vam)
+{
+ hash_pair_t *p;
+ name_sort_t *nses = 0, *ns;
+
+ if (vam->json_output)
{
- errmsg ("missing interface name or sw_if_index");
+ clib_warning
+ ("JSON output supported only for VPE API calls and dump_stats_table");
return -99;
}
- if (is_main)
- thread_index = 0;
- /* Construct the API message */
- M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->worker_id = ntohl (thread_index);
- mp->queue_id = ntohl (queue_id);
- mp->is_main = is_main;
-
- /* send it... */
- S (mp);
- /* Wait for a reply, return the good/bad news... */
- W (ret);
- return ret;
-}
+ /* *INDENT-OFF* */
+ hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
+ ({
+ vec_add2 (nses, ns, 1);
+ ns->name = (u8 *)(p->key);
+ ns->value = (u32) p->value[0];
+ }));
+ /* *INDENT-ON* */
-static void vl_api_sw_interface_rx_placement_details_t_handler
- (vl_api_sw_interface_rx_placement_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- u32 worker_id = ntohl (mp->worker_id);
+ vec_sort_with_function (nses, name_sort_cmp);
- print (vam->ofp,
- "\n%-11d %-11s %-6d %-5d %-9s",
- ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
- worker_id, ntohl (mp->queue_id),
- (mp->mode ==
- 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
+ print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
+ vec_foreach (ns, nses)
+ {
+ print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
+ }
+ vec_free (nses);
+ return 0;
}
-static void vl_api_sw_interface_rx_placement_details_t_handler_json
- (vl_api_sw_interface_rx_placement_details_t * mp)
+static int
+dump_ip_table (vat_main_t * vam, int is_ipv6)
{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
+ const ip_details_t *det = NULL;
+ const ip_address_details_t *address = NULL;
+ u32 i = ~0;
- if (VAT_JSON_ARRAY != vam->json_tree.type)
+ print (vam->ofp, "%-12s", "sw_if_index");
+
+ vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
+ {
+ i++;
+ if (!det->present)
+ {
+ continue;
+ }
+ print (vam->ofp, "%-12d", i);
+ print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
+ if (!det->addr)
+ {
+ continue;
+ }
+ vec_foreach (address, det->addr)
{
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
+ print (vam->ofp,
+ " %-30U%-13d",
+ is_ipv6 ? format_ip6_address : format_ip4_address,
+ address->ip, address->prefix_length);
}
- node = vat_json_array_add (&vam->json_tree);
+ }
- vat_json_init_object (node);
- vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
- vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
- vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
- vat_json_object_add_uint (node, "mode", mp->mode);
+ return 0;
}
static int
-api_sw_interface_rx_placement_dump (vat_main_t * vam)
+dump_ipv4_table (vat_main_t * vam)
{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_rx_placement_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- int ret;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ if (vam->json_output)
{
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set++;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set++;
- else
- break;
+ clib_warning
+ ("JSON output supported only for VPE API calls and dump_stats_table");
+ return -99;
}
- print (vam->ofp,
- "\n%-11s %-11s %-6s %-5s %-4s",
- "sw_if_index", "main/worker", "thread", "queue", "mode");
-
- /* Dump Interface rx placement */
- M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
-
- if (sw_if_index_set)
- mp->sw_if_index = htonl (sw_if_index);
- else
- mp->sw_if_index = ~0;
-
- S (mp);
+ return dump_ip_table (vam, 0);
+}
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
+static int
+dump_ipv6_table (vat_main_t * vam)
+{
+ if (vam->json_output)
+ {
+ clib_warning
+ ("JSON output supported only for VPE API calls and dump_stats_table");
+ return -99;
+ }
- W (ret);
- return ret;
+ return dump_ip_table (vam, 1);
}
+/*
+ * Pass CLI buffers directly in the CLI_INBAND API message,
+ * instead of an additional shared memory area.
+ */
static int
-api_sw_interface_clear_stats (vat_main_t * vam)
+exec_inband (vat_main_t * vam)
{
+ vl_api_cli_inband_t *mp;
unformat_input_t *i = vam->input;
- vl_api_sw_interface_clear_stats_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
int ret;
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ if (vec_len (i->buffer) == 0)
+ return -1;
+
+ if (vam->exec_mode == 0 && unformat (i, "mode"))
{
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else
- break;
+ vam->exec_mode = 1;
+ return 0;
+ }
+ if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
+ {
+ vam->exec_mode = 0;
+ return 0;
}
- /* Construct the API message */
- M (SW_INTERFACE_CLEAR_STATS, mp);
-
- if (sw_if_index_set == 1)
- mp->sw_if_index = ntohl (sw_if_index);
- else
- mp->sw_if_index = ~0;
+ /*
+ * In order for the CLI command to work, it
+ * must be a vector ending in \n, not a C-string ending
+ * in \n\0.
+ */
+ M2 (CLI_INBAND, mp, vec_len (vam->input->buffer));
+ vl_api_vec_to_api_string (vam->input->buffer, &mp->cmd);
- /* send it... */
S (mp);
-
- /* Wait for a reply, return the good/bad news... */
W (ret);
+ /* json responses may or may not include a useful reply... */
+ if (vec_len (vam->cmd_reply))
+ print (vam->ofp, "%v", (char *) (vam->cmd_reply));
return ret;
}
+int
+exec (vat_main_t * vam)
+{
+ return exec_inband (vam);
+}
+
static int
-api_sw_interface_add_del_address (vat_main_t * vam)
+api_create_loopback (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_sw_interface_add_del_address_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u8 is_add = 1, del_all = 0;
- u32 address_length = 0;
- u8 v4_address_set = 0;
- u8 v6_address_set = 0;
- ip4_address_t v4address;
- ip6_address_t v6address;
+ vl_api_create_loopback_t *mp;
+ vl_api_create_loopback_instance_t *mp_lbi;
+ u8 mac_address[6];
+ u8 mac_set = 0;
+ u8 is_specified = 0;
+ u32 user_instance = 0;
int ret;
- /* Parse args required to build the message */
+ clib_memset (mac_address, 0, sizeof (mac_address));
+
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "del-all"))
- del_all = 1;
- else if (unformat (i, "del"))
- is_add = 0;
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "%U/%d",
- unformat_ip4_address, &v4address, &address_length))
- v4_address_set = 1;
- else if (unformat (i, "%U/%d",
- unformat_ip6_address, &v6address, &address_length))
- v6_address_set = 1;
+ if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
+ mac_set = 1;
+ if (unformat (i, "instance %d", &user_instance))
+ is_specified = 1;
else
break;
}
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
- if (v4_address_set && v6_address_set)
- {
- errmsg ("both v4 and v6 addresses set");
- return -99;
- }
- if (!v4_address_set && !v6_address_set && !del_all)
- {
- errmsg ("no addresses set");
- return -99;
- }
-
- /* Construct the API message */
- M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
-
- mp->sw_if_index = ntohl (sw_if_index);
- mp->is_add = is_add;
- mp->del_all = del_all;
- if (v6_address_set)
+ if (is_specified)
{
- mp->prefix.address.af = ADDRESS_IP6;
- clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
+ M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
+ mp_lbi->is_specified = is_specified;
+ if (is_specified)
+ mp_lbi->user_instance = htonl (user_instance);
+ if (mac_set)
+ clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
+ S (mp_lbi);
}
else
{
- mp->prefix.address.af = ADDRESS_IP4;
- clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
+ /* Construct the API message */
+ M (CREATE_LOOPBACK, mp);
+ if (mac_set)
+ clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
+ S (mp);
}
- mp->prefix.len = address_length;
-
- /* send it... */
- S (mp);
- /* Wait for a reply, return good/bad news */
W (ret);
return ret;
}
static int
-api_sw_interface_set_mpls_enable (vat_main_t * vam)
+api_delete_loopback (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_mpls_enable_t *mp;
- u32 sw_if_index;
- u8 sw_if_index_set = 0;
- u8 enable = 1;
+ vl_api_delete_loopback_t *mp;
+ u32 sw_if_index = ~0;
int ret;
- /* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "disable"))
- enable = 0;
- else if (unformat (i, "dis"))
- enable = 0;
+ if (unformat (i, "sw_if_index %d", &sw_if_index))
+ ;
else
break;
}
- if (sw_if_index_set == 0)
+ if (sw_if_index == ~0)
{
- errmsg ("missing interface name or sw_if_index");
+ errmsg ("missing sw_if_index");
return -99;
}
/* Construct the API message */
- M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
-
+ M (DELETE_LOOPBACK, mp);
mp->sw_if_index = ntohl (sw_if_index);
- mp->enable = enable;
- /* send it... */
S (mp);
-
- /* Wait for a reply... */
W (ret);
return ret;
}
static int
-api_sw_interface_set_table (vat_main_t * vam)
+api_want_interface_events (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_table_t *mp;
- u32 sw_if_index, vrf_id = 0;
- u8 sw_if_index_set = 0;
- u8 is_ipv6 = 0;
+ vl_api_want_interface_events_t *mp;
+ int enable = -1;
int ret;
- /* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "vrf %d", &vrf_id))
- ;
- else if (unformat (i, "ipv6"))
- is_ipv6 = 1;
+ if (unformat (i, "enable"))
+ enable = 1;
+ else if (unformat (i, "disable"))
+ enable = 0;
else
break;
}
- if (sw_if_index_set == 0)
+ if (enable == -1)
{
- errmsg ("missing interface name or sw_if_index");
+ errmsg ("missing enable|disable");
return -99;
}
- /* Construct the API message */
- M (SW_INTERFACE_SET_TABLE, mp);
+ M (WANT_INTERFACE_EVENTS, mp);
+ mp->enable_disable = enable;
- mp->sw_if_index = ntohl (sw_if_index);
- mp->is_ipv6 = is_ipv6;
- mp->vrf_id = ntohl (vrf_id);
+ vam->interface_event_display = enable;
- /* send it... */
S (mp);
-
- /* Wait for a reply... */
W (ret);
return ret;
}
-static void vl_api_sw_interface_get_table_reply_t_handler
- (vl_api_sw_interface_get_table_reply_t * mp)
+
+/* Note: non-static, called once to set up the initial intfc table */
+int
+api_sw_interface_dump (vat_main_t * vam)
{
- vat_main_t *vam = &vat_main;
+ vl_api_sw_interface_dump_t *mp;
+ vl_api_control_ping_t *mp_ping;
+ hash_pair_t *p;
+ name_sort_t *nses = 0, *ns;
+ sw_interface_subif_t *sub = NULL;
+ int ret;
- print (vam->ofp, "%d", ntohl (mp->vrf_id));
+ /* Toss the old name table */
+ /* *INDENT-OFF* */
+ hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
+ ({
+ vec_add2 (nses, ns, 1);
+ ns->name = (u8 *)(p->key);
+ ns->value = (u32) p->value[0];
+ }));
+ /* *INDENT-ON* */
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
+ hash_free (vam->sw_if_index_by_interface_name);
-}
+ vec_foreach (ns, nses) vec_free (ns->name);
-static void vl_api_sw_interface_get_table_reply_t_handler_json
- (vl_api_sw_interface_get_table_reply_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t node;
+ vec_free (nses);
+
+ vec_foreach (sub, vam->sw_if_subif_table)
+ {
+ vec_free (sub->interface_name);
+ }
+ vec_free (vam->sw_if_subif_table);
- vat_json_init_object (&node);
- vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
- vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
+ /* recreate the interface name hash table */
+ vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
- vat_json_print (vam->ofp, &node);
- vat_json_free (&node);
+ /*
+ * Ask for all interface names. Otherwise, the epic catalog of
+ * name filters becomes ridiculously long, and vat ends up needing
+ * to be taught about new interface types.
+ */
+ M (SW_INTERFACE_DUMP, mp);
+ S (mp);
- vam->retval = ntohl (mp->retval);
- vam->result_ready = 1;
+ /* Use a control ping for synchronization */
+ MPING (CONTROL_PING, mp_ping);
+ S (mp_ping);
+
+ W (ret);
+ return ret;
}
static int
-api_sw_interface_get_table (vat_main_t * vam)
+api_sw_interface_set_flags (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_sw_interface_get_table_t *mp;
+ vl_api_sw_interface_set_flags_t *mp;
u32 sw_if_index;
u8 sw_if_index_set = 0;
- u8 is_ipv6 = 0;
+ u8 admin_up = 0;
int ret;
+ /* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
+ if (unformat (i, "admin-up"))
+ admin_up = 1;
+ else if (unformat (i, "admin-down"))
+ admin_up = 0;
+ else
+ if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
sw_if_index_set = 1;
else if (unformat (i, "sw_if_index %d", &sw_if_index))
sw_if_index_set = 1;
- else if (unformat (i, "ipv6"))
- is_ipv6 = 1;
else
break;
}
return -99;
}
- M (SW_INTERFACE_GET_TABLE, mp);
- mp->sw_if_index = htonl (sw_if_index);
- mp->is_ipv6 = is_ipv6;
+ /* Construct the API message */
+ M (SW_INTERFACE_SET_FLAGS, mp);
+ mp->sw_if_index = ntohl (sw_if_index);
+ mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
+ /* send it... */
S (mp);
+
+ /* Wait for a reply, return the good/bad news... */
W (ret);
return ret;
}
static int
-api_sw_interface_set_vpath (vat_main_t * vam)
+api_sw_interface_set_rx_mode (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_vpath_t *mp;
- u32 sw_if_index = 0;
+ vl_api_sw_interface_set_rx_mode_t *mp;
+ u32 sw_if_index;
u8 sw_if_index_set = 0;
- u8 is_enable = 0;
int ret;
+ u8 queue_id_valid = 0;
+ u32 queue_id;
+ vnet_hw_if_rx_mode mode = VNET_HW_IF_RX_MODE_UNKNOWN;
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
+ if (unformat (i, "queue %d", &queue_id))
+ queue_id_valid = 1;
+ else if (unformat (i, "polling"))
+ mode = VNET_HW_IF_RX_MODE_POLLING;
+ else if (unformat (i, "interrupt"))
+ mode = VNET_HW_IF_RX_MODE_INTERRUPT;
+ else if (unformat (i, "adaptive"))
+ mode = VNET_HW_IF_RX_MODE_ADAPTIVE;
+ else
+ if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
sw_if_index_set = 1;
else if (unformat (i, "sw_if_index %d", &sw_if_index))
sw_if_index_set = 1;
- else if (unformat (i, "enable"))
- is_enable = 1;
- else if (unformat (i, "disable"))
- is_enable = 0;
else
break;
}
errmsg ("missing interface name or sw_if_index");
return -99;
}
+ if (mode == VNET_HW_IF_RX_MODE_UNKNOWN)
+ {
+ errmsg ("missing rx-mode");
+ return -99;
+ }
/* Construct the API message */
- M (SW_INTERFACE_SET_VPATH, mp);
-
+ M (SW_INTERFACE_SET_RX_MODE, mp);
mp->sw_if_index = ntohl (sw_if_index);
- mp->enable = is_enable;
+ mp->mode = (vl_api_rx_mode_t) mode;
+ mp->queue_id_valid = queue_id_valid;
+ mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
/* send it... */
S (mp);
- /* Wait for a reply... */
+ /* Wait for a reply, return the good/bad news... */
W (ret);
return ret;
}
static int
-api_sw_interface_set_l2_xconnect (vat_main_t * vam)
+api_sw_interface_set_rx_placement (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_l2_xconnect_t *mp;
- u32 rx_sw_if_index;
- u8 rx_sw_if_index_set = 0;
- u32 tx_sw_if_index;
- u8 tx_sw_if_index_set = 0;
- u8 enable = 1;
+ vl_api_sw_interface_set_rx_placement_t *mp;
+ u32 sw_if_index;
+ u8 sw_if_index_set = 0;
int ret;
+ u8 is_main = 0;
+ u32 queue_id, thread_index;
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
- rx_sw_if_index_set = 1;
- else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
- tx_sw_if_index_set = 1;
- else if (unformat (i, "rx"))
- {
- if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam,
- &rx_sw_if_index))
- rx_sw_if_index_set = 1;
- }
- else
- break;
- }
- else if (unformat (i, "tx"))
- {
- if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam,
- &tx_sw_if_index))
- tx_sw_if_index_set = 1;
- }
- else
- break;
- }
- else if (unformat (i, "enable"))
- enable = 1;
- else if (unformat (i, "disable"))
- enable = 0;
+ if (unformat (i, "queue %d", &queue_id))
+ ;
+ else if (unformat (i, "main"))
+ is_main = 1;
+ else if (unformat (i, "worker %d", &thread_index))
+ ;
+ else
+ if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "sw_if_index %d", &sw_if_index))
+ sw_if_index_set = 1;
else
break;
}
- if (rx_sw_if_index_set == 0)
- {
- errmsg ("missing rx interface name or rx_sw_if_index");
- return -99;
- }
-
- if (enable && (tx_sw_if_index_set == 0))
+ if (sw_if_index_set == 0)
{
- errmsg ("missing tx interface name or tx_sw_if_index");
+ errmsg ("missing interface name or sw_if_index");
return -99;
}
- M (SW_INTERFACE_SET_L2_XCONNECT, mp);
-
- mp->rx_sw_if_index = ntohl (rx_sw_if_index);
- mp->tx_sw_if_index = ntohl (tx_sw_if_index);
- mp->enable = enable;
+ if (is_main)
+ thread_index = 0;
+ /* Construct the API message */
+ M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
+ mp->sw_if_index = ntohl (sw_if_index);
+ mp->worker_id = ntohl (thread_index);
+ mp->queue_id = ntohl (queue_id);
+ mp->is_main = is_main;
+ /* send it... */
S (mp);
+ /* Wait for a reply, return the good/bad news... */
W (ret);
return ret;
}
-static int
-api_sw_interface_set_l2_bridge (vat_main_t * vam)
+static void vl_api_sw_interface_rx_placement_details_t_handler
+ (vl_api_sw_interface_rx_placement_details_t * mp)
{
- unformat_input_t *i = vam->input;
- vl_api_sw_interface_set_l2_bridge_t *mp;
- vl_api_l2_port_type_t port_type;
- u32 rx_sw_if_index;
- u8 rx_sw_if_index_set = 0;
- u32 bd_id;
- u8 bd_id_set = 0;
- u32 shg = 0;
- u8 enable = 1;
- int ret;
-
- port_type = L2_API_PORT_TYPE_NORMAL;
+ vat_main_t *vam = &vat_main;
+ u32 worker_id = ntohl (mp->worker_id);
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
- rx_sw_if_index_set = 1;
- else if (unformat (i, "bd_id %d", &bd_id))
- bd_id_set = 1;
- else
- if (unformat
- (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
- rx_sw_if_index_set = 1;
- else if (unformat (i, "shg %d", &shg))
- ;
- else if (unformat (i, "bvi"))
- port_type = L2_API_PORT_TYPE_BVI;
- else if (unformat (i, "uu-fwd"))
- port_type = L2_API_PORT_TYPE_UU_FWD;
- else if (unformat (i, "enable"))
- enable = 1;
- else if (unformat (i, "disable"))
- enable = 0;
- else
- break;
- }
+ print (vam->ofp,
+ "\n%-11d %-11s %-6d %-5d %-9s",
+ ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
+ worker_id, ntohl (mp->queue_id),
+ (mp->mode ==
+ 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
+}
- if (rx_sw_if_index_set == 0)
- {
- errmsg ("missing rx interface name or sw_if_index");
- return -99;
- }
+static void vl_api_sw_interface_rx_placement_details_t_handler_json
+ (vl_api_sw_interface_rx_placement_details_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ vat_json_node_t *node = NULL;
- if (enable && (bd_id_set == 0))
+ if (VAT_JSON_ARRAY != vam->json_tree.type)
{
- errmsg ("missing bridge domain");
- return -99;
+ ASSERT (VAT_JSON_NONE == vam->json_tree.type);
+ vat_json_init_array (&vam->json_tree);
}
+ node = vat_json_array_add (&vam->json_tree);
- M (SW_INTERFACE_SET_L2_BRIDGE, mp);
-
- mp->rx_sw_if_index = ntohl (rx_sw_if_index);
- mp->bd_id = ntohl (bd_id);
- mp->shg = (u8) shg;
- mp->port_type = ntohl (port_type);
- mp->enable = enable;
-
- S (mp);
- W (ret);
- return ret;
+ vat_json_init_object (node);
+ vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
+ vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
+ vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
+ vat_json_object_add_uint (node, "mode", mp->mode);
}
static int
-api_bridge_domain_dump (vat_main_t * vam)
+api_sw_interface_rx_placement_dump (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_bridge_domain_dump_t *mp;
+ vl_api_sw_interface_rx_placement_dump_t *mp;
vl_api_control_ping_t *mp_ping;
- u32 bd_id = ~0;
int ret;
+ u32 sw_if_index;
+ u8 sw_if_index_set = 0;
- /* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "bd_id %d", &bd_id))
- ;
+ if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
+ sw_if_index_set++;
+ else if (unformat (i, "sw_if_index %d", &sw_if_index))
+ sw_if_index_set++;
else
break;
}
- M (BRIDGE_DOMAIN_DUMP, mp);
- mp->bd_id = ntohl (bd_id);
+ print (vam->ofp,
+ "\n%-11s %-11s %-6s %-5s %-4s",
+ "sw_if_index", "main/worker", "thread", "queue", "mode");
+
+ /* Dump Interface rx placement */
+ M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
+
+ if (sw_if_index_set)
+ mp->sw_if_index = htonl (sw_if_index);
+ else
+ mp->sw_if_index = ~0;
+
S (mp);
/* Use a control ping for synchronization */
}
static int
-api_bridge_domain_add_del (vat_main_t * vam)
+api_sw_interface_clear_stats (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_bridge_domain_add_del_t *mp;
- u32 bd_id = ~0;
- u8 is_add = 1;
- u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
- u8 *bd_tag = NULL;
- u32 mac_age = 0;
+ vl_api_sw_interface_clear_stats_t *mp;
+ u32 sw_if_index;
+ u8 sw_if_index_set = 0;
int ret;
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "bd_id %d", &bd_id))
- ;
- else if (unformat (i, "flood %d", &flood))
- ;
- else if (unformat (i, "uu-flood %d", &uu_flood))
- ;
- else if (unformat (i, "forward %d", &forward))
- ;
- else if (unformat (i, "learn %d", &learn))
- ;
- else if (unformat (i, "arp-term %d", &arp_term))
- ;
- else if (unformat (i, "mac-age %d", &mac_age))
- ;
- else if (unformat (i, "bd-tag %s", &bd_tag))
- ;
- else if (unformat (i, "del"))
- {
- is_add = 0;
- flood = uu_flood = forward = learn = 0;
- }
+ if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "sw_if_index %d", &sw_if_index))
+ sw_if_index_set = 1;
else
break;
}
- if (bd_id == ~0)
- {
- errmsg ("missing bridge domain");
- ret = -99;
- goto done;
- }
-
- if (mac_age > 255)
- {
- errmsg ("mac age must be less than 256 ");
- ret = -99;
- goto done;
- }
-
- if ((bd_tag) && (vec_len (bd_tag) > 63))
- {
- errmsg ("bd-tag cannot be longer than 63");
- ret = -99;
- goto done;
- }
+ /* Construct the API message */
+ M (SW_INTERFACE_CLEAR_STATS, mp);
- M (BRIDGE_DOMAIN_ADD_DEL, mp);
+ if (sw_if_index_set == 1)
+ mp->sw_if_index = ntohl (sw_if_index);
+ else
+ mp->sw_if_index = ~0;
- mp->bd_id = ntohl (bd_id);
- mp->flood = flood;
- mp->uu_flood = uu_flood;
- mp->forward = forward;
- mp->learn = learn;
- mp->arp_term = arp_term;
- mp->is_add = is_add;
- mp->mac_age = (u8) mac_age;
- if (bd_tag)
- {
- clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
- mp->bd_tag[vec_len (bd_tag)] = 0;
- }
+ /* send it... */
S (mp);
- W (ret);
-done:
- vec_free (bd_tag);
+ /* Wait for a reply, return the good/bad news... */
+ W (ret);
return ret;
}
static int
-api_l2fib_flush_bd (vat_main_t * vam)
+api_sw_interface_add_del_address (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_l2fib_flush_bd_t *mp;
- u32 bd_id = ~0;
+ vl_api_sw_interface_add_del_address_t *mp;
+ u32 sw_if_index;
+ u8 sw_if_index_set = 0;
+ u8 is_add = 1, del_all = 0;
+ u32 address_length = 0;
+ u8 v4_address_set = 0;
+ u8 v6_address_set = 0;
+ ip4_address_t v4address;
+ ip6_address_t v6address;
int ret;
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "bd_id %d", &bd_id));
+ if (unformat (i, "del-all"))
+ del_all = 1;
+ else if (unformat (i, "del"))
+ is_add = 0;
+ else
+ if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "sw_if_index %d", &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "%U/%d",
+ unformat_ip4_address, &v4address, &address_length))
+ v4_address_set = 1;
+ else if (unformat (i, "%U/%d",
+ unformat_ip6_address, &v6address, &address_length))
+ v6_address_set = 1;
else
break;
}
- if (bd_id == ~0)
+ if (sw_if_index_set == 0)
{
- errmsg ("missing bridge domain");
+ errmsg ("missing interface name or sw_if_index");
+ return -99;
+ }
+ if (v4_address_set && v6_address_set)
+ {
+ errmsg ("both v4 and v6 addresses set");
+ return -99;
+ }
+ if (!v4_address_set && !v6_address_set && !del_all)
+ {
+ errmsg ("no addresses set");
return -99;
}
- M (L2FIB_FLUSH_BD, mp);
+ /* Construct the API message */
+ M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
- mp->bd_id = htonl (bd_id);
+ mp->sw_if_index = ntohl (sw_if_index);
+ mp->is_add = is_add;
+ mp->del_all = del_all;
+ if (v6_address_set)
+ {
+ mp->prefix.address.af = ADDRESS_IP6;
+ clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
+ }
+ else
+ {
+ mp->prefix.address.af = ADDRESS_IP4;
+ clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
+ }
+ mp->prefix.len = address_length;
+ /* send it... */
S (mp);
+
+ /* Wait for a reply, return good/bad news */
W (ret);
return ret;
}
static int
-api_l2fib_flush_int (vat_main_t * vam)
+api_sw_interface_set_mpls_enable (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_l2fib_flush_int_t *mp;
- u32 sw_if_index = ~0;
+ vl_api_sw_interface_set_mpls_enable_t *mp;
+ u32 sw_if_index;
+ u8 sw_if_index_set = 0;
+ u8 enable = 1;
int ret;
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "sw_if_index %d", &sw_if_index));
- else
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
+ if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "sw_if_index %d", &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "disable"))
+ enable = 0;
+ else if (unformat (i, "dis"))
+ enable = 0;
else
break;
}
- if (sw_if_index == ~0)
+ if (sw_if_index_set == 0)
{
errmsg ("missing interface name or sw_if_index");
return -99;
}
- M (L2FIB_FLUSH_INT, mp);
+ /* Construct the API message */
+ M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
mp->sw_if_index = ntohl (sw_if_index);
+ mp->enable = enable;
+ /* send it... */
S (mp);
- W (ret);
- return ret;
-}
-
-static int
-api_l2fib_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_l2fib_add_del_t *mp;
- f64 timeout;
- u8 mac[6] = { 0 };
- u8 mac_set = 0;
- u32 bd_id;
- u8 bd_id_set = 0;
- u32 sw_if_index = 0;
- u8 sw_if_index_set = 0;
- u8 is_add = 1;
- u8 static_mac = 0;
- u8 filter_mac = 0;
- u8 bvi_mac = 0;
- int count = 1;
- f64 before = 0;
- int j;
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "mac %U", unformat_ethernet_address, mac))
- mac_set = 1;
- else if (unformat (i, "bd_id %d", &bd_id))
- bd_id_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if"))
- {
- if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat
- (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- }
- else
- break;
- }
- else if (unformat (i, "static"))
- static_mac = 1;
- else if (unformat (i, "filter"))
- {
- filter_mac = 1;
- static_mac = 1;
- }
- else if (unformat (i, "bvi"))
- {
- bvi_mac = 1;
- static_mac = 1;
- }
- else if (unformat (i, "del"))
- is_add = 0;
- else if (unformat (i, "count %d", &count))
- ;
- else
- break;
- }
+ /* Wait for a reply... */
+ W (ret);
+ return ret;
+}
- if (mac_set == 0)
- {
- errmsg ("missing mac address");
- return -99;
- }
+static int
+api_sw_interface_set_table (vat_main_t * vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_sw_interface_set_table_t *mp;
+ u32 sw_if_index, vrf_id = 0;
+ u8 sw_if_index_set = 0;
+ u8 is_ipv6 = 0;
+ int ret;
- if (bd_id_set == 0)
+ /* Parse args required to build the message */
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- errmsg ("missing bridge domain");
- return -99;
+ if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "sw_if_index %d", &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "vrf %d", &vrf_id))
+ ;
+ else if (unformat (i, "ipv6"))
+ is_ipv6 = 1;
+ else
+ break;
}
- if (is_add && sw_if_index_set == 0 && filter_mac == 0)
+ if (sw_if_index_set == 0)
{
errmsg ("missing interface name or sw_if_index");
return -99;
}
- if (count > 1)
- {
- /* Turn on async mode */
- vam->async_mode = 1;
- vam->async_errors = 0;
- before = vat_time_now (vam);
- }
+ /* Construct the API message */
+ M (SW_INTERFACE_SET_TABLE, mp);
- for (j = 0; j < count; j++)
- {
- M (L2FIB_ADD_DEL, mp);
+ mp->sw_if_index = ntohl (sw_if_index);
+ mp->is_ipv6 = is_ipv6;
+ mp->vrf_id = ntohl (vrf_id);
- clib_memcpy (mp->mac, mac, 6);
- mp->bd_id = ntohl (bd_id);
- mp->is_add = is_add;
- mp->sw_if_index = ntohl (sw_if_index);
+ /* send it... */
+ S (mp);
- if (is_add)
- {
- mp->static_mac = static_mac;
- mp->filter_mac = filter_mac;
- mp->bvi_mac = bvi_mac;
- }
- increment_mac_address (mac);
- /* send it... */
- S (mp);
- }
+ /* Wait for a reply... */
+ W (ret);
+ return ret;
+}
- if (count > 1)
- {
- vl_api_control_ping_t *mp_ping;
- f64 after;
+static void vl_api_sw_interface_get_table_reply_t_handler
+ (vl_api_sw_interface_get_table_reply_t * mp)
+{
+ vat_main_t *vam = &vat_main;
- /* Shut off async mode */
- vam->async_mode = 0;
+ print (vam->ofp, "%d", ntohl (mp->vrf_id));
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
+ vam->retval = ntohl (mp->retval);
+ vam->result_ready = 1;
- timeout = vat_time_now (vam) + 1.0;
- while (vat_time_now (vam) < timeout)
- if (vam->result_ready == 1)
- goto out;
- vam->retval = -99;
+}
- out:
- if (vam->retval == -99)
- errmsg ("timeout");
+static void vl_api_sw_interface_get_table_reply_t_handler_json
+ (vl_api_sw_interface_get_table_reply_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ vat_json_node_t node;
- if (vam->async_errors > 0)
- {
- errmsg ("%d asynchronous errors", vam->async_errors);
- vam->retval = -98;
- }
- vam->async_errors = 0;
- after = vat_time_now (vam);
+ vat_json_init_object (&node);
+ vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
+ vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
- print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
- count, after - before, count / (after - before));
- }
- else
- {
- int ret;
+ vat_json_print (vam->ofp, &node);
+ vat_json_free (&node);
- /* Wait for a reply... */
- W (ret);
- return ret;
- }
- /* Return the good/bad news */
- return (vam->retval);
+ vam->retval = ntohl (mp->retval);
+ vam->result_ready = 1;
}
static int
-api_bridge_domain_set_mac_age (vat_main_t * vam)
+api_sw_interface_get_table (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_bridge_domain_set_mac_age_t *mp;
- u32 bd_id = ~0;
- u32 mac_age = 0;
+ vl_api_sw_interface_get_table_t *mp;
+ u32 sw_if_index;
+ u8 sw_if_index_set = 0;
+ u8 is_ipv6 = 0;
int ret;
- /* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "bd_id %d", &bd_id));
- else if (unformat (i, "mac-age %d", &mac_age));
+ if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "sw_if_index %d", &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "ipv6"))
+ is_ipv6 = 1;
else
break;
}
- if (bd_id == ~0)
+ if (sw_if_index_set == 0)
{
- errmsg ("missing bridge domain");
+ errmsg ("missing interface name or sw_if_index");
return -99;
}
- if (mac_age > 255)
+ M (SW_INTERFACE_GET_TABLE, mp);
+ mp->sw_if_index = htonl (sw_if_index);
+ mp->is_ipv6 = is_ipv6;
+
+ S (mp);
+ W (ret);
+ return ret;
+}
+
+static int
+api_sw_interface_set_vpath (vat_main_t * vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_sw_interface_set_vpath_t *mp;
+ u32 sw_if_index = 0;
+ u8 sw_if_index_set = 0;
+ u8 is_enable = 0;
+ int ret;
+
+ /* Parse args required to build the message */
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- errmsg ("mac age must be less than 256 ");
+ if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "sw_if_index %d", &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "enable"))
+ is_enable = 1;
+ else if (unformat (i, "disable"))
+ is_enable = 0;
+ else
+ break;
+ }
+
+ if (sw_if_index_set == 0)
+ {
+ errmsg ("missing interface name or sw_if_index");
return -99;
}
- M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
+ /* Construct the API message */
+ M (SW_INTERFACE_SET_VPATH, mp);
- mp->bd_id = htonl (bd_id);
- mp->mac_age = (u8) mac_age;
+ mp->sw_if_index = ntohl (sw_if_index);
+ mp->enable = is_enable;
+ /* send it... */
S (mp);
+
+ /* Wait for a reply... */
W (ret);
return ret;
}
static int
-api_l2_flags (vat_main_t * vam)
+api_sw_interface_set_l2_xconnect (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_l2_flags_t *mp;
- u32 sw_if_index;
- u32 flags = 0;
- u8 sw_if_index_set = 0;
- u8 is_set = 0;
+ vl_api_sw_interface_set_l2_xconnect_t *mp;
+ u32 rx_sw_if_index;
+ u8 rx_sw_if_index_set = 0;
+ u32 tx_sw_if_index;
+ u8 tx_sw_if_index_set = 0;
+ u8 enable = 1;
int ret;
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if"))
+ if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
+ rx_sw_if_index_set = 1;
+ else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
+ tx_sw_if_index_set = 1;
+ else if (unformat (i, "rx"))
{
if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat
- (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
+ if (unformat (i, "%U", api_unformat_sw_if_index, vam,
+ &rx_sw_if_index))
+ rx_sw_if_index_set = 1;
}
else
break;
}
- else if (unformat (i, "learn"))
- flags |= L2_LEARN;
- else if (unformat (i, "forward"))
- flags |= L2_FWD;
- else if (unformat (i, "flood"))
- flags |= L2_FLOOD;
- else if (unformat (i, "uu-flood"))
- flags |= L2_UU_FLOOD;
- else if (unformat (i, "arp-term"))
- flags |= L2_ARP_TERM;
- else if (unformat (i, "off"))
- is_set = 0;
+ else if (unformat (i, "tx"))
+ {
+ if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "%U", api_unformat_sw_if_index, vam,
+ &tx_sw_if_index))
+ tx_sw_if_index_set = 1;
+ }
+ else
+ break;
+ }
+ else if (unformat (i, "enable"))
+ enable = 1;
else if (unformat (i, "disable"))
- is_set = 0;
+ enable = 0;
else
break;
}
- if (sw_if_index_set == 0)
+ if (rx_sw_if_index_set == 0)
+ {
+ errmsg ("missing rx interface name or rx_sw_if_index");
+ return -99;
+ }
+
+ if (enable && (tx_sw_if_index_set == 0))
{
- errmsg ("missing interface name or sw_if_index");
+ errmsg ("missing tx interface name or tx_sw_if_index");
return -99;
}
- M (L2_FLAGS, mp);
+ M (SW_INTERFACE_SET_L2_XCONNECT, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->feature_bitmap = ntohl (flags);
- mp->is_set = is_set;
+ mp->rx_sw_if_index = ntohl (rx_sw_if_index);
+ mp->tx_sw_if_index = ntohl (tx_sw_if_index);
+ mp->enable = enable;
S (mp);
W (ret);
}
static int
-api_bridge_flags (vat_main_t * vam)
+api_sw_interface_set_l2_bridge (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_bridge_flags_t *mp;
+ vl_api_sw_interface_set_l2_bridge_t *mp;
+ vl_api_l2_port_type_t port_type;
+ u32 rx_sw_if_index;
+ u8 rx_sw_if_index_set = 0;
u32 bd_id;
u8 bd_id_set = 0;
- u8 is_set = 1;
- bd_flags_t flags = 0;
+ u32 shg = 0;
+ u8 enable = 1;
int ret;
+ port_type = L2_API_PORT_TYPE_NORMAL;
+
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "bd_id %d", &bd_id))
+ if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
+ rx_sw_if_index_set = 1;
+ else if (unformat (i, "bd_id %d", &bd_id))
bd_id_set = 1;
- else if (unformat (i, "learn"))
- flags |= BRIDGE_API_FLAG_LEARN;
- else if (unformat (i, "forward"))
- flags |= BRIDGE_API_FLAG_FWD;
- else if (unformat (i, "flood"))
- flags |= BRIDGE_API_FLAG_FLOOD;
- else if (unformat (i, "uu-flood"))
- flags |= BRIDGE_API_FLAG_UU_FLOOD;
- else if (unformat (i, "arp-term"))
- flags |= BRIDGE_API_FLAG_ARP_TERM;
- else if (unformat (i, "off"))
- is_set = 0;
+ else
+ if (unformat
+ (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
+ rx_sw_if_index_set = 1;
+ else if (unformat (i, "shg %d", &shg))
+ ;
+ else if (unformat (i, "bvi"))
+ port_type = L2_API_PORT_TYPE_BVI;
+ else if (unformat (i, "uu-fwd"))
+ port_type = L2_API_PORT_TYPE_UU_FWD;
+ else if (unformat (i, "enable"))
+ enable = 1;
else if (unformat (i, "disable"))
- is_set = 0;
+ enable = 0;
else
break;
}
- if (bd_id_set == 0)
+ if (rx_sw_if_index_set == 0)
+ {
+ errmsg ("missing rx interface name or sw_if_index");
+ return -99;
+ }
+
+ if (enable && (bd_id_set == 0))
{
errmsg ("missing bridge domain");
return -99;
}
- M (BRIDGE_FLAGS, mp);
+ M (SW_INTERFACE_SET_L2_BRIDGE, mp);
+ mp->rx_sw_if_index = ntohl (rx_sw_if_index);
mp->bd_id = ntohl (bd_id);
- mp->flags = ntohl (flags);
- mp->is_set = is_set;
+ mp->shg = (u8) shg;
+ mp->port_type = ntohl (port_type);
+ mp->enable = enable;
S (mp);
W (ret);
}
static int
-api_bd_ip_mac_add_del (vat_main_t * vam)
+api_bridge_domain_dump (vat_main_t * vam)
{
- vl_api_address_t ip = VL_API_ZERO_ADDRESS;
- vl_api_mac_address_t mac = { 0 };
unformat_input_t *i = vam->input;
- vl_api_bd_ip_mac_add_del_t *mp;
- u32 bd_id;
- u8 is_add = 1;
- u8 bd_id_set = 0;
- u8 ip_set = 0;
- u8 mac_set = 0;
+ vl_api_bridge_domain_dump_t *mp;
+ vl_api_control_ping_t *mp_ping;
+ u32 bd_id = ~0;
int ret;
+ /* Parse args required to build the message */
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "bd_id %d", &bd_id))
+ ;
+ else
+ break;
+ }
+
+ M (BRIDGE_DOMAIN_DUMP, mp);
+ mp->bd_id = ntohl (bd_id);
+ S (mp);
+
+ /* Use a control ping for synchronization */
+ MPING (CONTROL_PING, mp_ping);
+ S (mp_ping);
+
+ W (ret);
+ return ret;
+}
+
+static int
+api_bridge_domain_add_del (vat_main_t * vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_bridge_domain_add_del_t *mp;
+ u32 bd_id = ~0;
+ u8 is_add = 1;
+ u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
+ u8 *bd_tag = NULL;
+ u32 mac_age = 0;
+ int ret;
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
if (unformat (i, "bd_id %d", &bd_id))
+ ;
+ else if (unformat (i, "flood %d", &flood))
+ ;
+ else if (unformat (i, "uu-flood %d", &uu_flood))
+ ;
+ else if (unformat (i, "forward %d", &forward))
+ ;
+ else if (unformat (i, "learn %d", &learn))
+ ;
+ else if (unformat (i, "arp-term %d", &arp_term))
+ ;
+ else if (unformat (i, "mac-age %d", &mac_age))
+ ;
+ else if (unformat (i, "bd-tag %s", &bd_tag))
+ ;
+ else if (unformat (i, "del"))
{
- bd_id_set++;
- }
- else if (unformat (i, "%U", unformat_vl_api_address, &ip))
- {
- ip_set++;
- }
- else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
- {
- mac_set++;
+ is_add = 0;
+ flood = uu_flood = forward = learn = 0;
}
- else if (unformat (i, "del"))
- is_add = 0;
else
break;
}
- if (bd_id_set == 0)
+ if (bd_id == ~0)
{
errmsg ("missing bridge domain");
- return -99;
+ ret = -99;
+ goto done;
}
- else if (ip_set == 0)
+
+ if (mac_age > 255)
{
- errmsg ("missing IP address");
- return -99;
+ errmsg ("mac age must be less than 256 ");
+ ret = -99;
+ goto done;
}
- else if (mac_set == 0)
+
+ if ((bd_tag) && (vec_len (bd_tag) > 63))
{
- errmsg ("missing MAC address");
- return -99;
+ errmsg ("bd-tag cannot be longer than 63");
+ ret = -99;
+ goto done;
}
- M (BD_IP_MAC_ADD_DEL, mp);
+ M (BRIDGE_DOMAIN_ADD_DEL, mp);
- mp->entry.bd_id = ntohl (bd_id);
+ mp->bd_id = ntohl (bd_id);
+ mp->flood = flood;
+ mp->uu_flood = uu_flood;
+ mp->forward = forward;
+ mp->learn = learn;
+ mp->arp_term = arp_term;
mp->is_add = is_add;
-
- clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
- clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
-
+ mp->mac_age = (u8) mac_age;
+ if (bd_tag)
+ {
+ clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
+ mp->bd_tag[vec_len (bd_tag)] = 0;
+ }
S (mp);
W (ret);
+
+done:
+ vec_free (bd_tag);
return ret;
}
static int
-api_bd_ip_mac_flush (vat_main_t * vam)
+api_l2fib_flush_bd (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_bd_ip_mac_flush_t *mp;
- u32 bd_id;
- u8 bd_id_set = 0;
+ vl_api_l2fib_flush_bd_t *mp;
+ u32 bd_id = ~0;
int ret;
+ /* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "bd_id %d", &bd_id))
- {
- bd_id_set++;
- }
+ if (unformat (i, "bd_id %d", &bd_id));
else
break;
}
- if (bd_id_set == 0)
+ if (bd_id == ~0)
{
errmsg ("missing bridge domain");
return -99;
}
- M (BD_IP_MAC_FLUSH, mp);
+ M (L2FIB_FLUSH_BD, mp);
- mp->bd_id = ntohl (bd_id);
+ mp->bd_id = htonl (bd_id);
S (mp);
W (ret);
return ret;
}
-static void vl_api_bd_ip_mac_details_t_handler
- (vl_api_bd_ip_mac_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- print (vam->ofp,
- "\n%-5d %U %U",
- ntohl (mp->entry.bd_id),
- format_vl_api_mac_address, mp->entry.mac,
- format_vl_api_address, &mp->entry.ip);
-}
-
-static void vl_api_bd_ip_mac_details_t_handler_json
- (vl_api_bd_ip_mac_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
- vat_json_object_add_string_copy (node, "mac_address",
- format (0, "%U", format_vl_api_mac_address,
- &mp->entry.mac));
- u8 *ip = 0;
-
- ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
- vat_json_object_add_string_copy (node, "ip_address", ip);
- vec_free (ip);
-}
-
static int
-api_bd_ip_mac_dump (vat_main_t * vam)
+api_l2fib_flush_int (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_bd_ip_mac_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
+ vl_api_l2fib_flush_int_t *mp;
+ u32 sw_if_index = ~0;
int ret;
- u32 bd_id;
- u8 bd_id_set = 0;
+ /* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "bd_id %d", &bd_id))
- {
- bd_id_set++;
- }
+ if (unformat (i, "sw_if_index %d", &sw_if_index));
+ else
+ if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
else
break;
}
- print (vam->ofp,
- "\n%-5s %-7s %-20s %-30s",
- "bd_id", "is_ipv6", "mac_address", "ip_address");
+ if (sw_if_index == ~0)
+ {
+ errmsg ("missing interface name or sw_if_index");
+ return -99;
+ }
- /* Dump Bridge Domain Ip to Mac entries */
- M (BD_IP_MAC_DUMP, mp);
+ M (L2FIB_FLUSH_INT, mp);
- if (bd_id_set)
- mp->bd_id = htonl (bd_id);
- else
- mp->bd_id = ~0;
+ mp->sw_if_index = ntohl (sw_if_index);
S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
W (ret);
return ret;
}
static int
-api_tap_create_v2 (vat_main_t * vam)
+api_l2fib_add_del (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_tap_create_v2_t *mp;
- u8 mac_address[6];
- u8 random_mac = 1;
- u32 id = ~0;
- u32 num_rx_queues = 0;
- u8 *host_if_name = 0;
- u8 host_if_name_set = 0;
- u8 *host_ns = 0;
- u8 host_ns_set = 0;
- u8 host_mac_addr[6];
- u8 host_mac_addr_set = 0;
- u8 *host_bridge = 0;
- u8 host_bridge_set = 0;
- u8 host_ip4_prefix_set = 0;
- u8 host_ip6_prefix_set = 0;
- ip4_address_t host_ip4_addr;
- ip4_address_t host_ip4_gw;
- u8 host_ip4_gw_set = 0;
- u32 host_ip4_prefix_len = 0;
- ip6_address_t host_ip6_addr;
- ip6_address_t host_ip6_gw;
- u8 host_ip6_gw_set = 0;
- u32 host_ip6_prefix_len = 0;
- u32 host_mtu_size = 0;
- u8 host_mtu_set = 0;
- u32 tap_flags = 0;
- int ret;
- u32 rx_ring_sz = 0, tx_ring_sz = 0;
-
- clib_memset (mac_address, 0, sizeof (mac_address));
+ vl_api_l2fib_add_del_t *mp;
+ f64 timeout;
+ u8 mac[6] = { 0 };
+ u8 mac_set = 0;
+ u32 bd_id;
+ u8 bd_id_set = 0;
+ u32 sw_if_index = 0;
+ u8 sw_if_index_set = 0;
+ u8 is_add = 1;
+ u8 static_mac = 0;
+ u8 filter_mac = 0;
+ u8 bvi_mac = 0;
+ int count = 1;
+ f64 before = 0;
+ int j;
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "id %u", &id))
- ;
- else
- if (unformat
- (i, "hw-addr %U", unformat_ethernet_address, mac_address))
- random_mac = 0;
- else if (unformat (i, "host-if-name %s", &host_if_name))
- host_if_name_set = 1;
- else if (unformat (i, "num-rx-queues %u", &num_rx_queues))
- ;
- else if (unformat (i, "host-ns %s", &host_ns))
- host_ns_set = 1;
- else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
- host_mac_addr))
- host_mac_addr_set = 1;
- else if (unformat (i, "host-bridge %s", &host_bridge))
- host_bridge_set = 1;
- else if (unformat (i, "host-ip4-addr %U/%u", unformat_ip4_address,
- &host_ip4_addr, &host_ip4_prefix_len))
- host_ip4_prefix_set = 1;
- else if (unformat (i, "host-ip6-addr %U/%u", unformat_ip6_address,
- &host_ip6_addr, &host_ip6_prefix_len))
- host_ip6_prefix_set = 1;
- else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
- &host_ip4_gw))
- host_ip4_gw_set = 1;
- else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
- &host_ip6_gw))
- host_ip6_gw_set = 1;
- else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
- ;
- else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
+ if (unformat (i, "mac %U", unformat_ethernet_address, mac))
+ mac_set = 1;
+ else if (unformat (i, "bd_id %d", &bd_id))
+ bd_id_set = 1;
+ else if (unformat (i, "sw_if_index %d", &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "sw_if"))
+ {
+ if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat
+ (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
+ sw_if_index_set = 1;
+ }
+ else
+ break;
+ }
+ else if (unformat (i, "static"))
+ static_mac = 1;
+ else if (unformat (i, "filter"))
+ {
+ filter_mac = 1;
+ static_mac = 1;
+ }
+ else if (unformat (i, "bvi"))
+ {
+ bvi_mac = 1;
+ static_mac = 1;
+ }
+ else if (unformat (i, "del"))
+ is_add = 0;
+ else if (unformat (i, "count %d", &count))
;
- else if (unformat (i, "host-mtu-size %u", &host_mtu_size))
- host_mtu_set = 1;
- else if (unformat (i, "no-gso"))
- tap_flags &= ~TAP_API_FLAG_GSO;
- else if (unformat (i, "gso"))
- tap_flags |= TAP_API_FLAG_GSO;
- else if (unformat (i, "csum-offload"))
- tap_flags |= TAP_API_FLAG_CSUM_OFFLOAD;
- else if (unformat (i, "persist"))
- tap_flags |= TAP_API_FLAG_PERSIST;
- else if (unformat (i, "attach"))
- tap_flags |= TAP_API_FLAG_ATTACH;
- else if (unformat (i, "tun"))
- tap_flags |= TAP_API_FLAG_TUN;
- else if (unformat (i, "gro-coalesce"))
- tap_flags |= TAP_API_FLAG_GRO_COALESCE;
- else if (unformat (i, "packed"))
- tap_flags |= TAP_API_FLAG_PACKED;
- else if (unformat (i, "in-order"))
- tap_flags |= TAP_API_FLAG_IN_ORDER;
else
break;
}
- if (vec_len (host_if_name) > 63)
- {
- errmsg ("tap name too long. ");
- return -99;
- }
- if (vec_len (host_ns) > 63)
- {
- errmsg ("host name space too long. ");
- return -99;
- }
- if (vec_len (host_bridge) > 63)
- {
- errmsg ("host bridge name too long. ");
- return -99;
- }
- if (host_ip4_prefix_len > 32)
- {
- errmsg ("host ip4 prefix length not valid. ");
- return -99;
- }
- if (host_ip6_prefix_len > 128)
+ if (mac_set == 0)
{
- errmsg ("host ip6 prefix length not valid. ");
+ errmsg ("missing mac address");
return -99;
}
- if (!is_pow2 (rx_ring_sz))
+
+ if (bd_id_set == 0)
{
- errmsg ("rx ring size must be power of 2. ");
+ errmsg ("missing bridge domain");
return -99;
}
- if (rx_ring_sz > 32768)
+
+ if (is_add && sw_if_index_set == 0 && filter_mac == 0)
{
- errmsg ("rx ring size must be 32768 or lower. ");
+ errmsg ("missing interface name or sw_if_index");
return -99;
}
- if (!is_pow2 (tx_ring_sz))
+
+ if (count > 1)
{
- errmsg ("tx ring size must be power of 2. ");
- return -99;
+ /* Turn on async mode */
+ vam->async_mode = 1;
+ vam->async_errors = 0;
+ before = vat_time_now (vam);
}
- if (tx_ring_sz > 32768)
+
+ for (j = 0; j < count; j++)
{
- errmsg ("tx ring size must be 32768 or lower. ");
- return -99;
+ M (L2FIB_ADD_DEL, mp);
+
+ clib_memcpy (mp->mac, mac, 6);
+ mp->bd_id = ntohl (bd_id);
+ mp->is_add = is_add;
+ mp->sw_if_index = ntohl (sw_if_index);
+
+ if (is_add)
+ {
+ mp->static_mac = static_mac;
+ mp->filter_mac = filter_mac;
+ mp->bvi_mac = bvi_mac;
+ }
+ increment_mac_address (mac);
+ /* send it... */
+ S (mp);
}
- if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
+
+ if (count > 1)
{
- errmsg ("host MTU size must be in between 64 and 65355. ");
- return -99;
- }
+ vl_api_control_ping_t *mp_ping;
+ f64 after;
- /* Construct the API message */
- M (TAP_CREATE_V2, mp);
+ /* Shut off async mode */
+ vam->async_mode = 0;
- mp->id = ntohl (id);
- mp->use_random_mac = random_mac;
- mp->num_rx_queues = (u8) num_rx_queues;
- mp->tx_ring_sz = ntohs (tx_ring_sz);
- mp->rx_ring_sz = ntohs (rx_ring_sz);
- mp->host_mtu_set = host_mtu_set;
- mp->host_mtu_size = ntohl (host_mtu_size);
- mp->host_mac_addr_set = host_mac_addr_set;
- mp->host_ip4_prefix_set = host_ip4_prefix_set;
- mp->host_ip6_prefix_set = host_ip6_prefix_set;
- mp->host_ip4_gw_set = host_ip4_gw_set;
- mp->host_ip6_gw_set = host_ip6_gw_set;
- mp->tap_flags = ntohl (tap_flags);
- mp->host_namespace_set = host_ns_set;
- mp->host_if_name_set = host_if_name_set;
- mp->host_bridge_set = host_bridge_set;
+ MPING (CONTROL_PING, mp_ping);
+ S (mp_ping);
- if (random_mac == 0)
- clib_memcpy (mp->mac_address, mac_address, 6);
- if (host_mac_addr_set)
- clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
- if (host_if_name_set)
- clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
- if (host_ns_set)
- clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
- if (host_bridge_set)
- clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
- if (host_ip4_prefix_set)
- {
- clib_memcpy (mp->host_ip4_prefix.address, &host_ip4_addr, 4);
- mp->host_ip4_prefix.len = (u8) host_ip4_prefix_len;
- }
- if (host_ip6_prefix_set)
- {
- clib_memcpy (mp->host_ip6_prefix.address, &host_ip6_addr, 16);
- mp->host_ip6_prefix.len = (u8) host_ip6_prefix_len;
- }
- if (host_ip4_gw_set)
- clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
- if (host_ip6_gw_set)
- clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
-
- vec_free (host_ns);
- vec_free (host_if_name);
- vec_free (host_bridge);
+ timeout = vat_time_now (vam) + 1.0;
+ while (vat_time_now (vam) < timeout)
+ if (vam->result_ready == 1)
+ goto out;
+ vam->retval = -99;
- /* send it... */
- S (mp);
+ out:
+ if (vam->retval == -99)
+ errmsg ("timeout");
- /* Wait for a reply... */
- W (ret);
- return ret;
+ if (vam->async_errors > 0)
+ {
+ errmsg ("%d asynchronous errors", vam->async_errors);
+ vam->retval = -98;
+ }
+ vam->async_errors = 0;
+ after = vat_time_now (vam);
+
+ print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
+ count, after - before, count / (after - before));
+ }
+ else
+ {
+ int ret;
+
+ /* Wait for a reply... */
+ W (ret);
+ return ret;
+ }
+ /* Return the good/bad news */
+ return (vam->retval);
}
static int
-api_tap_delete_v2 (vat_main_t * vam)
+api_bridge_domain_set_mac_age (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_tap_delete_v2_t *mp;
- u32 sw_if_index = ~0;
- u8 sw_if_index_set = 0;
+ vl_api_bridge_domain_set_mac_age_t *mp;
+ u32 bd_id = ~0;
+ u32 mac_age = 0;
int ret;
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
+ if (unformat (i, "bd_id %d", &bd_id));
+ else if (unformat (i, "mac-age %d", &mac_age));
else
break;
}
- if (sw_if_index_set == 0)
+ if (bd_id == ~0)
{
- errmsg ("missing vpp interface name. ");
+ errmsg ("missing bridge domain");
return -99;
}
- /* Construct the API message */
- M (TAP_DELETE_V2, mp);
+ if (mac_age > 255)
+ {
+ errmsg ("mac age must be less than 256 ");
+ return -99;
+ }
- mp->sw_if_index = ntohl (sw_if_index);
+ M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
- /* send it... */
- S (mp);
+ mp->bd_id = htonl (bd_id);
+ mp->mac_age = (u8) mac_age;
- /* Wait for a reply... */
+ S (mp);
W (ret);
return ret;
}
-uword
-unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
-{
- vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
- u32 x[4];
-
- if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
- return 0;
-
- addr->domain = x[0];
- addr->bus = x[1];
- addr->slot = x[2];
- addr->function = x[3];
-
- return 1;
-}
-
static int
-api_virtio_pci_create_v2 (vat_main_t * vam)
+api_l2_flags (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_virtio_pci_create_v2_t *mp;
- u8 mac_address[6];
- u8 random_mac = 1;
- u32 pci_addr = 0;
- u64 features = (u64) ~ (0ULL);
- u32 virtio_flags = 0;
+ vl_api_l2_flags_t *mp;
+ u32 sw_if_index;
+ u32 flags = 0;
+ u8 sw_if_index_set = 0;
+ u8 is_set = 0;
int ret;
- clib_memset (mac_address, 0, sizeof (mac_address));
-
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
+ if (unformat (i, "sw_if_index %d", &sw_if_index))
+ sw_if_index_set = 1;
+ else if (unformat (i, "sw_if"))
{
- random_mac = 0;
+ if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat
+ (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
+ sw_if_index_set = 1;
+ }
+ else
+ break;
}
- else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
- ;
- else if (unformat (i, "features 0x%llx", &features))
- ;
- else if (unformat (i, "gso-enabled"))
- virtio_flags |= VIRTIO_API_FLAG_GSO;
- else if (unformat (i, "csum-offload-enabled"))
- virtio_flags |= VIRTIO_API_FLAG_CSUM_OFFLOAD;
- else if (unformat (i, "gro-coalesce"))
- virtio_flags |= VIRTIO_API_FLAG_GRO_COALESCE;
- else if (unformat (i, "packed"))
- virtio_flags |= VIRTIO_API_FLAG_PACKED;
- else if (unformat (i, "in-order"))
- virtio_flags |= VIRTIO_API_FLAG_IN_ORDER;
- else if (unformat (i, "buffering"))
- virtio_flags |= VIRTIO_API_FLAG_BUFFERING;
+ else if (unformat (i, "learn"))
+ flags |= L2_LEARN;
+ else if (unformat (i, "forward"))
+ flags |= L2_FWD;
+ else if (unformat (i, "flood"))
+ flags |= L2_FLOOD;
+ else if (unformat (i, "uu-flood"))
+ flags |= L2_UU_FLOOD;
+ else if (unformat (i, "arp-term"))
+ flags |= L2_ARP_TERM;
+ else if (unformat (i, "off"))
+ is_set = 0;
+ else if (unformat (i, "disable"))
+ is_set = 0;
else
break;
}
- if (pci_addr == 0)
+ if (sw_if_index_set == 0)
{
- errmsg ("pci address must be non zero. ");
+ errmsg ("missing interface name or sw_if_index");
return -99;
}
- /* Construct the API message */
- M (VIRTIO_PCI_CREATE_V2, mp);
-
- mp->use_random_mac = random_mac;
-
- mp->pci_addr.domain = htons (((vlib_pci_addr_t) pci_addr).domain);
- mp->pci_addr.bus = ((vlib_pci_addr_t) pci_addr).bus;
- mp->pci_addr.slot = ((vlib_pci_addr_t) pci_addr).slot;
- mp->pci_addr.function = ((vlib_pci_addr_t) pci_addr).function;
-
- mp->features = clib_host_to_net_u64 (features);
- mp->virtio_flags = clib_host_to_net_u32 (virtio_flags);
+ M (L2_FLAGS, mp);
- if (random_mac == 0)
- clib_memcpy (mp->mac_address, mac_address, 6);
+ mp->sw_if_index = ntohl (sw_if_index);
+ mp->feature_bitmap = ntohl (flags);
+ mp->is_set = is_set;
- /* send it... */
S (mp);
-
- /* Wait for a reply... */
W (ret);
return ret;
}
static int
-api_virtio_pci_delete (vat_main_t * vam)
+api_bridge_flags (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_virtio_pci_delete_t *mp;
- u32 sw_if_index = ~0;
- u8 sw_if_index_set = 0;
+ vl_api_bridge_flags_t *mp;
+ u32 bd_id;
+ u8 bd_id_set = 0;
+ u8 is_set = 1;
+ bd_flags_t flags = 0;
int ret;
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
+ if (unformat (i, "bd_id %d", &bd_id))
+ bd_id_set = 1;
+ else if (unformat (i, "learn"))
+ flags |= BRIDGE_API_FLAG_LEARN;
+ else if (unformat (i, "forward"))
+ flags |= BRIDGE_API_FLAG_FWD;
+ else if (unformat (i, "flood"))
+ flags |= BRIDGE_API_FLAG_FLOOD;
+ else if (unformat (i, "uu-flood"))
+ flags |= BRIDGE_API_FLAG_UU_FLOOD;
+ else if (unformat (i, "arp-term"))
+ flags |= BRIDGE_API_FLAG_ARP_TERM;
+ else if (unformat (i, "off"))
+ is_set = 0;
+ else if (unformat (i, "disable"))
+ is_set = 0;
else
break;
}
- if (sw_if_index_set == 0)
+ if (bd_id_set == 0)
{
- errmsg ("missing vpp interface name. ");
+ errmsg ("missing bridge domain");
return -99;
}
- /* Construct the API message */
- M (VIRTIO_PCI_DELETE, mp);
+ M (BRIDGE_FLAGS, mp);
- mp->sw_if_index = htonl (sw_if_index);
+ mp->bd_id = ntohl (bd_id);
+ mp->flags = ntohl (flags);
+ mp->is_set = is_set;
- /* send it... */
S (mp);
-
- /* Wait for a reply... */
W (ret);
return ret;
}
static int
-api_bond_create (vat_main_t * vam)
+api_bd_ip_mac_add_del (vat_main_t * vam)
{
+ vl_api_address_t ip = VL_API_ZERO_ADDRESS;
+ vl_api_mac_address_t mac = { 0 };
unformat_input_t *i = vam->input;
- vl_api_bond_create_t *mp;
- u8 mac_address[6];
- u8 custom_mac = 0;
+ vl_api_bd_ip_mac_add_del_t *mp;
+ u32 bd_id;
+ u8 is_add = 1;
+ u8 bd_id_set = 0;
+ u8 ip_set = 0;
+ u8 mac_set = 0;
int ret;
- u8 mode;
- u8 lb;
- u8 mode_is_set = 0;
- u32 id = ~0;
- u8 numa_only = 0;
- clib_memset (mac_address, 0, sizeof (mac_address));
- lb = BOND_LB_L2;
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "mode %U", unformat_bond_mode, &mode))
- mode_is_set = 1;
- else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
- && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
- ;
- else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
- mac_address))
- custom_mac = 1;
- else if (unformat (i, "numa-only"))
- numa_only = 1;
- else if (unformat (i, "id %u", &id))
- ;
+ if (unformat (i, "bd_id %d", &bd_id))
+ {
+ bd_id_set++;
+ }
+ else if (unformat (i, "%U", unformat_vl_api_address, &ip))
+ {
+ ip_set++;
+ }
+ else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
+ {
+ mac_set++;
+ }
+ else if (unformat (i, "del"))
+ is_add = 0;
else
break;
}
- if (mode_is_set == 0)
+ if (bd_id_set == 0)
+ {
+ errmsg ("missing bridge domain");
+ return -99;
+ }
+ else if (ip_set == 0)
{
- errmsg ("Missing bond mode. ");
+ errmsg ("missing IP address");
+ return -99;
+ }
+ else if (mac_set == 0)
+ {
+ errmsg ("missing MAC address");
return -99;
}
- /* Construct the API message */
- M (BOND_CREATE, mp);
-
- mp->use_custom_mac = custom_mac;
+ M (BD_IP_MAC_ADD_DEL, mp);
- mp->mode = htonl (mode);
- mp->lb = htonl (lb);
- mp->id = htonl (id);
- mp->numa_only = numa_only;
+ mp->entry.bd_id = ntohl (bd_id);
+ mp->is_add = is_add;
- if (custom_mac)
- clib_memcpy (mp->mac_address, mac_address, 6);
+ clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
+ clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
- /* send it... */
S (mp);
-
- /* Wait for a reply... */
W (ret);
return ret;
}
static int
-api_bond_create2 (vat_main_t * vam)
+api_bd_ip_mac_flush (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_bond_create2_t *mp;
- u8 mac_address[6];
- u8 custom_mac = 0;
+ vl_api_bd_ip_mac_flush_t *mp;
+ u32 bd_id;
+ u8 bd_id_set = 0;
int ret;
- u8 mode;
- u8 lb;
- u8 mode_is_set = 0;
- u32 id = ~0;
- u8 numa_only = 0;
- u8 gso = 0;
-
- clib_memset (mac_address, 0, sizeof (mac_address));
- lb = BOND_LB_L2;
- /* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "mode %U", unformat_bond_mode, &mode))
- mode_is_set = 1;
- else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
- && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
- ;
- else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
- mac_address))
- custom_mac = 1;
- else if (unformat (i, "numa-only"))
- numa_only = 1;
- else if (unformat (i, "gso"))
- gso = 1;
- else if (unformat (i, "id %u", &id))
- ;
+ if (unformat (i, "bd_id %d", &bd_id))
+ {
+ bd_id_set++;
+ }
else
break;
}
- if (mode_is_set == 0)
+ if (bd_id_set == 0)
{
- errmsg ("Missing bond mode. ");
+ errmsg ("missing bridge domain");
return -99;
}
- /* Construct the API message */
- M (BOND_CREATE2, mp);
-
- mp->use_custom_mac = custom_mac;
-
- mp->mode = htonl (mode);
- mp->lb = htonl (lb);
- mp->id = htonl (id);
- mp->numa_only = numa_only;
- mp->enable_gso = gso;
+ M (BD_IP_MAC_FLUSH, mp);
- if (custom_mac)
- clib_memcpy (mp->mac_address, mac_address, 6);
+ mp->bd_id = ntohl (bd_id);
- /* send it... */
S (mp);
-
- /* Wait for a reply... */
W (ret);
return ret;
}
+static void vl_api_bd_ip_mac_details_t_handler
+ (vl_api_bd_ip_mac_details_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+
+ print (vam->ofp,
+ "\n%-5d %U %U",
+ ntohl (mp->entry.bd_id),
+ format_vl_api_mac_address, mp->entry.mac,
+ format_vl_api_address, &mp->entry.ip);
+}
+
+static void vl_api_bd_ip_mac_details_t_handler_json
+ (vl_api_bd_ip_mac_details_t * mp)
+{
+ vat_main_t *vam = &vat_main;
+ vat_json_node_t *node = NULL;
+
+ if (VAT_JSON_ARRAY != vam->json_tree.type)
+ {
+ ASSERT (VAT_JSON_NONE == vam->json_tree.type);
+ vat_json_init_array (&vam->json_tree);
+ }
+ node = vat_json_array_add (&vam->json_tree);
+
+ vat_json_init_object (node);
+ vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
+ vat_json_object_add_string_copy (node, "mac_address",
+ format (0, "%U", format_vl_api_mac_address,
+ &mp->entry.mac));
+ u8 *ip = 0;
+
+ ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
+ vat_json_object_add_string_copy (node, "ip_address", ip);
+ vec_free (ip);
+}
+
static int
-api_bond_delete (vat_main_t * vam)
+api_bd_ip_mac_dump (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_bond_delete_t *mp;
- u32 sw_if_index = ~0;
- u8 sw_if_index_set = 0;
+ vl_api_bd_ip_mac_dump_t *mp;
+ vl_api_control_ping_t *mp_ping;
int ret;
+ u32 bd_id;
+ u8 bd_id_set = 0;
- /* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
+ if (unformat (i, "bd_id %d", &bd_id))
+ {
+ bd_id_set++;
+ }
else
break;
}
- if (sw_if_index_set == 0)
- {
- errmsg ("missing vpp interface name. ");
- return -99;
- }
+ print (vam->ofp,
+ "\n%-5s %-7s %-20s %-30s",
+ "bd_id", "is_ipv6", "mac_address", "ip_address");
- /* Construct the API message */
- M (BOND_DELETE, mp);
+ /* Dump Bridge Domain Ip to Mac entries */
+ M (BD_IP_MAC_DUMP, mp);
+
+ if (bd_id_set)
+ mp->bd_id = htonl (bd_id);
+ else
+ mp->bd_id = ~0;
+
+ S (mp);
+
+ /* Use a control ping for synchronization */
+ MPING (CONTROL_PING, mp_ping);
+ S (mp_ping);
+
+ W (ret);
+ return ret;
+}
+
+uword
+unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
+{
+ vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
+ u32 x[4];
- mp->sw_if_index = ntohl (sw_if_index);
+ if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
+ return 0;
- /* send it... */
- S (mp);
+ addr->domain = x[0];
+ addr->bus = x[1];
+ addr->slot = x[2];
+ addr->function = x[3];
- /* Wait for a reply... */
- W (ret);
- return ret;
+ return 1;
}
static int
-api_bond_add_member (vat_main_t * vam)
+api_virtio_pci_create_v2 (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_bond_add_member_t *mp;
- u32 bond_sw_if_index;
+ vl_api_virtio_pci_create_v2_t *mp;
+ u8 mac_address[6];
+ u8 random_mac = 1;
+ u32 pci_addr = 0;
+ u64 features = (u64) ~ (0ULL);
+ u32 virtio_flags = 0;
int ret;
- u8 is_passive;
- u8 is_long_timeout;
- u32 bond_sw_if_index_is_set = 0;
- u32 sw_if_index;
- u8 sw_if_index_is_set = 0;
+
+ clib_memset (mac_address, 0, sizeof (mac_address));
/* Parse args required to build the message */
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_is_set = 1;
- else if (unformat (i, "bond %u", &bond_sw_if_index))
- bond_sw_if_index_is_set = 1;
- else if (unformat (i, "passive %d", &is_passive))
+ if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
+ {
+ random_mac = 0;
+ }
+ else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
;
- else if (unformat (i, "long-timeout %d", &is_long_timeout))
+ else if (unformat (i, "features 0x%llx", &features))
;
+ else if (unformat (i, "gso-enabled"))
+ virtio_flags |= VIRTIO_API_FLAG_GSO;
+ else if (unformat (i, "csum-offload-enabled"))
+ virtio_flags |= VIRTIO_API_FLAG_CSUM_OFFLOAD;
+ else if (unformat (i, "gro-coalesce"))
+ virtio_flags |= VIRTIO_API_FLAG_GRO_COALESCE;
+ else if (unformat (i, "packed"))
+ virtio_flags |= VIRTIO_API_FLAG_PACKED;
+ else if (unformat (i, "in-order"))
+ virtio_flags |= VIRTIO_API_FLAG_IN_ORDER;
+ else if (unformat (i, "buffering"))
+ virtio_flags |= VIRTIO_API_FLAG_BUFFERING;
else
break;
}
- if (bond_sw_if_index_is_set == 0)
- {
- errmsg ("Missing bond sw_if_index. ");
- return -99;
- }
- if (sw_if_index_is_set == 0)
+ if (pci_addr == 0)
{
- errmsg ("Missing member sw_if_index. ");
+ errmsg ("pci address must be non zero. ");
return -99;
}
/* Construct the API message */
- M (BOND_ADD_MEMBER, mp);
+ M (VIRTIO_PCI_CREATE_V2, mp);
- mp->bond_sw_if_index = ntohl (bond_sw_if_index);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->is_long_timeout = is_long_timeout;
- mp->is_passive = is_passive;
+ mp->use_random_mac = random_mac;
+
+ mp->pci_addr.domain = htons (((vlib_pci_addr_t) pci_addr).domain);
+ mp->pci_addr.bus = ((vlib_pci_addr_t) pci_addr).bus;
+ mp->pci_addr.slot = ((vlib_pci_addr_t) pci_addr).slot;
+ mp->pci_addr.function = ((vlib_pci_addr_t) pci_addr).function;
+
+ mp->features = clib_host_to_net_u64 (features);
+ mp->virtio_flags = clib_host_to_net_u32 (virtio_flags);
+
+ if (random_mac == 0)
+ clib_memcpy (mp->mac_address, mac_address, 6);
/* send it... */
S (mp);
}
static int
-api_bond_detach_member (vat_main_t * vam)
+api_virtio_pci_delete (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
- vl_api_bond_detach_member_t *mp;
+ vl_api_virtio_pci_delete_t *mp;
u32 sw_if_index = ~0;
u8 sw_if_index_set = 0;
int ret;
}
/* Construct the API message */
- M (BOND_DETACH_MEMBER, mp);
+ M (VIRTIO_PCI_DELETE, mp);
- mp->sw_if_index = ntohl (sw_if_index);
+ mp->sw_if_index = htonl (sw_if_index);
/* send it... */
S (mp);
return (0);
}
-static int
-api_sr_mpls_policy_add (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sr_mpls_policy_add_t *mp;
- u32 bsid = 0;
- u32 weight = 1;
- u8 type = 0;
- u8 n_segments = 0;
- u32 sid;
- u32 *segments = NULL;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "bsid %d", &bsid))
- ;
- else if (unformat (i, "weight %d", &weight))
- ;
- else if (unformat (i, "spray"))
- type = 1;
- else if (unformat (i, "next %d", &sid))
- {
- n_segments += 1;
- vec_add1 (segments, htonl (sid));
- }
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (bsid == 0)
- {
- errmsg ("bsid not set");
- return -99;
- }
-
- if (n_segments == 0)
- {
- errmsg ("no sid in segment stack");
- return -99;
- }
-
- /* Construct the API message */
- M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
-
- mp->bsid = htonl (bsid);
- mp->weight = htonl (weight);
- mp->is_spray = type;
- mp->n_segments = n_segments;
- memcpy (mp->segments, segments, sizeof (u32) * n_segments);
- vec_free (segments);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
-static int
-api_sr_mpls_policy_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sr_mpls_policy_del_t *mp;
- u32 bsid = 0;
- int ret;
-
- /* Parse args required to build the message */
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "bsid %d", &bsid))
- ;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (bsid == 0)
- {
- errmsg ("bsid not set");
- return -99;
- }
-
- /* Construct the API message */
- M (SR_MPLS_POLICY_DEL, mp);
-
- mp->bsid = htonl (bsid);
-
- /* send it... */
- S (mp);
-
- /* Wait for a reply... */
- W (ret);
- return ret;
-}
-
static int
api_mpls_tunnel_add_del (vat_main_t * vam)
{
u32 fib_table;
u8 nh_addr[16];
-static int
-api_sr_localsid_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_sr_localsid_add_del_t *mp;
-
- u8 is_del;
- ip6_address_t localsid;
- u8 end_psp = 0;
- u8 behavior = ~0;
- u32 sw_if_index;
- u32 fib_table = ~(u32) 0;
- ip46_address_t nh_addr;
- clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
-
- bool nexthop_set = 0;
-
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "del"))
- is_del = 1;
- else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
- else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
- nexthop_set = 1;
- else if (unformat (i, "behavior %u", &behavior));
- else if (unformat (i, "sw_if_index %u", &sw_if_index));
- else if (unformat (i, "fib-table %u", &fib_table));
- else if (unformat (i, "end.psp %u", &behavior));
- else
- break;
- }
-
- M (SR_LOCALSID_ADD_DEL, mp);
-
- clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
-
- if (nexthop_set)
- {
- clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
- }
- mp->behavior = behavior;
- mp->sw_if_index = ntohl (sw_if_index);
- mp->fib_table = ntohl (fib_table);
- mp->end_psp = end_psp;
- mp->is_del = is_del;
-
- S (mp);
- W (ret);
- return ret;
-}
-
static int
api_ioam_enable (vat_main_t * vam)
{
return ret;
}
-static void vl_api_sw_interface_tap_v2_details_t_handler
- (vl_api_sw_interface_tap_v2_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
-
- u8 *ip4 =
- format (0, "%U/%d", format_ip4_address, mp->host_ip4_prefix.address,
- mp->host_ip4_prefix.len);
- u8 *ip6 =
- format (0, "%U/%d", format_ip6_address, mp->host_ip6_prefix.address,
- mp->host_ip6_prefix.len);
-
- print (vam->ofp,
- "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
- mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
- ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
- format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
- mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
-
- vec_free (ip4);
- vec_free (ip6);
-}
-
-static void vl_api_sw_interface_tap_v2_details_t_handler_json
- (vl_api_sw_interface_tap_v2_details_t * mp)
-{
- vat_main_t *vam = &vat_main;
- vat_json_node_t *node = NULL;
-
- if (VAT_JSON_ARRAY != vam->json_tree.type)
- {
- ASSERT (VAT_JSON_NONE == vam->json_tree.type);
- vat_json_init_array (&vam->json_tree);
- }
- node = vat_json_array_add (&vam->json_tree);
-
- vat_json_init_object (node);
- vat_json_object_add_uint (node, "id", ntohl (mp->id));
- vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
- vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
- vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
- vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
- vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
- vat_json_object_add_string_copy (node, "host_mac_addr",
- format (0, "%U", format_ethernet_address,
- &mp->host_mac_addr));
- vat_json_object_add_string_copy (node, "host_namespace",
- mp->host_namespace);
- vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
- vat_json_object_add_string_copy (node, "host_ip4_addr",
- format (0, "%U/%d", format_ip4_address,
- mp->host_ip4_prefix.address,
- mp->host_ip4_prefix.len));
- vat_json_object_add_string_copy (node, "host_ip6_prefix",
- format (0, "%U/%d", format_ip6_address,
- mp->host_ip6_prefix.address,
- mp->host_ip6_prefix.len));
-
-}
-
-static int
-api_sw_interface_tap_v2_dump (vat_main_t * vam)
-{
- vl_api_sw_interface_tap_v2_dump_t *mp;
- vl_api_control_ping_t *mp_ping;
- int ret;
-
- print (vam->ofp,
- "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
- "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
- "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
- "host_ip6_addr");
-
- /* Get list of tap interfaces */
- M (SW_INTERFACE_TAP_V2_DUMP, mp);
- S (mp);
-
- /* Use a control ping for synchronization */
- MPING (CONTROL_PING, mp_ping);
- S (mp_ping);
-
- W (ret);
- return ret;
-}
-
static void vl_api_sw_interface_virtio_pci_details_t_handler
(vl_api_sw_interface_virtio_pci_details_t * mp)
{
return ret;
}
-static int
-api_qos_record_enable_disable (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_qos_record_enable_disable_t *mp;
- u32 sw_if_index, qs = 0xff;
- u8 sw_if_index_set = 0;
- u8 enable = 1;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "sw_if_index %d", &sw_if_index))
- sw_if_index_set = 1;
- else if (unformat (i, "%U", unformat_qos_source, &qs))
- ;
- else if (unformat (i, "disable"))
- enable = 0;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (sw_if_index_set == 0)
- {
- errmsg ("missing interface name or sw_if_index");
- return -99;
- }
- if (qs == 0xff)
- {
- errmsg ("input location must be specified");
- return -99;
- }
-
- M (QOS_RECORD_ENABLE_DISABLE, mp);
-
- mp->record.sw_if_index = ntohl (sw_if_index);
- mp->record.input_source = qs;
- mp->enable = enable;
-
- S (mp);
- W (ret);
- return ret;
-}
-
-
static int
q_or_quit (vat_main_t * vam)
{
"sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
_(bridge_flags, \
"bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
-_(tap_create_v2, \
- "id <num> [hw-addr <mac-addr>] [host-if-name <name>] [host-ns <name>] [num-rx-queues <num>] [rx-ring-size <num>] [tx-ring-size <num>] [host-bridge <name>] [host-mac-addr <mac-addr>] [host-ip4-addr <ip4addr/mask>] [host-ip6-addr <ip6addr/mask>] [host-mtu-size <mtu>] [gso | no-gso | csum-offload | gro-coalesce] [persist] [attach] [tun] [packed] [in-order]") \
-_(tap_delete_v2, \
- "<vpp-if-name> | sw_if_index <id>") \
-_(sw_interface_tap_v2_dump, "") \
_(virtio_pci_create_v2, \
"pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled [gro-coalesce] | csum-offload-enabled] [packed] [in-order] [buffering]") \
_(virtio_pci_delete, \
"<vpp-if-name> | sw_if_index <id>") \
_(sw_interface_virtio_pci_dump, "") \
-_(bond_create, \
- "[hw-addr <mac-addr>] {round-robin | active-backup | " \
- "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
- "[id <if-id>]") \
-_(bond_create2, \
- "[hw-addr <mac-addr>] {mode round-robin | active-backup | " \
- "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
- "[id <if-id>] [gso]") \
-_(bond_delete, \
- "<vpp-if-name> | sw_if_index <id>") \
-_(bond_add_member, \
- "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
-_(bond_detach_member, \
- "sw_if_index <n>") \
- _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
- _(sw_bond_interface_dump, "<intfc> | sw_if_index <nn>") \
- _(sw_member_interface_dump, \
- "<vpp-if-name> | sw_if_index <id>") \
_(ip_table_add_del, \
"table <n> [ipv6] [add | del]\n") \
_(ip_route_add_del, \
"[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
"[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
"[l2-only] [out-label <n>]") \
-_(sr_mpls_policy_add, \
- "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
-_(sr_mpls_policy_del, \
- "bsid <id>") \
_(sw_interface_set_unnumbered, \
"<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
_(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
_(l2_patch_add_del, \
"rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
"enable | disable") \
-_(sr_localsid_add_del, \
- "(del) address <addr> next_hop <addr> behavior <beh>\n" \
- "fib-table <num> (end.psp) sw_if_index <num>") \
_(get_node_index, "node <node-name") \
_(add_node_next, "node <node-name> next <next-node-name>") \
_(l2_fib_clear_table, "") \
"<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
_(session_rules_dump, "") \
_(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
-_(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
/* List of command functions, CLI names map directly to functions */
#define foreach_cli_function \