session: fix a crash when using unregistered transport proto
[vpp.git] / src / vnet / session / transport.c
index 0473f19..192a201 100644 (file)
@@ -314,6 +314,8 @@ transport_cleanup_half_open (transport_proto_t tp, u32 conn_index)
 int
 transport_connect (transport_proto_t tp, transport_endpoint_cfg_t * tep)
 {
+  if (PREDICT_FALSE (!tp_vfts[tp].connect))
+    return SESSION_E_TRANSPORT_NO_REG;
   return tp_vfts[tp].connect (tep);
 }
 
@@ -343,6 +345,8 @@ u32
 transport_start_listen (transport_proto_t tp, u32 session_index,
                        transport_endpoint_cfg_t *tep)
 {
+  if (PREDICT_FALSE (!tp_vfts[tp].start_listen))
+    return SESSION_E_TRANSPORT_NO_REG;
   return tp_vfts[tp].start_listen (session_index, tep);
 }
 
@@ -425,20 +429,13 @@ transport_endpoint_free (u32 tepi)
   pool_put_index (local_endpoints, tepi);
 }
 
-static void
-transport_endpoint_pool_realloc_rpc (void *rpc_args)
-{
-  pool_realloc_safe_aligned (local_endpoints, 0);
-}
-
 always_inline local_endpoint_t *
 transport_endpoint_alloc (void)
 {
   local_endpoint_t *lep;
 
   ASSERT (vlib_get_thread_index () <= transport_cl_thread ());
-  pool_get_aligned_safe (local_endpoints, lep, transport_cl_thread (),
-                        transport_endpoint_pool_realloc_rpc, 0);
+  pool_get_aligned_safe (local_endpoints, lep, 0);
   return lep;
 }