tcp: reuse and refactor use of del function 22/42922/4
authorFlorin Coras <[email protected]>
Sat, 3 May 2025 21:25:21 +0000 (17:25 -0400)
committerDave Barach <[email protected]>
Mon, 5 May 2025 18:29:56 +0000 (18:29 +0000)
Rename tcp_connection_del to tcp_connection_cleanup_and_notify and use
where needed.

Type: refactor

Change-Id: I6007205a63620f1bbf20b59999e833b6d6f631d4
Signed-off-by: Florin Coras <[email protected]>
src/vnet/tcp/tcp.c
src/vnet/tcp/tcp.h
src/vnet/tcp/tcp_input.c

index ed8c514..0fb1c1c 100644 (file)
@@ -283,7 +283,7 @@ tcp_connection_cleanup (tcp_connection_t * tc)
  * just remove the connection, call tcp_connection_cleanup instead.
  */
 void
-tcp_connection_del (tcp_connection_t * tc)
+tcp_connection_cleanup_and_notify (tcp_connection_t *tc)
 {
   session_transport_delete_notify (&tc->connection);
   tcp_connection_cleanup (tc);
@@ -356,11 +356,10 @@ tcp_program_cleanup (tcp_worker_ctx_t * wrk, tcp_connection_t * tc)
  * If at the end the connection is not in CLOSED state, it is not removed.
  * Instead, we rely on on TCP to advance through state machine to either
  * 1) LAST_ACK (passive close) whereby when the last ACK is received
- * tcp_connection_del is called. This notifies session of the delete and
- * calls cleanup.
- * 2) TIME_WAIT (active close) whereby after 2MSL the 2MSL timer triggers
- * and cleanup is called.
- *
+ * tcp_connection_cleanup_and_notify is called. This notifies session of the
+ * delete and calls cleanup.
+ * 2) TIME_WAIT (active close) whereby after 2MSL the 2MSL timer triggers and
+ * cleanup is called.
  */
 void
 tcp_connection_close (tcp_connection_t * tc)
index 67dc740..ad2f63a 100644 (file)
@@ -311,7 +311,7 @@ tcp_connection_t *tcp_connection_alloc_w_base (u8 thread_index,
 void tcp_connection_free (tcp_connection_t * tc);
 void tcp_connection_close (tcp_connection_t * tc);
 void tcp_connection_cleanup (tcp_connection_t * tc);
-void tcp_connection_del (tcp_connection_t * tc);
+void tcp_connection_cleanup_and_notify (tcp_connection_t *tc);
 int tcp_half_open_connection_cleanup (tcp_connection_t * tc);
 
 void tcp_send_reset_w_pkt (tcp_connection_t *tc, vlib_buffer_t *pkt,
index 47ae851..404afb1 100644 (file)
@@ -117,9 +117,9 @@ tcp_handle_rst (tcp_connection_t * tc)
   switch (tc->rst_state)
     {
     case TCP_STATE_SYN_RCVD:
-      /* Cleanup everything. App wasn't notified yet */
-      session_transport_delete_notify (&tc->connection);
-      tcp_connection_cleanup (tc);
+      /* Cleanup everything. App wasn't notified yet, but session layer must be
+       * notified that the session needs to be cleaned up. */
+      tcp_connection_cleanup_and_notify (tc);
       break;
     case TCP_STATE_SYN_SENT:
       session_stream_connect_notify (&tc->connection, SESSION_E_REFUSED);
@@ -2163,8 +2163,7 @@ tcp46_rcv_process_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
            {
              error = TCP_ERROR_MSG_QUEUE_FULL;
              tcp_send_reset (tc);
-             session_transport_delete_notify (&tc->connection);
-             tcp_connection_cleanup (tc);
+             tcp_connection_cleanup_and_notify (tc);
              goto drop;
            }
          error = TCP_ERROR_CONN_ACCEPTED;
@@ -2589,7 +2588,7 @@ tcp46_listen_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
 
          lc = tcp_lookup_listener (b[0], tc->c_fib_index, is_ip4);
          /* clean up the old session */
-         tcp_connection_del (tc);
+         tcp_connection_cleanup_and_notify (tc);
          /* listener was cleaned up */
          if (!lc)
            {