udp: regrab connected session after transport clone 39/43139/5
authorFlorin Coras <[email protected]>
Tue, 10 Jun 2025 21:53:47 +0000 (17:53 -0400)
committerDave Wallace <[email protected]>
Wed, 11 Jun 2025 15:27:49 +0000 (15:27 +0000)
Type: fix

Change-Id: Id8a23a14f9086a68bb235fec4e190a19447c109e
Signed-off-by: Florin Coras <[email protected]>
Signed-off-by: Matus Fabian <[email protected]>
src/vnet/session/session.c
src/vnet/session/session.h
src/vnet/udp/udp_input.c

index 27a4177..043ad43 100644 (file)
@@ -852,8 +852,8 @@ app_closed:
  * Move dgram session to the right thread
  */
 int
-session_dgram_connect_notify (transport_connection_t * tc,
-                             u32 old_thread_index, session_t ** new_session)
+session_dgram_connect_notify (transport_connection_t *tc,
+                             session_handle_tu_t osh, session_t **new_session)
 {
   session_t *new_s;
   session_switch_pool_args_t *rpc_args;
@@ -863,7 +863,7 @@ session_dgram_connect_notify (transport_connection_t * tc,
   /*
    * Clone half-open session to the right thread.
    */
-  new_s = session_clone_safe (tc->s_index, old_thread_index);
+  new_s = session_clone_safe (tc->s_index, osh.thread_index);
   new_s->connection_index = tc->c_index;
   session_set_state (new_s, SESSION_STATE_READY);
   new_s->flags |= SESSION_F_IS_MIGRATING;
@@ -888,7 +888,7 @@ session_dgram_connect_notify (transport_connection_t * tc,
   rpc_args->new_session_index = new_s->session_index;
   rpc_args->new_thread_index = new_s->thread_index;
   rpc_args->session_index = tc->s_index;
-  rpc_args->thread_index = old_thread_index;
+  rpc_args->thread_index = osh.thread_index;
   session_send_rpc_evt_to_thread (rpc_args->thread_index, session_switch_pool,
                                  rpc_args);
 
index 744955d..5977154 100644 (file)
@@ -591,9 +591,9 @@ transport_cleanup_cb (void *cb_fn, transport_connection_t *tc)
 
 int session_stream_connect_notify (transport_connection_t * tc,
                                   session_error_t err);
-int session_dgram_connect_notify (transport_connection_t * tc,
-                                 u32 old_thread_index,
-                                 session_t ** new_session);
+int session_dgram_connect_notify (transport_connection_t *tc,
+                                 session_handle_tu_t osh,
+                                 session_t **new_session);
 int session_stream_accept_notify (transport_connection_t * tc);
 void session_transport_closing_notify (transport_connection_t * tc);
 void session_transport_delete_notify (transport_connection_t * tc);
index ea53db5..e982895 100644 (file)
@@ -294,19 +294,19 @@ udp46_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
              error0 = UDP_ERROR_CONNECTED;
              if (s0->thread_index != thread_index)
                {
+                 /* uc0 clone may allow owner of s0 to grow its pool */
+                 session_handle_t osh = session_handle (s0);
                  /*
                   * Clone the transport. It will be cleaned up with the
                   * session once we notify the session layer.
                   */
                  uc0 = udp_connection_clone_safe (s0->connection_index,
                                                   s0->thread_index);
-                 ASSERT (s0->session_index == uc0->c_s_index);
-
+                 ASSERT (session_index_from_handle (osh) == uc0->c_s_index);
                  /*
                   * Ask session layer for a new session.
                   */
-                 session_dgram_connect_notify (&uc0->connection,
-                                               s0->thread_index, &s0);
+                 session_dgram_connect_notify (&uc0->connection, osh, &s0);
                  queue_event = 0;
                }
              else