#include "vat/json_format.h"
#include <vnet/ip/ip_types_api.h>
#include <vnet/ethernet/ethernet_types_api.h>
-#include <vlibapi/api_types_inlines.h>
#include <inttypes.h>
#include <sys/stat.h>
#define __plugin_msg_base 0
#include <vlibapi/vat_helper_macros.h>
+void vl_api_set_elog_main (elog_main_t * m);
+int vl_api_set_elog_trace_api_messages (int enable);
+
#if VPP_API_TEST_BUILTIN == 0
#include <netdb.h>
if (vam->ifp != stdin)
fformat (vam->ofp, "%s(%d): \n", vam->current_file,
vam->input_line_number);
- fformat (vam->ofp, (char *) s);
+ else
+ fformat (vam->ofp, "%s\n", (char *) s);
fflush (vam->ofp);
}
#endif
static void
increment_address (vl_api_address_t * a)
{
- if (a->af == ADDRESS_IP4)
+ if (clib_net_to_host_u32 (a->af) == ADDRESS_IP4)
increment_v4_address (&a->un.ip4);
- else if (a->af == ADDRESS_IP6)
+ else if (clib_net_to_host_u32 (a->af) == ADDRESS_IP6)
increment_v6_address (&a->un.ip6);
}
vat_json_object_add_prefix (vat_json_node_t * node,
const vl_api_prefix_t * prefix)
{
- vat_json_object_add_uint (node, "address_length", prefix->address_length);
- vat_json_object_add_address (node, "prefix", &prefix->address);
+ vat_json_object_add_uint (node, "len", prefix->len);
+ vat_json_object_add_address (node, "address", &prefix->address);
}
static void vl_api_create_loopback_reply_t_handler
p +=
vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
s = vl_api_from_api_to_vec ((vl_api_string_t *) p);
- vec_free (s);
-
errmsg ("build directory: %v\n", s);
+ vec_free (s);
}
vam->retval = retval;
vam->result_ready = 1;
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.address_length;
+ address->prefix_length = mp->prefix.len;
#undef addresses
}
{
unformat_input_t *i = vam->input;
vl_api_tap_create_v2_t *mp;
+#define TAP_FLAG_GSO (1 << 0)
u8 mac_address[6];
u8 random_mac = 1;
u32 id = ~0;
ip6_address_t host_ip6_gw;
u8 host_ip6_gw_set = 0;
u32 host_ip6_prefix_len = 0;
+ u8 host_mtu_set = 0;
+ u32 host_mtu_size = 0;
+ u32 tap_flags = 0;
int ret;
u32 rx_ring_sz = 0, tx_ring_sz = 0;
;
else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
;
+ else if (unformat (i, "host-mtu-size %d", &host_mtu_size))
+ host_mtu_set = 1;
+ else if (unformat (i, "no-gso"))
+ tap_flags &= ~TAP_FLAG_GSO;
+ else if (unformat (i, "gso"))
+ tap_flags |= TAP_FLAG_GSO;
else
break;
}
errmsg ("tx ring size must be 32768 or lower. ");
return -99;
}
+ if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
+ {
+ errmsg ("host MTU size must be in between 64 and 65355. ");
+ return -99;
+ }
/* Construct the API message */
M (TAP_CREATE_V2, mp);
mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
mp->rx_ring_sz = ntohs (rx_ring_sz);
mp->tx_ring_sz = ntohs (tx_ring_sz);
+ mp->host_mtu_set = host_mtu_set;
+ mp->host_mtu_size = ntohl (host_mtu_size);
+ mp->tap_flags = ntohl (tap_flags);
if (random_mac == 0)
clib_memcpy (mp->mac_address, mac_address, 6);
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;
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))
;
else
mp->mode = mode;
mp->lb = lb;
mp->id = htonl (id);
+ mp->numa_only = numa_only;
if (custom_mac)
clib_memcpy (mp->mac_address, mac_address, 6);
vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
{
vat_main_t *vam = &vat_main;
- int count = ntohl (mp->mr_route.mr_n_paths);
+ int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
vl_api_fib_path_t *fp;
int i;
(vl_api_mpls_route_details_t * mp)
{
vat_main_t *vam = &vat_main;
- int count = ntohl (mp->mr_route.mr_n_paths);
+ int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
vat_json_node_t *node = NULL;
vl_api_fib_path_t *fp;
int i;
print (vam->ofp,
"table-id %d, prefix %U/%d",
ntohl (mp->route.table_id),
- format_ip46_address,
- mp->route.prefix.address, mp->route.prefix.address_length);
+ format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
for (i = 0; i < count; i++)
{
fp = &mp->route.paths[i];
clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
vat_json_object_add_ip4 (node, "prefix", ip4);
}
- vat_json_object_add_uint (node, "mask_length",
- mp->route.prefix.address_length);
+ vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
vat_json_object_add_uint (node, "path_count", count);
for (i = 0; i < count; i++)
{
else
break;
}
- if (sw_if_index == ~0 || pfx.address_length == 0)
+ if (sw_if_index == ~0 || pfx.len == 0)
{
errmsg ("address and sw_if_index must be set");
return -99;
M (QOS_RECORD_ENABLE_DISABLE, mp);
- mp->sw_if_index = ntohl (sw_if_index);
- mp->input_source = qs;
+ mp->record.sw_if_index = ntohl (sw_if_index);
+ mp->record.input_source = qs;
mp->enable = enable;
S (mp);
return 0;
}
+static int
+elog_save (vat_main_t * vam)
+{
+#if VPP_API_TEST_BUILTIN == 0
+ elog_main_t *em = &vam->elog_main;
+ unformat_input_t *i = vam->input;
+ char *file, *chroot_file;
+ clib_error_t *error;
+
+ if (!unformat (i, "%s", &file))
+ {
+ errmsg ("expected file name, got `%U'", format_unformat_error, i);
+ return 0;
+ }
+
+ /* It's fairly hard to get "../oopsie" through unformat; just in case */
+ if (strstr (file, "..") || index (file, '/'))
+ {
+ errmsg ("illegal characters in filename '%s'", file);
+ return 0;
+ }
+
+ chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
+
+ vec_free (file);
+
+ errmsg ("Saving %wd of %wd events to %s",
+ elog_n_events_in_buffer (em),
+ elog_buffer_capacity (em), chroot_file);
+
+ error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
+ vec_free (chroot_file);
+
+ if (error)
+ clib_error_report (error);
+#else
+ errmsg ("Use the vpp event loger...");
+#endif
+
+ return 0;
+}
+
+static int
+elog_setup (vat_main_t * vam)
+{
+#if VPP_API_TEST_BUILTIN == 0
+ elog_main_t *em = &vam->elog_main;
+ unformat_input_t *i = vam->input;
+ u32 nevents = 128 << 10;
+
+ (void) unformat (i, "nevents %d", &nevents);
+
+ elog_init (em, nevents);
+ vl_api_set_elog_main (em);
+ vl_api_set_elog_trace_api_messages (1);
+ errmsg ("Event logger initialized with %u events", nevents);
+#else
+ errmsg ("Use the vpp event loger...");
+#endif
+ return 0;
+}
+
+static int
+elog_enable (vat_main_t * vam)
+{
+#if VPP_API_TEST_BUILTIN == 0
+ elog_main_t *em = &vam->elog_main;
+
+ elog_enable_disable (em, 1 /* enable */ );
+ vl_api_set_elog_trace_api_messages (1);
+ errmsg ("Event logger enabled...");
+#else
+ errmsg ("Use the vpp event loger...");
+#endif
+ return 0;
+}
+
+static int
+elog_disable (vat_main_t * vam)
+{
+#if VPP_API_TEST_BUILTIN == 0
+ elog_main_t *em = &vam->elog_main;
+
+ elog_enable_disable (em, 0 /* enable */ );
+ vl_api_set_elog_trace_api_messages (1);
+ errmsg ("Event logger disabled...");
+#else
+ errmsg ("Use the vpp event loger...");
+#endif
+ return 0;
+}
+
static int
statseg (vat_main_t * vam)
{
_(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-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
+ "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>] [host-mtu-size <mtu>] [gso | no-gso]") \
_(tap_delete_v2, \
"<vpp-if-name> | sw_if_index <id>") \
_(sw_interface_tap_v2_dump, "") \
_(dump_macro_table, "usage: dump_macro_table ") \
_(dump_node_table, "usage: dump_node_table") \
_(dump_msg_api_table, "usage: dump_msg_api_table") \
+_(elog_setup, "usage: elog_setup [nevents, default 128K]") \
+_(elog_disable, "usage: elog_disable") \
+_(elog_enable, "usage: elog_enable") \
+_(elog_save, "usage: elog_save <filename>") \
_(get_msg_id, "usage: get_msg_id name_and_crc") \
_(echo, "usage: echo <message>") \
_(exec, "usage: exec <vpe-debug-CLI-command>") \