ping: Check only PING_RESPONSE_IP4 and PING_RESPONSE_IP6 events 46/40246/10
authorNikita Skrynnik <[email protected]>
Wed, 24 Jan 2024 01:09:47 +0000 (12:09 +1100)
committerAndrew Yourtchenko <[email protected]>
Tue, 25 Feb 2025 16:57:59 +0000 (16:57 +0000)
Check only PING_RESPONSE_IP4 and PING_RESPONSE_IP6
in ping binary API so it doesn't block other binary API
requests while working. (current version of ping binary API
can read other events like SOCKET_READ_EVENT, for example).

Type: fix
Change-Id: Ie7c5c92322af28633680c9c0d60fed739d4e65a0
Signed-off-by: Nikita Skrynnik <[email protected]>
src/plugins/ping/ping_api.c

index 5578fa5..a5af103 100644 (file)
@@ -122,16 +122,22 @@ vl_api_want_ping_finished_events_t_handler (
       while ((sleep_interval =
                time_ping_sent + ping_interval - vlib_time_now (vm)) > 0.0)
        {
-         uword event_type;
+         uword event_count;
          vlib_process_wait_for_event_or_clock (vm, sleep_interval);
-         event_type = vlib_process_get_events (vm, 0);
 
-         if (event_type == ~0)
+         if (dst_addr.version == AF_IP4)
+           event_count =
+             vlib_process_get_events_with_type (vm, 0, PING_RESPONSE_IP4);
+         else if (dst_addr.version == AF_IP6)
+           event_count =
+             vlib_process_get_events_with_type (vm, 0, PING_RESPONSE_IP6);
+         else
            break;
 
-         if (event_type == PING_RESPONSE_IP4 ||
-             event_type == PING_RESPONSE_IP6)
-           reply_count += 1;
+         if (event_count == 0)
+           break;
+
+         reply_count += 1;
        }
     }