session: fix transport proto unformat 51/23551/4
authorFlorin Coras <fcoras@cisco.com>
Wed, 20 Nov 2019 01:23:22 +0000 (17:23 -0800)
committerFlorin Coras <florin.coras@gmail.com>
Wed, 20 Nov 2019 02:12:32 +0000 (02:12 +0000)
Type: fix

Change-Id: I38a5cbd53b278c21142bac4ee1bbe5dc8bcaaac9
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/plugins/hs_apps/echo_client.c
src/vnet/session/transport.c

index 0f8d9c5..ba9785c 100644 (file)
@@ -727,8 +727,14 @@ echo_clients_connect (vlib_main_t * vm, u32 n_clients)
       a->uri = (char *) ecm->connect_uri;
       a->api_context = i;
       a->app_index = ecm->app_index;
+
+      vlib_worker_thread_barrier_sync (vm);
       if ((rv = vnet_connect_uri (a)))
-       return clib_error_return (0, "connect returned: %d", rv);
+       {
+         vlib_worker_thread_barrier_release (vm);
+         return clib_error_return (0, "connect returned: %d", rv);
+       }
+      vlib_worker_thread_barrier_release (vm);
 
       /* Crude pacing for call setups  */
       if ((i % 16) == 0)
@@ -870,7 +876,8 @@ echo_clients_command_fn (vlib_main_t * vm,
   if ((rv = parse_uri ((char *) ecm->connect_uri, &sep)))
     return clib_error_return (0, "Uri parse error: %d", rv);
   ecm->transport_proto = sep.transport_proto;
-  ecm->is_dgram = (sep.transport_proto == TRANSPORT_PROTO_UDP);
+  ecm->is_dgram = (sep.transport_proto == TRANSPORT_PROTO_UDP
+                  || sep.transport_proto == TRANSPORT_PROTO_UDPC);
 
 #if ECHO_CLIENT_PTHREAD
   echo_clients_start_tx_pthread ();
@@ -903,7 +910,9 @@ echo_clients_command_fn (vlib_main_t * vm,
   /* Fire off connect requests */
   time_before_connects = vlib_time_now (vm);
   if ((error = echo_clients_connect (vm, n_clients)))
-    goto cleanup;
+    {
+      goto cleanup;
+    }
 
   /* Park until the sessions come up, or ten seconds elapse... */
   vlib_process_wait_for_event_or_clock (vm, syn_timeout);
index 3160a48..902c740 100644 (file)
@@ -136,20 +136,49 @@ format_transport_half_open_connection (u8 * s, va_list * args)
   return s;
 }
 
+static u8
+unformat_transport_str_match (unformat_input_t * input, const char *str)
+{
+  int i;
+
+  if (strlen (str) > vec_len (input->buffer) - input->index)
+    return 0;
+
+  for (i = 0; i < strlen (str); i++)
+    {
+      if (input->buffer[i + input->index] != str[i])
+       return 0;
+    }
+  return 1;
+}
+
 uword
 unformat_transport_proto (unformat_input_t * input, va_list * args)
 {
   u32 *proto = va_arg (*args, u32 *);
+  u8 longest_match = 0, match;
+  char *str_match = 0;
 
 #define _(sym, str, sstr)                                              \
-  if (unformat (input, str))                                           \
+  if (unformat_transport_str_match (input, str))                       \
     {                                                                  \
-      *proto = TRANSPORT_PROTO_ ## sym;                                        \
-      return 1;                                                                \
+      match = strlen (str);                                            \
+      if (match > longest_match)                                       \
+       {                                                               \
+         *proto = TRANSPORT_PROTO_ ## sym;                             \
+         longest_match = match;                                        \
+         str_match = str;                                              \
+       }                                                               \
     }
   foreach_transport_proto
 #undef _
-    return 0;
+    if (longest_match)
+    {
+      unformat (input, str_match);
+      return 1;
+    }
+
+  return 0;
 }
 
 u32