ikev2: add support for custom ipsec-over-udp port
[vpp.git] / src / plugins / lacp / cli.c
index 1062777..36a6f9b 100644 (file)
@@ -30,10 +30,10 @@ lacp_dump_ifs (lacp_interface_details_t ** out_lacpifs)
 
   /* *INDENT-OFF* */
   pool_foreach (sif, bm->neighbors,
-    if ((sif->port_enabled == 0) || (sif->lacp_enabled == 0))
+    if (sif->lacp_enabled == 0)
       continue;
     vec_add2(r_lacpifs, lacpif, 1);
-    memset (lacpif, 0, sizeof (*lacpif));
+    clib_memset (lacpif, 0, sizeof (*lacpif));
     lacpif->sw_if_index = sif->sw_if_index;
     hi = vnet_get_hw_interface (vnm, sif->hw_if_index);
     clib_memcpy(lacpif->interface_name, hi->name,
@@ -88,7 +88,7 @@ show_lacp (vlib_main_t * vm, u32 * sw_if_indices)
   for (i = 0; i < vec_len (sw_if_indices); i++)
     {
       sif = bond_get_slave_by_sw_if_index (sw_if_indices[i]);
-      if (!sif || (sif->port_enabled == 0) || (sif->lacp_enabled == 0))
+      if (!sif || (sif->lacp_enabled == 0))
        continue;
       bif = bond_get_master_by_dev_instance (sif->bif_dev_instance);
       vlib_cli_output (vm,
@@ -143,11 +143,13 @@ show_lacp (vlib_main_t * vm, u32 * sw_if_indices)
 static void
 show_lacp_details (vlib_main_t * vm, u32 * sw_if_indices)
 {
+  lacp_main_t *lm = &lacp_main;
   slave_if_t *sif;
   lacp_state_struct *state_entry;
   int i;
   f64 now;
 
+  vlib_cli_output (vm, "Number of interfaces: %d", lm->lacp_int);
   if (!sw_if_indices)
     return;
 
@@ -155,12 +157,36 @@ show_lacp_details (vlib_main_t * vm, u32 * sw_if_indices)
   for (i = 0; i < vec_len (sw_if_indices); i++)
     {
       sif = bond_get_slave_by_sw_if_index (sw_if_indices[i]);
-      if (!sif || (sif->port_enabled == 0) || (sif->lacp_enabled == 0))
+      if (!sif || (sif->lacp_enabled == 0))
        continue;
       vlib_cli_output (vm, "  %U", format_vnet_sw_if_index_name,
                       vnet_get_main (), sif->sw_if_index);
+      vlib_cli_output (vm, "    Good LACP PDUs received: %llu",
+                      sif->pdu_received);
+      vlib_cli_output (vm, "    Bad LACP PDUs received: %llu",
+                      sif->bad_pdu_received);
+      vlib_cli_output (vm, "    LACP PDUs sent: %llu", sif->pdu_sent);
+      if (lacp_timer_is_running (sif->last_lacpdu_recd_time))
+       vlib_cli_output (vm,
+                        "    last LACP PDU received: %10.2f seconds ago",
+                        now - sif->last_lacpdu_recd_time);
+      if (lacp_timer_is_running (sif->last_lacpdu_sent_time))
+       vlib_cli_output (vm, "    last LACP PDU sent: %10.2f seconds ago",
+                        now - sif->last_lacpdu_sent_time);
+      vlib_cli_output (vm, "    Good Marker PDUs received: %llu",
+                      sif->marker_pdu_received);
+      vlib_cli_output (vm, "    Bad Marker PDUs received: %llu",
+                      sif->marker_bad_pdu_received);
+      if (lacp_timer_is_running (sif->last_marker_pdu_recd_time))
+       vlib_cli_output (vm,
+                        "    last Marker PDU received: %10.2f seconds ago",
+                        now - sif->last_marker_pdu_recd_time);
+      if (lacp_timer_is_running (sif->last_marker_pdu_sent_time))
+       vlib_cli_output (vm, "    last Marker PDU sent: %10.2f seconds ago",
+                        now - sif->last_marker_pdu_sent_time);
       vlib_cli_output (vm, "    debug: %d", sif->debug);
       vlib_cli_output (vm, "    loopback port: %d", sif->loopback_port);
+      vlib_cli_output (vm, "    port_enabled: %d", sif->port_enabled);
       vlib_cli_output (vm, "    port moved: %d", sif->port_moved);
       vlib_cli_output (vm, "    ready_n: %d", sif->ready_n);
       vlib_cli_output (vm, "    ready: %d", sif->ready);
@@ -209,17 +235,17 @@ show_lacp_details (vlib_main_t * vm, u32 * sw_if_indices)
       if (!lacp_timer_is_running (sif->wait_while_timer))
        vlib_cli_output (vm, "      wait while timer: not running");
       else
-       vlib_cli_output (vm, "      wait while timer: %=10.2f seconds",
+       vlib_cli_output (vm, "      wait while timer: %10.2f seconds",
                         sif->wait_while_timer - now);
       if (!lacp_timer_is_running (sif->current_while_timer))
        vlib_cli_output (vm, "      current while timer: not running");
       else
-       vlib_cli_output (vm, "      current while timer: %=10.2f seconds",
+       vlib_cli_output (vm, "      current while timer: %10.2f seconds",
                         sif->current_while_timer - now);
       if (!lacp_timer_is_running (sif->periodic_timer))
        vlib_cli_output (vm, "      periodic timer: not running");
       else
-       vlib_cli_output (vm, "      periodic timer: %=10.2f seconds",
+       vlib_cli_output (vm, "      periodic timer: %10.2f seconds",
                         sif->periodic_timer - now);
       vlib_cli_output (vm, "    RX-state: %U", format_rx_sm_state,
                       sif->rx_state);
@@ -242,17 +268,14 @@ show_lacp_fn (vlib_main_t * vm, unformat_input_t * input,
   slave_if_t *sif;
   clib_error_t *error = 0;
   u8 details = 0;
-  u32 hw_if_index, *sw_if_indices = 0;
-  vnet_interface_main_t *im = &vnm->interface_main;
-  vnet_sw_interface_t *sw;
+  u32 sw_if_index, *sw_if_indices = 0;
 
   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     {
       if (unformat
-         (input, "%U", unformat_vnet_hw_interface, vnm, &hw_if_index))
+         (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
        {
-         sw = pool_elt_at_index (im->sw_interfaces, hw_if_index);
-         sif = bond_get_slave_by_sw_if_index (sw->sw_if_index);
+         sif = bond_get_slave_by_sw_if_index (sw_if_index);
          if (!sif)
            {
              error = clib_error_return (0, "interface is not enslaved");
@@ -292,6 +315,7 @@ VLIB_CLI_COMMAND (show_lacp_command, static) = {
   .path = "show lacp",
   .short_help = "show lacp [<interface>] [details]",
   .function = show_lacp_fn,
+  .is_mp_safe = 1,
 };
 /* *INDENT-ON* */
 
@@ -304,11 +328,9 @@ debug_lacp_command_fn (vlib_main_t * vm, unformat_input_t * input,
   lacp_main_t *lm = &lacp_main;
   u8 onoff = 0;
   u8 input_found = 0;
-  u32 hw_if_index = ~0;
+  u32 sw_if_index = ~0;
   slave_if_t *sif;
   vnet_main_t *vnm = vnet_get_main ();
-  vnet_interface_main_t *im = &vnm->interface_main;
-  vnet_sw_interface_t *sw;
 
   /* Get a line of input. */
   if (!unformat_user (input, unformat_line_input, line_input))
@@ -317,7 +339,7 @@ debug_lacp_command_fn (vlib_main_t * vm, unformat_input_t * input,
   while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
     {
       if (unformat (line_input, "%U",
-                   unformat_vnet_hw_interface, vnm, &hw_if_index))
+                   unformat_vnet_sw_interface, vnm, &sw_if_index))
        ;
       if (input_found)
        {
@@ -346,10 +368,9 @@ debug_lacp_command_fn (vlib_main_t * vm, unformat_input_t * input,
   if (!input_found)
     return clib_error_return (0, "must specify on or off");
 
-  if (hw_if_index != ~0)
+  if (sw_if_index != ~0)
     {
-      sw = pool_elt_at_index (im->sw_interfaces, hw_if_index);
-      sif = bond_get_slave_by_sw_if_index (sw->sw_if_index);
+      sif = bond_get_slave_by_sw_if_index (sw_if_index);
       if (!sif)
        return (clib_error_return (0, "Please enslave the interface first"));
       sif->debug = onoff;