ping: fix aborting on keypress 35/31035/4
authorIvan Shvedunov <ivan4th@gmail.com>
Mon, 1 Feb 2021 11:11:10 +0000 (14:11 +0300)
committerAndrew Yourtchenko <ayourtch@gmail.com>
Mon, 8 Feb 2021 12:32:04 +0000 (12:32 +0000)
Type: fix

Currently ping stops on events like SOCKET_READ_EVENT,
which makes it hard to use over e.g. govpp as it aborts
immediately most of the time. With this patch, ping only
stops upon real CLI read / quit events.

Signed-off-by: Ivan Shvedunov <ivan4th@gmail.com>
Change-Id: Id7a8d0b0fdeb7bbc7b85240e398d27bd5199345b

src/plugins/ping/ping.c
src/vlib/unix/cli.c
src/vlib/unix/unix.h

index 98add53..f3e238b 100644 (file)
@@ -16,6 +16,7 @@
 #include <stddef.h>
 
 #include <vlib/vlib.h>
+#include <vlib/unix/unix.h>
 #include <vnet/fib/ip6_fib.h>
 #include <vnet/fib/ip4_fib.h>
 #include <vnet/fib/fib_sas.h>
@@ -1173,11 +1174,11 @@ run_ping_ip46_address (vlib_main_t * vm, u32 table_id, ip4_address_t * pa4,
                  }
              }
              break;
-           default:
+           case UNIX_CLI_PROCESS_EVENT_READ_READY:
+           case UNIX_CLI_PROCESS_EVENT_QUIT:
              /* someone pressed a key, abort */
              vlib_cli_output (vm, "Aborted due to a keypress.");
              goto double_break;
-             break;
            }
          vec_free (event_data);
        }
index 8120bef..96e22a2 100644 (file)
@@ -449,13 +449,6 @@ static unix_cli_parse_actions_t unix_cli_parse_pager[] = {
 
 #undef _
 
-/** CLI session events. */
-typedef enum
-{
-  UNIX_CLI_PROCESS_EVENT_READ_READY,  /**< A file descriptor has data to be read. */
-  UNIX_CLI_PROCESS_EVENT_QUIT,       /**< A CLI session wants to close. */
-} unix_cli_process_event_type_t;
-
 /** CLI session telnet negotiation timer events. */
 typedef enum
 {
index 44dcf71..4b5f98a 100644 (file)
@@ -111,6 +111,14 @@ typedef struct
 
 } unix_main_t;
 
+/** CLI session events. */
+typedef enum
+{
+  UNIX_CLI_PROCESS_EVENT_READ_READY, /**< A file descriptor has data to be
+                                       read. */
+  UNIX_CLI_PROCESS_EVENT_QUIT,      /**< A CLI session wants to close. */
+} unix_cli_process_event_type_t;
+
 /* Global main structure. */
 extern unix_main_t unix_main;
 extern clib_file_main_t file_main;